diff --git a/yudao-ui-admin/.env.demo1024 b/yudao-ui-admin/.env.demo1024 index 99277133c..d2897f1ea 100644 --- a/yudao-ui-admin/.env.demo1024 +++ b/yudao-ui-admin/.env.demo1024 @@ -3,6 +3,9 @@ NODE_ENV = development # 测试环境配置 ENV = 'staging' +# 页面标题 +VUE_APP_TITLE = 芋道管理系统 + # 芋道管理系统/测试环境 VUE_APP_BASE_API = 'http://127.0.0.1:48080' diff --git a/yudao-ui-admin/.env.development b/yudao-ui-admin/.env.development index 8c1875f52..170c93cdc 100644 --- a/yudao-ui-admin/.env.development +++ b/yudao-ui-admin/.env.development @@ -1,6 +1,9 @@ # 开发环境配置 ENV = 'development' +# 页面标题 +VUE_APP_TITLE = 芋道管理系统 + # 芋道管理系统/开发环境 VUE_APP_BASE_API = '/dev-api' # VUE_APP_BASE_API = '/api' diff --git a/yudao-ui-admin/.env.production b/yudao-ui-admin/.env.production index cb6a54180..535990c4a 100644 --- a/yudao-ui-admin/.env.production +++ b/yudao-ui-admin/.env.production @@ -1,8 +1,12 @@ # 生产环境配置 ENV = 'production' +# 页面标题 +VUE_APP_TITLE = 芋道管理系统 + # 芋道管理系统/生产环境 VUE_APP_BASE_API = '/prod-api' + # 根据服务器或域名修改 PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/' # 二级部署路径 diff --git a/yudao-ui-admin/.env.staging b/yudao-ui-admin/.env.staging index 2e83e2225..7cb5fb84d 100644 --- a/yudao-ui-admin/.env.staging +++ b/yudao-ui-admin/.env.staging @@ -1,5 +1,8 @@ NODE_ENV = production +# 页面标题 +VUE_APP_TITLE = 芋道管理系统 + # 测试环境配置 ENV = 'staging' diff --git a/yudao-ui-admin/package.json b/yudao-ui-admin/package.json index 8f312914a..d56e2dead 100644 --- a/yudao-ui-admin/package.json +++ b/yudao-ui-admin/package.json @@ -56,6 +56,7 @@ "vue": "2.6.12", "vue-count-to": "1.0.13", "vue-cropper": "0.5.5", + "vue-meta": "^2.4.0", "vue-router": "3.4.9", "vuedraggable": "2.24.3", "vuex": "3.6.0", diff --git a/yudao-ui-admin/src/App.vue b/yudao-ui-admin/src/App.vue index e448b1130..934d71e0f 100644 --- a/yudao-ui-admin/src/App.vue +++ b/yudao-ui-admin/src/App.vue @@ -6,6 +6,14 @@ diff --git a/yudao-ui-admin/src/layout/components/Settings/index.vue b/yudao-ui-admin/src/layout/components/Settings/index.vue index 5b7351a67..04ef1feb5 100644 --- a/yudao-ui-admin/src/layout/components/Settings/index.vue +++ b/yudao-ui-admin/src/layout/components/Settings/index.vue @@ -38,6 +38,11 @@ +
+ 动态标题 + +
+

系统布局配置

@@ -129,6 +134,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) { @@ -160,6 +176,7 @@ export default { "tagsView":${this.tagsView}, "fixedHeader":${this.fixedHeader}, "sidebarLogo":${this.sidebarLogo}, + "dynamicTitle":${this.dynamicTitle}, "sideTheme":"${this.sideTheme}", "theme":"${this.theme}" }` diff --git a/yudao-ui-admin/src/main.js b/yudao-ui-admin/src/main.js index 5b3a896c2..c36b83fce 100644 --- a/yudao-ui-admin/src/main.js +++ b/yudao-ui-admin/src/main.js @@ -72,8 +72,11 @@ Vue.prototype.msgInfo = function (msg) { // 全局组件挂载 Vue.component('Pagination', Pagination) Vue.component('RightToolbar', RightToolbar) +// 头部标签插件 +import VueMeta from 'vue-meta' Vue.use(permission) +Vue.use(VueMeta) // Vue.use(hljs.vuePlugin); // bpmnProcessDesigner 需要引入 diff --git a/yudao-ui-admin/src/permission.js b/yudao-ui-admin/src/permission.js index d40972193..0dc85ed2f 100644 --- a/yudao-ui-admin/src/permission.js +++ b/yudao-ui-admin/src/permission.js @@ -12,6 +12,7 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regi router.beforeEach((to, from, next) => { NProgress.start() if (getToken()) { + to.meta.title && store.dispatch('settings/setTitle', to.meta.title) /* has token*/ if (to.path === '/login') { next({ path: '/' }) diff --git a/yudao-ui-admin/src/settings.js b/yudao-ui-admin/src/settings.js index ba5cbd03c..045f5eb3f 100644 --- a/yudao-ui-admin/src/settings.js +++ b/yudao-ui-admin/src/settings.js @@ -1,5 +1,4 @@ module.exports = { - title: '若依管理系统', /** * 侧边栏主题 深色主题theme-dark,浅色主题theme-light @@ -31,6 +30,11 @@ module.exports = { */ sidebarLogo: true, + /** + * 是否显示动态标题 + */ + dynamicTitle: false, + /** * @type {string | array} 'production' | ['production', 'development'] * @description Need show err logs component. diff --git a/yudao-ui-admin/src/store/modules/settings.js b/yudao-ui-admin/src/store/modules/settings.js index 93f7c040d..647a8ce0c 100644 --- a/yudao-ui-admin/src/store/modules/settings.js +++ b/yudao-ui-admin/src/store/modules/settings.js @@ -1,17 +1,19 @@ import variables from '@/assets/styles/element-variables.scss' import defaultSettings from '@/settings' -const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo } = defaultSettings +const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' const state = { + title: '', theme: storageSetting.theme || variables.theme, sideTheme: storageSetting.sideTheme || sideTheme, showSettings: showSettings, topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, - sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo + sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, + dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle } const mutations = { CHANGE_SETTING: (state, { key, value }) => { @@ -22,8 +24,13 @@ const mutations = { } const actions = { + // 修改布局设置 changeSetting({ commit }, data) { commit('CHANGE_SETTING', data) + }, + // 设置网页标题 + setTitle({ commit }, title) { + state.title = title } } diff --git a/yudao-ui-admin/vue.config.js b/yudao-ui-admin/vue.config.js index 7588779de..a8222bfa6 100644 --- a/yudao-ui-admin/vue.config.js +++ b/yudao-ui-admin/vue.config.js @@ -6,7 +6,7 @@ function resolve(dir) { return path.join(__dirname, dir) } -const name = defaultSettings.title || '芋道管理系统' // 标题 +const name = process.env.VUE_APP_TITLE || '芋道管理系统' // 网页标题 const port = process.env.port || process.env.npm_config_port || 80 // 端口