mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-18 02:14:32 +08:00
umi-request 替换为 axios
This commit is contained in:
@@ -51,9 +51,7 @@ const Config = () => {
|
||||
: value;
|
||||
|
||||
request
|
||||
.post(`${config.apiPrefix}configs/save`, {
|
||||
data: { content, name: select },
|
||||
})
|
||||
.post(`${config.apiPrefix}configs/save`, { content, name: select })
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('保存成功');
|
||||
|
||||
@@ -184,11 +184,9 @@ const CronDetailModal = ({
|
||||
return new Promise((resolve, reject) => {
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts`, {
|
||||
data: {
|
||||
filename: scriptInfo.filename,
|
||||
path: scriptInfo.parent || '',
|
||||
content,
|
||||
},
|
||||
filename: scriptInfo.filename,
|
||||
path: scriptInfo.parent || '',
|
||||
content,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -220,7 +218,7 @@ const CronDetailModal = ({
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/run`, { data: [currentCron.id] })
|
||||
.put(`${config.apiPrefix}crons/run`, [currentCron.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
setCurrentCron({ ...currentCron, status: CrontabStatus.running });
|
||||
@@ -250,7 +248,7 @@ const CronDetailModal = ({
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/stop`, { data: [currentCron.id] })
|
||||
.put(`${config.apiPrefix}crons/stop`, [currentCron.id] )
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
setCurrentCron({ ...currentCron, status: CrontabStatus.idle });
|
||||
@@ -282,9 +280,7 @@ const CronDetailModal = ({
|
||||
`${config.apiPrefix}crons/${
|
||||
currentCron.isDisabled === 1 ? 'enable' : 'disable'
|
||||
}`,
|
||||
{
|
||||
data: [currentCron.id],
|
||||
},
|
||||
[currentCron.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -320,9 +316,7 @@ const CronDetailModal = ({
|
||||
`${config.apiPrefix}crons/${
|
||||
currentCron.isPinned === 1 ? 'unpin' : 'pin'
|
||||
}`,
|
||||
{
|
||||
data: [currentCron.id],
|
||||
},
|
||||
[currentCron.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -457,7 +457,7 @@ const Crontab = () => {
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/run`, { data: [record.id] })
|
||||
.put(`${config.apiPrefix}crons/run`, [record.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
@@ -492,7 +492,7 @@ const Crontab = () => {
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/stop`, { data: [record.id] })
|
||||
.put(`${config.apiPrefix}crons/stop`, [record.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
@@ -533,9 +533,7 @@ const Crontab = () => {
|
||||
`${config.apiPrefix}crons/${
|
||||
record.isDisabled === 1 ? 'enable' : 'disable'
|
||||
}`,
|
||||
{
|
||||
data: [record.id],
|
||||
},
|
||||
[record.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -577,9 +575,7 @@ const Crontab = () => {
|
||||
`${config.apiPrefix}crons/${
|
||||
record.isPinned === 1 ? 'unpin' : 'pin'
|
||||
}`,
|
||||
{
|
||||
data: [record.id],
|
||||
},
|
||||
[record.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -725,9 +721,10 @@ const Crontab = () => {
|
||||
content: <>确认{OperationName[operationStatus]}选中的定时任务吗</>,
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/${OperationPath[operationStatus]}`, {
|
||||
data: selectedRowIds,
|
||||
})
|
||||
.put(
|
||||
`${config.apiPrefix}crons/${OperationPath[operationStatus]}`,
|
||||
selectedRowIds,
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
getCrons();
|
||||
|
||||
@@ -25,9 +25,10 @@ const CronModal = ({
|
||||
payload.id = cron.id;
|
||||
}
|
||||
try {
|
||||
const { code, data } = await request[method](`${config.apiPrefix}crons`, {
|
||||
data: payload,
|
||||
});
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}crons`,
|
||||
payload,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
message.success(cron ? '更新Cron成功' : '新建Cron成功');
|
||||
@@ -130,9 +131,7 @@ const CronLabelModal = ({
|
||||
try {
|
||||
const { code, data } = await request[action](
|
||||
`${config.apiPrefix}crons/labels`,
|
||||
{
|
||||
data: payload,
|
||||
},
|
||||
payload,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
|
||||
@@ -80,9 +80,7 @@ const ViewCreateModal = ({
|
||||
try {
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}crons/views`,
|
||||
{
|
||||
data: view ? { ...values, id: view.id } : values,
|
||||
},
|
||||
view ? { ...values, id: view.id } : values,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
|
||||
@@ -168,9 +168,9 @@ const ViewManageModal = ({
|
||||
|
||||
const onShowChange = (checked: boolean, record: any, index: number) => {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/views/${checked ? 'enable' : 'disable'}`, {
|
||||
data: [record.id],
|
||||
})
|
||||
.put(`${config.apiPrefix}crons/views/${checked ? 'enable' : 'disable'}`, [
|
||||
record.id,
|
||||
])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const _list = [...list];
|
||||
@@ -195,7 +195,9 @@ const ViewManageModal = ({
|
||||
const dragRow = list[dragIndex];
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/views/move`, {
|
||||
data: { fromIndex: dragIndex, toIndex: hoverIndex, id: dragRow.id },
|
||||
fromIndex: dragIndex,
|
||||
toIndex: hoverIndex,
|
||||
id: dragRow.id,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -269,9 +269,7 @@ const Dependence = () => {
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}dependencies/reinstall`, {
|
||||
data: [record.id],
|
||||
})
|
||||
.put(`${config.apiPrefix}dependencies/reinstall`, [record.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
handleDependence(data[0]);
|
||||
@@ -342,9 +340,7 @@ const Dependence = () => {
|
||||
content: <>确认重新安装选中的依赖吗</>,
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}dependencies/reinstall`, {
|
||||
data: selectedRowIds,
|
||||
})
|
||||
.put(`${config.apiPrefix}dependencies/reinstall`, selectedRowIds)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
setSelectedRowIds([]);
|
||||
|
||||
@@ -48,9 +48,7 @@ const DependenceModal = ({
|
||||
try {
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}dependencies`,
|
||||
{
|
||||
data: payload,
|
||||
},
|
||||
payload,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
@@ -122,7 +120,11 @@ const DependenceModal = ({
|
||||
name="name"
|
||||
label="名称"
|
||||
rules={[
|
||||
{ required: true, message: '请输入依赖名称,支持指定版本', whitespace: true },
|
||||
{
|
||||
required: true,
|
||||
message: '请输入依赖名称,支持指定版本',
|
||||
whitespace: true,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.TextArea
|
||||
|
||||
@@ -48,7 +48,8 @@ const Diff = () => {
|
||||
|
||||
request
|
||||
.post(`${config.apiPrefix}configs/save`, {
|
||||
data: { content, name: current },
|
||||
content,
|
||||
name: current,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
Vendored
+2
-4
@@ -19,10 +19,8 @@ const EditNameModal = ({
|
||||
setLoading(true);
|
||||
try {
|
||||
const { code, data } = await request.put(`${config.apiPrefix}envs/name`, {
|
||||
data: {
|
||||
ids,
|
||||
name: values.name,
|
||||
},
|
||||
ids,
|
||||
name: values.name,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
|
||||
Vendored
+8
-10
@@ -248,9 +248,7 @@ const Env = () => {
|
||||
`${config.apiPrefix}envs/${
|
||||
record.status === Status.已禁用 ? 'enable' : 'disable'
|
||||
}`,
|
||||
{
|
||||
data: [record.id],
|
||||
},
|
||||
[record.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -388,7 +386,8 @@ const Env = () => {
|
||||
const dragRow = value[dragIndex];
|
||||
request
|
||||
.put(`${config.apiPrefix}envs/${dragRow.id}/move`, {
|
||||
data: { fromIndex: dragIndex, toIndex: hoverIndex },
|
||||
fromIndex: dragIndex,
|
||||
toIndex: hoverIndex,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -438,9 +437,10 @@ const Env = () => {
|
||||
content: <>确认{OperationName[operationStatus]}选中的变量吗</>,
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}envs/${OperationPath[operationStatus]}`, {
|
||||
data: selectedRowIds,
|
||||
})
|
||||
.put(
|
||||
`${config.apiPrefix}envs/${OperationPath[operationStatus]}`,
|
||||
selectedRowIds,
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
getEnvs();
|
||||
@@ -477,9 +477,7 @@ const Env = () => {
|
||||
try {
|
||||
const { code, data } = await request.post(
|
||||
`${config.apiPrefix}envs/upload`,
|
||||
{
|
||||
data: formData,
|
||||
},
|
||||
formData,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
|
||||
Vendored
+4
-3
@@ -37,9 +37,10 @@ const EnvModal = ({
|
||||
payload = { ...values, id: env.id };
|
||||
}
|
||||
try {
|
||||
const { code, data } = await request[method](`${config.apiPrefix}envs`, {
|
||||
data: payload,
|
||||
});
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}envs`,
|
||||
payload,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
message.success(env ? '更新变量成功' : '新建变量成功');
|
||||
|
||||
@@ -36,10 +36,8 @@ const Initialization = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.put(`${config.apiPrefix}user/init`, {
|
||||
data: {
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
},
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -53,9 +51,7 @@ const Initialization = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.put(`${config.apiPrefix}user/notification/init`, {
|
||||
data: {
|
||||
...values,
|
||||
},
|
||||
values,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -35,10 +35,8 @@ const Login = () => {
|
||||
setWaitTime(null);
|
||||
request
|
||||
.post(`${config.apiPrefix}user/login`, {
|
||||
data: {
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
},
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
})
|
||||
.then((data) => {
|
||||
checkResponse(data, values);
|
||||
@@ -54,7 +52,8 @@ const Login = () => {
|
||||
setVerifying(true);
|
||||
request
|
||||
.put(`${config.apiPrefix}user/two-factor/login`, {
|
||||
data: { ...loginInfo, code: values.code },
|
||||
...loginInfo,
|
||||
code: values.code,
|
||||
})
|
||||
.then((data: any) => {
|
||||
checkResponse(data);
|
||||
|
||||
@@ -86,11 +86,9 @@ const EditModal = ({
|
||||
const content = editorRef.current.getValue().replace(/\r\n/g, '\n');
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts/run`, {
|
||||
data: {
|
||||
filename: cNode.title,
|
||||
path: cNode.parent || '',
|
||||
content,
|
||||
},
|
||||
filename: cNode.title,
|
||||
path: cNode.parent || '',
|
||||
content,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -106,11 +104,9 @@ const EditModal = ({
|
||||
}
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts/stop`, {
|
||||
data: {
|
||||
filename: cNode.title,
|
||||
path: cNode.parent || '',
|
||||
pid: currentPid,
|
||||
},
|
||||
filename: cNode.title,
|
||||
path: cNode.parent || '',
|
||||
pid: currentPid,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -44,9 +44,7 @@ const EditScriptNameModal = ({
|
||||
formData.append('content', '');
|
||||
formData.append('directory', directory);
|
||||
request
|
||||
.post(`${config.apiPrefix}scripts`, {
|
||||
data: formData,
|
||||
})
|
||||
.post(`${config.apiPrefix}scripts`, formData)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success(directory ? '新建文件夹成功' : '新建文件成功');
|
||||
|
||||
@@ -223,11 +223,9 @@ const Script = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts`, {
|
||||
data: {
|
||||
filename: currentNode.title,
|
||||
path: currentNode.parent || '',
|
||||
content,
|
||||
},
|
||||
filename: currentNode.title,
|
||||
path: currentNode.parent || '',
|
||||
content,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -341,9 +339,7 @@ const Script = () => {
|
||||
const downloadFile = () => {
|
||||
request
|
||||
.post(`${config.apiPrefix}scripts/download`, {
|
||||
data: {
|
||||
filename: currentNode.title,
|
||||
},
|
||||
filename: currentNode.title,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -21,11 +21,9 @@ const RenameModal = ({
|
||||
const { code, data } = await request.put(
|
||||
`${config.apiPrefix}scripts/rename`,
|
||||
{
|
||||
data: {
|
||||
filename: currentNode.title,
|
||||
path: currentNode.parent || '',
|
||||
newFilename: values.name,
|
||||
},
|
||||
filename: currentNode.title,
|
||||
path: currentNode.parent || '',
|
||||
newFilename: values.name,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ const SaveModal = ({
|
||||
setLoading(true);
|
||||
const payload = { ...file, ...values, originFilename: file.title };
|
||||
request
|
||||
.post(`${config.apiPrefix}scripts`, {
|
||||
data: payload,
|
||||
})
|
||||
.post(`${config.apiPrefix}scripts`, payload)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('保存文件成功');
|
||||
|
||||
@@ -19,9 +19,7 @@ const SettingModal = ({
|
||||
setLoading(true);
|
||||
const payload = { ...file, ...values };
|
||||
request
|
||||
.post(`${config.apiPrefix}scripts`, {
|
||||
data: payload,
|
||||
})
|
||||
.post(`${config.apiPrefix}scripts`, payload)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('保存文件成功');
|
||||
|
||||
@@ -23,9 +23,10 @@ const AppModal = ({
|
||||
payload.id = app.id;
|
||||
}
|
||||
try {
|
||||
const { code, data } = await request[method](`${config.apiPrefix}apps`, {
|
||||
data: payload,
|
||||
});
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}apps`,
|
||||
payload,
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
message.success(app ? '更新应用成功' : '新建应用成功');
|
||||
|
||||
@@ -129,7 +129,7 @@ const CheckUpdate = ({ socketMessage, systemInfo }: any) => {
|
||||
okText: '重启',
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}system/reload`, { data: { type: 'system' } })
|
||||
.put(`${config.apiPrefix}system/reload`, { type: 'system' })
|
||||
.then((_data: any) => {
|
||||
message.success({
|
||||
content: (
|
||||
|
||||
@@ -20,9 +20,7 @@ const NotificationSetting = ({ data }: any) => {
|
||||
|
||||
request
|
||||
.put(`${config.apiPrefix}user/notification`, {
|
||||
data: {
|
||||
...values,
|
||||
},
|
||||
values,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
+19
-36
@@ -19,6 +19,7 @@ import { saveAs } from 'file-saver';
|
||||
import './index.less';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import Countdown from 'antd/lib/statistic/Countdown';
|
||||
import useProgress from './progress';
|
||||
|
||||
const optionsWithDisabled = [
|
||||
{ label: '亮色', value: 'light' },
|
||||
@@ -39,6 +40,8 @@ const Other = ({
|
||||
const [form] = Form.useForm();
|
||||
const modalRef = useRef<any>();
|
||||
const [exportLoading, setExportLoading] = useState(false);
|
||||
const showUploadProgress = useProgress('上传');
|
||||
const showDownloadProgress = useProgress('下载');
|
||||
|
||||
const {
|
||||
enable: enableDarkMode,
|
||||
@@ -78,9 +81,7 @@ const Other = ({
|
||||
|
||||
const updateSystemConfig = () => {
|
||||
request
|
||||
.put(`${config.apiPrefix}system/config`, {
|
||||
data: { ...systemConfig },
|
||||
})
|
||||
.put(`${config.apiPrefix}system/config`, systemConfig)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('更新成功');
|
||||
@@ -94,7 +95,18 @@ const Other = ({
|
||||
const exportData = () => {
|
||||
setExportLoading(true);
|
||||
request
|
||||
.put(`${config.apiPrefix}system/data/export`, { responseType: 'blob' })
|
||||
.put<Blob>(
|
||||
`${config.apiPrefix}system/data/export`,
|
||||
{},
|
||||
{
|
||||
responseType: 'blob',
|
||||
onDownloadProgress: (e) => {
|
||||
if (e.progress) {
|
||||
showDownloadProgress(parseFloat((e.progress * 100).toFixed(1)));
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
.then((res) => {
|
||||
saveAs(res, 'data.tgz');
|
||||
})
|
||||
@@ -104,34 +116,6 @@ const Other = ({
|
||||
.finally(() => setExportLoading(false));
|
||||
};
|
||||
|
||||
const showUploadModal = (progress: number) => {
|
||||
if (modalRef.current) {
|
||||
modalRef.current.update({
|
||||
content: (
|
||||
<Progress
|
||||
style={{ display: 'flex', justifyContent: 'center' }}
|
||||
type="circle"
|
||||
percent={progress}
|
||||
/>
|
||||
),
|
||||
});
|
||||
} else {
|
||||
modalRef.current = Modal.info({
|
||||
width: 600,
|
||||
maskClosable: false,
|
||||
title: '上传中...',
|
||||
centered: true,
|
||||
content: (
|
||||
<Progress
|
||||
style={{ display: 'flex', justifyContent: 'center' }}
|
||||
type="circle"
|
||||
percent={progress}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const showReloadModal = () => {
|
||||
Modal.confirm({
|
||||
width: 600,
|
||||
@@ -142,8 +126,8 @@ const Other = ({
|
||||
okText: '重启',
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}system/reload`, { data: { type: 'data' } })
|
||||
.then((_data: any) => {
|
||||
.put(`${config.apiPrefix}system/reload`, { type: 'data' })
|
||||
.then(() => {
|
||||
message.success({
|
||||
content: (
|
||||
<span>
|
||||
@@ -231,8 +215,7 @@ const Other = ({
|
||||
action="/api/system/data/import"
|
||||
onChange={(e) => {
|
||||
if (e.event?.percent) {
|
||||
const percent = parseFloat(e.event?.percent.toFixed(1));
|
||||
showUploadModal(percent);
|
||||
showUploadProgress(parseFloat(e.event?.percent.toFixed(1)));
|
||||
if (e.event?.percent === 100) {
|
||||
showReloadModal();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Modal, Progress } from 'antd';
|
||||
import { useRef } from 'react';
|
||||
|
||||
export default function useProgress(title: string) {
|
||||
const modalRef = useRef<ReturnType<typeof Modal.info>>();
|
||||
|
||||
const ProgressElement = ({ percent }: { percent: number }) => (
|
||||
<Progress
|
||||
style={{ display: 'flex', justifyContent: 'center' }}
|
||||
type="circle"
|
||||
percent={percent}
|
||||
/>
|
||||
);
|
||||
|
||||
const showProgress = (percent: number) => {
|
||||
if (modalRef.current) {
|
||||
modalRef.current.update({
|
||||
title: `${title}${percent >= 100 ? '成功' : '中...'}`,
|
||||
content: <ProgressElement percent={percent} />,
|
||||
});
|
||||
} else {
|
||||
modalRef.current = Modal.info({
|
||||
width: 600,
|
||||
maskClosable: false,
|
||||
title: `${title}${percent >= 100 ? '成功' : '中...'}`,
|
||||
centered: true,
|
||||
content: <ProgressElement percent={percent} />,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return showProgress;
|
||||
}
|
||||
@@ -22,10 +22,8 @@ const SecuritySettings = ({ user, userChange }: any) => {
|
||||
const handleOk = (values: any) => {
|
||||
request
|
||||
.put(`${config.apiPrefix}user`, {
|
||||
data: {
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
},
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
@@ -64,7 +62,7 @@ const SecuritySettings = ({ user, userChange }: any) => {
|
||||
const completeTowFactor = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.put(`${config.apiPrefix}user/two-factor/active`, { data: { code } })
|
||||
.put(`${config.apiPrefix}user/two-factor/active`, { code })
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
if (data) {
|
||||
|
||||
@@ -254,7 +254,7 @@ const Subscription = () => {
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}subscriptions/run`, { data: [record.id] })
|
||||
.put(`${config.apiPrefix}subscriptions/run`, [record.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
@@ -289,7 +289,7 @@ const Subscription = () => {
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}subscriptions/stop`, { data: [record.id] })
|
||||
.put(`${config.apiPrefix}subscriptions/stop`, [record.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
@@ -386,9 +386,7 @@ const Subscription = () => {
|
||||
`${config.apiPrefix}subscriptions/${
|
||||
record.is_disabled === 1 ? 'enable' : 'disable'
|
||||
}`,
|
||||
{
|
||||
data: [record.id],
|
||||
},
|
||||
[record.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -47,9 +47,7 @@ const SubscriptionModal = ({
|
||||
try {
|
||||
const { code, data } = await request[method](
|
||||
`${config.apiPrefix}subscriptions`,
|
||||
{
|
||||
data: payload,
|
||||
},
|
||||
payload,
|
||||
);
|
||||
if (code === 200) {
|
||||
message.success(subscription ? '更新订阅成功' : '新建订阅成功');
|
||||
|
||||
Reference in New Issue
Block a user