feat(config): 支持配置 API 基础路径和开发环境标识
- 在配置存储中新增 dev 和 apiBaseUrl 字段 - 设置默认配置对象,包含基础 URL 构造逻辑 - 更新请求工具以使用动态配置的 baseURL - 调整应用初始化顺序确保配置先行加载 - 移除指令中不必要的调试日志输出
This commit is contained in:
@@ -11,16 +11,25 @@ export interface Config {
|
||||
agentRepository: {
|
||||
storageVersionIdentifier: string
|
||||
}
|
||||
// 是否是开发环境
|
||||
dev?: boolean
|
||||
// api base url
|
||||
apiBaseUrl?: string
|
||||
}
|
||||
|
||||
|
||||
const defaultConfig: Config = {
|
||||
apiBaseUrl: `${import.meta.env.BASE_URL || '/'}api`
|
||||
} as Config
|
||||
export const useConfigStore = defineStore('config', () => {
|
||||
const config = ref<Config>({} as Config)
|
||||
|
||||
// 异步调用readConfig
|
||||
async function initConfig() {
|
||||
config.value = await readConfig<Config>('config.json')
|
||||
const data = await readConfig<Config>('config.json')
|
||||
config.value = {
|
||||
...defaultConfig,
|
||||
...data
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user