FuncPlatformMenu.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Func from '@/Engine/ECS/Function';
  2. import {
  3. BuildNodeCode,
  4. GlobalCockpit,
  5. OpsNodeCode,
  6. PAGE_KEY,
  7. } from '@/Project/constants';
  8. import { getToken } from '@/Project/utils';
  9. import { FuncMainState } from '../FuncMain';
  10. export enum FuncPlatformMenuState {
  11. PlatformMenu,
  12. }
  13. export default class FuncPlatformMenu extends Func<FuncPlatformMenuState> {
  14. constructor(name: string) {
  15. super(name);
  16. super.initStates((sm) => {
  17. sm.addState(
  18. FuncPlatformMenuState.PlatformMenu,
  19. this.onStateIn,
  20. null,
  21. this.onStateExit,
  22. this,
  23. );
  24. });
  25. }
  26. onStateIn(): void {
  27. window.GT_APP.sysPage.add(PAGE_KEY.PlatformMenu, {
  28. onClickMenu: this.onClickMenu,
  29. });
  30. }
  31. onStateExit(): void {
  32. window.GT_APP.sysPage.removeByKey(PAGE_KEY.PlatformMenu);
  33. }
  34. onClickMenu(element: Api.IMenu) {
  35. const funcMain = window.GT_APP.funcMain;
  36. if (element.Code == BuildNodeCode) {
  37. funcMain.subModule = 1;
  38. funcMain.changeState(FuncMainState.ProjectSelection);
  39. } else if (element.Code == OpsNodeCode) {
  40. funcMain.subModule = 2;
  41. funcMain.changeState(FuncMainState.ProjectSelection);
  42. } else if (element.Code == GlobalCockpit) {
  43. //TODO: 跳转全局驾驶舱
  44. } else {
  45. if (element.WebPath == undefined) return;
  46. //网页端跳转页面
  47. let curHref = window.location.href;
  48. let sign = '?';
  49. if (curHref.indexOf('?') != -1) {
  50. sign = '&';
  51. }
  52. let isUrl =
  53. element.WebPath.indexOf('http') != -1 ||
  54. element.WebPath.indexOf('https') != -1;
  55. if (isUrl)
  56. window.location.href =
  57. element.WebPath + sign + 'JWT-TOKEN=' + getToken();
  58. }
  59. }
  60. }