-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
820 lines (804 loc) · 42.5 KB
/
Copy pathindex.html
File metadata and controls
820 lines (804 loc) · 42.5 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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net/" />
<title>genshin-tool</title>
<link href="https://cdn.jsdelivr.net/gh/picturepan2/spectre@0.5.9/dist/spectre.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/gh/picturepan2/spectre@0.5.9/dist/spectre-exp.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/gh/picturepan2/icons.css/dist/icons.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/iu-toast@1.1.2/dist/iu-toast.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/vue@3.2.4/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/iu-toast@1.1.2/dist/iu-toast.min.js"></script>
<script>
// hashRouter mini version
$router = Object.create(null);
Object.defineProperty($router, "path", {
get() {
return location.hash.slice(2).replace(/\/{2,}/g, "/");
},
set(str) {
location.hash = "/" + str.replace(/\/{2,}/g, "/");
},
});
Object.defineProperty($router, "array", {
get() {
return this.path.split("/");
},
set(arr) {
this.path = arr.join("/");
},
});
</script>
<style>
* {
word-break: break-all;
}
.inline-forms * {
display: inline;
max-width: 60%;
}
.iu-toast {
z-index: 999;
}
#app {
padding: 1rem;
}
body ::-webkit-scrollbar {
width: 5px;
height: 5px;
background: transparent;
}
@media (min-width: 1024px) {
body ::-webkit-scrollbar {
width: 8px;
height: 8px;
}
}
body ::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body class="container grid-lg" id="app">
<header class="navbar">
<section class="navbar-section">
<a href="https://github.com/yieldray/genshin-tool#readme" class="btn btn-link">Docs</a>
<a href="https://github.com/yieldray/genshin-tool" class="btn btn-link">GitHub</a>
</section>
<section class="navbar-center">
<a href="./"><i class="icon icon-search"></i></a>
</section>
<section class="navbar-section">
<a onclick="$server.classList.add('active')" class="btn btn-link">Server</a>
<a onclick="$cookie.classList.add('active')" class="btn btn-link">Cookie</a>
</section>
</header>
<!--part1-->
<div class="empty" style="margin-bottom: 0.5rem">
<div class="empty-icon">
<i class="icon icon-2x icon-search"></i>
</div>
<p class="empty-title h2">genshin-tool</p>
<p class="empty-subtitle">
<small>{{cookie?"cookie已填写":"未填写cookie,将使用服务器定义的cookie"}}</small>
</p>
<p>
请务必保护好自己的 cookie,
<br />
不要在不受信任的地址输入自己的 cookie!
<br />
cookie获取方法见左上角Docs
<br />
签到是cookie对应的由账号进行的
</p>
<div class="empty-action">
<button onclick="$cookie.classList.add('active')" class="btn btn-primary">设置cookie</button>
</div>
</div>
<!--part2-->
<div class="columns">
<!--column on-->
<ul class="menu column col-4 col-xs-12">
<li class="divider" data-content="签到"></li>
<li class="menu-item">
<a @click="doAction('selfInfo')">
<i class="icon icon-person"></i>
查询账号信息
</a>
</li>
<li class="menu-item">
<a @click="doAction('signReward')">
<i class="icon icon-flag"></i>
签到奖励
</a>
</li>
<li class="menu-item">
<a @click="checkin">
<i class="icon icon-check"></i>
执行签到
</a>
</li>
<li class="divider" data-content="查询"></li>
<div class="form-group inline-forms">
<input
v-model="target_uid"
class="form-input"
type="number"
placeholder="欲查询的uid"
min="100000001"
max="999999999"
maxlength="9"
/>
<select style="width: 25%" v-model="region" class="form-select">
<option value="cn_gf01" default>官服</option>
<option value="cn_qd01">渠道服</option>
</select>
</div>
历史记录:
<template v-for="uid in history">
<a @click="target_uid=uid">{{uid}}</a>
</template>
<button
onclick="localStorage.setItem('history','[]');app.history=[];iToast.success('已删除历史记录')"
class="btn btn-sm btn-action s-circle btn-primary"
>
╳
</button>
<li class="menu-item">
<a @click="doAction('gameInfo')">
<i class="icon icon-flag"></i>
游戏信息
</a>
</li>
<li class="menu-item">
<a @click="doAction('charDetail')">
<i class="icon icon-person"></i>
角色信息
</a>
</li>
<li class="menu-item">
<a @click="doAction('spiralAbyss1')">
<i class="icon icon-link"></i>
本期深渊
</a>
</li>
<li class="menu-item">
<a @click="doAction('spiralAbyss2')">
<i class="icon icon-link"></i>
上期深渊
</a>
</li>
</ul>
<br />
<!--part3 in 2-->
<div class="card column col-8 col-xs-12">
<div class="card-header">
<!--game-info-->
<template v-if="action==='gameInfo'&&data.stats">
<h3>数据总览</h3>
<div class="columns">
<div class="d-inline-block column col-2 col-xs-3 card text-center">
活跃天数
<br />
{{data.stats.active_day_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
成就达成数
<br />
{{data.stats.achievement_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
获得角色数
<br />
{{data.stats.avatar_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
解锁传送点
<br />
{{data.stats.way_point_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
风神瞳
<br />
{{data.stats.anemoculus_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
岩神瞳
<br />
{{data.stats.geoculus_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
雷神瞳
<br />
{{data.stats.electroculus_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
解锁秘境
<br />
{{data.stats.domain_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
深境螺旋
<br />
{{data.stats.spiral_abyss}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
华丽宝箱数
<br />
{{data.stats.luxurious_chest_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
珍贵宝箱数
<br />
{{data.stats.precious_chest_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
精致宝箱数
<br />
{{data.stats.exquisite_chest_number}}
</div>
<div class="d-inline-block column col-2 col-xs-3 card text-center">
普通宝箱数
<br />
{{data.stats.common_chest_number}}
</div>
</div>
<div class="divider"></div>
<h3>尘歌壶</h3>
<ul class="columns" v-if="data.homes">
<li
v-for="home in data.homes"
:key="home.name"
class="d-inline-block card column col-4 col-xs-12 p-centered text-center"
>
<div class="card-image">
<img :src="home.icon" class="img-responsive" />
</div>
<div class="card-body" style="display: flex; flex-direction: row; align-items: center">
<img class="d-inline-block" style="width: 2rem" :src="home.comfort_level_icon" />
<span class="text-left d-inline-block" style="font-size: .5rem">
{{home.comfort_level_name}}
</span>
<small class="text-right d-inline-block float-right">{{home.name}}</small>
</div>
<div class="divider" style="clear: both"></div>
<div class="columns">
<div class="column col-3 text-tiny">
{{home.level}}
<br />
信任等阶
</div>
<div class="column col-3 text-tiny">
{{home.comfort_num}}
<br />
最高洞天仙力
</div>
<div class="column col-3 text-tiny">
{{home.item_num}}
<br />
获得摆件数
</div>
<div class="column col-3 text-tiny">
{{home.visit_num}}
<br />
历史访客数
</div>
</div>
</li>
</ul>
<div class="divider"></div>
<h3>世界探索</h3>
<ul class="columns" v-if="data.world_explorations">
<li
v-for="world in data.world_explorations"
:key="world.id"
style="background-color: DimGray; color: #fff"
class="d-inline-block card column col-6 col-xs-12 p-centered text-center"
>
<img :src="world.icon" class="float-left" style="width: 40%" />
<div style="display: flex; flex-direction: column; align-items: center">
<strong class="d-inline-block">{{world.name}}</strong>
<span class="d-inline-block">探索度:{{(world.exploration_percentage*0.1).toFixed(1)}}%</span>
<progress
class="progress d-inline-block"
:value="world.exploration_percentage*0.1"
max="100"
></progress>
<span class="d-inline-block">声望等级:{{world.level}}</span>
<small class="d-inline-block" v-if="world.offerings[0]">
{{world.offerings[0].name}}等级:{{world.offerings[0].level}}
</small>
</div>
</li>
</ul>
<div class="divider"></div>
<details open>
<summary>
<h3 class="d-inline">角色</h3>
</summary>
<table class="table">
<thead>
<tr>
<th>角色</th>
<th>元素</th>
<th>稀有度</th>
<th>命座</th>
<th>好感度</th>
</tr>
</thead>
<tbody v-for="char in data.avatars" :key="char.id">
<tr>
<td>
<img :src="char.image" class="d-inline-block" style="width: 1.5rem; height: 1.5rem" />
<span class="d-inline-block">{{char.name}}</span>
</td>
<td>{{translate(char.element)}}</td>
<td>{{'★'.repeat(char.rarity)}}</td>
<td>{{char.actived_constellation_num}}</td>
<td>{{char.fetter}}</td>
</tr>
</tbody>
</table>
</details>
</template>
<!--game-info-->
<!--char-detail-->
<template v-else-if="action==='charDetail'&&data.avatars">
<strong>{{(action==='charDetail')?'时装暂不支持':''}}</strong>
<div v-for="char in data.avatars" :key="char.id" class="columns">
<div class="column col-5">
<img :src="char.image" style="max-width: 100%; min-height: 250px" />
</div>
<div class="column col-7">
<h4 class="d-inline">{{char.name}}</h4>
<small class="label" style="font-size: 0.5rem">
LV{{char.level}} {{char.actived_constellation_num}}命 {{translate(char.element)}}
</small>
<br />
<small>好感度等级:{{char.fetter}} </small>
<!--武器-->
<div class="popover popover-bottom">
<button class="btn btn-sm">
{{char.weapon.name}} LV{{char.weapon.level}}
<i class="icon icon-arrow-down"></i>
</button>
<div class="popover-container">
<div class="card">
<div class="card-body">
<img :src="char.weapon.icon" style="width: 20%; border: #000 solid 1px" />
<small class="float-right">
精炼{{char.weapon.affix_level?char.weapon.affix_level:1}}阶
<br />
{{char.weapon.type_name}}
<br />
{{'★'.repeat(char.weapon.rarity)}}
</small>
</div>
<div class="card-footer">{{char.weapon.desc}}</div>
</div>
</div>
</div>
<br />
<!--圣遗物-->
<div v-for="r in char.reliquaries" :key="r.id" class="popover popover-bottom" style="display: block">
<button class="btn btn-primary btn-sm text-tiny">
{{r.name}}
<i>+{{r.level}}</i>
<i class="icon icon-arrow-down"></i>
</button>
<div class="popover-container">
<div class="card">
<div class="card-body">
<img :src="r.icon" style="width: 20%; border: #000 solid 1px" />
<small class="float-right">
{{r.set.name}}
<br />
{{r.pos_name}}
<br />
{{'★'.repeat(r.rarity)}}
</small>
</div>
<div class="card-footer">
<p>{{r.set.name}}:</p>
<span v-for="a in r.set.affixes" :key="a.activation_number">
<strong>{{a.activation_number}}件套:</strong>
<i>{{a.effect}}</i>
<br />
</span>
</div>
</div>
</div>
</div>
<br />
<!--命座-->
<div v-for="c in char.constellations" class="popover popover-top">
<button
class="btn btn-primary btn-sm btn-action s-circle"
:class="{ disabled: !c.is_actived }"
style="margin-right: 1px"
>
{{c.pos}}
</button>
<div class="popover-container">
<div class="card" style="background-color: DimGray; color: #fff">
<div class="card-body">
<img :src="c.icon" style="width: 20%" />
<span class="text-large float-right">{{c.name}}</span>
<div
class="card-footer text-small float-right"
v-html="c.effect.replace(/\\n/g,'<br />')"
></div>
</div>
</div>
</div>
</div>
<!--结束-->
</div>
<div class="divider"></div>
</div>
</template>
<!--char-detail-->
<!--spiral-abyss-->
<template v-else-if="action==='spiralAbyss1'||action==='spiralAbyss2'">
<h3>
深境螺旋战绩
<small v-if="data.start_time" class="label text-tiny">
统计周期{{new Date(data.start_time*1000).toLocaleDateString()}} - {{new
Date(data.end_time*1000).toLocaleDateString()}}
</small>
</h3>
<template v-if="data.total_battle_times === 0">
<div class="card p-2 m-2">
<span class="text-large text-center">未挑战</span>
</div>
</template>
<div v-if="data.total_battle_times > 0" class="panel m-2 bg-secondary">
<div class="panel-header">
<div class="panel-title text-center">挑战回顾</div>
</div>
<div class="panel-nav text-center text-light bg-dark">
最深抵达 {{data.max_floor}} 战斗次数{{data.total_battle_times}} 挑战成功次数{{data.total_win_times}}
⚛{{data.total_star}}
</div>
<div class="panel-body" style="height: 400px">
<span class="text-warning">出战次数</span>
<div class="columns">
<figure
v-for="char in data.reveal_rank"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.avatar_icon" />
<figcaption class="figure-caption text-center bg-gray">{{char.value}}次</figcaption>
</figure>
</div>
<span class="text-warning d-block">战斗数据榜</span>
<small>击破数</small>
<div class="columns">
<figure
v-for="char in data.defeat_rank"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.avatar_icon" />
<figcaption class="figure-caption text-center bg-gray">{{char.value}}</figcaption>
</figure>
</div>
<small>承受伤害</small>
<div class="columns">
<figure
v-for="char in data.take_damage_rank"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.avatar_icon" />
<figcaption class="figure-caption text-center bg-gray">{{char.value}}</figcaption>
</figure>
</div>
<small>元素战技释放次数</small>
<div class="columns">
<figure
v-for="char in data.normal_skill_rank"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.avatar_icon" />
<figcaption class="figure-caption text-center bg-gray">{{char.value}}</figcaption>
</figure>
</div>
<small>元素爆发释放次数</small>
<div class="columns">
<figure
v-for="char in data.energy_skill_rank"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.avatar_icon" />
<figcaption class="figure-caption text-center bg-gray">{{char.value}}</figcaption>
</figure>
</div>
<small>最强一击</small>
<img :src="data.damage_rank[0].avatar_icon" style="width: 10%" class="bg-gray s-circle" />
{{data.damage_rank[0].value}}
</div>
<!--挑战队伍-->
<div v-for="floor in data.floors" class="panel m-2">
<div class="panel-header">
<span class="bg-dark text-light p-2 s-circle">{{floor.index.toString().padStart(2,'0')}}</span>
<span> 深境螺旋第{{floor.index}}层</span>
<span class="float-right">⚛ {{floor.star}}/{{floor.max_star}}</span>
</div>
<details close>
<div class="panel-body">
<div v-for="level in floor.levels">
第{{level.index}}间
<span class="float-right">⚛ {{level.star}}/{{level.max_star}}</span>
<div v-for="(battle,i) in level.battles">
<small>
<template v-if="i===0">上半</template>
<template v-if="i===1">下半</template>
{{new Date(battle.timestamp*1000).toLocaleString()}}
</small>
<div class="columns">
<figure
v-for="char in battle.avatars"
class="figure s-rounded column col-2 card"
:style="{background:(char.rarity===5)?'#ce8d55':'#9274bd',padding:'0'}"
>
<img class="img-responsive" :src="char.icon" />
<figcaption class="figure-caption text-center bg-gray">LV{{char.level}}</figcaption>
</figure>
</div>
</div>
</div>
</div>
<summary style="padding-left: 4rem">展开</summary>
</details>
</div>
</div>
</template>
<!--spiral-abyss-->
<!--sign-reward-->
<template v-else-if="action==='signReward'">
<h3>{{data.month}}月签到奖励</h3>
<div class="columns text-center">
<figure v-for="(award,i) in data.awards" class="figure s-rounded column col-xs-4 col-2 card" style="padding: 0">
<img class="img-responsive" :src="award.icon" />
<span class="text-tiny">{{award.name}} ×{{award.cnt}}</span>
<figcaption class="figure-caption bg-gray">第{{++i}}天</figcaption>
</figure>
</div>
</template>
<!--sign-reward-->
<!--no-handler-->
<div v-else>
<div class="card-title h5">Response</div>
<div class="card-subtitle text-gray">返回信息</div>
<div class="card-body">
<p style="white-space: pre-wrap">{{JSON.stringify(data,null,4)}}</p>
</div>
<div class="card-footer"></div>
</div>
<!--no-handler-->
</div>
</div>
<!--column off-->
</div>
<!--设置服务器start-->
<div class="modal" id="$server">
<a onclick="$server.classList.remove('active')" class="modal-overlay" aria-label="Close"></a>
<div class="modal-container">
<div class="modal-header">
<a onclick="$server.classList.remove('active')" class="btn btn-clear float-right" aria-label="Close"></a>
<div class="modal-title h5">设置服务器</div>
</div>
<div class="modal-body">
<div class="content">
<div class="form-group">
<label class="form-label" for="input-server">
当前服务器
<a :href="server">{{server}}</a>
</label>
<textarea v-model="server" class="form-input" id="input-server" placeholder="Server URL" rows="1"></textarea>
</div>
<div class="form-group">
<label class="form-label" for="input-checkin-server">
当前签到服务器
<a :href="server">{{checkin_server}}</a>
</label>
<textarea
v-model="checkin_server"
class="form-input"
id="input-checkin-server"
placeholder="Check In: Server URL"
rows="1"
></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button @click="saveServer" class="btn btn-primary">保存</button>
<button onclick="$server.classList.remove('active')" class="btn btn-primary">关闭</button>
</div>
</div>
</div>
<!--设置服务器end-->
<!--设置cookie start-->
<div class="modal" id="$cookie">
<a onclick="$cookie.classList.remove('active')" class="modal-overlay" aria-label="Close"></a>
<div class="modal-container">
<div class="modal-header">
<a onclick="$cookie.classList.remove('active')" class="btn btn-clear float-right" aria-label="Close"></a>
<div class="modal-title h5">设置cookie</div>
</div>
<div class="modal-body">
<div class="content">
<!-- <p>当前cookie: {{cookie?cookie:'未设置'}}</p> -->
<div class="form-group">
<label class="form-label" for="input-cookie"></label>
<textarea v-model="cookie" class="form-input" id="input-cookie" placeholder="米游社 cookie" rows="5"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button @click="saveCookie" class="btn btn-primary">保存</button>
<button onclick="$cookie.classList.remove('active')" class="btn btn-primary">关闭</button>
</div>
</div>
</div>
<!--设置cookie end-->
</body>
<script>
const app = Vue.createApp({
data() {
return {
server: "./api/",
checkin_server: "./api/checkin",
cookie: "",
self_uid: "",
target_uid: "",
region: "cn_gf01",
action: "",
data: {},
history: [],
};
},
computed: {
jsonBody: {
get() {
return {
cookie: this.cookie,
self_uid: this.self_uid,
target_uid: this.target_uid,
region: this.region,
action: this.action,
};
},
set(obj) {
this.action = obj.action;
this.cookie = obj.cookie;
this.self_uid = obj.self_uid;
this.target_uid = obj.target_uid;
this.region = obj.region;
},
},
},
methods: {
async fetchData(url) {
iToast.loading("请求中,请稍后");
try {
let resp = await fetch(url, {
method: "POST",
body: JSON.stringify(this.jsonBody),
});
if (!resp.ok) throw new Error("api服务器异常");
resp = await resp.json();
if (resp.success) {
iToast.success("请求成功");
if (["gameInfo", "charDetail", "spiralAbyss1", "spiralAbyss2"].includes(this.action))
$router.array = [this.action, this.target_uid];
this.data = resp.data;
return resp.data;
} else {
throw new Error(resp.msg);
}
} catch (e) {
iToast.fail({ message: e.message, duration: 3000 });
if (e.message === "Failed to fetch")
iToast.fail({
message: "请检查api服务器是否填写正确",
duration: 5000,
position: "top",
});
else if (e.message === "Please login")
iToast.fail({
message: "cookie填写错误或失效",
duration: 5000,
position: "top",
});
}
},
async checkin() {
//this.action = "";
this.fetchData(this.checkin_server);
},
getHistory() {
return JSON.parse(localStorage.getItem("history"));
},
addHistory(uid) {
this.history = this.getHistory();
let history = localStorage.getItem("history");
if (history) {
try {
history = JSON.parse(history);
} catch (e) {
localStorage.setItem("history", "[]");
}
} else {
localStorage.setItem("history", "[]");
}
history = JSON.parse(localStorage.getItem("history"));
if (history.includes(uid) || !uid || String(uid).length !== 9) {
return false;
} else {
history.push(uid);
history = JSON.stringify(history);
localStorage.setItem("history", history);
this.history = this.getHistory();
return true;
}
},
doAction(action) {
if (["gameInfo", "charDetail", "spiralAbyss1", "spiralAbyss2"].includes(action)) {
const len = this.target_uid ? String(this.target_uid).length : 0;
if (len !== 9) {
iToast.fail(`uid是9位数\n输入了${len}位数`);
return;
}
}
this.addHistory(this.target_uid); //添加历史记录
this.data = {};
this.action = action;
this.fetchData(this.server);
},
saveServer() {
localStorage.setItem("server", this.server);
localStorage.setItem("checkin_server", this.checkin_server);
iToast.success("保存成功");
},
saveCookie(event) {
localStorage.setItem("cookie", this.cookie);
iToast.success("保存成功");
},
translate(raw) {
return raw
.replace("Anemo", "风")
.replace("Geo", "岩")
.replace("Hydro", "水")
.replace("Pyro", "火")
.replace("Cryo", "冰")
.replace("Electro", "雷");
},
},
mounted() {
iToast.allowMultiToast();
if (localStorage.getItem("server")) this.server = localStorage.getItem("server");
if (localStorage.getItem("checkin_server")) this.checkin_server = localStorage.getItem("checkin_server");
if (localStorage.getItem("cookie")) this.cookie = localStorage.getItem("cookie");
if (localStorage.getItem("history")) this.history = this.getHistory();
const [action, uid] = $router.array;
this.target_uid = uid;
if (["gameInfo", "charDetail", "spiralAbyss1", "spiralAbyss2"].includes(action)) this.doAction(action);
},
}).mount("#app");
</script>
</html>