mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 09:34:31 +08:00
增加数据备份功能
This commit is contained in:
@@ -5,6 +5,7 @@ import config from '@/utils/config';
|
||||
import { request } from '@/utils/http';
|
||||
import CheckUpdate from './checkUpdate';
|
||||
import { SharedContext } from '@/layouts';
|
||||
import { saveAs } from 'file-saver';
|
||||
import './index.less';
|
||||
|
||||
const optionsWithDisabled = [
|
||||
@@ -76,6 +77,17 @@ const Other = ({
|
||||
});
|
||||
};
|
||||
|
||||
const exportData = () => {
|
||||
request
|
||||
.put(`${config.apiPrefix}system/data/export`, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
saveAs(res, 'data.tgz');
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getSystemConfig();
|
||||
}, []);
|
||||
@@ -127,6 +139,11 @@ const Other = ({
|
||||
</Button>
|
||||
</Input.Group>
|
||||
</Form.Item>
|
||||
<Form.Item label="数据备份还原" name="frequency">
|
||||
<Button type="primary" onClick={exportData}>
|
||||
备份
|
||||
</Button>
|
||||
</Form.Item>
|
||||
<Form.Item label="检查更新" name="update">
|
||||
<CheckUpdate systemInfo={systemInfo} socketMessage={socketMessage} />
|
||||
</Form.Item>
|
||||
|
||||
+13
-10
@@ -66,16 +66,19 @@ _request.interceptors.response.use(async (response) => {
|
||||
history.push('/login');
|
||||
}
|
||||
} else {
|
||||
const res = await response.clone().json();
|
||||
if (res.code !== 200) {
|
||||
const msg = res.message || res.data;
|
||||
msg &&
|
||||
message.error({
|
||||
content: msg,
|
||||
style: { maxWidth: 500, margin: '0 auto' },
|
||||
});
|
||||
}
|
||||
return res;
|
||||
try {
|
||||
const res = await response.clone().json();
|
||||
if (res.code !== 200) {
|
||||
const msg = res.message || res.data;
|
||||
msg &&
|
||||
message.error({
|
||||
content: msg,
|
||||
style: { maxWidth: 500, margin: '0 auto' },
|
||||
});
|
||||
}
|
||||
return res;
|
||||
} catch (error) { }
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user