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'
# 若依管理系统/开发环境
# VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = '/dev-api'
# 应用访问路径 例如使用前缀 /admin/
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_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

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

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

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

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

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

Loading…
Cancel
Save