|
@@ -1,5 +1,6 @@
|
|
import _ from 'lodash'
|
|
import _ from 'lodash'
|
|
import $ from 'jquery'
|
|
import $ from 'jquery'
|
|
|
|
+import qs from 'qs'
|
|
|
|
|
|
export default function () {
|
|
export default function () {
|
|
|
|
|
|
@@ -14,11 +15,14 @@ export default function () {
|
|
}),
|
|
}),
|
|
|
|
|
|
constructor(config) {
|
|
constructor(config) {
|
|
- const self = this
|
|
|
|
|
|
+ const me = this
|
|
const newConfig = _.defaultsDeep({}, config, {
|
|
const newConfig = _.defaultsDeep({}, config, {
|
|
listeners: {
|
|
listeners: {
|
|
tabchange(tabPanel, newCard, oldCard, eOpts) {
|
|
tabchange(tabPanel, newCard, oldCard, eOpts) {
|
|
- console.log('tabChange')
|
|
|
|
|
|
+ _.defer(() => {
|
|
|
|
+ me.changeHash(newCard.path)
|
|
|
|
+ })
|
|
|
|
+
|
|
$(window).trigger('tabChange', {
|
|
$(window).trigger('tabChange', {
|
|
tabPanel, newCard, oldCard, eOpts
|
|
tabPanel, newCard, oldCard, eOpts
|
|
});
|
|
});
|
|
@@ -29,7 +33,40 @@ export default function () {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- this.superclass.constructor.call(self, newConfig)
|
|
|
|
|
|
+ this.superclass.constructor.call(me, newConfig)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ initComponent() {
|
|
|
|
+ const me = this
|
|
|
|
+ this.on({
|
|
|
|
+ afterrender() {
|
|
|
|
+ _.defer(() => {
|
|
|
|
+ me.tryRestoryPage()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.superclass.initComponent.call(me)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ tryRestoryPage() {
|
|
|
|
+ const me = this
|
|
|
|
+ let hash = '' + window.location.hash
|
|
|
|
+ if (hash && hash.indexOf('page=') > 0) {
|
|
|
|
+ if (hash.startsWith('#')) {
|
|
|
|
+ hash = hash.substr(1)
|
|
|
|
+ }
|
|
|
|
+ if (hash) {
|
|
|
|
+ const {page} = qs.parse(hash)
|
|
|
|
+ if (page) {
|
|
|
|
+ // this.openScope(page)
|
|
|
|
+ me.fireEvent('restorypage', page)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ changeHash(pageUrl) {
|
|
|
|
+ window.location.hash = qs.stringify({page: pageUrl})
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -38,6 +75,7 @@ export default function () {
|
|
* @param config ExtJS配置对象
|
|
* @param config ExtJS配置对象
|
|
*/
|
|
*/
|
|
addScope(scopeInstance, config, reload) {
|
|
addScope(scopeInstance, config, reload) {
|
|
|
|
+ const me = this
|
|
if (config.path) {
|
|
if (config.path) {
|
|
for (let i = 0; i < this.items.items.length; i++) {
|
|
for (let i = 0; i < this.items.items.length; i++) {
|
|
// 找到当前 tabs 里有没有已经打开过
|
|
// 找到当前 tabs 里有没有已经打开过
|
|
@@ -56,12 +94,17 @@ export default function () {
|
|
}
|
|
}
|
|
|
|
|
|
// 添加业务模块
|
|
// 添加业务模块
|
|
- this.add({
|
|
|
|
|
|
+ const newTab = this.add({
|
|
closable: true,
|
|
closable: true,
|
|
...config,
|
|
...config,
|
|
})
|
|
})
|
|
|
|
|
|
this.setActiveTab(scopeInstance._handle);
|
|
this.setActiveTab(scopeInstance._handle);
|
|
|
|
+ newTab.on({
|
|
|
|
+ destroy(sender) {
|
|
|
|
+ me.changeHash('')
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|