From 5124b390a7bdb9238607299b781ea4bfca3c7e6a Mon Sep 17 00:00:00 2001 From: wangxiaogang <1433729587@qq.com> Date: Mon, 8 Jun 2026 11:02:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20configStore=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C=E7=AD=89=E5=BE=85=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - appName/appSlogan/appDescription 改为 computed,从 config 读取 - 后端配置加载完成前为空字符串 --- client/src/stores/config.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/client/src/stores/config.ts b/client/src/stores/config.ts index eb399da..371da2c 100644 --- a/client/src/stores/config.ts +++ b/client/src/stores/config.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import { ref } from 'vue' +import { ref, computed } from 'vue' import { getConfig } from '@/api/config' /** 系统配置 store,全局缓存品牌文案等配置 */ @@ -7,23 +7,20 @@ export const useConfigStore = defineStore('config', () => { const config = ref>({}) const loaded = ref(false) - /** 品牌名称 */ - const appName = ref('小菜记账') + /** 品牌名称(后端返回前为空) */ + const appName = computed(() => config.value.app_name || '') /** 品牌标语 */ - const appSlogan = ref('温暖 x 轻松的个人记账小程序') + const appSlogan = computed(() => config.value.app_slogan || '') /** 品牌描述 */ - const appDescription = ref('让记账从负担变成享受') + const appDescription = computed(() => config.value.app_description || '') async function fetchConfig() { try { const data = await getConfig() config.value = data - if (data.app_name) appName.value = data.app_name - if (data.app_slogan) appSlogan.value = data.app_slogan - if (data.app_description) appDescription.value = data.app_description loaded.value = true } catch { - // 配置加载失败时使用默认值 + // 配置加载失败 } }