Repository navigation
Expand file tree
/
Copy pathexport.html
More file actions
577 lines (512 loc) · 16.1 KB
/
Copy pathexport.html
File metadata and controls
577 lines (512 loc) · 16.1 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1">
<title>Cloud Studio - 开启云端开发模式 WebIDE</title>
<meta name="Keywords" content="Coding.net,Coding,WebIDE,Web IDE,IDE,Git,代码托管,在线开发,在线调试,Terminal,开发环境分享,软件团队协作,Cloud Studio">
<meta name="Description" content="Cloud Studio 是Coding自主研发的在线集成开发环境。用户可以通过 Cloud Studio 创建项目的工作空间,进行在线开发,调试等操作。与此同时,Cloud Studio 还提供了可分享的开发环境功能,用户可以保存当前的 Terminal 环境,分享给团队的其他成员。">
<link rel="shortcut icon" href="//studio-res.coding.net/StudioWebResource/Images/favicon.ico">
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?bc38dcf3aea6333c859d874c60648216";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background: #323A45;
}
main {
display: flex;
height: 100vh;
align-items: center;
justify-content: center;
flex-direction: column;
width: 100vw;
color: white;
}
.title {
/* width: 34%; */
font-size: 30px;
}
.intro {
width: 44%;
font-size: 14px;
margin-top: 20px;
line-height: 24px;
letter-spacing: 1px;
}
.intro a {
color: #297fff;
text-decoration: none;
}
.logo {
position: absolute;
bottom: 30px;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
}
.logo .qcloud-logo {
width: 112px;
}
.logo .coding-logo {
width: 127px;
}
.logo .multi {
width: 14px;
margin: 0 14px;
}
.button {
background: #297FFF;
cursor: pointer;
border-radius: 2px;
height: 34px;
line-height: 34px;
text-align: center;
text-decoration: none;
color: white;
width: 167px;
display: flex;
align-items: center;
justify-content: center;
}
.button img {
margin-right: 3px;
animation: loading 1.5s linear infinite;
}
@keyframes loading{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
.disable {
cursor: not-allowed;
background: #ABABAB;
}
.export-btn {
margin-top: 15px;
}
.start-btn {
margin-top: 30px;
}
.card {
padding: 9px;
border-radius: 2px;
border: 1px solid #515F72;
display: flex;
width: 300px;
margin-bottom: 15px;
cursor: pointer;
align-items: center;
}
.card .avatar {
width: auto;
height: 60px;
}
.card .meta {
margin-left: 10px;
width: 210px;
}
.card .mask {
align-self: start;
margin-top: -10.5px;
margin-right: -11px;
width: 34px;
height: 30px;
text-align: right;
background-repeat: no-repeat;
}
.mask path {
fill: red;
}
.card .mask .check {
margin-right: 1px;
}
.card .meta .time {
font-size: 14px;
line-height: 22px;
margin-top: 5px;
color: #AAAAAA;
}
.card .meta .name {
font-size: 16px;
line-height: 24px;
}
.list {
width: 654px;
margin-top: 25px;
}
.list .list-group {
display: flex;
flex-wrap: wrap;
padding: 15px;
padding-bottom: 0;
justify-content: space-between;
border: 1px solid #515F72;
border-radius: 2px;
margin-top: 8px;
/*overflow-y: scroll;*/
align-content: start;
min-height: 300px
}
.list .list-header {
display: flex;
justify-content: space-between;
}
.list .list-header .checkbox-container {
display: flex;
justify-content: space-between;
align-items: center;
width: 80px;
}
.list .list-header .checkbox-container input,label {
cursor: pointer;
}
.tip {
margin-top: 10px;
}
::-webkit-scrollbar-thumb {
height: 231px;
background: #181C23;
border-radius: 6px;
}
</style>
</head>
<body>
<script src="//cdn.staticfile.org/mithril/1.1.6/mithril.min.js"></script>
<script>
var STATIC_PATH = '<%= webpackConfig.output.publicPath %>/'
var BASE_URL = '/backend/'
var IMG_URL = 'https://coding.net'
var REDIRECT_URL = 'https://studio.dev.tencent.com'
var wsList = []
var tip = '导出成功!'
var canShowTip = false
var isError = false
var checked = 'checked'
var btnName = '导出所选空间'
var showLoading = false
var warpPath = function(path) {
return STATIC_PATH + path
}
var formatDate = function(ms) {
var date = new Date(ms)
var minutes = date.getMinutes()
if (minutes < 10) {
minutes = '0' + minutes
}
return date.getFullYear() + '-' + (date.getMonth() + 1)
+ '-' + date.getDate() + ' ' + date.getHours() + ':'
+ minutes
}
var ajax = function(fn, url, accept) {
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.withCredentials = true
xhr.setRequestHeader('Accept', 'application/vnd.coding.v2+json')
if (accept) {
// xhr.setRequestHeader('Accept-Encoding', 'gzip, deflate')
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.setRequestHeader('Accept-Language', 'zh-CN,zh;q=0.9,en;q=0.8')
xhr.responseType = 'blob'
}
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
fn(xhr)
}
}
return xhr.send()
}
var handleExport = function(error, el) {
tip = error ? '遇到了一些小问题,请尝试点击上面的按钮重新导出。'
: '导出成功!'
btnName = error ? '重新导出' : '再次导出'
isError = error
canShowTip = true
m.redraw()
setTimeout(function() {
canShowTip = false
el.className = el.className.replace(' disable', '')
m.redraw()
}, 2000)
}
// View
var Home = {
view: function() {
return [
m('main', [
m('h1', {
class: 'title'
}, '携手腾讯云,Cloud Studio 全面升级'),
m('div', {
class: 'intro'
},[
m('span', '为了优化 Cloud Studio 运行的基础设施,给用户提供体验更好、更稳定的产品服务, Cloud Studio 现已在'),
m('a', { href: 'https://dev.tencent.com/'}, '腾讯云开发者平台'),
m('span', '中全面升级,用户可长期免费使用。升级后,此版本后续不再做功能升级及维护。为避免影响您的后续使用,建议您将该版本数据导出,并迁移至新版'),
m('a', { href: 'https://studio.dev.tencent.com/intro' }, ' Cloud Studio'),
m('span', ',迁移教程可参考'),
m('a', { href: 'https://dev.tencent.com/help/cloud-studio/how-to-migrate-cs' }, '这里'),
m('span', '。'),
m('br'),
m('br'),
m('span', '如您已在 Cloud Studio 付费购买小主机,我们将在 2018 年 11 月 15 日前将已使用的金额返还至您的腾讯云账户中:'),
m('br'),
m('br'),
m('strong', [
m('span', '已支付现金部分,全额退还到您的腾讯云账户中,您可操作提现;'),
m('br'),
m('span', '已使用的代金券部分,返还等额通用代金券,发放于您的腾讯云账户中。')
]),
m('br'),
m('br'),
m('span', '如给您造成了不便,敬请谅解。我们将在新的平台,给您提供更优质的服务。感谢您的理解和支持。')
]),
m('a', {
href: '?/list',
class: 'button start-btn'
}, '开始导出')
]),
m(Footer)
]
}
}
var List = {
oncreate: function() {
var listGroup = document.getElementsByClassName('list-group')[0]
// Set scrollbar
if (listGroup.getClientRects()[0].height > 300) {
listGroup.style.height = '300px'
listGroup.style.overflowY = 'scroll'
var style = document.createElement('style')
style.innerText = '::-webkit-scrollbar{ width: 6px; }'
document.head.append(style)
}
},
view: function() {
return [
m('main', [
m('h1', {
class: 'list-title'
}, '选择工作空间导出'),
m('list', {
class: 'list'
}, [
m('div', {
class: 'list-header'
}, [
m('span', '选择空间导出'),
m('div', {
class: 'checkbox-container',
onselectstart: function () {
return false
}
}, [
m('input',{
type: 'checkbox',
checked: checked,
id: 'checkList',
style: {
cursor: showLoading ? 'not-allowed' : 'pointer'
},
onchange: function (e) {
if (showLoading) return
checked = checked === 'checked' ? ''
: 'checked'
for (var i = wsList.length - 1; i >= 0; i--) {
wsList[i].checked = checked ? true : false
}
}
}),
m('label', {
for: 'checkList',
style: {
cursor: showLoading ? 'not-allowed' : 'pointer'
}
}, '选择全部')
])
]),
m('div', {
class: 'list-group'
},
wsList.map(function(item) {
return m(Card, {
name: item.name,
time: item.time,
checked: item.checked,
spaceKey: item.spaceKey,
img: item.img
})
})
)
]),
m('a', {
href: '#',
class: 'button export-btn'
+ (wsList.every(function (item) {
return !item.checked
}) ? ' disable' : ''),
onclick: function(e) {
var el = this
if (el.className.includes('disable')) {
return
}
el.className += ' disable'
btnName = '正在导出...'
showLoading = true
var exportList = []
for (var i = wsList.length - 1; i >= 0; i--) {
var tmp = wsList[i]
if (tmp.checked) {
exportList.push(tmp.spaceKey)
}
}
var downloadURL = BASE_URL + 'workspaces/packing?spaceKeys=' + exportList.join(',')
ajax(function(xhr) {
showLoading = false
var reader = new FileReader()
reader.addEventListener('load', function () {
try {
var res = JSON.parse(this.result)
if (res.code === -1) {
handleExport(true, el)
}
} catch (e) {
var aLink = document.createElement('a')
aLink.setAttribute('type', 'hidden')
if (exportList.length > 1) {
aLink.download = wsList[0].ownerName + '.tar.gz'
} else {
aLink.download = exportList[0] + '.tar.gz'
}
aLink.href = URL.createObjectURL(xhr.response)
document.body.appendChild(aLink)
aLink.click()
aLink.remove()
handleExport(false, el)
}
}, false)
reader.readAsText(xhr.response)
}, downloadURL, true)
}
}, [
showLoading ? m('img', { src: warpPath('loading.svg') }) : ''
], btnName),
m('div', {
class: 'tip',
style: {
visibility: canShowTip ? 'visible' : 'hidden',
color: isError ? '#D65B4E' : '#37D180'
}
}, tip)
]),
m(Footer)
]
}
}
var Card = {
view: function(vnode) {
return m('div', {
class: 'card',
style: {
cursor: showLoading ? 'not-allowed' : 'pointer'
},
onclick: function() {
if (showLoading) return
wsList.map(function(item, i) {
if (item.spaceKey === vnode.attrs.spaceKey) {
var tmpChecked = wsList[i].checked
wsList[i].checked = tmpChecked ? false : true
}
})
checked = wsList.every(function (item) {
return item.checked
}) ? 'checked' : ''
}
}, [
m('img', { class: 'avatar', src: vnode.attrs.img }),
m('div', {
class: 'meta'
}, [
m('div', { class: 'name' }, vnode.attrs.name),
m('div', { class: 'time' }, '最后修改于 ' + vnode.attrs.time),
]),
m('div', {
class: 'mask',
style: {
'background-image': 'url('
+ (vnode.attrs.checked
? warpPath('mask.svg') : warpPath('mask-unselected.svg'))
+ ')'
}
}, [
m('img', {
src: vnode.attrs.checked
? warpPath('check.svg') : warpPath('check-unselected.svg'),
class: 'check'
})
]),
])
}
}
var Footer = {
view: function() {
return m('footer', {
class: 'logo'
}, [
m('a', { href: 'https://cloud.tencent.com/' }, [
m('img', { class: 'qcloud-logo', src: warpPath('qcloud-logo.png') })
]),
m('img', { class: 'multi', src: warpPath('multi.png') }),
m('a', { href: 'https://coding.net/' }, [
m('img', { class: 'coding-logo', src: warpPath('coding-logo.png') })
])
])
}
}
try{
ajax(function(xhr) {
var result = JSON.parse(xhr.responseText)
if (result.contents && result.contents.length) {
var lists = result.contents
lists.map(function(item) {
var project = item.project
var iconUrl = project.iconUrl
wsList.push({
spaceKey: item.spaceKey,
name: item.owner.globalKey + '/' + project.name,
time: formatDate(item.lastModifiedDate),
checked: true,
img: iconUrl.includes('http') ? iconUrl : IMG_URL + iconUrl,
ownerName: item.owner.globalKey
})
})
m.route.prefix('?')
m.route(document.body, '/home', {
'/list': List,
'/home': Home,
})
} else {
location.href = REDIRECT_URL
}
}, BASE_URL + 'workspaces?page=0&size=5&sort=lastModifiedDate,desc')
} catch (e) {
location.href = REDIRECT_URL
}
</script>
</body>
</html>