SysPage.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import System from '@/Engine/ECS/System';
  2. import { PAGE_KEY } from '@/Project/constants';
  3. import { getDvaApp } from 'umi';
  4. class SysRouter extends System {
  5. dispatch: any;
  6. constructor(name: string) {
  7. super(name);
  8. console.log('init SysPage');
  9. this.dispatch = getDvaApp()._store.dispatch;
  10. }
  11. /**
  12. * 新增界面
  13. * @param key 页面的唯一key
  14. * @param params 页面的参数
  15. */
  16. add(key: PAGE_KEY, params?: any) {
  17. this.dispatch({
  18. type: 'page/add',
  19. payload: { key, params },
  20. });
  21. }
  22. // 删除选中页面
  23. remove() {
  24. this.dispatch({
  25. type: 'page/remove',
  26. payload: {},
  27. });
  28. }
  29. // 根据pageId删除页面
  30. removeById(id?: number) {
  31. this.dispatch({
  32. type: 'page/remove',
  33. payload: { id },
  34. });
  35. }
  36. // 根据pageId删除页面
  37. removeByKey(key?: PAGE_KEY) {
  38. this.dispatch({
  39. type: 'page/removeByKey',
  40. payload: { key },
  41. });
  42. }
  43. /**
  44. * 跳转界面
  45. * @param key 新界面的唯一key
  46. * @param params 新界面的参数
  47. * @param id 待跳转的pageID
  48. */
  49. push(key: string, params?: any, id?: number) {
  50. this.dispatch({
  51. type: 'page/replace',
  52. payload: { key, params, id },
  53. });
  54. }
  55. /**
  56. * 返回界面
  57. * @param id 待返回的pageID
  58. */
  59. back(id?: number) {
  60. this.dispatch({
  61. type: 'page/back',
  62. payload: { id },
  63. });
  64. }
  65. /**
  66. * 界面最小化
  67. * @param index 界面的index
  68. * @param options 界面的配置信息
  69. */
  70. zoomOut(index: number, options: GT.IPageOptions) {
  71. this.dispatch({
  72. type: 'page/zoomOut',
  73. payload: { index, options },
  74. });
  75. }
  76. /**
  77. * 最大化
  78. * @param index 界面的index
  79. */
  80. zoomIn(index: number) {
  81. this.dispatch({
  82. type: 'page/zoomIn',
  83. payload: { index },
  84. });
  85. }
  86. }
  87. export default new SysRouter('SysRouter');