You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
/**
|
|
* 租户信息 store
|
|
*/
|
|
import { defineStore } from 'pinia';
|
|
import { getSiteInfo } from '@/api/layout';
|
|
import { Tenant } from '@/api/system/tennat/model';
|
|
import { Company } from '@/api/system/company/model';
|
|
import { WebsiteParam } from '@/api/cms/website/field/model';
|
|
// const EXTRA_MENUS: any = [];
|
|
|
|
export interface UserState {
|
|
tenant : Tenant | null;
|
|
company : Company | null;
|
|
params : WebsiteParam | null;
|
|
}
|
|
|
|
export const useTenantStore = defineStore({
|
|
id: 'tenant',
|
|
state: () : UserState => ({
|
|
// 租户信息
|
|
tenant: null,
|
|
// 企业信息
|
|
company: null,
|
|
// 参数配置
|
|
params: {},
|
|
}),
|
|
getters: {},
|
|
actions: {
|
|
/**
|
|
* 请求用户信息、权限、角色、菜单
|
|
*/
|
|
async fetchTenantInfo() {
|
|
const company = await getSiteInfo().catch(() => void 0);
|
|
if (!company) {
|
|
return {};
|
|
}
|
|
// 租户信息
|
|
this.company = company;
|
|
// 企业信息
|
|
if (company) {
|
|
this.company = company;
|
|
// 获取配置参数
|
|
// if (company.fields) {
|
|
// const obj = {}
|
|
// company.fields.map(d => {
|
|
// const key = d.name;
|
|
// obj[key] = d.value
|
|
// })
|
|
// this.setParams(obj);
|
|
// }
|
|
|
|
// localStorage.setItem('TenantId', String(company.tenantId));
|
|
// localStorage.setItem('TenantName', String(company.companyName));
|
|
// localStorage.setItem('CompanyId', String(company.companyId));
|
|
}
|
|
return company;
|
|
},
|
|
/**
|
|
* 更新租户信息
|
|
*/
|
|
setInfo(value : Tenant) {
|
|
this.tenant = value;
|
|
}
|
|
|
|
}
|
|
});
|