From ac33e4f8257a42a86d61c7f51d73d0f211655586 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Fri, 10 Dec 2021 12:03:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E6=A0=87=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Vue/.env.development | 6 ++-
ZR.Vue/.env.production | 5 ++-
ZR.Vue/.env.staging | 5 ++-
ZR.Vue/src/App.vue | 6 +--
.../src/layout/components/Settings/index.vue | 39 ++++++++++++++-----
ZR.Vue/src/permission.js | 3 +-
ZR.Vue/src/settings.js | 5 ++-
ZR.Vue/src/store/modules/settings.js | 10 ++++-
ZR.Vue/vue.config.js | 12 ------
9 files changed, 59 insertions(+), 32 deletions(-)
diff --git a/ZR.Vue/.env.development b/ZR.Vue/.env.development
index d7d1cf0..e3942d6 100644
--- a/ZR.Vue/.env.development
+++ b/ZR.Vue/.env.development
@@ -1,8 +1,10 @@
-# 关于此文件说明 必须以VUE_APP开头
# 开发环境配置
ENV = 'development'
-# ZR管理系统/开发环境
+# 页面标题
+VUE_APP_TITLE = ZrAdmin.NET管理系统
+
+# 开发环境
VUE_APP_BASE_API = '/dev-api'
# 路由前缀
diff --git a/ZR.Vue/.env.production b/ZR.Vue/.env.production
index 163fe39..c615a61 100644
--- a/ZR.Vue/.env.production
+++ b/ZR.Vue/.env.production
@@ -1,7 +1,10 @@
# 生产环境配置
ENV = 'production'
-# ZR管理系统/生产环境
+# 页面标题
+VUE_APP_TITLE = ZrAdmin.NET管理系统
+
+# 生产环境
VUE_APP_BASE_API = '/prod-api'
# 路由前缀
diff --git a/ZR.Vue/.env.staging b/ZR.Vue/.env.staging
index 184dcfe..6907d21 100644
--- a/ZR.Vue/.env.staging
+++ b/ZR.Vue/.env.staging
@@ -1,7 +1,10 @@
# 测试环境配置
ENV = 'staging'
-# ZR管理系统/生产环境
+# 页面标题
+VUE_APP_TITLE = ZrAdmin.NET管理系统
+
+# 测试环境
VUE_APP_BASE_API = '/stage-api'
# 路由前缀
diff --git a/ZR.Vue/src/App.vue b/ZR.Vue/src/App.vue
index e448b11..907acd2 100644
--- a/ZR.Vue/src/App.vue
+++ b/ZR.Vue/src/App.vue
@@ -5,7 +5,7 @@
diff --git a/ZR.Vue/src/layout/components/Settings/index.vue b/ZR.Vue/src/layout/components/Settings/index.vue
index df3d3f3..423f4d9 100644
--- a/ZR.Vue/src/layout/components/Settings/index.vue
+++ b/ZR.Vue/src/layout/components/Settings/index.vue
@@ -10,7 +10,8 @@
@@ -20,7 +21,8 @@
@@ -55,6 +57,10 @@
显示 Logo
+
+ 动态标题
+
+
保存配置
@@ -88,17 +94,20 @@ export default {
},
topNav: {
get() {
- return this.$store.state.settings.topNav
+ return this.$store.state.settings.topNav;
},
set(val) {
- this.$store.dispatch('settings/changeSetting', {
- key: 'topNav',
- value: val
- })
+ this.$store.dispatch("settings/changeSetting", {
+ key: "topNav",
+ value: val,
+ });
if (!val) {
- this.$store.commit("SET_SIDEBAR_ROUTERS", this.$store.state.permission.defaultRoutes);
+ this.$store.commit(
+ "SET_SIDEBAR_ROUTERS",
+ this.$store.state.permission.defaultRoutes
+ );
}
- }
+ },
},
tagsView: {
get() {
@@ -122,6 +131,17 @@ export default {
});
},
},
+ dynamicTitle: {
+ get() {
+ return this.$store.state.settings.dynamicTitle;
+ },
+ set(val) {
+ this.$store.dispatch("settings/changeSetting", {
+ key: "dynamicTitle",
+ value: val,
+ });
+ },
+ },
},
methods: {
themeChange(val) {
@@ -154,6 +174,7 @@ export default {
"tagsView":${this.tagsView},
"fixedHeader":${this.fixedHeader},
"sidebarLogo":${this.sidebarLogo},
+ "dynamicTitle":${this.dynamicTitle},
"sideTheme":"${this.sideTheme}",
"theme":"${this.theme}"
}`
diff --git a/ZR.Vue/src/permission.js b/ZR.Vue/src/permission.js
index 924803a..4ec5adc 100644
--- a/ZR.Vue/src/permission.js
+++ b/ZR.Vue/src/permission.js
@@ -13,9 +13,10 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register', '/demo']
router.beforeEach((to, from, next) => {
NProgress.start()
- console.log('router to ' + to.path);
+ console.log('path=' + to.path);
if (getToken()) {
+ to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
diff --git a/ZR.Vue/src/settings.js b/ZR.Vue/src/settings.js
index 6d7d224..27e509d 100644
--- a/ZR.Vue/src/settings.js
+++ b/ZR.Vue/src/settings.js
@@ -37,7 +37,10 @@ module.exports = {
* 是否显示logo
*/
sidebarLogo: true,
-
+ /**
+ * 是否显示动态标题
+ */
+ dynamicTitle: false,
/**
* @type {string | array} 'production' | ['production', 'development']
* @description Need show err logs component.
diff --git a/ZR.Vue/src/store/modules/settings.js b/ZR.Vue/src/store/modules/settings.js
index 907cede..67c5567 100644
--- a/ZR.Vue/src/store/modules/settings.js
+++ b/ZR.Vue/src/store/modules/settings.js
@@ -1,9 +1,10 @@
import defaultSettings from '@/settings'
-const { theme, sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo } = defaultSettings
+const { theme, sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
const state = {
+ title: '',
theme: storageSetting.theme || theme, //主题颜色
sideTheme: storageSetting.sideTheme || sideTheme, //侧边主题样式
topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,
@@ -11,7 +12,7 @@ const state = {
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
- // dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
+ dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
}
const mutations = {
@@ -26,6 +27,11 @@ const actions = {
//修改布局设置
changeSetting({ commit }, data) {
commit('CHANGE_SETTING', data)
+ },
+ // 设置网页标题
+ setTitle({ commit }, title) {
+ state.title = title;
+ document.title = state.dynamicTitle ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE;
}
}
diff --git a/ZR.Vue/vue.config.js b/ZR.Vue/vue.config.js
index a366f0e..8e08514 100644
--- a/ZR.Vue/vue.config.js
+++ b/ZR.Vue/vue.config.js
@@ -1,7 +1,6 @@
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
-// const FileManagerPlugin = require('filemanager-webpack-plugin');
function resolve(dir) {
return path.join(__dirname, dir)
@@ -53,17 +52,6 @@ module.exports = {
}
},
plugins: [
- // new FileManagerPlugin({
- // events: {
- // onEnd: {
- // //首先需要删除项目根目录下的dist.zip
- // delete: ["./dist/*.zip"],
-
- // //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
- // archive: [{ source: "./dist", destination: "./dist/dist.zip" }]
- // }
- // }
- // })
]
},
chainWebpack(config) {