refactor(usePagination): 将分页分组逻辑从divider改为paginator并更新相关属性名
更新分页分组逻辑,使用paginator作为分组边界标识 将page_prev_text、page_next_text和page_prev_disabled属性分别更名为back_title、next_title和is_back以保持命名一致性
Showing
1 changed file
with
7 additions
and
7 deletions
| ... | @@ -42,15 +42,15 @@ export function usePagination(formDataRef, options = {}) { | ... | @@ -42,15 +42,15 @@ export function usePagination(formDataRef, options = {}) { |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * 构建分页分组 | 44 | * 构建分页分组 |
| 45 | - * @description 优先按 divider 分组;若仅一组则按固定大小分片 | 45 | + * @description 优先按 paginator 分组;若仅一组则按固定大小分片 |
| 46 | */ | 46 | */ |
| 47 | const buildPages = () => { | 47 | const buildPages = () => { |
| 48 | const result = [] | 48 | const result = [] |
| 49 | let cur = [] | 49 | let cur = [] |
| 50 | formDataRef.value.forEach(item => { | 50 | formDataRef.value.forEach(item => { |
| 51 | const tag = item.component_props?.tag | 51 | const tag = item.component_props?.tag |
| 52 | - // 分隔符 divider 作为分页分组边界 | 52 | + // 分隔符 paginator 作为分页分组边界 |
| 53 | - if (tag === 'divider') { | 53 | + if (tag === 'paginator') { |
| 54 | if (cur.length) result.push(cur) | 54 | if (cur.length) result.push(cur) |
| 55 | cur = [] | 55 | cur = [] |
| 56 | return | 56 | return |
| ... | @@ -60,7 +60,7 @@ export function usePagination(formDataRef, options = {}) { | ... | @@ -60,7 +60,7 @@ export function usePagination(formDataRef, options = {}) { |
| 60 | if (cur.length) result.push(cur) | 60 | if (cur.length) result.push(cur) |
| 61 | if (result.length <= 1) { | 61 | if (result.length <= 1) { |
| 62 | const size = 8 | 62 | const size = 8 |
| 63 | - const keys = formDataRef.value.filter(i => i.component_props?.tag !== 'divider').map(i => i.key) | 63 | + const keys = formDataRef.value.filter(i => i.component_props?.tag !== 'paginator').map(i => i.key) |
| 64 | const chunked = [] | 64 | const chunked = [] |
| 65 | for (let i = 0; i < keys.length; i += size) { | 65 | for (let i = 0; i < keys.length; i += size) { |
| 66 | chunked.push(keys.slice(i, i + size)) | 66 | chunked.push(keys.slice(i, i + size)) |
| ... | @@ -94,9 +94,9 @@ export function usePagination(formDataRef, options = {}) { | ... | @@ -94,9 +94,9 @@ export function usePagination(formDataRef, options = {}) { |
| 94 | for (let k of keys) { | 94 | for (let k of keys) { |
| 95 | const item = formDataRef.value.find(i => i.key === k) | 95 | const item = formDataRef.value.find(i => i.key === k) |
| 96 | if (item && item.component_props) { | 96 | if (item && item.component_props) { |
| 97 | - if (item.component_props.page_prev_text) prev_text = item.component_props.page_prev_text | 97 | + if (item.component_props.back_title) prev_text = item.component_props.back_title |
| 98 | - if (item.component_props.page_next_text) next_text = item.component_props.page_next_text | 98 | + if (item.component_props.next_title) next_text = item.component_props.next_title |
| 99 | - if (typeof item.component_props.page_prev_disabled === 'boolean') prev_disabled = item.component_props.page_prev_disabled | 99 | + if (typeof item.component_props.is_back === 'boolean') prev_disabled = item.component_props.is_back |
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | return { prev_text, next_text, prev_disabled } | 102 | return { prev_text, next_text, prev_disabled } | ... | ... |
-
Please register or login to post a comment