forked from bigzhuangyoyo/search-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhanced.html
491 lines (462 loc) · 27 KB
/
enhanced.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
<!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">
<title>zhelper Search Page 搜索界面 🔍</title>
<meta name="description" content="zhelper Search Page 搜索界面 🔍">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7692266966719684"
crossorigin="anonymous"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7GH6KVXJXH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-7GH6KVXJXH');
</script>
<link href="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/css/bootstrap.min.css" type="text/css"
rel="stylesheet" />
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/js/bootstrap.bundle.min.js"
type="application/javascript"></script>
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/axios/0.26.0/axios.min.js"
type="application/javascript"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/3.2.31/vue.global.min.js"
type="application/javascript"></script>
<script src="https://browser.sentry-cdn.com/5.29.0/vue.min.js"
integrity="sha384-FKagncFah3a9nkKNEIDQqXhYnny5Wzc37/AZV5eKKnRVS8uPpeFPdu9dnrvAnRpF"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container" id="app">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<b>zhelper search enhanced</b>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false"
aria-label="Toggle navigation">
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24">
<path fill="currentColor" d="m12 15.375l-6-6l1.4-1.4l4.6 4.6l4.6-4.6l1.4 1.4Z" />
</svg>
</button>
<div class="collapse navbar-collapse pull-right" id="navbarTogglerDemo02">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<!-- <li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">{{language.home}}</a>
</li> -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
<!-- {{language.api}} -->
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"
preserveAspectRatio="xMidYMid meet" viewBox="0 0 1024 1024">
<path fill="currentColor"
d="m917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 0 0-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 0 0 0 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3c2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4l-186.8-186.8l59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7c35.3 0 68.4 13.7 93.4 38.7c24.9 24.9 38.7 58.1 38.7 93.4c0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 0 0-11.3 0L501 613.3L410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 0 0-11.3 0L363 475.3l-43-43a7.85 7.85 0 0 0-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 0 0 0 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3c51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 0 1-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 0 1-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4l186.8 186.8l-59.4 59.4z" />
</svg>
<span v-if="!api.name">{{language.apinotset}}</span>
{{api.name}}
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li v-if="noapi" class="dropdown-item">
{{language.noapi}}
</li>
<li v-for="api in apis" class="dropdown-item" :key="api.id" @click="changeapi(api)">
{{api.name}}
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="language_change" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"
preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
<path fill="currentColor"
d="m12.87 15.07l-2.54-2.51l.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11l.76-2.04M18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12m-2.62 7l1.62-4.33L19.12 17h-3.24Z" />
</svg>
</a>
<ul class="dropdown-menu" aria-labelledby="language_change">
<li v-for="language in languages" class="dropdown-item"
@click="change_language(language)">
{{language.name}}
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/zhelper-org/search-page"><svg
xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"
preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
<path fill="currentColor"
d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33c.85 0 1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2Z" />
</svg></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://t.me/zhelpertg"><svg xmlns="http://www.w3.org/2000/svg"
width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
<path fill="currentColor"
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19c-.14.75-.42 1-.68 1.03c-.58.05-1.02-.38-1.58-.75c-.88-.58-1.38-.94-2.23-1.5c-.99-.65-.35-1.01.22-1.59c.15-.15 2.71-2.48 2.76-2.69a.2.2 0 0 0-.05-.18c-.06-.05-.14-.03-.21-.02c-.09.02-1.49.95-4.22 2.79c-.4.27-.76.41-1.08.4c-.36-.01-1.04-.2-1.55-.37c-.63-.2-1.12-.31-1.08-.66c.02-.18.27-.36.74-.55c2.92-1.27 4.86-2.11 5.83-2.51c2.78-1.16 3.35-1.36 3.73-1.36c.08 0 .27.02.39.12c.1.08.13.19.14.27c-.01.06.01.24 0 .38z" />
</svg></a>
</li>
</ul>
</div>
</div>
</nav>
<div class="d-grid gap-2 d-flex justify-content-center">
<div class="input-group">
<input type="text" class="form-control" placeholder="" @keyup.enter="search" v-model="keyword">
<button class="btn btn-primary" @click="search">{{language.search}}</button>
</div>
</div>
<p></p>
<div v-for="api in apis" :key="api.id">
<h5 v-if="api.search_result">{{api.name}}</h5>
<div class="mx-auto">
<ol class="list-group list-group-flush">
<p v-if="api.noresult">无相关结果</p>
<a v-for="result in api.search_result" @click="get_detail(api,result)"
class=" list-group-item list-group-item-action " aria-current="true" style="text-align: left">
<div class="ms-2 align-items-start" style="text-align: start;">
<template v-if="result.info">
<b class="card-title">{{result.info}}</b>
{{language.source}}:{{result.source}}
</template>
<template v-if="result.title">
<b class="card-title">{{result.title}}</b>
{{language.author}}:{{result.author}},{{language.publisher}}:{{result.publisher}},{{language.year}}:{{result.year}},
{{language.source}}:{{result.source}}
<br>
<p class="fw-light">
<small>
{{language.filesize}}:{{filesizeToString(result.filesize)}},ID:{{result.id}},ISBN:{{result.isbn}},{{language.extension}}:{{result.extension}}
</small>
</p>
</template>
</div>
</a>
</ol>
</div>
</div>
<div v-if="is_homepage && !search_result.length" v-html="language.notice">
</div>
<div class="modal fade" id="detailModal" tabindex="-1" aria-labelledby="detailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{language.detail}}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<template v-if=" api.type == 'full'">
{{language.title}}:{{detail.title}},
{{language.source}}:{{detail.source}}
<br>
{{language.author}}:{{detail.author}},{{language.publisher}}:{{detail.publisher}},{{language.year}}:{{detail.year}}
<br>
MD5: {{detail.md5}}
<br>
{{language.filesize}}:{{detail.filesize}}
</template>
<template v-if="api.type == 'light'">
{{language.info}}:{{detail.info}},
{{language.source}}:{{detail.source}}
</template>
<p></p>
<div class="modal-footer">
<template v-if="api.type == 'full'">
<a v-if="detail.in_libgen" class="btn btn-secondary"
:href="'http://libgendown.1kbtool.com/'+detail.md5" target="_blank">
Libgen
</a>
<a v-if="detail.ipfs_cid !== null && detail.ipfs_cid" class="btn btn-secondary"
:href="'https://ipfs-checker.1kbtool.com/'+detail.ipfs_cid+'?filename='+detail.title+'_'+detail.author+'_zhelper-search.'+detail.extension"
target="_blank">
IPFS
</a>
<a v-if="detail.md5" class="btn btn-secondary"
:href="'https://rapidupload.1kbtool.com/'+detail.md5 + '#' + detail.filesize + '#' + detail.title + '_' + detail.author + '_zhelper-search.' + detail.extension"
target="_blank">
秒传
</a>
<a v-if="api.download" class="btn btn-secondary" :href="api.download+detail.id"
target="_blank">
下载
</a>
</template>
<template v-if="api.type == 'light'">
<a :href="detail.url" class="btn btn-secondary" target="_blank">
{{ language.direct_url }}
</a>
<button class="btn btn-primary" v-if="detail.download_link"
data-bs-target="#downloadModal"
data-bs-toggle="modal">{{language.download_links}}</button>
</template>
<!-- 可能需要 eval 一下,解释两次
<a v-for="methods in download_config" :hidden="!methods.condition" :href="methods.url" target="_blank" class="btn btn-secondary">
{{ methods.name }}
</a> -->
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="downloadModal" tabindex="-1" aria-labelledby="downloadModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{language.download_links}}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{{language.info}}:{{detail.info}},
{{language.source}}:{{detail.source}}
<p></p>
<div class="modal-footer">
<a v-for="download_link in detail.download_link" :href="download_link.url"
class="btn btn-secondary" target="_blank">
{{ download_link.name }}
</a>
<!-- 可能需要 eval 一下,解释两次
<a v-for="methods in download_config" :hidden="!methods.condition" :href="methods.url" target="_blank" class="btn btn-secondary">
{{ methods.name }}
</a> -->
</div>
</div>
</div>
</div>
</div>
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
<div class="col-md-4 d-flex text-center" style="margin-left: 4px">
<span class="mb-3 mb-md-0 text-muted text-center">© 2022 Zhelper Team</span>
</div>
</footer>
</div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7692266966719684"
crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7692266966719684" data-ad-slot="3408254862"
data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script>
function getCookie(name) {
// 拆分 cookie 字符串
var cookieArr = document.cookie.split(";");
// 循环遍历数组元素
for (var i = 0; i < cookieArr.length; i++) {
var cookiePair = cookieArr[i].split("=");
/* 删除 cookie 名称开头的空白并将其与给定字符串进行比较 */
if (name == cookiePair[0].trim()) {
// 解码cookie值并返回
return decodeURIComponent(cookiePair[1]);
}
}
// 如果未找到,则返回null
return null;
}
const app = Vue.createApp({
data() {
return {
inprogress: false,
languages: [
{
name: "中文", id: "zh", setting: {
changeapi: '切换API',
home: '返回首页',
doc: '查看文档',
title: '书名',
author: '作者',
publisher: '出版社',
year: '出版时间',
filesize: '文件大小',
extension: '文件类型',
source: '书源',
info: '信息',
noapi: '无可用API',
apinotset: '未指定API',
direct_url: '直达链接',
download_links: '下载链接',
detail: "详细结果",
next_page: "下一页",
previous_page: "前一页",
search: '搜索',
notice: ' <h1>使用须知</h1>\
<ul>\
<li><b>本模式默认对所有接口进行请求!请勿导入太多接口以免程序崩溃</b></li>\
<li>本网页本身不具备任何搜索或者下载功能,需要搭配合适的查询接口进行使用 <b>直接访问将显示无可用API</b></li>\
<li>点击搜索后,本网页将向查询接口发送查询信息,接口返回结果需要一定时间,请耐心等待,不要重复查询</li>\
<li>本网页所显示的查询结果完全取决于接口所返回的内容。请不要使用来历不明的接口,我们不对接口内容负责</li>\
<li>通过更改查询接口,可以实现不同内容的混合查询。<b>切换接口按钮:电脑版在左上角,手机版先按右上角展开、再点击</b></li>\
<li>本网页已经开源</li>\
</ul>'
}
},
{
name: "English", id: 'en', setting: {
changeapi: 'Change API',
home: 'Home',
doc: 'Docs',
title: 'Title',
author: 'Author',
publisher: 'Publisher',
year: 'Year',
filesize: 'Filesize',
extension: 'Extension',
source: 'Source',
info: 'Infomation',
noapi: 'No Avaliable API',
apinotset: 'API Not Set',
direct_url: 'Direct Link',
download_links: 'Download Links',
detail: 'Detail Infomation',
next_page: "Next Page",
previous_page: "Previous Page",
search: 'search',
notice: ' <h1>Notice</h1>\
<ul>\
<li>This Website dont storage API, <b>You need provide API by yourself</b></li>\
<li>When you Click Search, We will make requests to API endpoint, be patient</li>\
<li>This website is opensource</li>\
<li>You can change API by click upper left corner</li>\
</ul>'
}
},
],
language: {},
api: {},
apis: [],
search_result: [],
detail: {},
keyword: '',
hits: 0,
page: 1,
}
},
methods: {
changeapi(api) {
this.api = api
},
search() {
this.inprogress = true;
for (i in this.apis) {
console.log(i)
let api = this.apis[i]
//api.page = 1;
axios.post(api.url + '/api/search/', {
keyword: this.keyword,
page: 1,
sensitive: api.sensitive,
}).then(response => {
if (response.data.errorn) {
alert(response.data.msg)
}
else {
api.search_result = response.data.data
if (response.data.data.length == 0) {
api.noresult = true
}
else{
api.noresult = false
}
api.hits = response.data.hits
}
}).catch(error => {
if (error.toJSON().status == 429) {
alert('请求过于频繁,请稍等一下再次尝试(429)')
}
else {
alert(`未知错误,请打开控制台查看(${error.message})`)
}
})
}
this.inprogress = false;
},
// change_page(change) {
// this.page += change
// axios.post(this.api.url + '/api/search/', {
// keyword: this.keyword,
// page: this.page,
// sensitive: this.api.sensitive,
// }).then(response => {
// this.search_result = response.data.data
// }).catch(error => {
// if (error.toJSON().status == 429) {
// alert('请求过于频繁,请稍等一下再次尝试(429)')
// }
// else {
// alert(`未知错误,请打开控制台查看(${error.message})`)
// }
// })
// },
get_detail(api,item) {
if (api.detail) {
axios.post(api.url + '/api/detail/', {
id: item.id,
source: item.source
}).then(response => {
if (response.data.errorn) {
alert(response.data.msg)
}
else {
this.detail = response.data
}
}).catch(error => {
if (error.toJSON().status == 429) {
alert('请求过于频繁,请稍等一下再次尝试(429)')
}
else {
alert(`未知错误,请打开控制台查看(${error.message})`)
}
})
}
else {
this.detail = item;
}
var myModal = new bootstrap.Modal(document.getElementById('detailModal'), {})
myModal.toggle()
},
filesizeToString(filesize) {
if (filesize > 0 && filesize < 1) {
return (filesize * 8).toFixed(2).toString() + 'b'
} else if (filesize <= 1024) {
return filesize.toFixed(2).toString() + 'B'
} else if (filesize <= Math.pow(1024, 2)) {
return (filesize / 1024).toFixed(2).toString() + 'KB'
} else if (filesize <= Math.pow(1024, 3)) {
return (filesize / Math.pow(1024, 2)).toFixed(2).toString() + 'MB'
}
},
change_language(lan) {
this.language = lan.setting
}
},
computed: {
is_homepage() {
return location.pathname == '/'
},
noapi() {
return this.apis.length == 0
},
total_page(api) {
return Math.floor(api.hits / 20) + 1
},
},
mounted: function () {
this.language = this.languages[0].setting
this.apis = JSON.parse(decodeURI(location.search.slice(1)));
this.api = this.apis[0]
if (location.hash.slice(1)) {
this.keyword = decodeURI(location.hash.slice(1));
this.search()
}
}
})
app.mount('#app')
Sentry.init({
Vue,
dsn: "https://6f4cfc1a19be46efbdb2e412e307339e@o4504512193101824.ingest.sentry.io/4504512392265728",
});
</script>
</body>
</html>