feat: base 退出后可重定向
This commit is contained in:
parent
efe3bb7777
commit
767e2d8048
|
@ -36,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
|
||||||
//动态标题
|
//动态标题
|
||||||
document.title = to.meta.title ? `${to.meta.title} - ${config.APP_NAME}` : `${config.APP_NAME}`
|
document.title = to.meta.title ? `${to.meta.title} - ${config.APP_NAME}` : `${config.APP_NAME}`
|
||||||
|
|
||||||
let token = tool.cookie.get("TOKEN");
|
let token = tool.data.get("TOKEN");
|
||||||
//去往登录页
|
//去往登录页
|
||||||
if (to.path === "/login") {
|
if (to.path === "/login") {
|
||||||
//删除路由(替换当前layout路由)
|
//删除路由(替换当前layout路由)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" style="width: 100%" :loading="islogin" round @click="login">{{ $t("login.signIn")
|
<el-button type="primary" style="width: 100%" :loading="islogin" round @click="login">{{ $t("login.signIn")
|
||||||
}}</el-button>
|
}}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- <div class="login-reg">
|
<!-- <div class="login-reg">
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
redirect: undefined,
|
||||||
userType: "admin",
|
userType: "admin",
|
||||||
visitorsdialog: false,
|
visitorsdialog: false,
|
||||||
visitorform: {},
|
visitorform: {},
|
||||||
|
@ -99,6 +100,12 @@ export default {
|
||||||
this.form.password = "user";
|
this.form.password = "user";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
$route: {
|
||||||
|
handler: function (route) {
|
||||||
|
this.redirect = route.query && route.query.redirect;
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() { },
|
mounted() { },
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -117,19 +124,19 @@ export default {
|
||||||
//获取token
|
//获取token
|
||||||
try {
|
try {
|
||||||
var res = await that.$API.auth.token.post(data);
|
var res = await that.$API.auth.token.post(data);
|
||||||
that.$TOOL.cookie.set("TOKEN", res.access, {
|
|
||||||
expires: that.form.autologin ? 24 * 60 * 60 : 0,
|
|
||||||
});
|
|
||||||
that.$TOOL.data.set("TOKEN", res.access);
|
that.$TOOL.data.set("TOKEN", res.access);
|
||||||
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
|
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
|
||||||
that.$TOOL.cookie.set("TOKEN_REFRESH", res.refresh);
|
|
||||||
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
|
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
|
||||||
try {
|
try {
|
||||||
var res1 = await that.$API.auth.info.get();
|
var res1 = await that.$API.auth.info.get();
|
||||||
that.$TOOL.data.set("USER_INFO", res1);
|
that.$TOOL.data.set("USER_INFO", res1);
|
||||||
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
|
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
|
||||||
|
|
||||||
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
|
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
|
||||||
if (base_dashboard == null || base_dashboard == undefined) {
|
if (this.redirect) {
|
||||||
|
base_dashboard = this.redirect;
|
||||||
|
}
|
||||||
|
else if (base_dashboard == null || base_dashboard == undefined) {
|
||||||
base_dashboard = '/dashboard'
|
base_dashboard = '/dashboard'
|
||||||
}
|
}
|
||||||
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
|
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
|
||||||
|
@ -157,31 +164,6 @@ export default {
|
||||||
path: base_dashboard,
|
path: base_dashboard,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// if(this.$TOOL.data.get('BASE_INFO').base.base_name_short=='托克逊能管'){//托克逊
|
|
||||||
// this.$router.replace({
|
|
||||||
// path: "/dashboard_enm",
|
|
||||||
// });
|
|
||||||
// }else{//曲阳金隅
|
|
||||||
// that.$API.am.area.list.req({page_size:999}).then(res => {
|
|
||||||
// if (res.err_msg) {
|
|
||||||
// } else {
|
|
||||||
// debugger;
|
|
||||||
// let areaList = res.results;
|
|
||||||
// that.$TOOL.data.set("qyjyAreaList", areaList);
|
|
||||||
// if(res1.type==='employee'){
|
|
||||||
// this.$router.replace({
|
|
||||||
// path: "/",
|
|
||||||
// });
|
|
||||||
// }else{
|
|
||||||
// this.$router.replace({
|
|
||||||
// path: "/rpm/rpj",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// that.$message.success("Login Success 登录成功");
|
|
||||||
// that.islogin = false;
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
that.islogin = false;
|
that.islogin = false;
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -192,52 +174,6 @@ export default {
|
||||||
} finally {
|
} finally {
|
||||||
that.islogin = false;
|
that.islogin = false;
|
||||||
}
|
}
|
||||||
// var res = await this.$API.auth.token.post(data)
|
|
||||||
// console.log(res, err)
|
|
||||||
// if(!res){
|
|
||||||
// this.islogin = false
|
|
||||||
// this.$message.warning(res.err_msg)
|
|
||||||
// return false
|
|
||||||
// }else{
|
|
||||||
// this.$TOOL.cookie.set("TOKEN", res.token, {
|
|
||||||
// expires: this.form.autologin? 24*60*60 : 0
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// if(user.code == 200){
|
|
||||||
|
|
||||||
// this.$TOOL.data.set("USER_INFO", user.data.userInfo)
|
|
||||||
// }else{
|
|
||||||
|
|
||||||
// }
|
|
||||||
//获取菜单
|
|
||||||
// var menu = null
|
|
||||||
// if(this.form.user == 'admin'){
|
|
||||||
// menu = await this.$API.system.menu.myMenus.get()
|
|
||||||
// }else{
|
|
||||||
// menu = await this.$API.demo.menu.get()
|
|
||||||
// }
|
|
||||||
// if(menu.code == 200){
|
|
||||||
// if(menu.data.menu.length==0){
|
|
||||||
// this.islogin = false
|
|
||||||
// this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", {
|
|
||||||
// type: 'error',
|
|
||||||
// center: true
|
|
||||||
// })
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// this.$TOOL.data.set("MENU", menu.data.menu)
|
|
||||||
// this.$TOOL.data.set("PERMISSIONS", menu.data.permissions)
|
|
||||||
// }else{
|
|
||||||
// this.islogin = false
|
|
||||||
// this.$message.warning(menu.message)
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.$router.replace({
|
|
||||||
// path: '/'
|
|
||||||
// })
|
|
||||||
// this.$message.success("Login Success 登录成功")
|
|
||||||
// this.islogin = false
|
|
||||||
},
|
},
|
||||||
visitors() {
|
visitors() {
|
||||||
this.visitorsdialog = true;
|
this.visitorsdialog = true;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn')
|
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn')
|
||||||
}}</el-button>
|
}}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <div class="login-reg">
|
<!-- <div class="login-reg">
|
||||||
{{$t('login.noAccount')}} <router-link to="/user_register">{{$t('login.createAccount')}}</router-link>
|
{{$t('login.noAccount')}} <router-link to="/user_register">{{$t('login.createAccount')}}</router-link>
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
redirect: undefined,
|
||||||
form: {
|
form: {
|
||||||
phone: "",
|
phone: "",
|
||||||
code: "",
|
code: "",
|
||||||
|
@ -58,6 +59,14 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
$route: {
|
||||||
|
handler: function (route) {
|
||||||
|
this.redirect = route.query && route.query.redirect;
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getYzm() {
|
async getYzm() {
|
||||||
|
@ -86,18 +95,17 @@ export default {
|
||||||
this.$refs.loginForm.validate(async (valid) => {
|
this.$refs.loginForm.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$API.auth.login_sms_code.req(that.form).then(res => {
|
this.$API.auth.login_sms_code.req(that.form).then(res => {
|
||||||
that.$TOOL.cookie.set("TOKEN", res.access, {
|
|
||||||
expires: that.form.autologin ? 24 * 60 * 60 : 0,
|
|
||||||
});
|
|
||||||
that.$TOOL.data.set("TOKEN", res.access);
|
that.$TOOL.data.set("TOKEN", res.access);
|
||||||
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
|
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
|
||||||
that.$TOOL.cookie.set("TOKEN_REFRESH", res.refresh);
|
|
||||||
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
|
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
|
||||||
that.$API.auth.info.get().then(res1 => {
|
that.$API.auth.info.get().then(res1 => {
|
||||||
that.$TOOL.data.set("USER_INFO", res1);
|
that.$TOOL.data.set("USER_INFO", res1);
|
||||||
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
|
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
|
||||||
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
|
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
|
||||||
if (base_dashboard == null || base_dashboard == undefined) {
|
if (this.redirect) {
|
||||||
|
base_dashboard = this.redirect;
|
||||||
|
}
|
||||||
|
else if (base_dashboard == null || base_dashboard == undefined) {
|
||||||
base_dashboard = '/dashboard'
|
base_dashboard = '/dashboard'
|
||||||
}
|
}
|
||||||
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
|
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
|
||||||
|
|
|
@ -138,7 +138,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
this.$TOOL.cookie.remove("TOKEN")
|
this.$TOOL.data.remove("TOKEN")
|
||||||
|
this.$TOOL.data.remove("TOKEN_TIME")
|
||||||
|
this.$TOOL.data.remove("TOKEN_REFRESH")
|
||||||
this.$TOOL.data.remove("USER_INFO")
|
this.$TOOL.data.remove("USER_INFO")
|
||||||
this.$TOOL.data.remove("MENU")
|
this.$TOOL.data.remove("MENU")
|
||||||
this.$TOOL.data.remove("PERMISSIONS")
|
this.$TOOL.data.remove("PERMISSIONS")
|
||||||
|
|
Loading…
Reference in New Issue