Browse Source

maintab on

luoyifan 3 years ago
parent
commit
abc3cda1c2
1 changed files with 15 additions and 16 deletions
  1. 15 16
      src/controls/MainTab.js

+ 15 - 16
src/controls/MainTab.js

@@ -1,6 +1,7 @@
 import _ from 'lodash'
 import $ from 'jquery'
 import qs from 'qs'
+import {invokeMethod} from "../utils";
 
 export default function () {
 
@@ -16,29 +17,26 @@ export default function () {
 
         constructor(config) {
             const me = this
-            const newConfig = _.defaultsDeep({}, config, {
-                listeners: {
-                    tabchange(tabPanel, newCard, oldCard, eOpts) {
-                        _.defer(() => {
-                            me.changeHash(newCard.path)
-                        })
+            const newConfig = _.defaultsDeep({
+                // 强制属性
 
-                        $(window).trigger('tabChange', {
-                            tabPanel, newCard, oldCard, eOpts
-                        });
-
-                        if (typeof config.tabchange === 'function') {
-                            config.tabchange.apply(this, arguments)
-                        }
-                    }
-                }
-            })
+            }, config)
             this.superclass.constructor.call(me, newConfig)
         },
 
         initComponent() {
             const me = this
             this.on({
+                tabchange(tabPanel, newCard, oldCard, eOpts) {
+                    _.defer(() => {
+                        me.changeHash(newCard.path)
+                        window['cp'] = newCard
+                    })
+
+                    $(window).trigger('tabChange', {
+                        tabPanel, newCard, oldCard, eOpts
+                    });
+                },
                 afterrender() {
                     _.defer(() => {
                         me.tryRestoryPage()
@@ -103,6 +101,7 @@ export default function () {
             newTab.on({
                 destroy(sender) {
                     me.changeHash('')
+                    delete window['cp']
                 }
             })
         }