feat:rename subtree from frontend-vue to frontend
This commit is contained in:
39
frontend/src/stores/modules/config.ts
Normal file
39
frontend/src/stores/modules/config.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { readConfig } from '@/utils/readJson.ts'
|
||||
import { store } from '@/stores'
|
||||
|
||||
export interface Config {
|
||||
title: string
|
||||
subTitle: string
|
||||
centerTitle: string
|
||||
taskPromptWords: string[]
|
||||
agentRepository: {
|
||||
storageVersionIdentifier: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const useConfigStore = defineStore('config', () => {
|
||||
const config = ref<Config>({} as Config)
|
||||
|
||||
// 异步调用readConfig
|
||||
async function initConfig() {
|
||||
config.value = await readConfig<Config>('config.json')
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
config,
|
||||
initConfig
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 用于在组件外部(如在Pinia Store 中)使用 Pinia 提供的 store 实例。
|
||||
* 官方文档解释了如何在组件外部使用 Pinia Store:
|
||||
* https://pinia.vuejs.org/core-concepts/outside-component-usage.html#using-a-store-outside-of-a-component
|
||||
*/
|
||||
export function useConfigStoreHook() {
|
||||
return useConfigStore(store)
|
||||
}
|
||||
Reference in New Issue
Block a user