From 0b99ea00960a5eafbc768acc82256856039d4273 Mon Sep 17 00:00:00 2001 From: easy <1358086367@qq.com> Date: Fri, 17 Mar 2023 14:32:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bug#10532=E3=80=8110531=E3=80=8110530?= =?UTF-8?q?=E3=80=8110527=E3=80=8110534=E3=80=8110529?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/system.ts | 13 ++++++++-- src/views/system/Basis/index.vue | 44 ++++++++++++-------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/store/system.ts b/src/store/system.ts index e4d37681..4f3e63f7 100644 --- a/src/store/system.ts +++ b/src/store/system.ts @@ -1,14 +1,17 @@ import { defineStore } from 'pinia'; import { systemVersion } from '@/api/comm' import { useMenuStore } from './menu' +import { getDetails_api } from '@/api/system/basis'; export const useSystem = defineStore('system', { state: () => ({ - isCommunity: false + isCommunity: false, + configInfo: [] as any[] }), actions: { getSystemVersion(): Promise { - return new Promise(async(res, rej) => { + this.getSystemConfig(); + return new Promise(async (res, rej) => { const resp = await systemVersion() if (resp.success && resp.result) { const isCommunity = resp.result.edition === 'community' @@ -19,6 +22,12 @@ export const useSystem = defineStore('system', { res(menuData) } }) + }, + getSystemConfig() { + const params = ['front', 'amap', 'paths']; + getDetails_api(params).then(({ status, result }: any) => { + this.configInfo = status === 200 ? [...result] : []; + }) } } }) \ No newline at end of file diff --git a/src/views/system/Basis/index.vue b/src/views/system/Basis/index.vue index 1d234219..a680c581 100644 --- a/src/views/system/Basis/index.vue +++ b/src/views/system/Basis/index.vue @@ -292,6 +292,7 @@ import { LocalStore } from '@/utils/comm'; import { save_api, getDetails_api } from '@/api/system/basis'; import { usePermissionStore } from '@/store/permission'; +import { useSystem } from '@/store/system'; const action = `${BASE_API_PATH}/file/static`; const headers = { [TOKEN_KEY]: LocalStore.get(TOKEN_KEY) }; @@ -302,9 +303,9 @@ const form = reactive({ headerTheme: 'light', apiKey: '', 'base-path': `${window.location.origin}/api`, - logo: '/public/logo.png', - ico: '/public/favicon.ico', - backgroud: '/public/images/login.png', + logo: '', + ico: '', + backgroud: '', }, rulesFrom: { title: [ @@ -337,31 +338,18 @@ const form = reactive({ iconLoading: false, // 页签加载状态 saveLoading: false, getDetails: () => { - const params = ['front', 'amap', 'paths']; - getDetails_api(params).then((resp: any) => { - const basis = resp.result?.filter( - (item: any) => item.scope === 'front', - ); - const api = resp.result?.filter( - (item: any) => item.scope === 'amap', - ); - const basePath = resp.result?.filter( - (item: any) => item.scope === 'paths', - ); - form.formValue = { - ...basis[0].properties, - apiKey: api[0].properties.apiKey, - 'base-path': basePath[0].properties['base-path'], - logo: form.formValue.logo || '/public/logo.png', - ico: form.formValue.ico || '/public/favicon.ico', - backgroud: - form.formValue.backgroud || '/public/images/login.png', - }; - // localStorage.setItem( - // SystemConst.AMAP_KEY, - // api[0].properties.apiKey, - // ); - }); + const configInfo = useSystem().$state.configInfo; + const basis = configInfo.find((item: any) => item.scope === 'front'); + const api = configInfo.find((item: any) => item.scope === 'amap'); + const basePath = configInfo.find((item: any) => item.scope === 'paths'); + form.formValue = { + ...basis.properties, + apiKey: api.properties.apiKey, + 'base-path': basePath.properties['base-path'], + logo: basis.properties.logo || '/public/logo.png', + ico: basis.properties.ico || '/public/favicon.ico', + backgroud: basis.properties.backgroud || '/public/images/login.png', + }; }, clickSave: () => { const hasPermission = usePermissionStore().hasPermission;