-
Notifications
You must be signed in to change notification settings - Fork 3
/
application.html
864 lines (820 loc) · 31.2 KB
/
application.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
<!DOCTYPE html>
<html lang="zxx">
<head>
<!--====== Required meta tags ======-->
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="description" content="" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<!--====== Title ======-->
<title>
应用 - Serverless Registry - Serverless package management platform
</title>
<!--====== Bootstrap css ======-->
<link rel="stylesheet" href="static/css/bootstrap.min.css" />
<!--=== Owl-Carousel ===-->
<link rel="stylesheet" href="static/css/owl.carousel.min.css" />
<!--====== Magnific ======-->
<link rel="stylesheet" href="static/css/magnific-popup.css" />
<!--===nice-select===-->
<link rel="stylesheet" href="static/css/nice-select.css" />
<!--====== Animate CSS ======-->
<link rel="stylesheet" href="static/css/animate.min.css" />
<!--====== Font Awesome ======-->
<link rel="stylesheet" href="static/css/font-awesome.min.css" />
<!--====== Main Css ======-->
<link rel="stylesheet" href="static/css/style.css" />
<!--====== Responsive Css ======-->
<link rel="stylesheet" href="static/css/responsive.css" />
<script src="https://res.zvo.cn/translate/translate.js"></script>
<style>
.text-flow-ellipsis-multiple {
/* 多余内容省略号处理-多行 */
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}
.text-flow-ellipsis-single {
/* 多余内容省略号处理-单行 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.preButton {
width: 120px;
height: 34px;
border: 1px solid rgba(4, 10, 41, 0.12);
border-radius: 3px;
color: #fff;
line-height: 2.53;
text-align: center;
font-weight: 500;
background: #547af8;
}
.download {
margin-left: 20px;
width: 120px;
height: 34px;
border: 1px solid rgba(4, 10, 41, 0.12);
border-radius: 3px;
color: #051c35;
line-height: 2.53;
text-align: center;
font-weight: 500;
background: #fff;
}
</style>
<script>
function alertfun() {
const alerted = localStorage.getItem("alerted") || "none";
if (alerted != "ok") {
localStorage.setItem("alerted", "ok");
alert(
"Reminder: English information of some content is automatically presented through machine translation. The machine translation process may cause some semantic and other content problems. If you find any, please feedback to the community maintainer email [email protected]"
);
}
}
</script>
</head>
<body>
<!--====== Preloader Start ======-->
<div id="preloader">
<div class="loader-cubes">
<div class="loader-cube1 loader-cube"></div>
<div class="loader-cube2 loader-cube"></div>
<div class="loader-cube4 loader-cube"></div>
<div class="loader-cube3 loader-cube"></div>
</div>
</div>
<!--====== Preloader End ======-->
<!--====== Header Part Start ======-->
<header class="header-one sticky-header">
<div
class="header-navigation"
style="padding-top: 10px; padding-bottom: 7px"
>
<div
class="container-fluid d-flex align-items-center justify-content-between container-1470"
>
<div class="header-left">
<h1 href="index.html" style="color: black">Serverless Registry</h1>
</div>
<div
class="header-right d-flex align-items-center justify-content-end"
>
<div class="site-nav-menu">
<ul class="primary-menu">
<li>
<a class="nav-link" href="index.html">首页</a>
</li>
<li class="current">
<a class="nav-link" href="application.html">应用</a>
</li>
<li>
<a class="nav-link" href="component.html">组件</a>
</li>
<li>
<a class="nav-link" href="plugin.html">插件</a>
</li>
<li>
<a
class="nav-link"
href="https://github.com/Serverless-Devs/Serverless-Devs/blob/master/spec/zh/0.0.2/serverless_registry_model/readme.md"
target="_blank"
>规范</a
>
</li>
<li>
<a class="nav-link" href="faq.html">常见问题</a>
</li>
<li>
<a
href="javascript:translate.changeLanguage('chinese_simplified');"
class="ignore"
>中文</a
>
</li>
<li>
<a
href="javascript:translate.changeLanguage('english');"
onclick="alertfun()"
class="ignore"
>English</a
>
</li>
</ul>
<a href="#0" class="nav-close"><i class="fal fa-times"></i></a>
</div>
<div class="header-extra d-flex align-items-center">
<div class="search-widget">
<a href="#0" class="search-icon"
><i class="fal fa-search"></i
></a>
<div class="search-form">
<form action="search.html" method="GET">
<input
type="search"
placeholder="请输入要搜索的 Serverless Package 关键词"
name="keyword"
/>
</form>
<a href="#0" class="search-close"
><i class="fal fa-times"></i
></a>
</div>
</div>
<div class="offcanvas-widget d-none">
<div class="offcanvas-icon">
<span></span><span></span><span></span>
</div>
</div>
<div class="nav-toggler">
<span></span><span></span><span></span>
</div>
</div>
</div>
</div>
</div>
</header>
<!--====== Header Part End ======-->
<!--====== Banner Start ======-->
<section class="breadcrumb-area">
<div class="container">
<div class="content">
<h2 class="breadd wow fadeInUp">应用</h2>
<ul class="breadcrumb-list wow fadeInUp">
<li><a href="index.html">首页 /</a></li>
<li>应用</li>
</ul>
</div>
</div>
</section>
<!--====== Banner End ======-->
<!--====== Unique Themes Start ======-->
<section class="unique themes producttwo">
<div class="container">
<div class="row">
<div class="col-lg-12 wow fadeInUp">
<div class="product-show">
<div class="left-box">
<p class="text" id="showinfo"></p>
</div>
<div class="right-box">
<div class="language-select">
<select
class="select-bar"
onchange="getPackages()"
id="sortselect"
>
<option value="time">按时间排序</option>
<option value="download">按下载排序</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-8 col-lg-7">
<div class="row" id="itemlist"></div>
</div>
<div class="col-xl-4 col-lg-5">
<div class="widget widget-search wow fadeInUp">
<h5 class="widtitle">应用搜索</h5>
<div class="search-form">
<div class="form-group">
<input
type="text"
placeholder="Search"
required=""
id="searchdata"
onkeydown="if(event.keyCode==13)getPackages()"
/>
<button onclick="getPackages()">
<i class="fas fa-search"></i>
</button>
</div>
</div>
</div>
<div class="widget m-0 widget-categories wow fadeInUp">
<h5 class="widtitle">分类</h5>
<ul id="categorylist"></ul>
</div>
<div class="widget m-0 widget-categories wow fadeInUp">
<h5 class="widtitle">云厂商</h5>
<ul id="providerlist"></ul>
</div>
</div>
</div>
</div>
</section>
<!--====== Unique Themes End ======-->
<!--====== Footer Area START ======-->
<footer class="footer-area two">
<div class="container">
<div class="row justify-content-between">
<div class="col-lg-4 col-md-6 wow fadeInUp" data-wow-delay="0.2s">
<div class="footer-box one">
<div class="logo">
<h1 style="color: white">Serverless Registry</h1>
</div>
<p class="text">
Serverless Registry 是 Serverless Devs 社区的衍生品,遵循
Serverless Devs Model 规范,为打造 Serverless 生态基础,繁荣
Serverless 开源生态而努力。正在为成为好用的 Serverless 领域的
NPM,Pypi ... 而努力。
</p>
<div class="social">
<a href="https://github.com/serverless-devs/serverless-devs"
><i class="fab fa-github"></i
></a>
<a href="https://gitee.com/serverless-devs/Serverless-Devs"
><i class="fab fa-git"></i
></a>
<a href="https://www.serverless-devs.com"
><i class="fab fa-page4"></i
></a>
</div>
</div>
</div>
<div class="col-lg-2 col-md-6 wow fadeInUp" data-wow-delay="0.3s">
<div class="footer-box two">
<h4 class="lasthead">相关资源</h4>
<div class="footer-list">
<ul>
<li><a href="about.html"> 关于我们 </a></li>
<li>
<a
href="https://github.com/serverless-devs/serverless-devs"
>
Serverless Devs 仓库
</a>
</li>
<li>
<a
href="https://github.com/Serverless-Devs/Serverless-Devs/blob/master/spec/readme.md"
>
SDM 规范文档
</a>
</li>
<li>
<a
href="https://github.com/Serverless-Devs/Serverless-Devs/discussions"
>
Serverless Devs 社区
</a>
</li>
<li>
<a
href="https://github.com/Serverless-Devs/Serverless-Devs/blob/master/CONTRIBUTORS.md"
>
贡献者列表
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-lg-2 col-md-6 wow fadeInUp" data-wow-delay="0.4s">
<div class="footer-box three">
<h4 class="lasthead">钉钉交流群</h4>
<div class="footer-list">
<img
src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1648814797378_20220401120637498673.png"
/>
</div>
</div>
</div>
<div class="col-lg-2 col-md-6 wow fadeInUp" data-wow-delay="0.5s">
<div class="footer-box none">
<h4 class="lasthead">微信公众号</h4>
<div class="footer-list">
<img
src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1648814758343_20220401120558862369.png"
/>
</div>
</div>
</div>
</div>
</div>
</footer>
<div class="copyright two">
<div class="container">
<div class="row">
<div class="col-12 wow fadeInUp text-center">
<p class="text">Copyright © 2022. Serverless Devs</p>
</div>
</div>
</div>
</div>
<!--====== Footer Area END ======-->
<!--====== Back to top start ======-->
<div class="back-to-top">
<a href="#0"> <i class="fas fa-arrow-up"></i> </a>
</div>
<!--====== Back to top start ======-->
<!--====== Jquery ======-->
<script src="static/js/jquery-3.6.0.min.js"></script>
<!--====== Bootstrap ======-->
<script src="static/js/bootstrap.bundle.min.js"></script>
<!--=== Owl-Carousel ===-->
<script src="static/js/owl.carousel.min.js"></script>
<!--====== Nice Select ======-->
<script src="static/js/jquery.nice-select.min.js"></script>
<!--====== Magnific ======-->
<script src="static/js/jquery.magnific-popup.min.js"></script>
<!--====== Nice Select ======-->
<script src="static/js/jquery.nice-select.min.js"></script>
<!--====== Wow ======-->
<script src="static/js/wow.min.js"></script>
<!-- ====== 模版引擎 ====== -->
<script src="vendors/art-template/template-web.js"></script>
<!--====== Main JS ======-->
<script src="static/js/main.js"></script>
<script src="config/URL.js"></script>
<script src="utils/_Get.js"></script>
<script src="utils/_Post.js"></script>
<script src="utils/renderTpl.js"></script>
<script src="utils/splitMaxLenth.js"></script>
<script src="services/downloadV3Plugin.js"></script>
<script src="services/getPackagesSearchForV3.js"></script>
<!-- 注入总数模版 -->
<script type="text/template" id="totalTpl">
<i class="fas fa-list"></i> 找到 {{total}} 条结果
</script>
<!-- 注入搜索模板 -->
<script type="text/template" id="searchTpl">
{{each data}}
<div class="col-xl-6 wow fadeInUp" data-wow-delay="{{$value.delayTime}}s" style="visibility: visible; animation-delay: 0.2s; animation-name: fadeInUp;">
<div class="themes-box" style="overflow: hidden;">
{{if $value.package_type === 'v2' }}
<div class="ribbon" data-spm-anchor-id="5176.28448578.0.i154.758e60cczu7hm5">仅维护</div>
{{ /if }}
<div class="main-content">
<h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_type}}" class="text-flow-ellipsis-single">{{$imports.splitMaxLenth($value.name, 27)}}</a> <i class="fas fa-fire" style="float: right; color: orange;"> {{$value.download}} </i></h5>
<div class="last-part">
<div class="right" style="width: 100%">
<p class="text" style="width: 100%">
{{if $value.published_at }}
<i class="fas fa-calendar"></i> {{$value.published_at}}
{{ /if }}
{{if $value.published_at&&$value.version }}
|
{{ /if }}
{{if $value.version }}
<i class="fas fa-desktop"></i> V{{$value.version}}
{{ /if }}
</p>
<p class="text-flow-ellipsis-multiple" style="height: 70px">
{{$value.description}}
</p>
</div>
</div>
<div class="past-part" style="margin-top: 10px">
<center>
<div class="buton">
<a href="details.html?name={{$value.name}}&package_type={{$value.package_type}}" class="preButton"> <i class="fas fa-book"></i> 查看详情 </a>
{{if $value.zipball_url }}
<a href="{{$value.zipball_url}}" target="_blank" class="download"> <i class="fas fa-download"></i> 下载组件 </a>
{{else}}
<a onclick="downloadPlugin( '{{$value.name}}' )" class="download"> <i class="fas fa-download"></i> 下载组件 </a>
{{ /if }}
</div>
</center>
</div>
</div>
</div>
</div>
{{/each}}
</script>
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return false;
}
function insertParam(
key,
value,
sourceData = document.location.search.substr(1)
) {
key = escape(key);
// value = escape(value);
var kvp = sourceData.split("&");
if (kvp == "") {
return "?" + key + "=" + value;
} else {
var i = kvp.length;
var x;
while (i--) {
x = kvp[i].split("=");
if (x[0] == key) {
x[1] = value;
kvp[i] = x.join("=");
break;
}
}
if (i < 0) {
kvp[kvp.length] = [key, value].join("=");
}
return kvp.join("&");
}
}
function downloadPlugin(name) {
downloadV3Plugin(name);
}
function onClick(value, key, package_type, name) {
var obj = {};
if (key === "category") {
obj[key] = value;
if (getQueryVariable("provider")) {
obj["provider"] = getQueryVariable("provider");
}
if (getQueryVariable("package_type")) {
obj["package_type"] = getQueryVariable("package_type");
}
if (name) {
// 添加一个category_name字段
obj["category_name"] = name;
}
}
if (key === "provider") {
obj[key] = value;
if (getQueryVariable("category")) {
obj["category"] = getQueryVariable("category");
}
if (getQueryVariable("category_name")) {
// 添加一个category_name字段
obj["category_name"] = getQueryVariable("category_name");
}
if (package_type) {
obj["package_type"] = package_type;
}
}
window.location.href = objectSerialize(obj);
}
function setBaseList(listData, idName, name) {
var attrString = "";
var keys = [
{
id: "-1",
name: "全部",
package_type: "",
},
...listData,
];
for (var i = 0; i < keys.length; i++) {
var item = keys[i];
// console.log(item.id, item.name, item.package_type);
attrString =
attrString +
`<li>
<a onclick="onClick('${item.id}', '${name}','${
item.package_type
}', '${item.name}')" class="link ${
item.id == decodeURI(getQueryVariable(name) || "-1")
? "active"
: ""
}">
<span>${item.name || "全部"}</span>
</a>
</li>`;
}
document.getElementById(idName).innerHTML = attrString;
}
// 获取 分类 / 信息
// 1. 调用V2接口 获取V2分类
// 2. 调用V3接口 获取V3分类
function getCategory() {
var categoryList = []; // package_type
(function getCategoryV2() {
_GetJSON(
"https://registry.devsapp.cn/common/category",
function (tempData) {
for (var key in tempData) {
var obj = {};
var value = tempData[key];
// obj["package_type"] = 'v2'
obj["id"] = key;
obj["name"] = value;
categoryList.push(obj);
}
}
);
})();
(function getCategoryV3() {
var base_url = BASE_V3_URL;
_GetJSON(base_url + "/common/categories", function (tempData) {
// 计算获取V3比V2多的分类item
var body = tempData.body;
if (body && body.length > 0) {
// 找出不在categoryList中的body对象
var notInArray1 = body
.filter(
(obj2) =>
!categoryList.find((obj1) => obj1.name === obj2.name)
)
.map((obj) => {
return {
// 'package_type':'v3',
id: obj.id + "", // id属性转换为字符串
name: obj.name,
};
});
// categoryList.push({
// 'package_category_type':'v3',
// 'id': 2,
// 'name': 'Web 应用'
// })
// 合并两个数组
notInArray1.forEach((element) => {
categoryList.push(element);
});
}
});
})();
// 查找ID为2的元素
var itemToMove = categoryList.find(
(item) => item.id === 2 || item.id === "2"
);
if (itemToMove) {
// 移除该元素
var indexToRemove = categoryList.indexOf(itemToMove);
categoryList.splice(indexToRemove, 1);
// 插入到新位置
var newIndex = 1; // 目标索引位置
categoryList.splice(newIndex, 0, itemToMove);
}
// 渲染的方法: 渲染分类数据
setBaseList(categoryList, "categorylist", "category");
}
// 获取 云厂商 / 信息
// 1. 调用V2接口 获取V2云厂商
// 2. 调用V3接口 获取V3云厂商
function getProvider() {
var providerList = []; // package_type
(function getProviderV2() {
_GetJSON(
"https://registry.devsapp.cn/common/provider",
function (tempData) {
for (var key in tempData) {
var obj = {};
var value = tempData[key];
obj["package_type"] = "v2";
obj["id"] = value; // 如果是云厂商, 使用名称字符串搜索
obj["name"] = value;
providerList.push(obj);
}
},
);
})();
(function getProviderV3() {
var base_url = BASE_V3_URL;
_GetJSON(
base_url + "/common/providers",
function (tempData) {
// 计算获取V3比V2多的云厂商item
// console.log('v3---tempData===')
var body = tempData.body;
if (body && body.length > 0) {
// providerList.push({ 'package_type':'v3','_id': 8, 'name': '专有云' ,'id': '专有云' })
// providerList.push({ 'package_type':'v3','_id': 10,'name': '火山引擎', 'id': '火山引擎' })
// providerList.push({ 'package_type':'v3','_id': 11,'name': '天翼云' ,'id': '天翼云' })
// providerList.push({ 'package_type':'v3','_id': 12,'name': '移动云' ,'id': '移动云' })
// providerList.push({ 'package_type':'v3','_id': 13,'name': '联通云' ,'id': '联通云' })
// 找出不在providerList中的body对象
var notInArray1 = body
.filter(
(obj2) =>
!providerList.find((obj1) => obj1.name === obj2.name)
)
.map((obj) => {
return {
package_type: "v3",
id: obj.name,
_id: obj.id,
name: obj.name,
};
});
// 合并两个数组
notInArray1.forEach((element) => {
providerList.push(element);
});
// 查找ID为10的元素
var itemToMove = providerList.find((item) => item._id === 10);
if (itemToMove) {
// 移除该元素
var indexToRemove = providerList.indexOf(itemToMove);
providerList.splice(indexToRemove, 1);
// 插入到新位置
var newIndex = 1; // 目标索引位置
providerList.splice(newIndex, 0, itemToMove);
}
}
},
);
})();
setBaseList(providerList, "providerlist", "provider");
}
function getPackages() {
var selectData = document.getElementById("sortselect");
var index = selectData.selectedIndex;
var sort = selectData.options[index].value;
// console.log(document.getElementById("sortselect").selectedIndex);
// 列表存储数据
var dataList = [];
var v3Total = 0;
var v2Total = 0;
// 左侧内容主体区域
// V3: 搜索/获取 Package 信息
(function getPackagesV3() {
var data = `type=${V3_SEARCH_TYPE["Project"]}&sort=${sort}`;
if ((getQueryVariable("category") || "-1") !== "-1") {
// 如果是这个方法categrory传文字
data = insertParam(
"category",
getQueryVariable("category_name"),
data
);
}
if (document.getElementById("searchdata").value) {
data = insertParam(
"search",
document.getElementById("searchdata").value,
data
);
}
if ((getQueryVariable("provider") || "-1") !== "-1") {
data = insertParam("provider", getQueryVariable("provider"), data);
}
getPackagesSearchForV3(
data,
function (result) {
if (!Array.isArray(result)) {
return;
}
var keys = Object.keys(result);
var times = [0.3, 0.2, 0.1];
for (var i = 0; i < keys.length; i++) {
var item = {};
item.delayTime =
times[Math.floor(Math.random() * times.length)];
item.name = result[keys[i]].name;
item.download = result[keys[i]].download;
item.published_at = result[keys[i]].latest_create.split(" ")[0];
item.published_at_source = dateFunction(
result[keys[i]].latest_create
);
// item.version = result[keys[i]].version.tag_name;
item.version = "";
item.description = result[keys[i]].description;
// item.zipball_url = result[keys[i]].version.zipball_url;
item.zipball_url = "";
item.package_type = "v3"; // v2 v3标识
dataList.push(item);
}
v3Total = keys.length;
reRender(dataList, sort, v2Total, v3Total);
return;
},
true
);
})();
// V2: 获取 Package 信息
(function getPackagesV2() {
var data = `type=Application&sort=${sort}`;
if ((getQueryVariable("category") || "-1") !== "-1") {
data = insertParam("category", getQueryVariable("category"), data);
}
if (document.getElementById("searchdata").value) {
data = insertParam(
"keyword",
document.getElementById("searchdata").value,
data
);
}
if ((getQueryVariable("provider") || "-1") !== "-1") {
data = insertParam("provider", getQueryVariable("provider"), data);
}
// 如果发现是type为v3接口新增类型,则不调用v2
if (getQueryVariable("package_type") === "v3") {
return;
}
var base_url = BASE_V2_URL;
_Post(
base_url + "/package/search",
data,
function (result) {
var keys = Object.keys(result);
var times = [0.3, 0.2, 0.1];
for (var i = 0; i < keys.length; i++) {
var item = {};
item.delayTime =
times[Math.floor(Math.random() * times.length)];
item.name = result[keys[i]].package;
item.download = result[keys[i]].download;
item.published_at =
result[keys[i]].version.published_at.split("T")[0];
item.published_at_source = dateFunction(
result[keys[i]].version.published_at
);
item.version = result[keys[i]].version.tag_name;
item.description = result[keys[i]].description;
item.zipball_url = result[keys[i]].version.zipball_url;
item.package_type = "v2"; // v2 v3标识
dataList.push(item);
}
v2Total = keys.length;
reRender(dataList, sort, v2Total, v3Total);
},
true
);
})();
}
function reRender(_dataList, sort, v2Total, v3Total) {
let dataList = [..._dataList];
if (dataList && dataList.length > 0) {
if (sort === "time") {
dataList = dataList.sort((a, b) =>
compareTimeStrings(b.published_at_source, a.published_at_source)
);
} else if (sort === "download") {
// 根据download字段排序
dataList = dataList.sort((a, b) => b.download - a.download);
}
renderTpl("searchTpl", { data: dataList }, "#itemlist");
} else {
renderTpl("searchTpl", { data: [] }, "#itemlist");
}
renderTpl("totalTpl", { total: v2Total + v3Total }, "#showinfo");
}
function main() {
getPackages();
getProvider();
getCategory();
}
main();
</script>
<script>
//translate.ignore.tag.push('span'); //翻译时追加上自己想指定忽略的tag标签,凡是在这里面的,都不进行翻译。
//translate.ignore.class.push('test'); //翻译时指定忽略的class name,凡是class name 在这里面的,都不进行翻译。如果不设置默认只有 ignore 这一个
//translate.setAutoDiscriminateLocalLanguage(); //设置用户第一次用时,自动识别其所在国家的语种进行切换
translate.setUseVersion2(); //设置使用v2.x 版本
translate.language.setLocal("chinese_simplified");
translate.selectLanguageTag.show = false;
translate.execute(); //执行翻译初始化操作,显示出select语言选择
</script>
</body>
</html>