重构前端错误提示

This commit is contained in:
whyour
2022-09-22 23:59:23 +08:00
parent e274d3e2f9
commit f2fea47336
33 changed files with 347 additions and 363 deletions
+22 -10
View File
@@ -22,15 +22,23 @@ const Diff = () => {
const editorRef = useRef<any>(null);
const getConfig = () => {
request.get(`${config.apiPrefix}configs/${current}`).then((data) => {
setCurrentValue(data.data);
});
request
.get(`${config.apiPrefix}configs/${current}`)
.then(({ code, data }) => {
if (code === 200) {
setCurrentValue(data);
}
});
};
const getSample = () => {
request.get(`${config.apiPrefix}configs/${origin}`).then((data) => {
setOriginValue(data.data);
});
request
.get(`${config.apiPrefix}configs/${origin}`)
.then(({ code, data }) => {
if (code === 200) {
setOriginValue(data);
}
});
};
const updateConfig = () => {
@@ -42,8 +50,10 @@ const Diff = () => {
.post(`${config.apiPrefix}configs/save`, {
data: { content, name: current },
})
.then((data: any) => {
message.success(data.message);
.then(({ code, data }) => {
if (code === 200) {
message.success('保存成功');
}
});
};
@@ -51,8 +61,10 @@ const Diff = () => {
setLoading(true);
request
.get(`${config.apiPrefix}configs/files`)
.then((data: any) => {
setFiles(data.data);
.then(({ code, data }) => {
if (code === 200) {
setFiles(data);
}
})
.finally(() => setLoading(false));
};