import Func from '@/Engine/ECS/Function'; import { BuildNodeCode, GlobalCockpit, OpsNodeCode, PAGE_KEY, } from '@/Project/constants'; import { getToken } from '@/Project/utils'; import { FuncMainState } from '../FuncMain'; export enum FuncPlatformMenuState { PlatformMenu, } export default class FuncPlatformMenu extends Func { constructor(name: string) { super(name); super.initStates((sm) => { sm.addState( FuncPlatformMenuState.PlatformMenu, this.onStateIn, null, this.onStateExit, this, ); }); } onStateIn(): void { window.GT_APP.sysPage.add(PAGE_KEY.PlatformMenu, { onClickMenu: this.onClickMenu, }); } onStateExit(): void { window.GT_APP.sysPage.removeByKey(PAGE_KEY.PlatformMenu); } onClickMenu(element: Api.IMenu) { const funcMain = window.GT_APP.funcMain; if (element.Code == BuildNodeCode) { funcMain.subModule = 1; funcMain.changeState(FuncMainState.ProjectSelection); } else if (element.Code == OpsNodeCode) { funcMain.subModule = 2; funcMain.changeState(FuncMainState.ProjectSelection); } else if (element.Code == GlobalCockpit) { //TODO: 跳转全局驾驶舱 } else { if (element.WebPath == undefined) return; //网页端跳转页面 let curHref = window.location.href; let sign = '?'; if (curHref.indexOf('?') != -1) { sign = '&'; } let isUrl = element.WebPath.indexOf('http') != -1 || element.WebPath.indexOf('https') != -1; if (isUrl) window.location.href = element.WebPath + sign + 'JWT-TOKEN=' + getToken(); } } }