Skip to content

Commit

Permalink
Merge pull request #6 from lhxcccccccccc/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
lhxcccccccccc authored Jun 4, 2024
2 parents 750c75b + 00065af commit 18e46d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion details.html
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ <h4 class="lasthead">微信公众号</h4>
let tempData = JSON.parse(xmlhttp.responseText).Response;
document.getElementById("title").innerHTML = `${tempData.name}
<h4><i class="fas fa-calendar"></i> ${
tempData.create.split("T")[0]
tempData&&tempData.create&&tempData.create.split("T")[0]
} / V${
tempData.version
} <a href="https://registry.devsapp.cn/simple/${
Expand Down
5 changes: 3 additions & 2 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ <h5><a href="details.html?name={{$value.name}}" class="text-flow-ellipsis-single
document.body.removeChild(link);
}
return ;
}, true)

}, 'isAllData')
}

function getQueryVariable(variable) {
Expand Down Expand Up @@ -492,8 +493,8 @@ <h5><a href="details.html?name={{$value.name}}" class="text-flow-ellipsis-single

document.getElementById("keyword").innerHTML = `搜索词:${searchValue}`;
// 并行调用两个接口
getPackagesV2();
getPackagesV3();
getPackagesV2();

if(dataList && dataList.length > 0){
renderTpl('searchTpl', { data: dataList }, '#itemlist')
Expand Down
22 changes: 18 additions & 4 deletions utils/_Get.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
function _Get(url, callback, isAllData) {
// get方法 默认返回Body
function _Get(url, callback, type) {
type = type || 'body'

var xmlhttp = window.XMLHttpRequest
? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
Expand All @@ -9,13 +12,24 @@ function _Get(url, callback, isAllData) {
);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
if (isAllData) {
if (type === 'isAllData') {// get方法返回所有接口数据
var result = JSON.parse(xmlhttp.responseText)
callback&&callback(result)
return ;
}
var result = JSON.parse(xmlhttp.responseText).body;
callback&&callback(result)

if (type === 'response') { // get方法返回Response
var result = JSON.parse(xmlhttp.responseText).Response;
callback&&callback(result)
return ;
}

// get方法返回Body
if (type === 'body') {
var result = JSON.parse(xmlhttp.responseText).body;
callback&&callback(result)
return ;
}
}
};
xmlhttp.setRequestHeader(
Expand Down

0 comments on commit 18e46d1

Please sign in to comment.