forked from mrwill84/DOClever
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.js
More file actions
executable file
·264 lines (261 loc) · 8.43 KB
/
console.js
File metadata and controls
executable file
·264 lines (261 loc) · 8.43 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
var svg=require("component/svg.vue");
var proxyImg=require("common/director/proxyImg");
var sessionChange=require("common/mixins/session");
var ver=require("../../../../ver.json");
var store=require("./store");
var project=require("./project/project.vue");
var team=require("./team/team.vue");
var person=require("./person/person.vue");
var message=require("./message/message.vue");
session.remove("snapshotId");
session.remove("snapshotDis");
session.remove("snapshotCreator");
session.remove("snapshotDate");
session.remove("teamId");
session.remove("teamName");
session.remove("versionId");
session.remove("versionName");
session.remove("versionDis");
session.remove("projectType");
session.remove("projectId");
session.remove("projectName");
var vue=new Vue({
el:"#app",
data:{
type:0,
showTeam:false,
applyPending:false,
applyName:"",
applyDis:"",
proxy:session.get("proxy")?true:false,
},
mixins:[sessionChange],
directives:{
proxy:proxyImg
},
components:{
"mysvg":svg,
"project":project,
"team":team,
"person":person,
"message":message
},
store:store,
watch:{
proxy:function (val) {
if(val)
{
session.set("proxy",1);
$.tip("Proxy代理已开启",1)
}
else
{
session.remove("proxy");
$.tip("Proxy代理已关闭",1)
}
}
},
computed:{
backTitle:function () {
if(this.type==0)
{
if(this.session.projectId)
{
return "返回项目列表"
}
else
{
return "退出团队"
}
}
else if(this.type==1 && this.session.teamId)
{
return "退出团队"
}
},
showDot:function () {
return this.$store.getters["message/totalLength"]>0
},
title:function () {
if(this.type==0)
{
if(this.session.projectName)
{
var str="";
if(this.session.teamName)
{
str=this.session.teamName+"-"+this.session.projectName
}
else
{
str=this.session.projectName
}
if(this.session.versionName)
{
str+="("+this.session.versionName+")";
}
return str;
}
else
{
if(this.session.teamName)
{
return this.session.teamName+"的项目列表"
}
else
{
return "项目列表"
}
}
}
else if(this.type==1)
{
if(this.session.teamName)
{
return this.session.teamName
}
else
{
return "团队列表"
}
}
else if(this.type==2)
{
return "个人"
}
else if(this.type==3)
{
return "消息"
}
}
},
methods:{
handleCommand:function (command) {
if(command=="update")
{
var xml=new XMLHttpRequest();
$.startHud();
xml.onreadystatechange=function () {
if(xml.readyState==4 && xml.status==200)
{
$.stopHud();
var obj=JSON.parse(xml.responseText);
var verArr=obj[0].name.split(".");
var verLocalArr=ver.version.split(".");
var bNew=false;
for(var i=0;i<3;i++)
{
if(verArr[i]>verLocalArr[i])
{
bNew=true;
break;
}
else if(verArr[i]<verLocalArr[i])
{
break;
}
}
if(bNew)
{
$.confirm("已发现新版本"+verArr.join(".")+" 是否现在下载?",function () {
window.open(obj[0].zipball_url,"_blank");
})
}
else
{
$.tip("已经是最新版本了",1);
}
}
}
xml.open("GET","https://api.github.com/repos/sx1989827/DOClever/tags?timestamp="+(new Date()).getTime(),true);
xml.send();
}
else if(command=="quit")
{
var _this=this;
if(this.adminPage)
{
net.post("/admin/logout",{}).then(function (data) {
if(data.code==200)
{
_this.$notify({
title: '退出成功',
type: 'success'
});
sessionStorage.removeItem("admin");
setTimeout(function () {
location.href="/";
},1000)
}
})
}
else
{
net.post("/user/logout",{}).then(function (data) {
if(data.code==200)
{
_this.$notify({
title: '退出成功',
type: 'success'
});
session.clear();
setTimeout(function () {
location.href="/";
},1000)
}
})
}
}
else if(command=="help")
{
window.open("../help/help.html","_blank");
}
},
back:function (event,type) {
if(this.type==0 && !this.session.projectId && this.session.teamId)
{
var _this=this;
var display=this.$refs.project.$el.style.display;
this.$refs.project.$el.style.display="none";
store.state.event.$on("initTeamList",function() {
_this.$refs.project.$el.style.display=display;
store.state.event.$off("initTeamList");
})
store.dispatch("team/changeToList");
}
else if(this.type==0 && this.session.projectId)
{
store.dispatch("project/changeToList");
}
else if(this.type==1 && this.session.teamId)
{
if(this.session.projectId)
{
store.state.team.list.bRefreshProjectList=0;
}
store.dispatch("team/changeToList");
}
}
},
created:function () {
window.hljs.initHighlightingOnLoad();
var _this=this;
store.dispatch("init").then(function () {
$.stopLoading();
if(store.getters["project/list/projectNotTeamLength"]==0 && store.getters["team/list/teamListLength"]>0)
{
_this.type=1;
}
}).catch(function (err) {
$.notify(err,0);
})
}
});
window.vueObj=vue;
window.worker=new Worker('worker.js');
$.ready(function () {
$.startLoading();
});
if (module.hot) {
module.hot.accept();
}