fix: 兼容旧前端可改配置文件

This commit is contained in:
TsMask
2023-11-06 10:46:08 +08:00
parent 0b58c00566
commit de16c3d1f5
4 changed files with 42 additions and 16 deletions

View File

@@ -9,6 +9,7 @@ import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { uploadFile } from '@/api/tool/file';
import { changeValue } from '@/api/system/config';
import { computed } from 'vue';
import { sessionGet } from '@/utils/cache-session-utils';
const appStore = useAppStore();
const { t } = useI18n();
@@ -64,13 +65,15 @@ function fnUpload(up: UploadRequestOption) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success('文件上传成功,提交保存生效', 3);
state.filePath = res.data.fileName;
// appStore.setLOGO(state.type, res.data.fileName);
const baseApi = import.meta.env.VITE_API_BASE_URL;
// 兼容旧前端可改配置文件
const baseUrl = import.meta.env.PROD
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
: import.meta.env.VITE_API_BASE_URL;
if (state.type === 'icon') {
state.icon = `${baseApi}${res.data.fileName}`;
state.icon = `${baseUrl}${res.data.fileName}`;
}
if (state.type === 'brand') {
state.brand = `${baseApi}${res.data.fileName}`;
state.brand = `${baseUrl}${res.data.fileName}`;
}
} else {
message.error(res.msg, 3);