File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import router from "../router.js";
3
3
4
4
// 配置API接口地址
5
5
var root = "http://localhost:58427/api" ;
6
- var root1 = "http://123.206.33.109:8012 /api" ;
6
+ var root1 = "http://123.206.33.109:8018 /api" ;
7
7
// 引用axios
8
8
var axios = require ( "axios" ) ;
9
9
// 自定义判断元素类型JS
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ const router = new Router({
53
53
54
54
router . beforeEach ( ( to , from , next ) => {
55
55
if ( to . meta . requireAuth ) { // 判断该路由是否需要登录权限
56
- if ( window . localStorage . Token ) { // 通过vuex state获取当前的token是否存在
56
+ if ( window . localStorage . Token && window . localStorage . Token . length >= 128 ) { // 通过vuex state获取当前的token是否存在
57
57
next ( ) ;
58
58
}
59
59
else {
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<el-row type =" flex" justify =" center" >
3
- <el-form ref =" loginForm" :model =" user" :rules =" rules" status-icon label-width =" 50px" >
3
+ <el-card v-if =" isLogin" >
4
+ 欢迎:admins
5
+ <br >
6
+ <br >
7
+ <el-button type =" primary" icon =" el-icon-upload" @click =" loginOut" >退出登录</el-button >
8
+ </el-card >
9
+ <el-form v-else ref =" loginForm" :model =" user" :rules =" rules" status-icon label-width =" 50px" >
4
10
<el-form-item label =" 账号" prop =" name" >
5
11
<el-input v-model =" user.name" ></el-input >
6
12
</el-form-item >
@@ -50,16 +56,27 @@ export default {
50
56
return false ;
51
57
}
52
58
});
53
- }
59
+ },
60
+ loginOut (){
61
+ this .isLogin = false ;
62
+ window .localStorage .setItem (" Token" ," " );
63
+ }
54
64
},
55
65
data () {
56
66
return {
67
+ isLogin: false ,
57
68
user: {},
58
69
rules: {
59
70
name: [{ required: true , message: " 用户名不能为空" , trigger: " blur" }],
60
71
pass: [{ required: true , message: " 密码不能为空" , trigger: " blur" }]
61
72
}
62
73
};
63
- }
74
+ },
75
+ created () {
76
+ if (window .localStorage .Token && window .localStorage .Token .length >= 128 ){
77
+ this .isLogin = true ;
78
+ }
79
+ }
80
+
64
81
};
65
82
</script >
You can’t perform that action at this time.
0 commit comments