From 3950ec3159547f77cdfa59655f5fa893b65e1577 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 26 Oct 2023 09:29:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4LOGO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/app.ts | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 6da5e628..efd92961 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -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); } }