From 3e6eac1bfa9766f431bb2e59758a8f65f661960c Mon Sep 17 00:00:00 2001 From: XieYongHong <18010623010@163.com> Date: Fri, 9 Jun 2023 17:49:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=A0=87=E7=AD=BEtitl?= =?UTF-8?q?e=EF=BC=8Cico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/basis.ts | 2 ++ src/store/system.ts | 16 +++++++++++++++- src/views/system/Basis/index.vue | 10 ++++++---- src/views/user/Login/index.vue | 15 +++------------ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/api/system/basis.ts b/src/api/system/basis.ts index ea3677ec..267093fe 100644 --- a/src/api/system/basis.ts +++ b/src/api/system/basis.ts @@ -4,3 +4,5 @@ import server from '@/utils/request'; export const save_api = (data: any) => server.post(`/system/config/scope/_save`, data) // 获取详情 export const getDetails_api = (data: any) => server.post(`/system/config/scopes`, data) + +export const settingDetail = (scopes: string) => server.get(`/system/config/${scopes}`) diff --git a/src/store/system.ts b/src/store/system.ts index d5065be0..024daa98 100644 --- a/src/store/system.ts +++ b/src/store/system.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { systemVersion } from '@/api/comm' import { useMenuStore } from './menu' -import { getDetails_api } from '@/api/system/basis'; +import {getDetails_api, settingDetail} from '@/api/system/basis'; import type { ConfigInfoType } from '@/views/system/Basis/typing'; import { LocalStore } from '@/utils/comm' import { SystemConst } from '@/utils/consts' @@ -33,12 +33,26 @@ export const useSystem = defineStore('system', { } }) }, + async getFront () { + const res = await settingDetail('front') + if (res.success) { + const ico: any = document.querySelector('link[rel="icon"]'); + ico.href = res.result.ico; + document.title = res.result.title || ''; + } + }, async getSystemConfig() { const params = ['front', 'amap', 'paths']; const { status, result } = await getDetails_api(params); if (status === 200) { params.forEach((key: string) => { this.configInfo[key] = { ...result.find((item: any) => item.scope === key)?.properties } + if (key === 'front') { + const data = result.find((item: any) => item.scope === key).properties + const ico: any = document.querySelector('link[rel="icon"]'); + ico.href = data.ico; + document.title = data.title || ''; + } }) } } diff --git a/src/views/system/Basis/index.vue b/src/views/system/Basis/index.vue index 4a2dde94..0a5b541b 100644 --- a/src/views/system/Basis/index.vue +++ b/src/views/system/Basis/index.vue @@ -337,6 +337,8 @@ import { settingDetail } from '@/api/login'; const action = `${BASE_API_PATH}/file/static`; const headers = { [TOKEN_KEY]: LocalStore.get(TOKEN_KEY) }; const formRef = ref(); +const system = useSystem(); + const form = reactive({ formValue: { title: '', @@ -378,10 +380,10 @@ const form = reactive({ iconLoading: false, // 页签加载状态 saveLoading: false, getDetails: async () => { - const system = useSystem(); - await system.getSystemConfig(); - await settingDetail('front'); - const configInfo = system.$state.configInfo; + + // await system.getSystemConfig(); + // await settingDetail('front'); + const configInfo = system.configInfo; form.formValue = { title: configInfo.front?.title, headerTheme: configInfo.front?.headerTheme, diff --git a/src/views/user/Login/index.vue b/src/views/user/Login/index.vue index 4e563dc3..b98d58a3 100644 --- a/src/views/user/Login/index.vue +++ b/src/views/user/Login/index.vue @@ -172,11 +172,13 @@ import { settingDetail, userDetail } from '@/api/login' import { useUserInfo } from '@/store/userInfo'; +import { useSystem } from '@/store/system' import { LocalStore } from '@/utils/comm'; import { BASE_API_PATH, TOKEN_KEY, Version_Code } from '@/utils/variable'; import { SystemConst } from '@/utils/consts'; const store = useUserInfo(); +const systemStore = useSystem(); const router = useRouter(); const bgImage = getImage('/logo.png'); const viewLogo = getImage('/view-logo.png'); @@ -310,18 +312,7 @@ const getOpen = () => { } } }); - settingDetail('front').then((res: any) => { - if (res.status === 200) { - const ico: any = document.querySelector('link[rel="icon"]'); - ico.href = res.result.ico; - basis.value = res.result; - if (res.result.title) { - document.title = res.result.title; - } else { - document.title = ''; - } - } - }); + systemStore.getFront() }; const handleClickOther = (item: any) => {