Browse Source

chore: 处理环境兼容

master
wangxiang 2 years ago
parent
commit
29772d2cd6
  1. 4
      .env.development
  2. 2
      .env.test
  3. 14
      src/views/system/file/file.data.ts

4
.env.development

@ -16,6 +16,10 @@ VITE_GLOB_API_URL=/api
# 文件上传地址,可选 # 文件上传地址,可选
VITE_GLOB_UPLOAD_URL=/upload VITE_GLOB_UPLOAD_URL=/upload
# 文件预览地址
# 可以通过nginx转发或者直接写实际地址
VITE_GLOB_FILE_PREVIEW_URL=http://192.168.3.10:8086
# 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换 # 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换
VITE_GLOB_API_URL_PREFIX= VITE_GLOB_API_URL_PREFIX=

2
.env.test

@ -24,7 +24,7 @@ VITE_GLOB_UPLOAD_URL=/prod-upload
# 文件预览地址 # 文件预览地址
# 可以通过nginx转发或者直接写实际地址 # 可以通过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= VITE_GLOB_API_URL_PREFIX=

14
src/views/system/file/file.data.ts

@ -10,10 +10,10 @@ import { FormSchema } from '/@/components/Table';
import { getFileSize } from '/@/utils/file/download'; import { getFileSize } from '/@/utils/file/download';
import { h } from 'vue'; import { h } from 'vue';
import { useGlobSetting } from '/@/hooks/setting'; import { useGlobSetting } from '/@/hooks/setting';
import { Tag } from 'ant-design-vue'; import { Tag, Button } from 'ant-design-vue';
import { useBase64 } from '@vueuse/core';
const { filePreviewUrl = '', apiUrl } = useGlobSetting(); const { filePreviewUrl = '', apiUrl } = useGlobSetting();
import { Api } from '/@/api/platform/system/controller/file'; import { Api } from '/@/api/platform/system/controller/file';
import { encodeURL } from 'js-base64';
/** 表格列配置 */ /** 表格列配置 */
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
@ -28,11 +28,15 @@ export const columns: BasicColumn[] = [
{ {
title: '文件名称', title: '文件名称',
dataIndex: 'fileName', dataIndex: 'fileName',
align: 'left',
ellipsis: true,
width: 380,
customRender: ({ record }) => { customRender: ({ record }) => {
const { base64 } = useBase64(`${apiUrl}${Api.get}/${record.bucket}/${record.fileName}`); const url = encodeURL(`${apiUrl}${Api.get}/${record.bucket}/${record.fileName}`);
return record.icon ? h('a-button', { return record.fileName ? h(Button, {
type: 'link', 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' }, () => '暂无文件'); : h(Tag, { color: 'red' }, () => '暂无文件');
} }
}, },

Loading…
Cancel
Save