fix: 默认LOGO

This commit is contained in:
TsMask
2023-10-26 09:29:53 +08:00
parent b56530d44c
commit 3950ec3159

View File

@@ -1,26 +1,11 @@
import { getSysConf } from '@/api';
import defaultLOGO from '@/assets/logo_icon.png';
import defaultLOGOIcon from '@/assets/logo_icon.png';
import defaultLOGOBrand from '@/assets/logo_brand.png';
import defaultLoginBackground from '@/assets/background.svg';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { validHttp } from '@/utils/regular-utils';
import { defineStore } from 'pinia';
/**
* 格式解析LOGO地址
* @param 资源路径
* @returns url地址
*/
function parseLOGO(path: string): string {
if (!path) {
return defaultLOGO;
}
if (validHttp(path)) {
return path;
}
const baseApi = import.meta.env.VITE_API_BASE_URL;
return `${baseApi}${path}`;
}
/**应用参数类型 */
type AppStore = {
/**应用名称 */
@@ -61,7 +46,15 @@ const useAppStore = defineStore('app', {
* @returns LOGO地址url
*/
getLOGOIcon(state) {
return parseLOGO(state.filePathIcon);
const path = state.filePathIcon;
if (!path) {
return defaultLOGOIcon;
}
if (validHttp(path)) {
return path;
}
const baseApi = import.meta.env.VITE_API_BASE_URL;
return `${baseApi}${path}`;
},
/**
* 获取正确LOGO地址-brand
@@ -69,7 +62,15 @@ const useAppStore = defineStore('app', {
* @returns LOGO地址url
*/
getLOGOBrand(state) {
return parseLOGO(state.filePathBrand);
const path = state.filePathBrand;
if (!path) {
return defaultLOGOBrand;
}
if (validHttp(path)) {
return path;
}
const baseApi = import.meta.env.VITE_API_BASE_URL;
return `${baseApi}${path}`;
},
/**
* 获取正确登录背景地址
@@ -128,10 +129,10 @@ const useAppStore = defineStore('app', {
// 修改html内容
const iconDom = document.querySelector("link[rel~='icon']");
if (iconDom) {
if(this.logoType === 'icon'){
if (this.logoType === 'icon') {
iconDom.setAttribute('href', this.getLOGOIcon);
}
if(this.logoType === 'brand'){
if (this.logoType === 'brand') {
iconDom.setAttribute('href', this.getLOGOBrand);
}
}