diff --git a/src/pages-infra/file/components/config-list.vue b/src/pages-infra/file/components/config-list.vue index 54c4704..a92adf1 100644 --- a/src/pages-infra/file/components/config-list.vue +++ b/src/pages-infra/file/components/config-list.vue @@ -37,18 +37,18 @@ + + 设为主配置 + 测试 - - 设为主配置 - @@ -151,30 +151,27 @@ function handleDetail(item: FileConfig) { /** 测试文件配置 */ async function handleTest(item: FileConfig) { - try { - toast.loading('测试上传中...') - const url = await testFileConfig(item.id!) - toast.close() - uni.showModal({ - title: '测试上传成功', - content: '是否要访问该文件?', - confirmText: '访问', - cancelText: '取消', - success: (res) => { - if (res.confirm && url) { - // 复制链接到剪贴板 - uni.setClipboardData({ - data: url, - success: () => { - toast.success('链接已复制,请在浏览器中打开') - }, - }) - } - }, - }) - } catch { - toast.show('测试失败') - } + toast.loading('测试上传中...') + const url = await testFileConfig(item.id!) + toast.close() + uni.showModal({ + title: '测试上传成功', + content: '是否要访问该文件?', + confirmText: '访问', + success: (res) => { + if (!res.confirm || !url) { + return + } + // 复制链接到剪贴板 + uni.setClipboardData({ + data: url, + success: () => { + uni.hideToast() + toast.success('链接已复制,请在浏览器中打开') + }, + }) + }, + }) } /** 设为主配置 */ @@ -193,7 +190,7 @@ function handleMaster(item: FileConfig) { // 刷新列表 handleQuery() } catch { - toast.show('设置失败') + toast.close() } }, }) diff --git a/src/pages-infra/file/components/file-list.vue b/src/pages-infra/file/components/file-list.vue index 750d7ce..703e7d1 100644 --- a/src/pages-infra/file/components/file-list.vue +++ b/src/pages-infra/file/components/file-list.vue @@ -13,7 +13,7 @@ > - + {{ item.name || item.path }} @@ -29,19 +29,20 @@ 文件大小: {{ formatFileSize(item.size) }} - - - - 上传时间: {{ formatDateTime(item.createTime) || '-' }} + + + @@ -86,6 +87,7 @@ import { uploadFile } from '@/api/infra/file' import { useAccess } from '@/hooks/useAccess' import { http } from '@/http/http' import { formatDateTime } from '@/utils/date' +import { formatFileSize } from '@/utils/download' import FileSearchForm from './file-search-form.vue' /** 文件信息 */ @@ -110,15 +112,6 @@ const queryParams = ref({ pageSize: 10, }) -/** 格式化文件大小 */ -function formatFileSize(size?: number) { - if (!size) return '-' - if (size < 1024) return `${size} B` - if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB` - if (size < 1024 * 1024 * 1024) return `${(size / 1024 / 1024).toFixed(2)} MB` - return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB` -} - /** 查询列表 */ async function getList() { loadMoreState.value = 'loading' @@ -191,14 +184,6 @@ function handleCopyUrl(item: FileInfo) { }) } -/** 预览图片 */ -function handlePreviewImage(url?: string) { - if (!url) return - uni.previewImage({ - urls: [url], - }) -} - /** 查看详情 */ function handleDetail(item: FileInfo) { uni.navigateTo({ diff --git a/src/pages-infra/file/detail/index.vue b/src/pages-infra/file/detail/index.vue index 08ccec8..c27fe4a 100644 --- a/src/pages-infra/file/detail/index.vue +++ b/src/pages-infra/file/detail/index.vue @@ -18,17 +18,17 @@ - 文件预览 - @@ -57,6 +57,7 @@ import { useAccess } from '@/hooks/useAccess' import { http } from '@/http/http' import { navigateBackPlus } from '@/utils' import { formatDateTime } from '@/utils/date' +import { formatFileSize } from '@/utils/download' /** 文件信息 */ interface FileInfo { @@ -86,15 +87,6 @@ const toast = useToast() const formData = ref() const deleting = ref(false) -/** 格式化文件大小 */ -function formatFileSize(size?: number) { - if (!size) return '-' - if (size < 1024) return `${size} B` - if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB` - if (size < 1024 * 1024 * 1024) return `${(size / 1024 / 1024).toFixed(2)} MB` - return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB` -} - /** 返回上一页 */ function handleBack() { navigateBackPlus('/pages-infra/file/index') @@ -122,19 +114,12 @@ function handleCopyUrl() { uni.setClipboardData({ data: formData.value.url, success: () => { + uni.hideToast() toast.success('复制成功') }, }) } -/** 预览图片 */ -function handlePreviewImage() { - if (!formData.value?.url) return - uni.previewImage({ - urls: [formData.value.url], - }) -} - /** 删除 */ function handleDelete() { if (!props.id) { diff --git a/src/pages-system/operate-log/detail/index.vue b/src/pages-system/operate-log/detail/index.vue index cd60643..d6cf809 100644 --- a/src/pages-system/operate-log/detail/index.vue +++ b/src/pages-system/operate-log/detail/index.vue @@ -23,7 +23,14 @@ - + + + @@ -59,15 +66,6 @@ function handleBack() { navigateBackPlus('/pages-system/operate-log/index') } -/** 获取请求 URL */ -// TODO @AI:放在界面里,这里不要这么搞; -function getRequestUrl() { - if (formData.value?.requestMethod && formData.value?.requestUrl) { - return `${formData.value.requestMethod} ${formData.value.requestUrl}` - } - return '-' -} - /** 加载操作日志详情 */ async function getDetail() { if (!props.id) { diff --git a/src/utils/download.ts b/src/utils/download.ts index d90a88e..776d08c 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -106,3 +106,20 @@ function resolveFileName(url: string): string { return url.slice(url.lastIndexOf('/') + 1) || defaultName } } + +/** 格式化文件大小 */ +export function formatFileSize(size?: number): string { + if (!size) { + return '-' + } + if (size < 1024) { + return `${size} B` + } + if (size < 1024 * 1024) { + return `${(size / 1024).toFixed(2)} KB` + } + if (size < 1024 * 1024 * 1024) { + return `${(size / 1024 / 1024).toFixed(2)} MB` + } + return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB` +}