-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtools-board.html
891 lines (843 loc) · 38.7 KB
/
tools-board.html
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
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
<html lang="en">
<head>
<meta charSet="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="keywords" content="程序员阿诺,阿诺,倒计时,倒计时列表,实用小工具,高考倒计时,春节,春节倒计时"/>
<title>公众号:程序员阿诺</title>
<style>
body {font-family: Tahoma, Verdana, Arial, sans-serif;} .notice {background: #B4EEB4;position: fixed;border: 1px solid #1a1a1a;border-radius: 5px;z-index: 100;width: auto;height: 30px;text-align: center;font-weight: bold;line-height: 30px;padding: 7px;left: 50%;top: 27%;transform: translate(-50%, -50%);} a:link, a:visited, a:active {text-decoration: none;color: blue;} a:hover {text-decoration: underline;} .board {position: relative;float: left;margin: 5px 17px 5px 17px;padding: 5px 17px 5px 17px;} .badge {position: absolute;font-size: 17px;width: 23px;height: 23px;line-height: 23px;text-align: center;} .up {top: -12px;right: -12px;} .down {bottom: -12px;right: -12px;} .my-button {position: relative;cursor: pointer;} .my-button:active {padding-bottom: -1px;} .item-x {display: none;} .item:hover > .item-x, .item-x:hover {display: inline-block;} .group-name {position: relative;} .group-name:hover {color: transparent;} .edit {background-color: transparent;display: none;position: absolute;top: 0;margin: 0;padding: 0;width: 100%;height: 100%;font-family: inherit;font-size: inherit;font-weight: bold;border: none;outline: none;} .group-name:hover .edit {display: block;} td {padding-left: 5px;}
</style>
<script src="x.js"></script>
<script src="calendar/lunar.js?5"></script>
<script src="js/vue.min.js"></script>
<script src="js/bluebird.min.js"></script>
<script src="js/html2canvas.min.js"></script>
<script type="text/javascript">
function notice(message, opts) {
function destroy() {
document.body.removeChild(document.getElementById("noticeLayer"));
}
function createBtn(parent, title, opt) {
let btn = document.createElement("button");
btn.innerText = title;
btn.style.margin = "2px";
btn.onclick = opt;
parent.append(btn)
}
if (document.getElementById("noticeLayer") == null) {
let noticeLayer = document.createElement("div");
document.body.appendChild(noticeLayer);
noticeLayer.id = "noticeLayer";
noticeLayer.setAttribute('class', 'notice');
noticeLayer.append(message);
if (opts) {
noticeLayer.style.height = '60px';
noticeLayer.append(document.createElement("br"));
opts.forEach(opt => {
createBtn(noticeLayer, opt.title, () => {
opt.handler();
destroy();
})
})
createBtn(noticeLayer, "取消", () => {
destroy();
})
} else {
setTimeout(destroy, 1313);
}
}
}
window.oncontextmenu = function (e) {
e.preventDefault();
confirm("备份?") && function () {
let content = localStorage.getItem(StoreKey.ToolGroups);
let blob = new Blob([content], {
type: "text/plain;charset=utf-8"
});
let reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = function (e) {
let a = document.createElement('a');
a.download = `工具板-${new Date().toISOString().replace("T", " ").replace(/\..*/, "")}.json`;
a.href = e.target.result;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
}()
};
// canvas生成图片
function screenshot() {
let content = document.getElementById(StoreKey.Countdown);
let width = content.offsetWidth;
let height = content.offsetHeight;
let canvas = document.createElement("canvas");
let context = canvas.getContext('2d');
let backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 0.5;
let scale = (window.devicePixelRatio || 0.5) / backingStore;
context.scale(scale, scale);
canvas.width = width * scale;
canvas.height = height * scale;
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
let opts = {
scale: scale,
canvas: canvas,
width: width,
height: height,
dpi: window.devicePixelRatio
};
html2canvas(content, opts).then(function (canvas) {
context.imageSmoothingEnabled = false;
context.webkitImageSmoothingEnabled = false;
context.msImageSmoothingEnabled = false;
canvas.toBlob(async blob => {
const data = [
new ClipboardItem({
[blob.type]: blob,
}),
];
await navigator.clipboard.write(data)
.then(() => {
notice('截图已复制到剪切板');
}, () => {
notice('截图失败');
}
);
});
});
}
String.prototype.visualLength = function () {
let ruler = document.getElementById('ruler');
ruler.innerHTML = this;
return ruler.offsetWidth;
}
</script>
</head>
<body>
<span id="ruler" style="position:absolute;visibility: hidden;"></span>
<template id="group">
<div>
<div :style="{backgroundColor:group.background}" class="board item">
<h1 v-bind:class="!group.custom?'':'group-name'">
{{ group.name === "" ? "请输入标题" : group.name }}
<input class="edit" placeholder="请输入标题" v-if="group.custom" v-model="group.name"/>
</h1>
<template v-if="group.groups">
<list :list="group.groups" v-slot="{item,index}">
<draggable :couldplace="item.custom" :draggable="item.custom" :index="index" :item="item" :list="group.groups" :sublist="true" :type="DragType.Group">
<group :group="item" :groups="group.groups"></group>
</draggable>
</list>
</template>
<template v-else>
<ol style="margin-bottom: 22px">
<list :list="group.tools" v-slot="{item,index}">
<draggable :couldPlace="item.custom" :draggable="item.custom" :index="index" :item="item" :list="group.tools" :type="DragType.Tool">
<li class="item" style="padding-right: 2px">
<a :href="item.url" draggable="false" target="_blank"><span v-html="item.name"></span></a>
<span @click="confirm(`确定删除[${item.name}]?`)&&(item.name=ToDelete)" class="my-button item-x"
style="position: absolute;margin-left: 1px"
v-if="item.custom">❌</span>
</li>
</draggable>
</list>
</ol>
<div class="item-x" style="position: absolute;left:20px;width: 92%;bottom: 2px" v-if="group.custom">
<input @keyup.enter="newTool(group)" placeholder="链接" style="width: 40%" v-model="url"/>
<input @keyup.enter="newTool(group)" placeholder="名称(回车新增)" style="width: 40%" v-model="name"/>
<span @click="newTool(group)" class="my-button" style="position: absolute;margin-left: 3px">✅</span>
</div>
</template>
<div class="badge up item-x" v-if="group.custom">
<span @click="confirm(`确定删除[${group.name}]?`)&&(group.name=ToDelete)" class="my-button">❌</span>
</div>
<div class="badge down item-x">
<span @click="newGroup(group)" class="my-button">➕</span>
</div>
</div>
</div>
</template>
<template id="draggable">
<div :draggable="draggable" @dragover.prevent @dragstart="dragging(event)" @drop="drop(event)">
<slot></slot>
</div>
</template>
<template id="list">
<div>
<div v-for="(item,index) in list">
<slot v-bind:index="index" v-bind:item="item"></slot>
</div>
</div>
</template>
<div id="app" style="width:100%;height: 100%;">
<!--countdown-->
<div class="board item" style="backgroundColor:#fedf55" id="countdown">
<h1 onclick="screenshot()">倒计时</h1>
<div style="padding-left: 20px;width: auto;height: auto; font-size:14pt;text-align:center;border:2px solid #0da0ec;">
<span v-html="formatDate(countdown.date)"></span><br>
<span v-html="weekday(countdown.date)"></span>
<span style="color: black; ">{{countdown.time}}</span><br>
<span style="color: violet; ">{{`${countdown.lunar.chineseYear}【${countdown.lunar.animal}】年 ${countdown.lunar.cyclical(countdown.lunar.months)}月 ${countdown.lunar.cyclical(countdown.lunar.days + 1)}日`}}</span><br>
<span style="color: #000066; ">{{`${countdown.lunar.chineseMonth}月${countdown.lunar.chineseDay}`}}</span><br>
<span style="background-color:#ccffcc; color:#000066">{{countdown._festivals.join('、')}}</span>
</div>
<ol style="margin-bottom: 22px" v-for="each in [holidays, countdown.tools]">
<li class="item" v-for="item in each" v-if="!item.hide">
<span :style="[item.descStyle]" style="display:inline-block;">
<strong style='color: black' v-html="item.desc"></strong>
</span>
<span :style="[item.diffStyle]" style="display:inline-block;">{{item.diffShow}}</span>
<span v-html="item.time"></span>
<span @click="!confirm(`确定删除[${item.desc}]?`)||countdown.tools.splice(countdown.tools.indexOf(item),1)" class="my-button item-x" style="position: absolute;margin-left: 1px"
v-if="item.custom">❌</span>
</li>
</ol>
<div class="item-x" style="position: absolute;left:20px;width: 92%;bottom: 2px">
<input style="width: 40%" placeholder="日期(09-16或八月十二)" v-model="date" @keyup.enter="newCountdown()"/>
<input style="width: 40%" placeholder="描述(回车新增)" v-model="desc" @keyup.enter="newCountdown()"/>
<span class="my-button" style="position: absolute;margin-left: 3px" @click="newCountdown()">✅</span>
</div>
</div>
<!--tools-board-->
<list :list="toolGroups" v-slot="{item,index}">
<draggable :couldplace="item.custom" :draggable="item.custom" :index="index" :item="item" :list="toolGroups" :sublist="!!item.groups" :type="DragType.Group">
<group :group="item" :groups="toolGroups"></group>
</draggable>
</list>
</div>
</body>
<script>
function clone(object) {
let buf;
if (object instanceof Array) {
buf = [];
let i = object.length;
while (i--) {
buf[i] = clone(object[i]);
}
return buf;
} else if (object instanceof Object) {
buf = {};
for (let k in object) {
buf[k] = clone(object[k]);
}
return buf;
} else {
return object;
}
}
const DragType = {Group: 1, Tool: 2};
const StoreKey = {ToolGroups: "toolGroups", Countdown: "countdown", Readme: "readme", Version: "version"};
const ToDelete = '$delete';
let draggingType = null;
let draggingFromList = null;
let draggingItem = null;
let draggingIndex = null;
let draggable = {
props: {
draggable: {},
sublist: false,
type: {},
list: {},
item: {},
index: {},
couldplace: {},
},
template: '#draggable',
methods: {
clear() {
draggingType = null;
draggingFromList = null;
draggingItem = null;
},
dragging(event) {
event.stopPropagation();
draggingType = this.type;
draggingFromList = this.list;
draggingItem = this.item;
draggingIndex = this.index;
},
drop() {
if (this.couldplace && draggingType === this.type) {
if (draggingItem === this.item && draggingIndex === this.index) {
return
}
let inSameList = draggingFromList === this.list;
let before = inSameList && draggingIndex > this.index;
let this0 = this;
function mergeGroups() {
before = false;
let _item = clone(this0.item);
this0.$set(this0.item, 'name', '合并的组')
this0.$set(this0.item, 'custom', true)
this0.$set(this0.item, 'tools', []);
this0.$set(this0.item, 'groups', [_item, clone(draggingItem)])
let base = 138, max = 255 - base;
let time = new Date().getTime();
let r = time % max;
this0.$set(this0.item, 'background', r % 2 === 0 ? colors[Math.ceil(Math.random() * colors.length)]
: `rgb(${r + base} , ${Math.floor(Math.random() * max) + base} , ${Math.floor(Math.random() * max) + base})`)
return true;
}
let opts = [{
title: `移动到[${this0.item.name}]之${before ? '前' : '后'}?`,
handler: function () {
this0.list.splice(before ? this0.index : this0.index + 1, 0, clone(draggingItem));
draggingFromList.splice(before ? draggingIndex + 1 : draggingIndex, 1);
}
}, {
title: '合并工具组?',
handler: function () {
mergeGroups();
draggingFromList.splice(before ? draggingIndex + 1 : draggingIndex, 1);
}
}];
notice('选择操作', draggingType === DragType.Group ? opts : [opts[0]]);
}
if (draggingType >= this.type) {
event.stopPropagation();
}
}
}
};
let list = {
name: 'list',
props: {
list: {},
},
template: '#list',
watch: {
list: {
handler(list) {
if (!list) {
return;
}
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.name === ToDelete || item.groups && item.groups.length === 0) {
list.splice(i, 1);
}
}
},
deep: true
}
}
};
let group = {
name: 'group',
props: {
group: {},
groups: []
},
data() {
return {
name: "",
url: "",
}
},
template: '#group',
components: {
draggable,
list,
},
methods: {
newGroup(previousGroup) {
let base = 138, max = 255 - base;
let time = new Date().getTime();
let r = time % max;
this.groups.splice(this.groups.indexOf(previousGroup) + 1, 0, {
name: "请输入标题",
custom: true,
background: r % 2 === 0 ? colors[Math.ceil(Math.random() * colors.length)]
: `rgb(${r + base} , ${Math.floor(Math.random() * max) + base} , ${Math.floor(Math.random() * max) + base})`,
tools: []
});
},
newTool(group) {
group.tools.push({name: this.name || '', url: this.url, custom: true})
},
}
};
let colors = ['AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque', 'BlanchedAlmond', 'BurlyWood', 'CadetBlue', 'Chartreuse', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Cyan', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkKhaki', 'Darkorange', 'DarkSalmon', 'DarkSeaGreen', 'DarkTurquoise', 'DeepPink', 'DeepSkyBlue', 'Feldspar', 'FloralWhite', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', 'GoldenRod', 'GreenYellow', 'HoneyDew', 'HotPink', 'IndianRed', 'Ivory', 'Khaki', 'Lavender', 'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral', 'LightCyan', 'LightGoldenRodYellow', 'LightGrey', 'LightGreen', 'LightPink', 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', 'LightSteelBlue', 'LightYellow', 'Lime', 'LimeGreen', 'Linen', 'Magenta', 'MediumAquaMarine', 'MediumOrchid', 'MediumPurple', 'MediumSeaGreen', 'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', 'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed', 'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', 'PowderBlue', 'Red', 'RosyBrown', 'Salmon', 'SandyBrown', 'SeaGreen', 'SeaShell', 'Silver', 'SkyBlue', 'SlateGray', 'Snow', 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato', 'Turquoise', 'Violet', 'VioletRed', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen',];
new Vue({
el: '#app',
components: {
group,
list,
draggable,
},
data: {
toolGroups: [{
name: "公众号-程序员阿诺",
background: "pink",
tools: [{
url: "https://qjyoung.github.io/",
name: '扫码关注 <img src="./qrcode.png" alt="公众号:程序员阿诺" style="width: 90px;height: 90px"/>',
},
{url: 'https://github.com/qjyoung', name: 'github'},
{url: '', name: ''},
{url: 'https://v.qq.com/x/page/n0536o6npn5.html', name: '踩着单车去拉萨'},
{url: '', name: ''},
{url: 'https://mp.weixin.qq.com/s/QaU5B0m4Oo-hhIigu10ehg', name: '北疆2872公里之旅'},
{url: 'https://mp.weixin.qq.com/s/HARgAEd3G36cMgioiwA04A', name: '西藏,魂归之地'},
{url: '', name: ''},
{url: 'https://mp.weixin.qq.com/s/PUp5bCDyRKZ_CHkW3KMMlw', name: 'qjy-geth v0.4, 支持自定义链id、自动发现相似合约'},
{url: 'https://mp.weixin.qq.com/s/aXaQD0xJem63rLSPtwsBWQ', name: 'qjy-geth v0.3, 支持上传abi,让交易自己开口说话'},
{url: 'https://mp.weixin.qq.com/s/JpqA_ygEYDKHZiTm7fgQkw', name: 'qjy-geth v0.2, 支持地址别名'},
{url: 'https://mp.weixin.qq.com/s/3k-cGz0gt64ULGdm7FwrvQ', name: '666!还有比这更好用的以太坊测试节点吗'},
{url: 'https://mp.weixin.qq.com/s/MAbFOeiZEVMiAfgzFlUL9g', name: '回顾经典排序算法'},
{url: 'https://mp.weixin.qq.com/s/6yLwK5OLOFZ9tWSBVUGv2w', name: '白嫖Apple OCR文字识别'},
{url: 'https://mp.weixin.qq.com/s/32WFce0eQHZacG26k6D-Iw', name: '让以太坊geth支持hardhat console日志'},
{url: 'https://mp.weixin.qq.com/s/ts-B-W2sj7ciaz9L7pfmDw', name: '从一次JVM内存泄露说起'},
{url: 'https://mp.weixin.qq.com/s/51b7n81DxyRjVoyyi2U-tA', name: '用vue写一个傻瓜式倒计时列表'},
{url: 'https://mp.weixin.qq.com/s/UhyQ5lnaqfV0i-O90OEQEw', name: 'git补丁的妙用,将代码差异化发布到外网github'},
{url: 'https://mp.weixin.qq.com/s/WSEz9CdUze8RNppATl6_kw', name: '这或许是封装的最优雅的Excel数据导出工具'},
{url: 'https://mp.weixin.qq.com/s/gf5G484F_Jbi0Ppwyzaq-w', name: '究极效率,一行sql拿到全流程测试数据'},
{url: 'https://mp.weixin.qq.com/s/X1R4ozZ_QmZZHa_2kCt0KA', name: '受宠若惊,竟被DDoS攻击了'},
{url: 'https://mp.weixin.qq.com/s/gttv67UBfCn-JapSfzHMlA', name: '商城下单-三方支付-时序图'},
{url: 'https://mp.weixin.qq.com/s/ZlK9vPLLkNFP73TPDrth5A', name: '借助lambda灵活控制事物粒度'},
{url: 'https://mp.weixin.qq.com/s/nbzWbws4o53tO42WZMFynA', name: '注解、代理简化redis分布式锁-实现代码'},
{url: 'https://mp.weixin.qq.com/s/ycdvhfzIP6Y_CpskCyrQmQ', name: '通用的区块链智能合约web3.go调用服务'},
{url: 'https://mp.weixin.qq.com/s/KJv8m_1exKeMEU__pGR4Ug', name: 'docker快速搭建elk-2-解析Java、go、nginx日志'},
{url: 'https://mp.weixin.qq.com/s/hoOZqeHwkvwWyP8BhCKP7Q', name: 'Git 多人协作,诸葛亮带你玩转cherry-pick 、rebase'},
{url: 'https://mp.weixin.qq.com/s/ZrDaT1kMT30EDqBLi28lUA', name: '精简版-五颜六色的常用工具板-基于Vue'},
{url: 'https://mp.weixin.qq.com/s/fc9O0Yow6YQrhPepmCVHAw', name: 'SQL查看数据 - 借助view、group_concat节省你宝贵时间'},
{url: 'https://mp.weixin.qq.com/s/dunLcQ8O1gfwAf6jb4S1mA', name: '用VUE做一个常用工具板'},
{url: 'https://mp.weixin.qq.com/s/IkQVKnA-iHG_fyJ0EDO9PQ', name: '被工具(Goland)坑的最惨的一次'},
{url: 'https://mp.weixin.qq.com/s/45zu-OcP5UNbLdj5X3hUwA', name: '做一个会偷懒的程序员'},
{url: 'https://mp.weixin.qq.com/s/VJIFYZchRjEzC2bzVladmw', name: 'idea定制groovy脚本,导出db数据到csv自动加行号和标题'},
{url: 'https://mp.weixin.qq.com/s/rn2IbAWIpRVRE631hPNUfg', name: '60行shell脚本快速生成Java项目脚手架'},
{url: 'https://mp.weixin.qq.com/s/iDA08QqL9xp3eo5znjWleA', name: '用docker快速搭建elk日志平台'},
{url: 'https://mp.weixin.qq.com/s/1m7OKcqOcB2e_2K_mFG_8A', name: '50行go实现tree命令'},
{url: 'https://mp.weixin.qq.com/s/EgE_sF8xmDfrkkX_zsdycA', name: '错怪Mybatis, 原来这并不是bug'},
{url: 'https://mp.weixin.qq.com/s/h-ZrmzfRjhdsxfZneMyvuw', name: '注解+代理 加持分布式锁,让代码更简洁'},
{url: 'https://mp.weixin.qq.com/s/kuJnTjMxdPv32E7a-r-zRQ', name: 'DIY插件,自动生成set调用,解放双手'},
{url: 'https://mp.weixin.qq.com/s/zm-f6ENkt93dU53K2mNVZg', name: 'Java回调、Lambda与Redis分布式锁新玩法'},
{url: 'https://mp.weixin.qq.com/s/_JCRYeo65c9CTklhqUJZBA', name: '巨烧脑-估计没几人能看懂:实现tree命令 - 探索你D盘的秘密'},
{url: 'https://mp.weixin.qq.com/s/BFU-IHHg422aHZX-c0_3IQ', name: '基于shiro的权限自动录入'},
{url: '', name: ''},
{url: 'https://mp.weixin.qq.com/s/gjpqdLBuMlvzkdY_qHI54A', name: '南天门上,三千忠魂奋孤勇;祭旗坡下,一腔热血照青山'},
{url: '', name: ''},
{url: 'https://mp.weixin.qq.com/s/a9gXbNS_U3JMvzaaKvdkrA', name: '2020年5月,比特币即将迎来第三次减半,为什么比特币会减半'},
{url: 'https://mp.weixin.qq.com/s/O04kd9SIvZcKHIRpHVz8Bw', name: '不小心敲了 rm -rf / 后反应是怎样的?'},
{url: 'https://mp.weixin.qq.com/s/T-IMeuMTgwC7ZIpYAo2EEQ', name: '星际穿越的完全解析'},
{url: 'https://mp.weixin.qq.com/s/D0RA8dv3e0_oDTdiN8CK8w', name: '奇记|生死荒原路,52天首次单人完整横穿大羌塘'},
{url: '', name: ''},]
}, {
name: "实用小工具",
custom: true,
background: "22e674",
tools: [
{url: '.', name: '主页'},
{url: './calendar', name: '万年历'},
{url: './format', name: 'JSON-格式化'},
{url: "./security_password.html", name: "复杂密码生成器"},
{url: 'http://tool.oschina.net/codeformat/xml', name: '其他代码格式化'},
{url: 'http://cron.qqe2.com/', name: '在线Cron表达式生成器'},
{url: 'http://tool.chinaz.com/tools/unicode.aspx', name: 'Unicode编码'},
{url: 'http://www.bejson.com/xml2json/', name: 'XML 2 JSON'},
{url: './json2bean', name: 'JSON 2 BEAN'},
{url: './encrypt/encrypt.html', name: 'AES-DES'},
{url: 'http://tool.chacuo.net/cryptaes', name: 'AES-2'},
{url: './encrypt/encrypt2.html', name: '哈希散列'},
{url: 'https://tool.lu/hexconvert/', name: '进制转换'},
{url: './encrypt/encrypt3.html', name: 'BASE64编码'},
{url: './encrypt/encrypt4.html', name: '图片转base64'},
{url: 'https://c.runoob.com/front-end/59/', name: '图片BASE64编码'},
{url: 'https://cli.im/', name: '二维码生成器'},
{url: 'http://www.jq22.com/textDifference', name: 'Show diff'},
{url: 'http://tool.oschina.net/jscompress/', name: 'js/css compresss'},
{url: 'http://imgbase64.duoshitong.com/', name: '图片 base64 互转'},
{url: 'https://www.ip.cn', name: 'IP 域名地址查询'},
{url: 'https://github.com/qjyoung', name: 'qjyoung-github'},
{url: 'https://blog.csdn.net/qq_33303700', name: 'qjyoung-CSDN'},
{url: 'https://www.bootcdn.cn/', name: '开源项目CDN'},
{url: 'http://www.yuangongju.com/css3button', name: 'css-button'},
{url: 'http://www.jq22.com/webqd5122', name: 'css-input'},
{url: 'https://www.processon.com/', name: 'processon'},
{url: 'http://www.txttool.com/WenBen_Sort4.asp', name: '在线字典排序'},
{url: 'https://wantwords.net/', name: 'wantwords'},
{url: 'https://tool.ip138.com/rgbhex/', name: '在线颜色值转换'},
]
}],
countdown: {
name: "倒计时",
background: "FFE56F",
date: new Date(),
lunar: new Lunar(new Date()),
time: '',
today: -1,
_festivals: [],
tools: [{
date: "xxxx-09-16",
desc: "公历生日",
custom: true
}, {
isLunar: true,
date: "xxxx-八-十二",
desc: "农历生日",
custom: true
}]
},
holidays: [],
date: "",
desc: "",
readme: `⭐工具板&倒计时列表⭐️
此工具板可方便分类收纳工作中常用的在线工具或参考资料链接
如下所示,不同色块代表了不同的工具组,每组可添加若干子项(网页链接)
鼠标移动到不同区域即可唤出各自的操作按钮和输入框
使用指南:
① 每组右下角➕按钮,可在该组后追增新工具组
② 每组右上角❌按钮,可将该组删除,同时组内所有条目都将被移除
③ 每组的标题都可实时编辑,只需要移动光标到相应位置
子项操作:
④ 按输入框提示,正确输入数据后回车或点击✅按钮即可新增子项
⑤ 每个子项右侧同样有❌按钮,可将该条目删除
⑥ 工具组及其子项均可自由拖拽变换位置,工具组可两两合并,子项可跨组移动
⑦ 倒计时列表同理,不可移动。在电脑上点击标题可获取倒计时列表截图
⑧ 🎯🎯🎯此工具是一个纯本地工具,所有新增数据都只保存在本地,放心使用
点击确认下次打开不再提示
🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹
`
},
mounted() {
this.handleVersion();
let doc = this.toolGroups[0];
this.toolGroups = this.getFromLocal(StoreKey.ToolGroups, this.toolGroups);
this.toolGroups[0] = doc;
this.countdown.tools = this.getFromLocal(StoreKey.Countdown, this.countdown).tools.filter(item => {
return item.custom
});
this.reloadCountDown();
this.updateTime();
setInterval(this.updateTime, 1000);
},
methods: {
handleVersion() {
let currentVersion = 3;
let lastVersion = -1;
let _version = localStorage.getItem(StoreKey.Version);
if (_version) {
lastVersion = parseInt(_version);
}
if (lastVersion < 3) { // replace title to name
let _groups = localStorage.getItem(StoreKey.ToolGroups);
_groups && localStorage.setItem(StoreKey.ToolGroups, _groups.replaceAll("\"title\"", "\"name\""));
}
localStorage.setItem(StoreKey.Version, currentVersion.toString())
setTimeout(() => {
if (this.readme !== localStorage.getItem(StoreKey.Readme)) {
confirm(this.readme) && localStorage.setItem(StoreKey.Readme, this.readme);
}
}, 177);
},
getFromLocal(key, field) {
let cache = JSON.parse(localStorage.getItem(key));
if (cache != null) {
return cache;
}
return field;
},
updateTime() {
let now = new Date();
this.countdown.time = [this.paddingLeft(now.getHours()), this.paddingLeft(now.getMinutes()), this.paddingLeft(now.getSeconds())].join(':');
let today = now.getDate();
if (this.countdown.today === today) {
return
}
this.reloadCountDown();
this.countdown.today = today;
},
newCountdown() {
let isLunar = false;
let year = 'xxxx', month = 'xx', day = '';
if (!this.desc || this.desc.length === 0) {
notice("请填写描述");
return;
}
if (/[\u4E00-\u9FA5]/.test(this.date)) {
isLunar = true;
let strings = this.date.split("年");
if (strings.length > 2) {
notice("日期错误");
return;
}
if (strings.length === 2) {
year = strings[0] === '' ? year : strings[0];
}
if (year !== 'xxxx' && parseInt(year) > 2050) {
notice("最大支持年份2050");
return;
}
if (!/^xxxx$|^[1-9]\d{3}$/.test(year)) {
notice("年份错误");
return;
}
strings = strings[strings.length - 1].split("月");
if (strings.length > 2) {
notice("农历月份错误");
return;
}
if (strings.length === 2) {
month = strings[0] === '' ? month : strings[0];
let _month = month;
if (_month !== 'xx') {
_month = _month.replace('闰', '');
if (_month.length > 1
|| _month[0] === '一'
|| XXXUnits.indexOf(_month[0]) < 0
&& _month[0] !== '正'
&& _month[0] !== '冬'
&& _month[0] !== '腊') {
notice("农历月份错误(正月二月...十月冬月腊月)");
return;
}
}
}
day = strings[strings.length - 1];
} else {
let strings = this.date.split('-');
let length = strings.length;
if (length > 3 || length === 0) {
notice("日期错误");
return;
}
day = strings[length - 1];
if (length > 1) {
month = strings[length - 2];
}
if (length > 2) {
year = strings[length - 3];
}
if (!/^xxxx$|^[1-9]\d{3}$/.test(year)) {
notice("年份错误");
return;
}
if (!/^xx$|^1[0-2]$|^0?[1-9]$/.test(month)) {
notice("公历月份错误");
return
}
if (!/^(0?[1-9]$|^[1-2][0-9]$|^3[0-1]$)/.test(day)) {
notice("日期错误");
return
}
}
this.countdown.tools.push({
date: [year, month, day].join('-'),
isLunar: isLunar,
desc: this.desc,
url: undefined,
custom: true
});
},
reloadCountDown() {
let items = this.countdown.tools;
let todayDate = new Date();
let thisYear = todayDate.getFullYear();
let thisMonth = todayDate.getMonth();
let thisDay = todayDate.getDate();
todayDate = new Date(thisYear, thisMonth, thisDay);
this.countdown.date = todayDate;
this.countdown.lunar = new Lunar(todayDate);
this.countdown._festivals = [];
let _festivals = festivals(this.countdown.lunar);
if (_festivals.length > 0) {
_festivals.map(value => this.countdown._festivals.push(value.festival.replace('*', '').replace('.', '')));
}
this.findHolidays();
thisMonth += 1;
let lastDiff = 0;
let maxDescWidth = 0, maxDiffWidth = 0;
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (!item.date) {
item.diff = lastDiff + 0.00001;
continue
}
let strings = item.isLunar && item.lunarDate ? item.lunarDate.split('-') : item.date.split('-');
let autoYear = strings[0] === 'xxxx', autoMonth = strings[1] === 'xx';
let thatYear = autoYear ? thisYear : parseInt(strings[0]);
let thatMonth = strings[1], thatDay = strings[2];
let thatDate, name = '';
item.hide = false;
if (item.isLunar) {
let found = false;
this.find(lunar => {
if ((lunar.chineseMonth === thatMonth || autoMonth) && lunar.chineseDay === thatDay) {
found = true;
thatDate = new Date(lunar.date.getFullYear(), lunar.date.getMonth(), lunar.date.getDate());
if (item.isLunar) {
name += ' ' + lunar.chineseMonth + '月' + lunar.chineseDay;
}
}
return found
}, !autoYear && thatYear > thisYear ? thatYear : undefined);
if (!found) {
if (!autoYear) {
items.splice(i, 1);
i--;
continue;
}
item.hide = true;
}
} else {
thatDay = parseInt(thatDay);
if (autoMonth) {
thatMonth = thisMonth;
if (thisDay > thatDay && (autoYear || thisMonth !== 12)) {
thatMonth = (thisMonth + 1) % 12;
thatYear = thisYear + (thatMonth === 1 ? 1 : 0);
}
} else {
thatMonth = parseInt(thatMonth);
if (autoYear && (thisMonth > thatMonth || thisMonth === thatMonth && thisDay > thatDay)) {
thatYear += 1;
}
}
thatDate = new Date(thatYear, thatMonth - 1, thatDay);
}
if (!item.hide) {
let diff = this.calDiff(thatDate);
if (diff === 0 && item.custom) {
this.countdown._festivals.push(item.desc);
} else if (diff < 0) {
items.splice(i, 1);
i--;
continue;
}
let descWidth = `<strong>${item.desc}</strong>`.visualLength();
maxDescWidth = descWidth > maxDescWidth ? descWidth : maxDescWidth;
let diffWidth = (diff + '天').visualLength();
maxDiffWidth = diffWidth > maxDiffWidth ? diffWidth : maxDiffWidth;
item.diff = lastDiff = diff;
item.time = this.formatDate(thatDate).replace(thisYear + "-", "") + name;
} else {
item.diff = 0;
}
}
this.sortAndSetStyle(items, maxDiffWidth + 1, maxDescWidth + 1);
localStorage.setItem(StoreKey.Countdown, JSON.stringify(this.countdown));
},
findHolidays() {
this.holidays = [];
let thisYear = new Date().getFullYear();
let theWinterSolsticeDay, lastWinterSolsticeDay;
this.find(lunar => {
festivals(lunar).forEach(each => {
if (!theWinterSolsticeDay && each.festival.indexOf("冬至.") >= 0) {
theWinterSolsticeDay = new Date(lunar.date);
}
let isHoliday = each.festival.indexOf("*") > 0;
let isKeySolarTermsDay = each.festival.indexOf(".") > 0;
if (isHoliday || isKeySolarTermsDay) {
this.holidays.push({
custom: false,
time: this.formatDate(lunar.date).replace(thisYear + "-", '') + ' ' + lunar.chineseMonth + '月' + lunar.chineseDay,
desc: `<span style="background-color:${isHoliday ? '#ccffcc' : ''}">${each.festival.replace('*', '').replace('.', '')}</span>`,
diff: this.calDiff(lunar.date)
});
}
})
});
// nine periods after winter solstice day
let date = new Date();
let j = 0;
out:for (; j < 81; j++) {
let lunar = new Lunar(date);
let _festivals = festivals(lunar);
for (let i = 0; i < _festivals.length; i++) {
if (_festivals[i].festival.indexOf("冬至.") >= 0) {
lastWinterSolsticeDay = date;
break out;
}
}
date.setDate(date.getDate() - 1);
}
let periodIndex = parseInt(j / 9);
if (lastWinterSolsticeDay) {
this.countdown._festivals.push(`${XXXUnits[periodIndex + 1]}九第${j % 9 + 1}天`);
}
let total = 3
let winterSolsticeDay = lastWinterSolsticeDay;
while (total-- > 0) {
if (!winterSolsticeDay) {
periodIndex = 0;
winterSolsticeDay = theWinterSolsticeDay;
}
if (++periodIndex < 9) {
if (total === 0 && periodIndex > 2) {
periodIndex = 8;
}
let date1 = new Date(winterSolsticeDay);
date1.setDate(date1.getDate() + 9 * periodIndex);
let lunar = new Lunar(date1);
this.holidays.push({
custom: false,
time: this.formatDate(lunar.date).replace(thisYear + "-", '') + ' ' + lunar.chineseMonth + '月' + lunar.chineseDay,
desc: `${XXXUnits[periodIndex + 1]}九`,
diff: this.calDiff(lunar.date)
});
} else {
total++
winterSolsticeDay = undefined;
}
}
this.sortAndSetStyle(this.holidays, '365天'.visualLength() + 1, '<strong>国庆节</strong>'.visualLength() + 1);
},
find(consumer, year, findDays) {
findDays = findDays || 386;
let date = year ? new Date(year, 0, 1) : new Date();
for (let j = 0; j < findDays; j++) {
let lunar = new Lunar(date);
if (consumer(lunar)) {
break
}
date.setDate(date.getDate() + 1);
}
},
formatDate(date) {
return [date.getFullYear(), this.paddingLeft(date.getMonth() + 1), this.paddingLeft(date.getDate())].join('-');
},
paddingLeft(num) {
num = parseInt(num);
return num < 10 ? '0' + num : num;
},
calDiff(that) {
let today = new Date();
today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
return (new Date(that.getFullYear(), that.getMonth(), that.getDate()) - today) / 86400000
},
sortAndSetStyle(items, diffWidth, descWidth) {
items.sort(function (a, b) {
return a.diff - b.diff;
});
items.forEach(item => {
item.descStyle = {width: `${descWidth}px`};
item.diffStyle = {width: `${diffWidth}px`, color: item.diff === 0 ? 'red' : 'blue'};
item.diffShow = item.diff === 0 ? '今天' : item.diff + '天';
})
}
},
watch: {
toolGroups: {
handler(groups) {
localStorage.setItem(StoreKey.ToolGroups, JSON.stringify(groups));
},
deep: true
},
"countdown.tools.length": {
handler(val) {
this.reloadCountDown();
}
}
}
})
</script>
</html>