This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneral-vue.js
65 lines (60 loc) · 1.66 KB
/
general-vue.js
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
if (logout.includes("true")) {
// localStorage.clear();
document.cookie = `uid=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
document.cookie = `username=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
document.cookie = `api=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
document.cookie = `api_key=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
document.cookie = `role=; expires=Thu, 01 Jan 1970 00:00:00 UTC;`;
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
let header = new Vue({
el: "#header",
data() {
return {
loggedin: false,
admin: false,
role: getCookie("role"),
username: getCookie("username")
}
},
mounted() {
if (this.role == "Admin") {
this.admin = true;
} else {
this.admin = false;
}
if (this.username) {
this.loggedin = true;
} else {
this.loggedin = false;
}
},
watch: {
admin(roleChange) {
if (this.role == "Admin") {
this.admin = true;
} else {
this.admin = false;
}
if (this.username) {
this.loggedin = true;
} else {
this.loggedin = false;
}
}
}
})