fix: 兼容旧前端可改配置文件
This commit is contained in:
@@ -4,6 +4,7 @@ import defaultLOGOBrand from '@/assets/logo_brand.png';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { validHttp } from '@/utils/regular-utils';
|
||||
import { defineStore } from 'pinia';
|
||||
import { sessionGet } from '@/utils/cache-session-utils';
|
||||
|
||||
/**应用参数类型 */
|
||||
type AppStore = {
|
||||
@@ -52,8 +53,11 @@ const useAppStore = defineStore('app', {
|
||||
if (validHttp(path)) {
|
||||
return path;
|
||||
}
|
||||
const baseApi = import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseApi}${path}`;
|
||||
// 兼容旧前端可改配置文件
|
||||
const baseUrl = import.meta.env.PROD
|
||||
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
||||
: import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseUrl}${path}`;
|
||||
},
|
||||
/**
|
||||
* 获取正确LOGO地址-brand
|
||||
@@ -68,8 +72,11 @@ const useAppStore = defineStore('app', {
|
||||
if (validHttp(path)) {
|
||||
return path;
|
||||
}
|
||||
const baseApi = import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseApi}${path}`;
|
||||
// 兼容旧前端可改配置文件
|
||||
const baseUrl = import.meta.env.PROD
|
||||
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
||||
: import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseUrl}${path}`;
|
||||
},
|
||||
/**
|
||||
* 获取正确登录背景地址
|
||||
@@ -84,8 +91,11 @@ const useAppStore = defineStore('app', {
|
||||
if (validHttp(path)) {
|
||||
return path;
|
||||
}
|
||||
const baseApi = import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseApi}${path}`;
|
||||
// 兼容旧前端可改配置文件
|
||||
const baseUrl = import.meta.env.PROD
|
||||
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
||||
: import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseUrl}${path}`;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { defineStore } from 'pinia';
|
||||
import { TOKEN_RESPONSE_FIELD } from '@/constants/token-constants';
|
||||
import { validHttp } from '@/utils/regular-utils';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { sessionGet } from '@/utils/cache-session-utils';
|
||||
|
||||
/**用户信息类型 */
|
||||
type UserInfo = {
|
||||
@@ -43,8 +44,11 @@ function parseAvatar(avatar: string): string {
|
||||
if (validHttp(avatar)) {
|
||||
return avatar;
|
||||
}
|
||||
const baseApi = import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseApi}${avatar}`;
|
||||
// 兼容旧前端可改配置文件
|
||||
const baseUrl = import.meta.env.PROD
|
||||
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
||||
: import.meta.env.VITE_API_BASE_URL;
|
||||
return `${baseUrl}${avatar}`;
|
||||
}
|
||||
|
||||
const useUserStore = defineStore('user', {
|
||||
@@ -168,7 +172,7 @@ const useUserStore = defineStore('user', {
|
||||
waterMarkContent = `${this.userName} ${this.phonenumber}`;
|
||||
}
|
||||
// useLayoutStore().changeWaterMark(waterMarkContent);
|
||||
useLayoutStore().changeWaterMark("");
|
||||
useLayoutStore().changeWaterMark('');
|
||||
}
|
||||
// 网络错误时退出登录状态
|
||||
if (res.code === 0) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { changeValue } from '@/api/system/config';
|
||||
import { uploadFile } from '@/api/tool/file';
|
||||
import { FileType } from 'ant-design-vue/lib/upload/interface';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
import { sessionGet } from '@/utils/cache-session-utils';
|
||||
const appStore = useAppStore();
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -62,8 +63,11 @@ function fnUpload(up: UploadRequestOption) {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success('文件上传成功,提交保存生效', 3);
|
||||
state.filePath = res.data.fileName;
|
||||
const baseApi = import.meta.env.VITE_API_BASE_URL;
|
||||
state.flag = `${baseApi}${res.data.fileName}`;
|
||||
// 兼容旧前端可改配置文件
|
||||
const baseUrl = import.meta.env.PROD
|
||||
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
||||
: import.meta.env.VITE_API_BASE_URL;
|
||||
state.flag = `${baseUrl}${res.data.fileName}`;
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
@@ -181,7 +185,12 @@ onMounted(() => {
|
||||
|
||||
<template v-else>
|
||||
<a-button type="default" @click="fnEdit(true)"> 编辑 </a-button>
|
||||
<a-button type="text" danger style="margin-left: 10px" @click="fnRevert">
|
||||
<a-button
|
||||
type="text"
|
||||
danger
|
||||
style="margin-left: 10px"
|
||||
@click="fnRevert"
|
||||
>
|
||||
还原
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user