fix:调整端口和调整前端路由

pull/180/head
Layne Cai 4 years ago
parent 5d7bf376c2
commit 37e8b1a478

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9200 port: 12200
# Spring # Spring
spring: spring:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 8080 port: 12080
# Spring # Spring
spring: spring:
@ -35,7 +35,7 @@ spring:
eager: true eager: true
transport: transport:
# 控制台地址 # 控制台地址
dashboard: 127.0.0.1:8718 dashboard: 127.0.0.1:12718
# nacos配置持久化 # nacos配置持久化
datasource: datasource:
ds1: ds1:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9300 port: 12300
# Spring # Spring
spring: spring:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9202 port: 12202
# Spring # Spring
spring: spring:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9203 port: 12203
# Spring # Spring
spring: spring:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9201 port: 12201
# Spring # Spring
spring: spring:

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9100 port: 12100
# Spring # Spring
spring: spring:

@ -6,3 +6,6 @@ VITE_APP_ENV = 'development'
# pinn个人管理系统/开发环境 # pinn个人管理系统/开发环境
VITE_APP_BASE_API = '/dev-api' VITE_APP_BASE_API = '/dev-api'
#路由守卫的虚拟目录
VITE_APP_BASE_DIR = '/dConsole'

@ -7,5 +7,8 @@ VITE_APP_ENV = 'production'
# pinn个人管理系统/生产环境 # pinn个人管理系统/生产环境
VITE_APP_BASE_API = '/prod-api' VITE_APP_BASE_API = '/prod-api'
#路由守卫的虚拟目录
VITE_APP_BASE_DIR = '/pConsole'
# 是否在打包时开启压缩,支持 gzip 和 brotli # 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip VITE_BUILD_COMPRESS = gzip

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 16 KiB

@ -9,15 +9,16 @@ import { isRelogin } from '@/utils/request'
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']; const baseDir = import.meta.env.VITE_APP_BASE_DIR;
const whiteList = [baseDir+'/login', baseDir+'/auth-redirect', baseDir+'/bind', baseDir+'/register'];
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
if (getToken()) { if (getToken()) {
to.meta.title && store.dispatch('settings/setTitle', to.meta.title) to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
/* has token*/ /* has token*/
if (to.path === '/login') { if (to.path === baseDir+'/login') {
next({ path: '/' }) next({ path: baseDir+'/' })
NProgress.done() NProgress.done()
} else { } else {
if (store.getters.roles.length === 0) { if (store.getters.roles.length === 0) {
@ -37,7 +38,7 @@ router.beforeEach((to, from, next) => {
}).catch(err => { }).catch(err => {
store.dispatch('LogOut').then(() => { store.dispatch('LogOut').then(() => {
ElMessage.error(err) ElMessage.error(err)
next({ path: '/' }) next({ path: baseDir+'/' })
}) })
}) })
} else { } else {
@ -50,7 +51,7 @@ router.beforeEach((to, from, next) => {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next()
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next( baseDir + `/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
NProgress.done() NProgress.done()
} }
} }

@ -21,10 +21,12 @@ import Layout from '@/layout'
} }
*/ */
const baseDir = import.meta.env.VITE_APP_BASE_DIR;
// 公共路由 // 公共路由
export const constantRoutes = [ export const constantRoutes = [
{ {
path: '/redirect', path: baseDir+'/redirect',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [
@ -35,29 +37,29 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/login', path: baseDir+'/login',
component: () => import('@/views/login'), component: () => import('@/views/login'),
hidden: true hidden: true
}, },
{ {
path: '/register', path: baseDir+'/register',
component: () => import('@/views/register'), component: () => import('@/views/register'),
hidden: true hidden: true
}, },
{ {
path: "/:pathMatch(.*)*", path: baseDir+"/:pathMatch(.*)*",
component: () => import('@/views/error/404'), component: () => import('@/views/error/404'),
hidden: true hidden: true
}, },
{ {
path: '/401', path: baseDir+'/401',
component: () => import('@/views/error/401'), component: () => import('@/views/error/401'),
hidden: true hidden: true
}, },
{ {
path: '', path: baseDir+'',
component: Layout, component: Layout,
redirect: '/index', redirect: baseDir+'/index',
children: [ children: [
{ {
path: '/index', path: '/index',
@ -68,7 +70,7 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/user', path: baseDir+'/user',
component: Layout, component: Layout,
hidden: true, hidden: true,
redirect: 'noredirect', redirect: 'noredirect',
@ -82,7 +84,7 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/system/user-auth', path: baseDir+'/system/user-auth',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [
@ -95,7 +97,7 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/system/role-auth', path: baseDir+'/system/role-auth',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [
@ -108,7 +110,7 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/system/dict-data', path: baseDir+'/system/dict-data',
component: Layout, component: Layout,
hidden: true, hidden: true,
children: [ children: [

@ -5,12 +5,12 @@ import createVitePlugins from './vite/plugins'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => { export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd()) const env = loadEnv(mode, process.cwd())
const { VITE_APP_ENV } = env const { VITE_APP_ENV, VITE_APP_BASE_DIR } = env
return { return {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
base: VITE_APP_ENV === 'production' ? '/' : '/', base: VITE_APP_ENV === 'production' ? VITE_APP_BASE_DIR : VITE_APP_BASE_DIR,
plugins: createVitePlugins(env, command === 'build'), plugins: createVitePlugins(env, command === 'build'),
resolve: { resolve: {
// https://cn.vitejs.dev/config/#resolve-alias // https://cn.vitejs.dev/config/#resolve-alias
@ -25,13 +25,13 @@ export default defineConfig(({ mode, command }) => {
}, },
// vite 相关配置 // vite 相关配置
server: { server: {
port: 80, port: 12008,
host: true, host: true,
open: true, open: true,
proxy: { proxy: {
// https://cn.vitejs.dev/config/#server-proxy // https://cn.vitejs.dev/config/#server-proxy
'/dev-api': { '/dev-api': {
target: 'http://localhost:8080', target: 'http://localhost:12080',
changeOrigin: true, changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '') rewrite: (p) => p.replace(/^\/dev-api/, '')
} }

Loading…
Cancel
Save