新增加路由器前缀通过环境变量配置

This commit is contained in:
izory 2021-10-14 17:34:05 +08:00
parent 24ced6b9b5
commit 4d58a154cc
7 changed files with 7 additions and 6 deletions

View File

@ -20,6 +20,7 @@ namespace ZR.Admin.WebApi.Filters
/// </summary>
public string Permission { get; set; }
private bool HasPermi { get; set; }
private bool HasRole { get; set; }
public ActionPermissionFilter() { }

View File

@ -6,4 +6,4 @@ ENV = 'development'
VUE_APP_BASE_API = 'http://localhost:8888/'
# 路由前缀
VUE_APP_ROUTER_PREFIX = ''
VUE_APP_ROUTER_PREFIX = '/admin'

View File

@ -5,4 +5,4 @@ ENV = 'production'
VUE_APP_BASE_API = '/prod-api'
# 路由前缀
VUE_APP_ROUTER_PREFIX = ''
VUE_APP_ROUTER_PREFIX = '/admin/'

View File

@ -88,7 +88,7 @@ export default {
type: "warning",
}).then(() => {
this.$store.dispatch("LogOut").then(() => {
location.href = "/index";
location.href = process.env.VUE_APP_ROUTER_PREFIX + "index";
});
});
},

View File

@ -109,8 +109,8 @@ export const constantRoutes = [
]
export default new Router({
base: process.env.VUE_APP_ROUTER_PREFIX,
mode: 'history', // 去掉url中的#
// base: '',
// scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})

View File

@ -54,7 +54,7 @@ service.interceptors.response.use(res => {
}
).then(() => {
store.dispatch('LogOut').then(() => {
location.href = '/index';
location.href = process.env.VUE_APP_ROUTER_PREFIX + '/index';
})
})

View File

@ -18,7 +18,7 @@ module.exports = {
// 部署生产环境和开发环境下的URL。
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.baidu.com/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.baidu.com/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.VUE_ROUTER_PREFIX,
publicPath: process.env.VUE_APP_ROUTER_PREFIX,
// 在npm run build 或 yarn build 时 生成文件的目录名称要和baseUrl的生产环境路径一致默认dist
outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)