Skip to content

Commit

Permalink
Merge pull request #18 from lhxcccccccccc/master
Browse files Browse the repository at this point in the history
[Severless官网] 插件页面接口支持V3接口
  • Loading branch information
lhxcccccccccc authored Jun 12, 2024
2 parents c9009bf + c4d5b34 commit 7f7c14f
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 186 deletions.
40 changes: 28 additions & 12 deletions application.html
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,21 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ
// 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) {
Expand Down Expand Up @@ -591,19 +606,20 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ

});
})();
;(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)
}
});
})()


// 查找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');
}
Expand Down
40 changes: 27 additions & 13 deletions component.html
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,19 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ
// 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) {
Expand Down Expand Up @@ -694,19 +707,20 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ
});
})();

;(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)
}
});
})()


// 查找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');
}
Expand Down
3 changes: 1 addition & 2 deletions details.html
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,7 @@ <h4 id="usename">
}
if (tempData.body) {
tempData = tempData.body
console.log('tempData')
console.log(tempData)
// console.log('tempData')
if (typeof tempData === 'string') {
renderTpl('titleTpl',
{
Expand Down
60 changes: 58 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
/*width: 200px;*/
}
</style>
<style>
@media (max-width: 1500px){
.title-name{
width: 180px;
}
}
</style>
<script>
function alertfun() {
const alerted = localStorage.getItem("alerted") || "none";
Expand All @@ -63,6 +70,8 @@
}
}
</script>
<script src="config/URL.js"></script>
<script src="utils/_Get.js"></script>
</head>

<body>
Expand Down Expand Up @@ -723,7 +732,7 @@ <h4 class="lasthead">微信公众号</h4>
<!--====== Back to top start ======-->

<script>
function getPackages() {
function getV2PackagesRecommend() {
const xmlhttp = window.XMLHttpRequest
? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
Expand Down Expand Up @@ -781,8 +790,55 @@ <h5>
);
xmlhttp.send();
}
// V2版本 推荐应用
// getV2PackagesRecommend();
</script>

<script>
// 获取 V3版本 推荐应用
function getV3PackagesRecommend(params) {
var url = BASE_V3_URL + '/console/1/tabs/5?lang=zh'
_Get(url, function (result) {
if (!result) {
return ;
}
var itemString = "";
var keys = Object.keys(result);
var times = [0.3, 0.2, 0.1];
for (var i = 0; i < keys.length; i++) {
var item = result[keys[i]];
// console.log(item)
var package = item && item.package && item.package.name || '';
var created_at = item && item.version && item.version.created_at && item.version.created_at.split(" ")[0] || '';
var tag_name = item && item.version && item.version.tag_name || '';
itemString = itemString + `<div class="feature-box item">
<a href="details.html?name=${package}&package_type=v3" style="width: 100%; display: inline-block;">
<div class="content">
<h5>
<font size="6" class="text-flow-ellipsis-single title-name" style="display: inline-block;">${package}</font>
<i class="fas fa-fire" style="float: right; color: orange; margin-top: 12px">
${item.download} </i>
</h5>
<p class="text">
<i class="fas fa-calendar"></i> ${created_at}&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
<i class="fas fa-desktop"></i> V${tag_name}
</p>
<p class="text-flow-ellipsis-multiple" style="height: 80px">
${item.description}
</p>
</div>
</a>
</div>`;
}

getPackages();
document.getElementById("itemlist").innerHTML = itemString;

return ;
})
}
// V3版本 推荐应用
getV3PackagesRecommend();
</script>

<!--====== Jquery ======-->
Expand Down
Loading

0 comments on commit 7f7c14f

Please sign in to comment.