umi-request 替换为 axios

This commit is contained in:
whyour
2023-07-17 23:13:06 +08:00
parent bd166ee794
commit efd4f1d5ab
32 changed files with 215 additions and 214 deletions
+7 -13
View File
@@ -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) {
+8 -11
View File
@@ -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();
+5 -6
View File
@@ -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) {
+1 -3
View File
@@ -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) {
+6 -4
View File
@@ -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) {