From ae2b7a86ef8d83141a05b6972c9a03258381ba2f Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: 星期六, 28 十一月 2020 19:47:23 +0800 Subject: [PATCH] 新增:动态修改标题的 api;:star: #150 feat: add api of dynamic modify tab title; --- src/plugins/tabs-page-plugin.js | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/src/plugins/tabs-page-plugin.js b/src/plugins/tabs-page-plugin.js index eab3d74..d3c2ed2 100644 --- a/src/plugins/tabs-page-plugin.js +++ b/src/plugins/tabs-page-plugin.js @@ -9,6 +9,24 @@ $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 } } }) -- Gitblit v1.9.1