mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-30 21:06:20 +08:00
修复订阅自动增加/删除任务默认值
This commit is contained in:
parent
7bce5c4f6a
commit
622fe2a8f8
|
@ -1,4 +1,5 @@
|
||||||
import { Subscription } from '../data/subscription';
|
import { Subscription } from '../data/subscription';
|
||||||
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
export function formatUrl(doc: Subscription) {
|
export function formatUrl(doc: Subscription) {
|
||||||
let url = doc.url;
|
let url = doc.url;
|
||||||
|
@ -33,11 +34,9 @@ export function formatCommand(doc: Subscription, url?: string) {
|
||||||
if (type === 'file') {
|
if (type === 'file') {
|
||||||
command += `raw "${_url}"`;
|
command += `raw "${_url}"`;
|
||||||
} else {
|
} else {
|
||||||
command += `repo "${_url}" "${whitelist || ''}" "${blacklist || ''}" "${
|
command += `repo "${_url}" "${whitelist || ''}" "${blacklist || ''}" "${dependences || ''
|
||||||
dependences || ''
|
}" "${branch || ''}" "${extensions || ''}" "${proxy || ''}" "${isNil(autoAddCron) ? true : Boolean(autoAddCron)
|
||||||
}" "${branch || ''}" "${extensions || ''}" "${proxy || ''}" "${
|
}" "${isNil(autoDelCron) ? true : Boolean(autoDelCron)}"`;
|
||||||
Boolean(autoAddCron) ?? ''
|
|
||||||
}" "${Boolean(autoDelCron) ?? ''}"`;
|
|
||||||
}
|
}
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class SubscriptionService {
|
||||||
['createdAt', 'DESC'],
|
['createdAt', 'DESC'],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
return result as any;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import cron_parser from 'cron-parser';
|
import cron_parser from 'cron-parser';
|
||||||
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const repoUrlRegx = /[^\/\:]+\/[^\/]+(?=\.git)/;
|
const repoUrlRegx = /[^\/\:]+\/[^\/]+(?=\.git)/;
|
||||||
|
@ -243,6 +244,14 @@ const SubscriptionModal = ({
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const formatParams = (sub) => {
|
||||||
|
return {
|
||||||
|
...sub,
|
||||||
|
autoAddCron: isNil(sub.autoAddCron) ? true : Boolean(sub.autoAddCron),
|
||||||
|
autoDelCron: isNil(sub.autoDelCron) ? true : Boolean(sub.autoDelCron),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
window.addEventListener('paste', onPaste);
|
window.addEventListener('paste', onPaste);
|
||||||
|
@ -252,7 +261,9 @@ const SubscriptionModal = ({
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.setFieldsValue(subscription || {});
|
form.setFieldsValue(
|
||||||
|
{ ...subscription, ...formatParams(subscription) } || {},
|
||||||
|
);
|
||||||
setType((subscription && subscription.type) || 'public-repo');
|
setType((subscription && subscription.type) || 'public-repo');
|
||||||
setScheduleType((subscription && subscription.schedule_type) || 'crontab');
|
setScheduleType((subscription && subscription.schedule_type) || 'crontab');
|
||||||
setPullType((subscription && subscription.pull_type) || 'ssh-key');
|
setPullType((subscription && subscription.pull_type) || 'ssh-key');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user