|
|
@@ -5,6 +5,7 @@ class SimpleService{
|
|
|
constructor() {
|
|
|
this.footprint = [];
|
|
|
this.cache = [];
|
|
|
+ this.token_ = localStorage.getItem('token');
|
|
|
this.memory = [];
|
|
|
this.mem_pointer = -1;
|
|
|
this.cache_djcs = [];
|
|
|
@@ -28,6 +29,10 @@ class SimpleService{
|
|
|
};
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ setToken(token) {
|
|
|
+ this.token_ = token;
|
|
|
+ }
|
|
|
|
|
|
ip() {
|
|
|
//return "/api"//return "http://127.0.0.1:8000"
|
|
|
@@ -66,37 +71,41 @@ class SimpleService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async generateQufei(name) {
|
|
|
+ async generateQufei(name, navigate) {
|
|
|
const response = await fetch(this.ip().concat("/qufei/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body : JSON.stringify({
|
|
|
"name": name
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
}
|
|
|
}
|
|
|
- async generateOutline2(name) {
|
|
|
+ async generateOutline2(name, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/outline2"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body : JSON.stringify({
|
|
|
"name": name
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
@@ -104,30 +113,33 @@ class SimpleService{
|
|
|
}
|
|
|
|
|
|
|
|
|
- async generateDetail2(name) {
|
|
|
+ async generateDetail2(name, navigate) {
|
|
|
const response = await fetch(this.ip().concat("/detail2"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body : JSON.stringify({
|
|
|
"name": name
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async generateBaojiahuizong2(name, id) {
|
|
|
+ async generateBaojiahuizong2(name, id, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/baojiahuizong2/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
name: name,
|
|
|
@@ -135,19 +147,21 @@ class SimpleService{
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async generateGuifeishuijin2(name, id) {
|
|
|
+ async generateGuifeishuijin2(name, id, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/guifeishuijin2/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
name: name,
|
|
|
@@ -155,8 +169,9 @@ class SimpleService{
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
@@ -165,11 +180,12 @@ class SimpleService{
|
|
|
|
|
|
|
|
|
|
|
|
- async generateQitaxiangmu2(name, id) {
|
|
|
+ async generateQitaxiangmu2(name, id, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/qitaxiangmu2/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
name: name,
|
|
|
@@ -177,8 +193,9 @@ class SimpleService{
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
@@ -294,11 +311,12 @@ class SimpleService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async generateQingdanxiangmu2(name, id) {
|
|
|
+ async generateQingdanxiangmu2(name, id, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/qingdanxiangmu2/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
name: name,
|
|
|
@@ -306,8 +324,9 @@ class SimpleService{
|
|
|
})
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
@@ -359,11 +378,12 @@ async generateQingdanTuijian(name, bh, bt, bm) {
|
|
|
return data;
|
|
|
}
|
|
|
}
|
|
|
- async generateZjcs(name, bh) {
|
|
|
+ async generateZjcs(name, bh, navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/zjcs/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
},
|
|
|
body: JSON.stringify(
|
|
|
{
|
|
|
@@ -373,8 +393,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
|
|
|
)
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
@@ -382,16 +403,18 @@ async generateQingdanTuijian(name, bh, bt, bm) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- async generateFiles2() {
|
|
|
+ async generateFiles2(navigate) {
|
|
|
const response = await fetch(this.ip().concat( "/files2/"), {
|
|
|
method : "POST",
|
|
|
headers: {
|
|
|
- "Content-type": "application/json"
|
|
|
+ "Content-type": "application/json",
|
|
|
+ 'Authorization': `Bearer ${this.token_}`
|
|
|
}
|
|
|
});
|
|
|
if (!response.ok) {
|
|
|
- //const error = await response.json();
|
|
|
- console.error('error');
|
|
|
+ if (response.status == 401) {
|
|
|
+ navigate("/editor/signin");
|
|
|
+ }
|
|
|
} else {
|
|
|
const data = await response.json();
|
|
|
return data;
|