-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
889 lines (776 loc) · 32.8 KB
/
index.html
File metadata and controls
889 lines (776 loc) · 32.8 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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<meta name="description" content="DirectGo 直达常用平台搜索,少干扰、更高效。支持知乎、微博、小红书、哔哩哔哩等平台。">
<meta name="google-site-verification" content="nXbYRKUwXwReStmNMFc4euXmHP3ZDSE7eVSnOjnof7U" />
<title>DirectGo 直达 | 常用平台搜索入口</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
background: #f2e8c9 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzuYqtHRVG2y4x+KOlnyqla8AoWWpuBoYRxzXrfKuILl6SfiWCbjxoZJUaCBj1CjH7GIaDbc9kqBY3W/Rgjda1iqQcOJu2WW+76pZC9QG7M00dffe9hNnseupFL53r8F7YHSwJWUKP2q+k7RdsxyOB11n0xtOvnW4irMMFNV4H0uqwS5ExsmP9AxbDTc9JwgneAT5vTiUSm1E7BSflSt3bfa1tv8Di3R8n3Af7MNWzs49hmauE2wP+ttrq+AsWpFG2awvsuOqbipWHgtuvuaAE+A1Z/7gC9hesnr+7wqCwG8c5yAg3AL1fm8T9AZtp/bbJGwl1pNrE7RuOX7PeMRUERVaPpEs+yqeoSmuOlokqw49pgomjLeh7icHNlG19yjs6XXOMedYm5xH2YxpV2tc0Ro2jJfxC50ApuxGob7lMsxfTbeUv07TyYxpeLucEH1gNd4IKH2LAg5TdVhlCafZvpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
width: 100%;
max-width: 600px;
}
.header {
text-align: center;
margin-bottom: 48px;
}
.title {
font-size: 3.5rem;
font-weight: bold;
color: #5d4037;
margin-bottom: 16px;
text-shadow: 2px 2px 4px rgba(139, 69, 19, 0.4);
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
}
.subtitle {
font-size: 1.35rem;
color: #795548;
margin-bottom: 8px;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
font-style: normal;
}
.description {
font-size: 0.95rem;
color: #8d6e63;
font-style: italic;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
}
.search-card {
background: rgba(245, 231, 193, 0.85);
border-radius: 12px;
box-shadow: 0 6px 20px rgba(139, 69, 19, 0.3), inset 0 0 40px rgba(139, 69, 19, 0.15);
padding: 40px;
margin-bottom: 40px;
border: 2px solid #d2b48c;
backdrop-filter: blur(5px);
}
.form-group {
margin-bottom: 24px;
}
.label {
display: block;
font-size: 1rem;
font-weight: 600;
color: #5d4037;
margin-bottom: 10px;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
text-shadow: 1px 1px 2px rgba(139, 69, 19, 0.2);
}
.input {
width: 100%;
padding: 14px 18px;
font-size: 1.1rem;
border: 2px solid #d2b48c;
border-radius: 8px;
transition: border-color 0.3s, background-color 0.3s;
background-color: #faf6e9;
color: #5d4037;
box-shadow: inset 0 2px 5px rgba(139, 69, 19, 0.15);
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
}
.input:focus {
outline: none;
border-color: #a1887f;
background-color: #fff8e1;
box-shadow: inset 0 2px 5px rgba(139, 69, 19, 0.25), 0 0 0 3px rgba(161, 136, 127, 0.3);
}
.search-btn {
width: 100%;
background: #8d6e63;
color: #f5e7c1;
border: 2px solid #795548;
padding: 18px;
font-size: 1.25rem;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
box-shadow: 0 4px 8px rgba(139, 69, 19, 0.3);
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
letter-spacing: 1px;
}
.search-btn:hover {
background: #795548;
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(139, 69, 19, 0.4);
}
.platforms {
text-align: center;
margin-bottom: 32px;
}
.platforms-title {
font-size: 1rem;
color: #795548;
margin-bottom: 20px;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
font-style: normal;
font-weight: 600;
}
.platform-tags {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
margin-bottom: 16px;
}
.platform-tag {
background: #e6d7b8;
color: #5d4037;
padding: 10px 20px;
border-radius: 25px;
font-size: 0.95rem;
cursor: grab;
transition: all 0.3s ease;
border: 2px solid #d2b48c;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
box-shadow: 0 2px 4px rgba(139, 69, 19, 0.1);
user-select: none;
touch-action: none;
-webkit-user-drag: none;
}
.platform-tag:hover {
background: #d7cdb2;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(139, 69, 19, 0.2);
}
.platform-tag.active {
background: #a1887f;
color: #f5e7c1;
border-color: #8d6e63;
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}
.platform-tag.dragging {
opacity: 0.5;
transform: rotate(5deg);
cursor: grabbing;
z-index: 1000;
}
.platform-tag.drag-over {
background: #c8b99c;
transform: scale(1.05);
}
.alias-info {
font-size: 0.8rem;
color: #8d6e63;
font-style: italic;
font-family: sans-serif;
margin-top: 10px;
}
.browse-options {
display: flex;
gap: 20px;
margin-top: 10px;
}
.mode-hint {
font-size: 0.78rem;
color: #8d6e63;
margin-top: 8px;
font-family: sans-serif;
}
.platform-actions {
margin-top: 8px;
}
.text-btn {
background: transparent;
border: 1px solid #cbb28f;
border-radius: 6px;
color: #6d4c41;
padding: 6px 10px;
font-size: 0.78rem;
cursor: pointer;
}
.text-btn:hover {
background: rgba(210, 180, 140, 0.2);
}
.help-details {
margin-top: 10px;
color: #8d6e63;
font-size: 0.8rem;
text-align: left;
}
.help-details summary {
cursor: pointer;
user-select: none;
color: #795548;
font-weight: 600;
}
.help-details-content {
margin-top: 8px;
line-height: 1.5;
font-style: italic;
}
.radio-label {
display: flex;
align-items: center;
font-size: 1rem;
color: #5d4037;
cursor: pointer;
font-family: 'STFangsong', 'KaiTi', 'LiSu', 'Palatino Linotype', serif;
}
.radio-label input[type="radio"] {
margin-right: 8px;
appearance: none;
width: 18px;
height: 18px;
border: 2px solid #a1887f;
border-radius: 50%;
outline: none;
cursor: pointer;
position: relative;
transition: all 0.2s ease;
}
.radio-label input[type="radio"]:checked {
background-color: #8d6e63;
border-color: #795548;
}
.radio-label input[type="radio"]:checked::before {
content: '';
display: block;
width: 8px;
height: 8px;
background-color: #f5e7c1;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.message {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
padding: 10px 20px;
border-radius: 5px;
color: white;
font-weight: bold;
z-index: 1000;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.message.success {
background-color: #4CAF50;
}
.message.error {
background-color: #f44336;
}
.message.warning {
background-color: #ff9800;
}
.version-watermark {
position: fixed;
right: 14px;
bottom: 10px;
font-size: 0.75rem;
color: rgba(93, 64, 55, 0.65);
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
letter-spacing: 0.5px;
user-select: none;
pointer-events: none;
}
@media (max-width: 640px) {
.title {
font-size: 2.5rem;
}
.search-card {
padding: 30px;
}
}
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "DirectGo 直达",
"description": "纯净平台内容搜索引擎,直达知乎、微博、小红书等平台内容",
"applicationCategory": "SearchApplication",
"operatingSystem": "Any"
}
</script>
</head>
<body>
<div class="container">
<!-- 标题区域 -->
<div class="header">
<h1 class="title">DirectGo 直达</h1>
<p class="subtitle">一个搜索框,直达常用平台</p>
</div>
<!-- 搜索区域 -->
<div class="search-card">
<div class="form-group">
<label class="label" for="platform-input">平台(可填别名)</label>
<input
type="text"
class="input"
id="platform-input"
placeholder="如:知乎 / zh / xhs(留空默认 Bing)"
>
</div>
<div class="form-group">
<label class="label" for="keyword-input">关键词</label>
<input
type="text"
class="input"
id="keyword-input"
placeholder="输入关键词"
>
</div>
<details class="help-details" style="margin-top: -15px; margin-bottom: 20px;">
<summary>查看示例与别名</summary>
<div class="help-details-content">
例:知乎 AI Agent|小红书 春季穿搭<br>
支持别名:知乎/zh、小红书/xhs、微博/wb、哔哩哔哩/bl/b站、必应/bing、高德/amap<br>
快捷命令:在关键词输入框直接输入「zh AI Agent」也可自动识别平台
</div>
</details>
<div class="form-group">
<label class="label">打开方式</label>
<div class="browse-options">
<label class="radio-label">
<input type="radio" id="browse-mode-web" name="browse-mode" value="web" checked>
Web
</label>
<label class="radio-label">
<input type="radio" id="browse-mode-scheme" name="browse-mode" value="scheme">
Scheme
</label>
<label class="radio-label">
<input type="radio" id="browse-mode-intent" name="browse-mode" value="intent">
Intent
</label>
</div>
<p class="mode-hint">Web 通用;Scheme/Intent 优先调起 App,不支持时自动回退 Web。</p>
</div>
<button class="search-btn" id="search-btn" type="button">
<span>🔍</span>
<span>搜索</span>
<span>→</span>
</button>
</div>
<!-- 常用平台快捷按钮 -->
<div class="platforms">
<p class="platforms-title">常用平台</p>
<div class="platform-tags" id="platform-tags">
<button class="platform-tag" draggable="true" data-platform="zhihu" type="button">知乎</button>
<button class="platform-tag" draggable="true" data-platform="xiaohongshu" type="button">小红书</button>
<button class="platform-tag" draggable="true" data-platform="weibo" type="button">微博</button>
<button class="platform-tag" draggable="true" data-platform="bilibili" type="button">哔哩哔哩</button>
<button class="platform-tag" draggable="true" data-platform="bing" type="button">Bing</button>
<button class="platform-tag" draggable="true" data-platform="amap" type="button">高德地图</button>
</div>
<div class="platform-actions">
<button id="reset-order-btn" class="text-btn" type="button">恢复默认排序</button>
</div>
<p class="alias-info"><small style="color: #a0896b;">💡 可拖动排序,自动保存</small></p>
</div>
<!-- 消息提示区域 -->
<div id="message-div" class="message" role="status" aria-live="polite" style="display: none;"></div>
<!-- 版本日期水印 -->
<div class="version-watermark">版本日期:2026-03-08</div>
<script>
// 支持的平台配置
const platforms = [
{
id: 'zhihu',
name: '知乎',
aliases: ['zh', 'zhihu', '知乎'],
searchUrl: 'https://www.zhihu.com/search?type=content&q={keyword}',
schemeUrl: 'zhihu://search?query={keyword}',
intentUrl: 'intent://search?query={keyword}#Intent;scheme=zhihu;package=com.zhihu.android;end',
},
{
id: 'xiaohongshu',
name: '小红书',
aliases: ['xhs', 'xiaohongshu', '小红书'],
searchUrl: 'https://www.xiaohongshu.com/search_result?keyword={keyword}',
schemeUrl: 'xhsdiscover://search?keyword={keyword}',
intentUrl: 'intent://search?keyword={keyword}#Intent;scheme=xhs;package=com.xingin.xhs;end',
},
{
id: 'weibo',
name: '微博',
aliases: ['wb', 'weibo', '微博'],
searchUrl: 'https://s.weibo.com/weibo?q={keyword}',
schemeUrl: '', // 微博暂不支持直接搜索的 Scheme 链接
intentUrl: '', // 微博暂不支持直接搜索的 Intent 链接
},
{
id: 'bilibili',
name: '哔哩哔哩',
aliases: ['bl', 'bilibili', '哔哩哔哩', 'b站'],
searchUrl: 'https://search.bilibili.com/all?keyword={keyword}',
schemeUrl: 'bilibili://search?keyword={keyword}',
intentUrl: 'intent://search?keyword={keyword}#Intent;scheme=bilibili;package=tv.danmaku.bili;end',
},
{
id: 'bing',
name: 'Bing',
aliases: ['bing', '必应', 'Bing'],
searchUrl: 'https://www.bing.com/search?q={keyword}',
},
{
id: 'amap',
name: '高德地图',
aliases: ['amap', '高德', '高德地图'],
searchUrl: 'https://ditu.amap.com/search?query={keyword}',
}
];
const defaultPlatformOrder = platforms.map(p => p.id);
// 根据别名获取平台信息
function getPlatformByAlias(alias) {
return platforms.find(p =>
p.id === alias.toLowerCase() ||
p.aliases.some(a => a.toLowerCase() === alias.toLowerCase())
);
}
// 获取选中的浏览方式
function getSelectedBrowseMode() {
const radios = document.getElementsByName("browse-mode");
for (let i = 0; i < radios.length; i++) {
if (radios[i].checked) {
return radios[i].value;
}
}
return "web"; // 默认返回web
}
// 处理搜索
function handleSearch() {
const platformInput = document.getElementById('platform-input');
const keywordInput = document.getElementById('keyword-input');
let platform = platformInput.value.trim();
let keyword = keywordInput.value.trim();
// 支持单框快捷命令:平台别名 + 空格 + 关键词(如: zh AI Agent)
if (!platform && keyword.includes(' ')) {
const firstSpaceIndex = keyword.indexOf(' ');
const possiblePlatform = keyword.slice(0, firstSpaceIndex).trim();
const possibleKeyword = keyword.slice(firstSpaceIndex + 1).trim();
const fastPlatformInfo = getPlatformByAlias(possiblePlatform);
if (fastPlatformInfo && possibleKeyword) {
platform = fastPlatformInfo.id;
keyword = possibleKeyword;
platformInput.value = platform;
keywordInput.value = keyword;
}
}
if (!keyword) {
showMessage("请输入搜索关键词", "error");
return;
}
// 如果平台为空,默认使用Bing
if (!platform) {
platform = "bing";
platformInput.value = "bing"; // 更新输入框显示
}
let platformInfo = getPlatformByAlias(platform);
let swapped = false;
// 如果平台不匹配,尝试交换平台和关键词
if (!platformInfo) {
const tempPlatform = keyword;
const tempKeyword = platform;
platformInfo = getPlatformByAlias(tempPlatform);
if (platformInfo) {
platform = tempPlatform;
keyword = tempKeyword;
swapped = true;
}
}
if (!platformInfo) {
showMessage(`不支持的平台: ${platform}`, 'error');
return;
}
if (swapped) {
platformInput.value = platform; // 更新输入框内容
keywordInput.value = keyword; // 更新输入框内容
showMessage('已自动交换输入框', 'success');
}
// 对关键词进行URL编码
const encodedKeyword = encodeURIComponent(keyword);
// 获取选中的浏览方式
const browseMode = getSelectedBrowseMode();
let targetUrl = '';
if (browseMode === 'web') {
targetUrl = platformInfo.searchUrl.replace('{keyword}', encodedKeyword);
} else if (browseMode === 'scheme') {
if (platformInfo.schemeUrl) {
targetUrl = platformInfo.schemeUrl.replace('{keyword}', encodedKeyword);
} else {
targetUrl = platformInfo.searchUrl.replace('{keyword}', encodedKeyword);
showMessage(`该平台不支持 Scheme,已回退到 Web:${platformInfo.name}`, 'warning');
}
} else if (browseMode === 'intent') {
if (platformInfo.intentUrl) {
targetUrl = platformInfo.intentUrl.replace('{keyword}', encodedKeyword);
} else {
targetUrl = platformInfo.searchUrl.replace('{keyword}', encodedKeyword);
showMessage(`该平台不支持 Intent,已回退到 Web:${platformInfo.name}`, 'warning');
}
}
// 直接跳转到目标平台的搜索结果页
window.open(targetUrl, '_blank', 'noopener,noreferrer');
}
// 显示提示信息
function showMessage(message, type) {
const messageDiv = document.getElementById('message-div');
messageDiv.textContent = message;
messageDiv.className = 'message ' + type;
messageDiv.style.display = 'block';
setTimeout(() => {
messageDiv.style.display = 'none';
}, 3000);
}
// 选择平台
function selectPlatform(platformId, sourceElement) {
const platformInput = document.getElementById('platform-input');
platformInput.value = platformId;
// 更新按钮状态
document.querySelectorAll('.platform-tag').forEach(btn => {
btn.classList.remove('active');
});
if (sourceElement) {
sourceElement.classList.add('active');
}
}
// 键盘事件处理和拖拽功能初始化
document.addEventListener('DOMContentLoaded', function() {
const platformInput = document.getElementById('platform-input');
const keywordInput = document.getElementById('keyword-input');
const searchBtn = document.getElementById('search-btn');
const resetOrderBtn = document.getElementById('reset-order-btn');
const platformTagButtons = document.querySelectorAll('.platform-tag');
searchBtn.addEventListener('click', handleSearch);
resetOrderBtn.addEventListener('click', resetPlatformOrder);
platformTagButtons.forEach(button => {
button.addEventListener('click', function() {
if (suppressClickAfterTouchDrag) {
return;
}
const platformId = this.getAttribute('data-platform');
selectPlatform(platformId, this);
});
});
platformInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
handleSearch();
}
});
keywordInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
handleSearch();
}
});
// 快捷键:/ 聚焦关键词;Ctrl/Cmd + Enter 发起搜索
document.addEventListener('keydown', function(e) {
const activeTag = document.activeElement ? document.activeElement.tagName : '';
const isTyping = activeTag === 'INPUT' || activeTag === 'TEXTAREA';
if (e.key === '/' && !isTyping) {
e.preventDefault();
keywordInput.focus();
return;
}
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
e.preventDefault();
handleSearch();
}
});
// 初始化拖拽功能
initializeDragAndDrop();
// 加载保存的排序
loadPlatformOrder();
});
// 拖拽功能相关变量
let draggedElement = null;
let isTouchDragging = false;
let touchDropTarget = null;
let suppressClickAfterTouchDrag = false;
// 初始化拖拽功能
function initializeDragAndDrop() {
const platformTags = document.querySelectorAll('.platform-tag');
platformTags.forEach(tag => {
// 桌面端 HTML5 拖拽
tag.addEventListener('dragstart', handleDragStart);
tag.addEventListener('dragover', handleDragOver);
tag.addEventListener('drop', handleDrop);
tag.addEventListener('dragend', handleDragEnd);
tag.addEventListener('dragenter', handleDragEnter);
tag.addEventListener('dragleave', handleDragLeave);
// 移动端触摸拖拽(Android/iOS)
tag.addEventListener('touchstart', handleTouchStart, { passive: false });
tag.addEventListener('touchmove', handleTouchMove, { passive: false });
tag.addEventListener('touchend', handleTouchEnd);
tag.addEventListener('touchcancel', handleTouchCancel);
});
}
// 根据目标平台卡片执行重排
function reorderPlatformTags(targetElement) {
if (!draggedElement || !targetElement || draggedElement === targetElement) {
return;
}
const container = document.getElementById('platform-tags');
const draggedIndex = Array.from(container.children).indexOf(draggedElement);
const targetIndex = Array.from(container.children).indexOf(targetElement);
if (draggedIndex < targetIndex) {
container.insertBefore(draggedElement, targetElement.nextSibling);
} else {
container.insertBefore(draggedElement, targetElement);
}
}
// 拖拽开始
function handleDragStart(e) {
draggedElement = this;
this.classList.add('dragging');
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/html', this.outerHTML);
}
// 拖拽经过
function handleDragOver(e) {
if (e.preventDefault) {
e.preventDefault();
}
e.dataTransfer.dropEffect = 'move';
return false;
}
// 拖拽进入
function handleDragEnter(e) {
if (this !== draggedElement) {
this.classList.add('drag-over');
}
}
// 拖拽离开
function handleDragLeave(e) {
this.classList.remove('drag-over');
}
// 放置
function handleDrop(e) {
if (e.stopPropagation) {
e.stopPropagation();
}
if (draggedElement !== this) {
reorderPlatformTags(this);
// 保存新的排序
savePlatformOrder();
}
return false;
}
// 拖拽结束
function handleDragEnd(e) {
document.querySelectorAll('.platform-tag').forEach(tag => {
tag.classList.remove('dragging', 'drag-over');
});
draggedElement = null;
}
// 触摸拖拽开始
function handleTouchStart(e) {
draggedElement = this;
isTouchDragging = true;
touchDropTarget = null;
this.classList.add('dragging');
}
// 触摸拖拽中
function handleTouchMove(e) {
if (!isTouchDragging || !draggedElement) {
return;
}
e.preventDefault();
const touch = e.touches[0];
const target = document.elementFromPoint(touch.clientX, touch.clientY);
const tagTarget = target ? target.closest('.platform-tag') : null;
document.querySelectorAll('.platform-tag').forEach(tag => tag.classList.remove('drag-over'));
if (tagTarget && tagTarget !== draggedElement) {
tagTarget.classList.add('drag-over');
touchDropTarget = tagTarget;
suppressClickAfterTouchDrag = true;
}
}
// 触摸拖拽结束
function handleTouchEnd() {
if (isTouchDragging && draggedElement && touchDropTarget) {
reorderPlatformTags(touchDropTarget);
savePlatformOrder();
}
cleanupTouchDragState();
}
// 触摸拖拽取消
function handleTouchCancel() {
cleanupTouchDragState();
}
function cleanupTouchDragState() {
document.querySelectorAll('.platform-tag').forEach(tag => {
tag.classList.remove('dragging', 'drag-over');
});
draggedElement = null;
touchDropTarget = null;
isTouchDragging = false;
if (suppressClickAfterTouchDrag) {
setTimeout(() => {
suppressClickAfterTouchDrag = false;
}, 0);
}
}
// 保存平台排序到本地存储
function savePlatformOrder() {
const container = document.getElementById('platform-tags');
const order = Array.from(container.children).map(tag => tag.getAttribute('data-platform'));
localStorage.setItem('nofeed-platform-order', JSON.stringify(order));
showMessage('平台排序已保存', 'success');
}
// 从本地存储加载平台排序
function loadPlatformOrder() {
const savedOrder = localStorage.getItem('nofeed-platform-order');
if (savedOrder) {
try {
const order = JSON.parse(savedOrder);
const container = document.getElementById('platform-tags');
const tags = Array.from(container.children);
const mergedOrder = [...order];
// 兼容老数据:补齐新增平台
defaultPlatformOrder.forEach(platformId => {
if (!mergedOrder.includes(platformId)) {
mergedOrder.push(platformId);
}
});
// 按保存的顺序重新排列
mergedOrder.forEach(platformId => {
const tag = tags.find(t => t.getAttribute('data-platform') === platformId);
if (tag) {
container.appendChild(tag);
}
});
} catch (e) {
console.log('加载平台排序失败:', e);
}
}
}
function resetPlatformOrder() {
const container = document.getElementById('platform-tags');
const tags = Array.from(container.children);
defaultPlatformOrder.forEach(platformId => {
const tag = tags.find(t => t.getAttribute('data-platform') === platformId);
if (tag) {
container.appendChild(tag);
}
});
savePlatformOrder();
showMessage('已恢复默认排序', 'success');
}
</script>
</body>
</html>