4
0
mirror of https://github.com/iczer/vue-antd-admin.git synced 2025-10-13 20:36:59 +08:00
vue-antd-admin/src/plugins/tabs-page-plugin.js
chenghongxing ae1f7e5197 修复:设置页签标题不生效的bug;🐛
fix: the problem that setting tabs title not affect;
2020-11-29 20:10:31 +08:00

38 lines
1.1 KiB
JavaScript

const TabsPagePlugin = {
install(Vue) {
Vue.mixin({
methods: {
$closePage(closeRoute, nextRoute) {
const event = new CustomEvent('page:close', {detail:{closeRoute, nextRoute}})
window.dispatchEvent(event)
},
$refreshPage(route) {
const path = typeof route === 'object' ? route.path : route
const event = new CustomEvent('page:refresh', {detail:{pageKey: path}})
window.dispatchEvent(event)
},
$openPage(route, title) {
this.$setPageTitle(route, title)
this.$router.push(route)
},
$setPageTitle(route, title) {
if (title) {
const path = typeof route === 'object' ? route.path : route
this.$store.commit('setting/setCustomTitle', {path, title})
}
}
},
computed: {
customTitle() {
const customTitles = this.$store.state.setting.customTitles
const path = this.$route.path
const custom = customTitles.find(item => item.path === path)
return custom && custom.title
}
}
})
}
}
export default TabsPagePlugin