4
0
mirror of https://github.com/iczer/vue-antd-admin.git synced 2025-05-11 23:39:03 +08:00
vue-antd-admin/src/plugins/tabs-page-plugin.js
chenghongxing d9b5e4b766 优化:刷新页签 api 增加路由对象参数支持;
optimize: add support of route parameter for refresh page api;
2020-11-29 14:31:22 +08:00

38 lines
1.2 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 fullPath = typeof route === 'object' ? route.fullPath : route
const event = new CustomEvent('page:refresh', {detail:{fullPath}})
window.dispatchEvent(event)
},
$openPage(route, title) {
this.$setPageTitle(route, title)
this.$router.push(route)
},
$setPageTitle(route, title) {
if (title) {
const fullPath = typeof route === 'object' ? route.fullPath : route
this.$store.commit('setting/setCustomTitle', {path: fullPath, title})
}
}
},
computed: {
customTitle() {
const customTitles = this.$store.state.setting.customTitles
const fullPath = this.$route.fullPath
const custom = customTitles.find(item => item.path === fullPath)
return custom && custom.title
}
}
})
}
}
export default TabsPagePlugin