diff --git a/components.d.ts b/components.d.ts index c674d5ee..8d95d316 100644 --- a/components.d.ts +++ b/components.d.ts @@ -24,8 +24,10 @@ declare module 'vue' { ChannelIcons: typeof import('./src/components/ChannelIcons/ChannelIcons.vue')['default'] Checkbox: typeof import('./src/components/base/checkbox/Checkbox.vue')['default'] Close: typeof import('./src/components/icon/Close.vue')['default'] + Collapse: typeof import('./src/components/base/Collapse.vue')['default'] CommonSetting: typeof import('./src/components/setting/CommonSetting.vue')['default'] ConflictNotice: typeof import('./src/components/ConflictNotice.vue')['default'] + ConflictNoticeText: typeof import('./src/components/ConflictNoticeText.vue')['default'] DeleteIcon: typeof import('./src/components/icon/DeleteIcon.vue')['default'] Dialog: typeof import('./src/components/dialog/Dialog.vue')['default'] DictGroup: typeof import('./src/components/list/DictGroup.vue')['default'] @@ -49,6 +51,7 @@ declare module 'vue' { IconFluentArrowClockwise20Regular: typeof import('~icons/fluent/arrow-clockwise20-regular')['default'] IconFluentArrowDownload20Regular: typeof import('~icons/fluent/arrow-download20-regular')['default'] IconFluentArrowLeft16Regular: typeof import('~icons/fluent/arrow-left16-regular')['default'] + IconFluentArrowMove20Regular: typeof import('~icons/fluent/arrow-move20-regular')['default'] IconFluentArrowRepeatAll20Regular: typeof import('~icons/fluent/arrow-repeat-all20-regular')['default'] IconFluentArrowRight16Regular: typeof import('~icons/fluent/arrow-right16-regular')['default'] IconFluentArrowShuffle16Regular: typeof import('~icons/fluent/arrow-shuffle16-regular')['default'] @@ -159,6 +162,7 @@ declare module 'vue' { WeChat: typeof import('./src/components/ChannelIcons/WeChat.vue')['default'] WordItem: typeof import('./src/components/WordItem.vue')['default'] WordList: typeof import('./src/components/list/WordList.vue')['default'] + WordList2: typeof import('./src/components/list/WordList2.vue')['default'] WordSetting: typeof import('./src/components/setting/WordSetting.vue')['default'] } } diff --git a/src/components/BaseTable.vue b/src/components/BaseTable.vue index 6e56b5d8..73692372 100644 --- a/src/components/BaseTable.vue +++ b/src/components/BaseTable.vue @@ -22,13 +22,13 @@ const props = withDefaults(defineProps<{ exportLoading?: boolean importLoading?: boolean request?: Function + list?: any[] }>(), { loading: true, showToolbar: true, showPagination: true, exportLoading: false, importLoading: false, - request: () => void 0, }) const emit = defineEmits<{ @@ -59,7 +59,7 @@ function scrollToTop() { function scrollToItem(index: number) { nextTick(() => { - listRef?.children[index]?.scrollIntoView({block: 'center', behavior: 'smooth'}) + listRef?.children[index]?.scrollIntoView({ block: 'center', behavior: 'smooth' }) }) } @@ -140,11 +140,15 @@ function cancelSearch() { } async function getData() { - loading2 = true - let {list, total} = await props.request(params) - params.list = list - params.total = total - loading2 = false + if (props.request) { + loading2 = true + let { list, total } = await props.request(params) + params.list = list + params.total = total + loading2 = false + } else { + params.list = props.list ?? [] + } } function handlePageNo(e) { @@ -155,177 +159,182 @@ function handlePageNo(e) { onMounted(async () => { getData() + }) defineRender( - () => { - const d = (item) => toggleSelect(item)} - size="large"/> + () => { + const d = (item) => toggleSelect(item)} + size="large"/> - return ( -
- { - props.showToolbar &&
+ return ( +
{ - showSearchInput ? ( -
- search(e), 500)} - class="flex-1" - autofocus> - {{ - subfix: () => - }} - - 取消 -
- ) : ( -
-
- toggleSelectAll()} - modelValue={selectAll} - size="large"/> - {selectIds.length} / {params.total} -
+ props.showToolbar &&
+ { + showSearchInput ? ( +
+ search(e), 500)} + class="flex-1" + autofocus> + {{ + subfix: () => + }} + + 取消 +
+ ) : ( +
+
+ toggleSelectAll()} + modelValue={selectAll} + size="large"/> + {selectIds.length} / {params.total} +
-
- { - selectIds.length ? - - - - - - : null - } - showImportDialog = true} - title="导入"> - - - emit('export')} - title="导出"> - {props.exportLoading ? : } - - emit('add')} - title="添加单词"> - - - showSortDialog = !showSortDialog} - > - - - showSearchInput = !showSearchInput} - title="搜索"> - - - showSortDialog = e} - style="width: 8rem;" - > -
- 列表顺序设置 -
-
- sort(Sort.reverse)}>翻转当前页 - sort(Sort.reverseAll)}>翻转所有 -
- sort(Sort.random)}>随机当前页 - sort(Sort.randomAll)}>随机所有 -
-
-
-
- ) - } -
- } - { - loading2 ? -
- -
- : params.list.length ? ( - <> -
listRef = e}> - {params.list.map((item, index) => { - return ( -
- {s.default({checkbox: d, item, index: (params.pageSize * (params.pageNo - 1)) + index + 1})} -
+
+ { + selectIds.length ? + + + + + + : null + } + showImportDialog = true} + title="导入"> + + + emit('export')} + title="导出"> + {props.exportLoading ? : } + + emit('add')} + title="添加单词"> + + + showSortDialog = !showSortDialog} + > + + + showSearchInput = !showSearchInput} + title="搜索"> + + + showSortDialog = e} + style="width: 8rem;" + > +
+ 列表顺序设置 +
+
+ sort(Sort.reverse)}>翻转当前页 + sort(Sort.reverseAll)}>翻转所有 +
+ sort(Sort.random)}>随机当前页 + sort(Sort.randomAll)}>随机所有 +
+
+
+
) - })} + }
- { - props.showPagination &&
- params.pageSize = e} - pageSizes={[20, 50, 100, 200]} - layout="total,sizes" - total={params.total}/> + } + { + loading2 ? +
+
- } - - ) : - } + : params.list.length ? ( + <> +
listRef = e}> + {params.list.map((item, index) => { + return ( +
+ {s.default({ + checkbox: d, + item, + index: (params.pageSize * (params.pageNo - 1)) + index + 1 + })} +
+ ) + })} +
+ { + props.showPagination &&
+ params.pageSize = e} + pageSizes={[20, 50, 100, 200]} + layout="total,sizes" + total={params.total}/> +
+ } + + ) : + } - -
-
请按照模板的格式来填写数据
-
单词项为必填,其他项可不填
-
翻译:一行一个翻译,前面词性,后面内容(如n.取消);多个翻译请换行
-
例句:一行原文,一行译文;多个请换
-
短语:一行原文,一行译文;多个请换
-
同义词、同根词、词源:请前往官方词典,然后编辑其中某个单词,参考其格式
-
- 模板下载地址:单词导入模板 -
-
- { - let d: HTMLDivElement = document.querySelector('#upload-trigger') - d.click() - }} - loading={props.importLoading}>导入 - emit('import', e)} - class="w-0 h-0 opacity-0"/> -
+ +
+
请按照模板的格式来填写数据
+
单词项为必填,其他项可不填
+
翻译:一行一个翻译,前面词性,后面内容(如n.取消);多个翻译请换行
+
例句:一行原文,一行译文;多个请换
+
短语:一行原文,一行译文;多个请换
+
同义词、同根词、词源:请前往官方词典,然后编辑其中某个单词,参考其格式
+
+ 模板下载地址:单词导入模板 +
+
+ { + let d: HTMLDivElement = document.querySelector('#upload-trigger') + d.click() + }} + loading={props.importLoading}>导入 + emit('import', e)} + class="w-0 h-0 opacity-0"/> +
+
+
-
-
- ) - } + ) + } ) diff --git a/src/components/list/WordList.vue b/src/components/list/WordList.vue index 00668145..5431d5aa 100644 --- a/src/components/list/WordList.vue +++ b/src/components/list/WordList.vue @@ -44,20 +44,7 @@ defineExpose({ scrollToBottom, scrollToItem })