fix: 移除 configStore 默认值,等待后端返回

- appName/appSlogan/appDescription 改为 computed,从 config 读取
- 后端配置加载完成前为空字符串
This commit is contained in:
2026-06-08 11:02:16 +08:00
parent 6af876a8f4
commit 5124b390a7

View File

@@ -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<Record<string, string>>({})
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 {
// 配置加载失败时使用默认值
// 配置加载失败
}
}