fix: 默认LOGO
This commit is contained in:
@@ -1,26 +1,11 @@
|
|||||||
import { getSysConf } from '@/api';
|
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 defaultLoginBackground from '@/assets/background.svg';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { validHttp } from '@/utils/regular-utils';
|
import { validHttp } from '@/utils/regular-utils';
|
||||||
import { defineStore } from 'pinia';
|
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 = {
|
type AppStore = {
|
||||||
/**应用名称 */
|
/**应用名称 */
|
||||||
@@ -61,7 +46,15 @@ const useAppStore = defineStore('app', {
|
|||||||
* @returns LOGO地址url
|
* @returns LOGO地址url
|
||||||
*/
|
*/
|
||||||
getLOGOIcon(state) {
|
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
|
* 获取正确LOGO地址-brand
|
||||||
@@ -69,7 +62,15 @@ const useAppStore = defineStore('app', {
|
|||||||
* @returns LOGO地址url
|
* @returns LOGO地址url
|
||||||
*/
|
*/
|
||||||
getLOGOBrand(state) {
|
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内容
|
// 修改html内容
|
||||||
const iconDom = document.querySelector("link[rel~='icon']");
|
const iconDom = document.querySelector("link[rel~='icon']");
|
||||||
if (iconDom) {
|
if (iconDom) {
|
||||||
if(this.logoType === 'icon'){
|
if (this.logoType === 'icon') {
|
||||||
iconDom.setAttribute('href', this.getLOGOIcon);
|
iconDom.setAttribute('href', this.getLOGOIcon);
|
||||||
}
|
}
|
||||||
if(this.logoType === 'brand'){
|
if (this.logoType === 'brand') {
|
||||||
iconDom.setAttribute('href', this.getLOGOBrand);
|
iconDom.setAttribute('href', this.getLOGOBrand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user