Commit 7bf9a85263e0c44b2bc88485b83557c129583f5c

Authored by YunaiV
1 parent 7df42db2

v3.5.0 系统布局配置支持动态标题开关

yudao-ui-admin/.env.demo1024
@@ -3,6 +3,9 @@ NODE_ENV = development @@ -3,6 +3,9 @@ NODE_ENV = development
3 # 测试环境配置 3 # 测试环境配置
4 ENV = 'staging' 4 ENV = 'staging'
5 5
  6 +# 页面标题
  7 +VUE_APP_TITLE = 芋道管理系统
  8 +
6 # 芋道管理系统/测试环境 9 # 芋道管理系统/测试环境
7 VUE_APP_BASE_API = 'http://127.0.0.1:48080' 10 VUE_APP_BASE_API = 'http://127.0.0.1:48080'
8 11
yudao-ui-admin/.env.development
1 # 开发环境配置 1 # 开发环境配置
2 ENV = 'development' 2 ENV = 'development'
3 3
  4 +# 页面标题
  5 +VUE_APP_TITLE = 芋道管理系统
  6 +
4 # 芋道管理系统/开发环境 7 # 芋道管理系统/开发环境
5 VUE_APP_BASE_API = '/dev-api' 8 VUE_APP_BASE_API = '/dev-api'
6 # VUE_APP_BASE_API = '/api' 9 # VUE_APP_BASE_API = '/api'
yudao-ui-admin/.env.production
1 # 生产环境配置 1 # 生产环境配置
2 ENV = 'production' 2 ENV = 'production'
3 3
  4 +# 页面标题
  5 +VUE_APP_TITLE = 芋道管理系统
  6 +
4 # 芋道管理系统/生产环境 7 # 芋道管理系统/生产环境
5 VUE_APP_BASE_API = '/prod-api' 8 VUE_APP_BASE_API = '/prod-api'
  9 +
6 # 根据服务器或域名修改 10 # 根据服务器或域名修改
7 PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/' 11 PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/'
8 # 二级部署路径 12 # 二级部署路径
yudao-ui-admin/.env.staging
1 NODE_ENV = production 1 NODE_ENV = production
2 2
  3 +# 页面标题
  4 +VUE_APP_TITLE = 芋道管理系统
  5 +
3 # 测试环境配置 6 # 测试环境配置
4 ENV = 'staging' 7 ENV = 'staging'
5 8
yudao-ui-admin/package.json
@@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
56 "vue": "2.6.12", 56 "vue": "2.6.12",
57 "vue-count-to": "1.0.13", 57 "vue-count-to": "1.0.13",
58 "vue-cropper": "0.5.5", 58 "vue-cropper": "0.5.5",
  59 + "vue-meta": "^2.4.0",
59 "vue-router": "3.4.9", 60 "vue-router": "3.4.9",
60 "vuedraggable": "2.24.3", 61 "vuedraggable": "2.24.3",
61 "vuex": "3.6.0", 62 "vuex": "3.6.0",
yudao-ui-admin/src/App.vue
@@ -6,6 +6,14 @@ @@ -6,6 +6,14 @@
6 6
7 <script> 7 <script>
8 export default { 8 export default {
9 - name: 'App' 9 + name: 'App',
  10 + metaInfo() {
  11 + return {
  12 + title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
  13 + titleTemplate: title => {
  14 + return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
  15 + }
  16 + }
  17 + }
10 } 18 }
11 </script> 19 </script>
yudao-ui-admin/src/layout/components/Settings/index.vue
@@ -38,6 +38,11 @@ @@ -38,6 +38,11 @@
38 </div> 38 </div>
39 </div> 39 </div>
40 40
  41 + <div class="drawer-item">
  42 + <span>动态标题</span>
  43 + <el-switch v-model="dynamicTitle" class="drawer-switch" />
  44 + </div>
  45 +
41 <el-divider/> 46 <el-divider/>
42 47
43 <h3 class="drawer-title">系统布局配置</h3> 48 <h3 class="drawer-title">系统布局配置</h3>
@@ -129,6 +134,17 @@ export default { @@ -129,6 +134,17 @@ export default {
129 }) 134 })
130 } 135 }
131 }, 136 },
  137 + dynamicTitle: {
  138 + get() {
  139 + return this.$store.state.settings.dynamicTitle
  140 + },
  141 + set(val) {
  142 + this.$store.dispatch('settings/changeSetting', {
  143 + key: 'dynamicTitle',
  144 + value: val
  145 + })
  146 + }
  147 + },
