研发图纸文件管理系统-前端项目
chenghongxing
2020-11-28 ae2b7a86ef8d83141a05b6972c9a03258381ba2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const TabsPagePlugin = {
  install(Vue) {
    Vue.mixin({
      methods: {
        $closePage(closeRoute, nextRoute) {
          const event = new CustomEvent('page:close', {detail:{closeRoute, nextRoute}})
          window.dispatchEvent(event)
        },
        $refreshPage(pageKey) {
          const event = new CustomEvent('page:refresh', {detail:{pageKey}})
          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