mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 17:54:32 +08:00
重构前端错误提示
This commit is contained in:
@@ -263,8 +263,8 @@ const Subscription = () => {
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}subscriptions/run`, { data: [record.id] })
|
||||
.then((data: any) => {
|
||||
if (data.code === 200) {
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
const i = result.findIndex((x) => x.id === record.id);
|
||||
if (i !== -1) {
|
||||
@@ -274,8 +274,6 @@ const Subscription = () => {
|
||||
});
|
||||
setValue(result);
|
||||
}
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -300,8 +298,8 @@ const Subscription = () => {
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}subscriptions/stop`, { data: [record.id] })
|
||||
.then((data: any) => {
|
||||
if (data.code === 200) {
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const result = [...value];
|
||||
const i = result.findIndex((x) => x.id === record.id);
|
||||
if (i !== -1) {
|
||||
@@ -312,8 +310,6 @@ const Subscription = () => {
|
||||
});
|
||||
setValue(result);
|
||||
}
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -327,9 +323,11 @@ const Subscription = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.get(`${config.apiPrefix}subscriptions?searchValue=${searchText}`)
|
||||
.then((data: any) => {
|
||||
setValue(data.data);
|
||||
setCurrentPage(1);
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
setValue(data);
|
||||
setCurrentPage(1);
|
||||
}
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
@@ -359,8 +357,8 @@ const Subscription = () => {
|
||||
onOk() {
|
||||
request
|
||||
.delete(`${config.apiPrefix}subscriptions`, { data: [record.id] })
|
||||
.then((data: any) => {
|
||||
if (data.code === 200) {
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('删除成功');
|
||||
const result = [...value];
|
||||
const i = result.findIndex((x) => x.id === record.id);
|
||||
@@ -368,8 +366,6 @@ const Subscription = () => {
|
||||
result.splice(i, 1);
|
||||
setValue(result);
|
||||
}
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -402,8 +398,8 @@ const Subscription = () => {
|
||||
data: [record.id],
|
||||
},
|
||||
)
|
||||
.then((data: any) => {
|
||||
if (data.code === 200) {
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
const newStatus = record.is_disabled === 1 ? 0 : 1;
|
||||
const result = [...value];
|
||||
const i = result.findIndex((x) => x.id === record.id);
|
||||
@@ -414,8 +410,6 @@ const Subscription = () => {
|
||||
});
|
||||
setValue(result);
|
||||
}
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -36,11 +36,12 @@ const SubscriptionLogModal = ({
|
||||
? logUrl
|
||||
: `${config.apiPrefix}subscriptions/${subscription.id}/log`,
|
||||
)
|
||||
.then((data: any) => {
|
||||
.then(({ code, data }) => {
|
||||
if (
|
||||
code === 200 &&
|
||||
localStorage.getItem('logSubscription') === String(subscription.id)
|
||||
) {
|
||||
const log = data.data as string;
|
||||
const log = data as string;
|
||||
setValue(log || '暂无日志');
|
||||
setExecuting(log && !log.includes('执行结束'));
|
||||
if (log && !log.includes('执行结束')) {
|
||||
|
||||
@@ -40,8 +40,6 @@ const SubscriptionModal = ({
|
||||
if (code === 200) {
|
||||
message.success(subscription ? '更新订阅成功' : '新建订阅成功');
|
||||
handleCancel(data);
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error: any) {
|
||||
@@ -208,8 +206,8 @@ const SubscriptionModal = ({
|
||||
type === 'raw'
|
||||
? 'file'
|
||||
: url.startsWith('http')
|
||||
? 'public-repo'
|
||||
: 'private-repo';
|
||||
? 'public-repo'
|
||||
: 'private-repo';
|
||||
|
||||
form.setFieldsValue({
|
||||
type: _type,
|
||||
@@ -252,9 +250,7 @@ const SubscriptionModal = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
subscription ? '编辑订阅' : '新建订阅'
|
||||
}
|
||||
title={subscription ? '编辑订阅' : '新建订阅'}
|
||||
open={visible}
|
||||
forceRender
|
||||
centered
|
||||
@@ -274,7 +270,10 @@ const SubscriptionModal = ({
|
||||
>
|
||||
<Form form={form} name="form_in_modal" layout="vertical">
|
||||
<Form.Item name="name" label="名称">
|
||||
<Input placeholder="支持拷贝ql repo/raw命令,粘贴导入" onPaste={onNamePaste} />
|
||||
<Input
|
||||
placeholder="支持拷贝ql repo/raw命令,粘贴导入"
|
||||
onPaste={onNamePaste}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="type"
|
||||
|
||||
Reference in New Issue
Block a user