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' }, () => '暂无文件'); } },