import { Injectable } from '@angular/core'; import { RhStorageService, RhAppConfigService } from 'rh-base/core'; import { RhLoginedUserDto, RhMenusDto } from 'rh-base/model'; import { Subject } from 'rxjs'; /** 程序根服务,用于存取整个程序中通用的一些数据 */ @Injectable({ providedIn: 'root' }) export class AppService { // /** 车间列表 */ // workshopList: WorkShopLineInfoDto[] = []; // private workshopSubject = new BehaviorSubject(false); // get workshopSubject$() { // return this.workshopSubject.asObservable(); // } // /** 触发弹出车间选择对话框 */ // workshopTrigger(status: boolean) { // this.workshopSubject.next(status); // } // 调试组件订阅方法 private debugSubject = new Subject(); get debugSubject$() { return this.debugSubject.asObservable(); } debugSubjectTrigger(status: boolean) { this.debugSubject.next(status); } /** 项目配置 */ get projectConfig() { return this.appConfigSer.projectConfig; } get currentMenu() { return this.storage.get('CURRENT_MENU') as RhMenusDto; } constructor(private storage: RhStorageService, private appConfigSer: RhAppConfigService) {} getUser(): RhLoginedUserDto { return this.storage.getUserSession()?.User as RhLoginedUserDto; } getDebug() { return this.storage.getDebug(); } setLoginStatus(status: boolean) { this.storage.setLoginStatus(status); } getUserSession() { return this.storage.getUserSession(); } //#region 车间存储区域 // storeWorkshop(dto: WorkShopLineInfoDto) { // this.storage.store('CURRENT_WORKSHOP', dto); // } // getWorkshop(): WorkShopLineInfoDto { // const target = this.storage.get('CURRENT_WORKSHOP'); // return target ? target : null; // } removeWorkshop(menu: RhMenusDto) { this.storage.remove(`CURRENT_WORKSHOP_${menu ? menu.Url : this.currentMenu.Url}`); } //#endregion 车间存储区域结束 }