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 { - // 配置加载失败时使用默认值 + // 配置加载失败 } }