Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #6

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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