新增加动态标题
This commit is contained in:
parent
0f5f81a717
commit
ac33e4f825
@ -1,8 +1,10 @@
|
||||
# 关于此文件说明 必须以VUE_APP开头
|
||||
# 开发环境配置
|
||||
ENV = 'development'
|
||||
|
||||
# ZR管理系统/开发环境
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = ZrAdmin.NET管理系统
|
||||
|
||||
# 开发环境
|
||||
VUE_APP_BASE_API = '/dev-api'
|
||||
|
||||
# 路由前缀
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
# 生产环境配置
|
||||
ENV = 'production'
|
||||
|
||||
# ZR管理系统/生产环境
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = ZrAdmin.NET管理系统
|
||||
|
||||
# 生产环境
|
||||
VUE_APP_BASE_API = '/prod-api'
|
||||
|
||||
# 路由前缀
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
# 测试环境配置
|
||||
ENV = 'staging'
|
||||
|
||||
# ZR管理系统/生产环境
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = ZrAdmin.NET管理系统
|
||||
|
||||
# 测试环境
|
||||
VUE_APP_BASE_API = '/stage-api'
|
||||
|
||||
# 路由前缀
|
||||
|
||||
@ -6,6 +6,6 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App'
|
||||
}
|
||||
name: "App",
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
<div v-if="sideTheme === 'theme-dark'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
|
||||
<i aria-label="图标: check" class="anticon anticon-check">
|
||||
<svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true" focusable="false" class="">
|
||||
<path d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z" />
|
||||
<path
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z" />
|
||||
</svg>
|
||||
</i>
|
||||
</div>
|
||||
@ -20,7 +21,8 @@
|
||||
<div v-if="sideTheme === 'theme-light'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
|
||||
<i aria-label="图标: check" class="anticon anticon-check">
|
||||
<svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true" focusable="false" class="">
|
||||
<path d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z" />
|
||||
<path
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z" />
|
||||
</svg>
|
||||
</i>
|
||||
</div>
|
||||
@ -55,6 +57,10 @@
|
||||
<span>显示 Logo</span>
|
||||
<el-switch v-model="sidebarLogo" class="drawer-switch" />
|
||||
</div>
|
||||
<div class="drawer-item">
|
||||
<span>动态标题</span>
|
||||
<el-switch v-model="dynamicTitle" class="drawer-switch" />
|
||||
</div>
|
||||
<el-divider />
|
||||
|
||||
<el-button size="small" type="primary" plain icon="el-icon-document-add" @click="saveSetting">保存配置</el-button>
|
||||
@ -88,18 +94,21 @@ 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() {
|
||||
return this.$store.state.settings.tagsView;
|
||||
@ -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}"
|
||||
}`
|
||||
|
||||
@ -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: '/' })
|
||||
|
||||
@ -37,7 +37,10 @@ module.exports = {
|
||||
* 是否显示logo
|
||||
*/
|
||||
sidebarLogo: true,
|
||||
|
||||
/**
|
||||
* 是否显示动态标题
|
||||
*/
|
||||
dynamicTitle: false,
|
||||
/**
|
||||
* @type {string | array} 'production' | ['production', 'development']
|
||||
* @description Need show err logs component.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user