- {{ 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 @@
-
+