-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartOfCode.txt
More file actions
239 lines (212 loc) · 5.48 KB
/
partOfCode.txt
File metadata and controls
239 lines (212 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<div>
<nav class="navbar navbar-light">
<router-link to="/Home">
<button type="button" class="btn btn-default btn-lg">
<span class="iconfont icon-home"></span>
Youke 平台在线管理
</button>
</router-link>
<ul class="nav nav-fill nav-pills" id="lis">
<li class="nav-item">
<router-link class="nav-link" to="/Comment">
<button type="button" class="btn btn-default btn-lg">
<span class="iconfont icon-xuexiao_kemu"></span>
Comment
</button>
</router-link>
</li>
<li class="nav-item">
<router-link class="nav-link" to="/Search">
<button type="button" class="btn btn-default btn-lg">
<span class="iconfont icon-sousuo"></span>
Search
</button>
</router-link>
</li>
<li class="nav-item">
<div class="nav-link">
<button
type="button"
class="btn btn-default btn-lg"
@click="manage"
>
<span class="iconfont icon-manage"></span>
Users
</button>
</div>
</li>
</ul>
<div>
<router-link v-if="isLogin === -1" to="/Log">
<button type="button" class="btn btn-default btn-lg">
<span class="iconfont icon-weidenglu"></span>
<span>登录/注册</span>
</button>
</router-link>
<div class="row mr-0" v-else>
<el-dropdown class="mr-3" style="cursor: pointer" trigger="click">
<span class="el-dropdown-link">
<i class="iconfont icon-guanliyuan text-primary">管理员</i>
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
<div>管理员:{{ user.account }}</div>
</el-dropdown-item>
<el-dropdown-item>
<router-link class="nav-link" to="/About">
管理员职能与守则
</router-link>
</el-dropdown-item>
<el-dropdown-item>
<div @click="signout">
<span class="iconfont icon-tuichu text-danger"></span>退出登录
</div>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</nav>
</div>
import {mapState} from 'vuex'
export default {
name: "NavBar",
methods: {
signout() {
this.$store.commit("Person/signout");
this.$router.push("/Home");
this.$forceUpdate();
},
manage(){
this.$store.dispatch('Person/getUsers');
this.$router.push('/Users');
}
},
computed:{
...mapState({
isLogin: state=>state.Person.isLogin,
user: state=>state.Person.user
})
}
};
<template>
<div id="t" class="text-center">
<div class="form-signin">
<h1 class="h3 mb-6 font-weight-bold">please sign in</h1>
<label for="inputEmail" class="sr-only">Account</label>
<input
type="text"
id="inputEmail"
class="form-control"
placeholder="Account"
v-model="SignIn.account"
required
autofocus
/>
<label for="inputPassword" class="sr-only">Password</label>
<input
type="password"
id="inputPassword"
class="form-control"
placeholder="Password"
v-model="SignIn.password"
required
autofocus
/>
<hr />
<button
class="btn btn-group-lg btn-primary btn-block bg-primary"
type="submit"
@click="url1()"
>
Log in
</button>
</div>
</div>
</template>
<script>
import { reqLogin } from "../api";
export default {
name: "Login",
data() {
return {
SignIn: {
account: "",
password: ""
}
};
},
methods: {
url1() {
reqLogin({
account: this.SignIn.account,
password: this.SignIn.password
}).then(res => {
let num = res.id;
switch (num) {
case -1: //forbid
this.$message({
message: "用户已被禁用",
type: "error",
duration: 1000,
showClose: true
});
return false;
case -2: //nobody
this.$message({
message: "错误的用户名或密码",
type: "warning",
duration: 1000,
showClose: true
});
return false;
default:
//allowed
this.$store.commit("Person/changeLogin", num);
this.$store.commit("Person/signin", res);
this.$message({
message: "登陆成功",
type: "success",
duration: 1000,
showClose: true
});
this.$router.push("/Home");
}
});
}
}
};
</script>
<style scoped>
html,
template {
height: 100%;
}
template {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
width: 100%;
max-width: 450px;
padding: 15px;
margin: auto;
}
.form-signin {
font-weight: 400;
}
.form-signin .form-control {
position: relative;
box-sizing: border-box;
height: auto;
padding: 10px;
font-size: 16px;
margin-bottom: 10px;
}
</style>