Commit 7bf9a85263e0c44b2bc88485b83557c129583f5c

Authored by YunaiV
1 parent 7df42db2

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

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