refactor(api): 重构 API调用并优化企业信息处理
- 移除各 API函数中的重复 headers 设置 - 在全局请求拦截器中添加企业 ID 头部信息 - 优化企业信息状态管理,确保信息不为空时才进行更新 -调整 API 调用方式,统一使用新格式
This commit is contained in:
@ -7,8 +7,12 @@ interface EnterpriseInfo {
|
||||
used_sub_account_count: number;
|
||||
}
|
||||
|
||||
interface EnterpriseState {
|
||||
enterpriseInfo: EnterpriseInfo | null;
|
||||
}
|
||||
|
||||
export const useEnterpriseStore = defineStore('enterprise', {
|
||||
state: () => ({
|
||||
state: (): EnterpriseState => ({
|
||||
// todo 暂时写死,登录功能完成后记得重置为null哦
|
||||
enterpriseInfo: {
|
||||
id: 1,
|
||||
@ -24,15 +28,21 @@ export const useEnterpriseStore = defineStore('enterprise', {
|
||||
this.enterpriseInfo = enterpriseInfo;
|
||||
},
|
||||
setEnterpriseName(name: string) {
|
||||
this.enterpriseInfo.name = name;
|
||||
if (this.enterpriseInfo) {
|
||||
this.enterpriseInfo.name = name;
|
||||
}
|
||||
},
|
||||
incUsedUpdateNameCount() {
|
||||
this.enterpriseInfo.used_update_name_count++;
|
||||
if (this.enterpriseInfo) {
|
||||
this.enterpriseInfo.used_update_name_count++;
|
||||
}
|
||||
},
|
||||
incUsedSubAccountCount() {
|
||||
this.enterpriseInfo.used_sub_account_count++;
|
||||
if (this.enterpriseInfo) {
|
||||
this.enterpriseInfo.used_sub_account_count++;
|
||||
}
|
||||
},
|
||||
getEnterpriseInfo(): EnterpriseInfo {
|
||||
getEnterpriseInfo(): EnterpriseInfo | null {
|
||||
return this.enterpriseInfo;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user