From 29772d2cd69d429a62cda71daa6e7987313350ad Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Wed, 19 Jul 2023 21:30:11 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A4=84=E7=90=86=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 ++++ .env.test | 2 +- src/views/system/file/file.data.ts | 14 +++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.env.development b/.env.development index f85ae8f..2d46029 100644 --- a/.env.development +++ b/.env.development @@ -16,6 +16,10 @@ VITE_GLOB_API_URL=/api # 文件上传地址,可选 VITE_GLOB_UPLOAD_URL=/upload +# 文件预览地址 +# 可以通过nginx转发或者直接写实际地址 +VITE_GLOB_FILE_PREVIEW_URL=http://192.168.3.10:8086 + # 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换 VITE_GLOB_API_URL_PREFIX= diff --git a/.env.test b/.env.test index 5c27102..04b2bc0 100644 --- a/.env.test +++ b/.env.test @@ -24,7 +24,7 @@ VITE_GLOB_UPLOAD_URL=/prod-upload # 文件预览地址 # 可以通过nginx转发或者直接写实际地址 -VITE_GLOB_FILE_PREVIEW_URL=http:192.168.3.10:8086 +VITE_GLOB_FILE_PREVIEW_URL=http://192.168.3.10:8086 # 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换 VITE_GLOB_API_URL_PREFIX= diff --git a/src/views/system/file/file.data.ts b/src/views/system/file/file.data.ts index f903c37..e05bfea 100644 --- a/src/views/system/file/file.data.ts +++ b/src/views/system/file/file.data.ts @@ -10,10 +10,10 @@ import { FormSchema } from '/@/components/Table'; import { getFileSize } from '/@/utils/file/download'; import { h } from 'vue'; import { useGlobSetting } from '/@/hooks/setting'; -import { Tag } from 'ant-design-vue'; -import { useBase64 } from '@vueuse/core'; +import { Tag, Button } from 'ant-design-vue'; const { filePreviewUrl = '', apiUrl } = useGlobSetting(); import { Api } from '/@/api/platform/system/controller/file'; +import { encodeURL } from 'js-base64'; /** 表格列配置 */ export const columns: BasicColumn[] = [ @@ -28,11 +28,15 @@ export const columns: BasicColumn[] = [ { title: '文件名称', dataIndex: 'fileName', + align: 'left', + ellipsis: true, + width: 380, customRender: ({ record }) => { - const { base64 } = useBase64(`${apiUrl}${Api.get}/${record.bucket}/${record.fileName}`); - return record.icon ? h('a-button', { + const url = encodeURL(`${apiUrl}${Api.get}/${record.bucket}/${record.fileName}`); + return record.fileName ? h(Button, { type: 'link', - href: `${filePreviewUrl}/onlinePreview?url=${encodeURIComponent(base64.value)}` }, ()=> record.fileName) + target: '_blank', + href: `${filePreviewUrl}/onlinePreview?url=${encodeURIComponent(url)}` }, () => record.fileName) : h(Tag, { color: 'red' }, () => '暂无文件'); } },