start grid

This commit is contained in:
2023-04-02 23:54:41 +08:00
parent 4e230ed7e7
commit c44aaf5177
8 changed files with 649 additions and 25 deletions

View File

@ -8,8 +8,7 @@ function combineUrl(url) {
return (consts.path || '') + url;
}
function get(url, options) {
options ??= {};
function get(url, options = {}) {
return fetch(combineUrl(url), {
method: options.method || 'GET',
headers: {
@ -21,8 +20,7 @@ function get(url, options) {
});
}
function post(url, data, options) {
options ??= {};
function post(url, data, options = {}) {
// let contentType;
if (data instanceof FormData) {
// contentType = 'multipart/form-data';
@ -47,7 +45,7 @@ function post(url, data, options) {
});
}
function upload(url, data, options) {
function upload(url, data, options = {}) {
return new Promise((resolve, reject) => {
const request = new XMLHttpRequest();
request.onreadystatechange = function () {
@ -59,7 +57,6 @@ function upload(url, data, options) {
}
}
};
options ??= {};
if (typeof options.progress === 'function') {
request.upload.addEventListener('progress', function (ev) {
if (ev.lengthComputable) {