diff --git a/src/components/AnTable/components/column.tsx b/src/components/AnTable/components/column.tsx index d2f7c5b..1fa1c2f 100644 --- a/src/components/AnTable/components/column.tsx +++ b/src/components/AnTable/components/column.tsx @@ -3,14 +3,14 @@ import { TableColumn } from '../hooks/useTableColumn'; export function useUpdateColumn(extra: TableColumn = {}): TableColumn { return { - title: '更新用户', + title: '更新', dataIndex: 'createdAt', - width: 190, + width: 180, render: ({ record }) => (
{record.updatedBy ?? '无'} - - {dayjs(record.updatedAt).format()} + + 更新于 {dayjs(record.updatedAt).fromNow()}
), @@ -20,14 +20,14 @@ export function useUpdateColumn(extra: TableColumn = {}): TableColumn { export function useCreateColumn(extra: TableColumn = {}): TableColumn { return { - title: '创建用户', + title: '作者', dataIndex: 'createdAt', - width: 190, + width: 180, render: ({ record }) => (
{record.createdBy ?? '无'} - - {dayjs(record.createdAt).format()} + + 创建于 {dayjs(record.createdAt).fromNow()}
), diff --git a/src/components/AnTable/hooks/useTableColumn.tsx b/src/components/AnTable/hooks/useTableColumn.tsx index 74a8460..4a99025 100644 --- a/src/components/AnTable/hooks/useTableColumn.tsx +++ b/src/components/AnTable/hooks/useTableColumn.tsx @@ -153,7 +153,7 @@ function useTableButtonColumn(column: TableButtonColumn & TableColumnData) { } return ( <> - {index !== 0 && } + {index !== 0 && } item.onClick?.(props)}> {item.text} diff --git a/src/components/AnTable/plugins/useRowDelete.tsx b/src/components/AnTable/plugins/useRowDelete.tsx index f6cd541..67016ad 100644 --- a/src/components/AnTable/plugins/useRowDelete.tsx +++ b/src/components/AnTable/plugins/useRowDelete.tsx @@ -2,6 +2,7 @@ import { delConfirm, delOptions } from '@/utils'; import { AnTableContext } from '../components/Table'; import { AnTablePlugin } from '../hooks/useTablePlugin'; import { Message } from '@arco-design/web-vue'; +import { defaultsDeep } from 'lodash-es'; export function useRowDelete(): AnTablePlugin { let ctx: AnTableContext; @@ -19,6 +20,11 @@ export function useRowDelete(): AnTablePlugin { if (!btn) { continue; } + defaultsDeep(btn, { + buttonProps: { + status: 'danger', + }, + }); const onClick = btn.onClick; btn.onClick = async props => { let confirm = btn.confirm ?? {}; diff --git a/src/pages/content/media/components/AnUpload.vue b/src/pages/content/media/components/AnUpload.vue index 6eefb4f..54ffbec 100644 --- a/src/pages/content/media/components/AnUpload.vue +++ b/src/pages/content/media/components/AnUpload.vue @@ -6,15 +6,15 @@ 上传 -
+
-
  • +
  • -
    - {{ item.name }} +
    +
    + {{ item.name }} + {{ numeral(item.file?.size).format('0 b') }} +
    +
    + 停止 + 重试 + + 删除 + +
    -
    - - {{ numeral(item.file?.size).format('0 b') }} - + +
    - - - - 速度:{{ numeral(fileMap.get(item.uid)?.speed || 0).format('0 b') }}/s, 进度:{{ - Math.floor((item.percent || 0) * 100) - }}% - + + + 等待上传 - - 完成( 耗时:{{ fileMap.get(item.uid)?.cost || 0 }}秒, 平均:{{ - numeral(fileMap.get(item.uid)?.aspeed || 0).format('0 b') - }}/s) + + + 正在上传 + + + + 上传成功 - 失败(原因:{{ fileMap.get(item.uid)?.error }}) + + 上传失败 + + + + 速度:{{ formatSpeed(item.uid) }}/s, 进度:{{ formatProgress(item) }} % + + + 耗时:{{ fileMap.get(item.uid)?.cost || 0 }} 秒, 平均:{{ formatAspeed(item.uid) }}/s + + 原因:{{ fileMap.get(item.uid)?.error }} +
    - -
    -
    - 停止 - 重试 - 删除
  • @@ -132,9 +144,20 @@ const fileMap = reactive< > >(new Map()); -/** - * 统计信息 - */ +const formatProgress = (item: FileItem, small?: boolean) => { + let percent = Math.floor((item.percent || 0) * 100); + percent = percent < 100 ? percent : item.response ? percent : 99; + return small ? percent / 100 : percent; +}; + +const formatSpeed = (uid: string) => { + return numeral(fileMap.get(uid)?.speed || 0).format('0 b'); +}; + +const formatAspeed = (uid: string) => { + return numeral(fileMap.get(uid)?.aspeed || 0).format('0 b'); +}; + const stat = computed(() => { const result = { initCount: 0, @@ -151,17 +174,10 @@ const stat = computed(() => { return result; }); -/** - * 开始上传 - */ const startUpload = () => { uploadRef.value?.submit(); }; -/** - * 中止上传 - * @param item 文件 - */ const pauseItem = (item: FileItem) => { uploadRef.value?.abort(item); const file = fileMap.get(item.uid); @@ -170,10 +186,6 @@ const pauseItem = (item: FileItem) => { } }; -/** - * 移除文件 - * @param item 文件 - */ const removeItem = (item: FileItem) => { const index = fileList.value.findIndex(i => i.uid === item.uid); if (index > -1) { @@ -181,17 +193,10 @@ const removeItem = (item: FileItem) => { } }; -/** - * 重新上传 - * @param item 文件 - */ const retryItem = (item: FileItem) => { uploadRef.value?.submit(item); }; -/** - * 清空已上传 - */ const clearUploaded = async () => { if (stat.value.doneCount !== fileList.value.length) { await delConfirm('当前有未上传完成的文件,是否继续清空?'); @@ -199,18 +204,10 @@ const clearUploaded = async () => { fileList.value = []; }; -/** - * 上传成功后处理 - * @param item 文件 - */ const onUploadSuccess = (item: FileItem) => { emit('success', item); }; -/** - * 上传失败后处理 - * @param item 文件 - */ const onUploadError = (item: FileItem) => { const file = fileMap.get(item.uid); if (file) { @@ -218,9 +215,6 @@ const onUploadError = (item: FileItem) => { } }; -/** - * 关闭前检测 - */ const onBeforeCancel = () => { if (fileList.value.some(i => i.status === 'uploading')) { Message.warning('提示:文件上传中,请稍后再试!'); @@ -229,19 +223,12 @@ const onBeforeCancel = () => { return true; }; -/** - * 关闭后处理 - */ const onClose = () => { fileMap.clear(); fileList.value = []; emit('close', stat.value.doneCount); }; -/** - * 自定义上传逻辑 - * @param option - */ const upload = (option: RequestOption) => { const { fileItem, onError, onProgress, onSuccess } = option; const source = axios.CancelToken.source(); @@ -257,26 +244,26 @@ const upload = (option: RequestOption) => { } const item = fileMap.get(fileItem.uid)!; const startTime = Date.now(); + const data = { file: fileItem.file as any }; + const params: RequestParams = { + onUploadProgress(e) { + let percent = 0; + const { lastTime, lastLoaded } = item; + if (e.total && e.total > 0) { + percent = e.loaded / e.total; + const nowTime = Date.now(); + const diff = (e.loaded - lastLoaded) / (nowTime - lastTime); + const speed = Math.floor(diff * 1000); + item.aspeed = (item.speed + speed) / 2; + item.speed = speed; + item.lastLoaded = e.loaded; + item.lastTime = nowTime; + } + onProgress(percent, e as any); + }, + cancelToken: source.token, + }; const up = async () => { - const data = { file: fileItem.file as any }; - const params: RequestParams = { - onUploadProgress(e) { - let percent = 0; - const { lastTime, lastLoaded } = item; - if (e.total && e.total > 0) { - percent = e.loaded / e.total; - const nowTime = Date.now(); - const diff = (e.loaded - lastLoaded) / (nowTime - lastTime); - const speed = Math.floor(diff * 1000); - item.aspeed = (item.speed + speed) / 2; - item.speed = speed; - item.lastLoaded = e.loaded; - item.lastTime = nowTime; - } - onProgress(percent, e as any); - }, - cancelToken: source.token, - }; try { const res = await api.file.addFile(data, params); const currentTime = Date.now(); diff --git a/src/pages/content/media/index.vue b/src/pages/content/media/index.vue index 34aefa7..0d5dbef 100644 --- a/src/pages/content/media/index.vue +++ b/src/pages/content/media/index.vue @@ -18,11 +18,12 @@ + { diff --git a/src/pages/system/dict/index.vue b/src/pages/system/dict/index.vue index 72f5469..e05a204 100644 --- a/src/pages/system/dict/index.vue +++ b/src/pages/system/dict/index.vue @@ -39,7 +39,7 @@ const { component: DictTable, tableRef } = useTable({
    {record.name} - {record.code} + @{record.code}
    {record.description}
    diff --git a/src/pages/system/logl/index.vue b/src/pages/system/logl/index.vue index 8d47a1c..6e9617d 100644 --- a/src/pages/system/logl/index.vue +++ b/src/pages/system/logl/index.vue @@ -1,52 +1,64 @@