mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
update:优化页面样式
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
function post(api, bodyData, fn) {
|
||||
let basePath = 'http://localhost:8001';
|
||||
let token = localStorage.getItem('token');
|
||||
fetch(basePath + api, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token,
|
||||
},
|
||||
body: bodyData==null ? null : JSON.stringify(bodyData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 401){
|
||||
window.location = 'login.html';
|
||||
return
|
||||
}
|
||||
fn(data);
|
||||
});
|
||||
}
|
||||
|
||||
function get(api, fn) {
|
||||
let basePath = 'http://localhost:8001';
|
||||
let token = localStorage.getItem('token');
|
||||
fetch(basePath + api, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token,
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 401){
|
||||
window.location = 'login.html';
|
||||
return
|
||||
}
|
||||
fn(data);
|
||||
});
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user