This commit is contained in:
Taric Xin
2022-01-04 18:00:50 +08:00
parent 94536ab262
commit ae2bde8d33
8 changed files with 267 additions and 74 deletions

View File

@ -5,7 +5,7 @@ import { BaseService } from '../core/base.service';
import { EACacheService } from './../core/cache.service';
@Injectable({
providedIn: 'root',
providedIn: 'root'
})
export class EAEnvironmentService extends BaseService {
constructor(public injector: Injector, private eaCacheSrv: EACacheService) {
@ -15,12 +15,13 @@ export class EAEnvironmentService extends BaseService {
/**
* 环境信息
*/
public get env(): { appId: string; tenantId: string } {
public get env(): { appId: string; tenantId: string; enterpriseId: string } {
const cacheEnv: any = this.eaCacheSrv.get(cacheConf.env);
// 附加环境变量
const env: { appId: string; tenantId: string } = {
const env: { appId: string; tenantId: string; enterpriseId: string } = {
appId: cacheEnv?.appId || sysConf.appId,
tenantId: cacheEnv?.tenantId || sysConf.tenantId,
enterpriseId: cacheEnv?.enterpriseId || sysConf.enterpriseId
};
return env;
}

View File

@ -135,6 +135,11 @@ export class EAUserService extends BaseService {
*/
async loadUserInfo() {
return this.asyncRequest(this.$api_get_user_by_token).then(res => {
this.cacheSrv.set(cacheConf.env, {
appId: sysConf.appId,
tenantId: res?.tenantId || sysConf.tenantId,
enterpriseId: res?.enterpriseId || sysConf.enterpriseId
});
this.cacheSrv.set(cacheConf.user, res);
this.settings.setUser(res);
});