This commit is contained in:
2024-12-21 22:59:06 +03:00
parent d630370039
commit e6e8fc46dc
2 changed files with 38 additions and 19 deletions
+37 -18
View File
@@ -514,30 +514,49 @@ kit.config = kit.config || {};
self.config.debug && console.log(`Plugin ${self.id}: httpGet ${url}`);
var xhr = new XMLHttpRequest();
var url2 = url;
if(self.config.isSetTimestamp){
url2 = getUrlWithTimestamp(url);
}
xhr.open('GET', url2, true);
p = fetch(url2, {
method: 'GET', redirect: 'follow'
})
.then(function (response) {
if (response.ok) {
return response.text();
}
console.log(`%cPlugin.load(${self.id}): bad status ${response.status}!`, "color: red;");
throw ['bad status', response.status, response.statusText].filter().join(' ');
}, function(reason){
reject('Network Error');
})
.then(function(data){
resolve(data);
}, function(reason){
reject(reason);
});
xhr.onload = function() {
if (this.status == 200) {
resolve(this.response);
} else {
console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
var error = new Error(this.statusText);
error.code = this.status;
reject(error);
}
};
xhr.onerror = function() {
console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
reject(new Error("Network Error"));
};
xhr.send();
// var xhr = new XMLHttpRequest();
// xhr.open('GET', url2, true);
//
// xhr.onload = function() {
// if (this.status == 200) {
// resolve(this.response);
// } else {
// console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
// var error = new Error(this.statusText);
// error.code = this.status;
// reject(error);
// }
// };
//
// xhr.onerror = function() {
// console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
// reject(new Error("Network Error"));
// };
//
// xhr.send();
});
}
+1 -1
View File
File diff suppressed because one or more lines are too long