Browse Source

登录返回原来url

dev
mh 5 months ago
parent
commit
ce6481773a
  1. 4
      ruoyi-ui/.env.development
  2. BIN
      ruoyi-ui/dist.rar
  3. 14
      ruoyi-ui/src/permission.js
  4. 36
      ruoyi-ui/src/router/index.js
  5. 2
      ruoyi-ui/src/views/login.vue

4
ruoyi-ui/.env.development

@ -5,7 +5,7 @@ VUE_APP_TITLE = 广州市城市建设职业学校
ENV = 'development' ENV = 'development'
# 若依管理系统/开发环境 # 若依管理系统/开发环境
# VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = '/dev-api'
# 应用访问路径 例如使用前缀 /admin/ # 应用访问路径 例如使用前缀 /admin/
VUE_APP_CONTEXT_PATH = '/' VUE_APP_CONTEXT_PATH = '/'
@ -17,7 +17,7 @@ VUE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/login'
VUE_APP_XXL_JOB_ADMIN = 'http://localhost:9100/xxl-job-admin' VUE_APP_XXL_JOB_ADMIN = 'http://localhost:9100/xxl-job-admin'
# VUE_APP_BASE_API = 'https://bxserver.mhito.net:8090' # VUE_APP_BASE_API = 'https://bxserver.mhito.net:8090'
VUE_APP_BASE_API = 'http://192.168.1.55:8080' # VUE_APP_BASE_API = 'http://192.168.1.55:8080'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true

BIN
ruoyi-ui/dist.rar

Binary file not shown.

14
ruoyi-ui/src/permission.js

@ -30,11 +30,11 @@ router.beforeEach((to, from, next) => {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
}) })
}).catch(err => { }).catch(err => {
store.dispatch('LogOut').then(() => { store.dispatch('LogOut').then(() => {
Message.error(err) Message.error(err)
next({ path: '/' }) next({ path: '/' })
})
}) })
})
} else { } else {
next() next()
} }
@ -45,7 +45,11 @@ router.beforeEach((to, from, next) => {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next()
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 localStorage.setItem("intendedRoute", to.fullPath);
next({
path: '/login',
query: { redirect: to.fullPath }
}) // 否则全部重定向到登录页
NProgress.done() NProgress.done()
} }
} }

36
ruoyi-ui/src/router/index.js

@ -262,23 +262,23 @@ const router = new Router({
routes: constantRoutes, routes: constantRoutes,
}); });
router.beforeEach((to, from, next) => { // router.beforeEach((to, from, next) => {
let token = getToken(); // let token = getToken();
debugger; // debugger;
if (token) { // if (token) {
// 如果有token // // 如果有token
next(); // next();
} else { // } else {
if (to.path == "/login") { // if (to.path == "/login") {
next(); // next();
} else { // } else {
if (to.path.includes("bx/start")) { // if (to.path.includes("bx/start")) {
next(); // next();
} else { // } else {
next("/login"); // next("/login");
} // }
} // }
} // }
}); // });
export default router; export default router;

2
ruoyi-ui/src/views/login.vue

@ -1,5 +1,5 @@
<template> <template>
<div class="login"> <div class="login" v-show="false">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<h3 class="title">广州市城市建设职业学校</h3> <h3 class="title">广州市城市建设职业学校</h3>
<el-form-item prop="username"> <el-form-item prop="username">

Loading…
Cancel
Save