132 }, 148 },
133 methods: { 149 methods: {
134 themeChange(val) { 150 themeChange(val) {
@@ -160,6 +176,7 @@ export default { @@ -160,6 +176,7 @@ export default {
160 "tagsView":${this.tagsView}, 176 "tagsView":${this.tagsView},
161 "fixedHeader":${this.fixedHeader}, 177 "fixedHeader":${this.fixedHeader},
162 "sidebarLogo":${this.sidebarLogo}, 178 "sidebarLogo":${this.sidebarLogo},
  179 + "dynamicTitle":${this.dynamicTitle},
163 "sideTheme":"${this.sideTheme}", 180 "sideTheme":"${this.sideTheme}",
164 "theme":"${this.theme}" 181 "theme":"${this.theme}"
165 }` 182 }`
yudao-ui-admin/src/main.js
@@ -72,8 +72,11 @@ Vue.prototype.msgInfo = function (msg) { @@ -72,8 +72,11 @@ Vue.prototype.msgInfo = function (msg) {
72 // 全局组件挂载 72 // 全局组件挂载
73 Vue.component('Pagination', Pagination) 73 Vue.component('Pagination', Pagination)
74 Vue.component('RightToolbar', RightToolbar) 74 Vue.component('RightToolbar', RightToolbar)
  75 +// 头部标签插件
  76 +import VueMeta from 'vue-meta'
75 77
76 Vue.use(permission) 78 Vue.use(permission)
  79 +Vue.use(VueMeta)
77 // Vue.use(hljs.vuePlugin); 80 // Vue.use(hljs.vuePlugin);
78 81
79 // bpmnProcessDesigner 需要引入 82 // bpmnProcessDesigner 需要引入
yudao-ui-admin/src/permission.js
@@ -12,6 +12,7 @@ const whiteList = [&#39;/login&#39;, &#39;/social-login&#39;, &#39;/auth-redirect&#39;, &#39;/bind&#39;, &#39;/regi @@ -12,6 +12,7 @@ const whiteList = [&#39;/login&#39;, &#39;/social-login&#39;, &#39;/auth-redirect&#39;, &#39;/bind&#39;, &#39;/regi
12 router.beforeEach((to, from, next) => { 12 router.beforeEach((to, from, next) => {
13 NProgress.start() 13 NProgress.start()
14 if (getToken()) { 14 if (getToken()) {
  15 + to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
15 /* has token*/ 16 /* has token*/
16 if (to.path === '/login') { 17 if (to.path === '/login') {
17 next({ path: '/' }) 18 next({ path: '/' })
yudao-ui-admin/src/settings.js
1 module.exports = { 1 module.exports = {
2 - title: '若依管理系统',  
3 2
4 /** 3 /**
5 * 侧边栏主题 深色主题theme-dark,浅色主题theme-light 4 * 侧边栏主题 深色主题theme-dark,浅色主题theme-light
@@ -32,6 +31,11 @@ module.exports = { @@ -32,6 +31,11 @@ module.exports = {
32 sidebarLogo: true, 31 sidebarLogo: true,
33 32
34 /** 33 /**
  34 + * 是否显示动态标题
  35 + */
  36 + dynamicTitle: false,
  37 +
  38 + /**
35 * @type {string | array} 'production' | ['production', 'development'] 39 * @type {string | array} 'production' | ['production', 'development']
36 * @description Need show err logs component. 40 * @description Need show err logs component.
37 * The default is only used in the production env 41 * The default is only used in the production env
yudao-ui-admin/src/store/modules/settings.js
1 import variables from '@/assets/styles/element-variables.scss' 1 import variables from '@/assets/styles/element-variables.scss'
2 import defaultSettings from '@/settings' 2 import defaultSettings from '@/settings'
3 3
4 -const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo } = defaultSettings 4 +const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
5 5
6 const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' 6 const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
7 const state = { 7 const state = {
  8 + title: '',
8 theme: storageSetting.theme || variables.theme, 9 theme: storageSetting.theme || variables.theme,
9 sideTheme: storageSetting.sideTheme || sideTheme, 10 sideTheme: storageSetting.sideTheme || sideTheme,
10 showSettings: showSettings, 11 showSettings: showSettings,
11 topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, 12 topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,
12 tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, 13 tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
13 fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, 14 fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
14 - sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo 15 + sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
  16 + dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
15 } 17 }
16 const mutations = { 18 const mutations = {
17 CHANGE_SETTING: (state, { key, value }) => { 19 CHANGE_SETTING: (state, { key, value }) => {
@@ -22,8 +24,13 @@ const mutations = { @@ -22,8 +24,13 @@ const mutations = {
22 } 24 }
23 25
24 const actions = { 26 const actions = {
  27 + // 修改布局设置
25 changeSetting({ commit }, data) { 28 changeSetting({ commit }, data) {
26 commit('CHANGE_SETTING', data) 29 commit('CHANGE_SETTING', data)
  30 + },
  31 + // 设置网页标题
  32 + setTitle({ commit }, title) {
  33 + state.title = title
27 } 34 }
28 } 35 }
29 36
yudao-ui-admin/vue.config.js
@@ -6,7 +6,7 @@ function resolve(dir) { @@ -6,7 +6,7 @@ function resolve(dir) {
6 return path.join(__dirname, dir) 6 return path.join(__dirname, dir)
7 } 7 }
8 8
9 -const name = defaultSettings.title || '芋道管理系统' // 标题 9 +const name = process.env.VUE_APP_TITLE || '芋道管理系统' // 网页标题
10 10
11 const port = process.env.port || process.env.npm_config_port || 80 // 端口 11 const port = process.env.port || process.env.npm_config_port || 80 // 端口
12 12