12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import System from '@/Engine/ECS/System';
- import { PAGE_KEY } from '@/Project/constants';
- import { getDvaApp } from 'umi';
- class SysRouter extends System {
- dispatch: any;
- constructor(name: string) {
- super(name);
- console.log('init SysPage');
- this.dispatch = getDvaApp()._store.dispatch;
- }
- /**
- * 新增界面
- * @param key 页面的唯一key
- * @param params 页面的参数
- */
- add(key: PAGE_KEY, params?: any) {
- this.dispatch({
- type: 'page/add',
- payload: { key, params },
- });
- }
- // 删除选中页面
- remove() {
- this.dispatch({
- type: 'page/remove',
- payload: {},
- });
- }
- // 根据pageId删除页面
- removeById(id?: number) {
- this.dispatch({
- type: 'page/remove',
- payload: { id },
- });
- }
- // 根据pageId删除页面
- removeByKey(key?: PAGE_KEY) {
- this.dispatch({
- type: 'page/removeByKey',
- payload: { key },
- });
- }
- /**
- * 跳转界面
- * @param key 新界面的唯一key
- * @param params 新界面的参数
- * @param id 待跳转的pageID
- */
- push(key: string, params?: any, id?: number) {
- this.dispatch({
- type: 'page/replace',
- payload: { key, params, id },
- });
- }
- /**
- * 返回界面
- * @param id 待返回的pageID
- */
- back(id?: number) {
- this.dispatch({
- type: 'page/back',
- payload: { id },
- });
- }
- /**
- * 界面最小化
- * @param index 界面的index
- * @param options 界面的配置信息
- */
- zoomOut(index: number, options: GT.IPageOptions) {
- this.dispatch({
- type: 'page/zoomOut',
- payload: { index, options },
- });
- }
- /**
- * 最大化
- * @param index 界面的index
- */
- zoomIn(index: number) {
- this.dispatch({
- type: 'page/zoomIn',
- payload: { index },
- });
- }
- }
- export default new SysRouter('SysRouter');
|