|
@@ -45,10 +45,8 @@ export default function NodeConfigEditModal({
|
|
|
const [orderId, setOrderId] = useState('');
|
|
const [orderId, setOrderId] = useState('');
|
|
|
const [accountUsername, setAccountUsername] = useState('');
|
|
const [accountUsername, setAccountUsername] = useState('');
|
|
|
const [accountPassword, setAccountPassword] = useState('');
|
|
const [accountPassword, setAccountPassword] = useState('');
|
|
|
- const [supportPta, setSupportPta] = useState(false);
|
|
|
|
|
- const [expectedStartDate, setExpectedStartDate] = useState('');
|
|
|
|
|
- const [expectedEndDate, setExpectedEndDate] = useState('');
|
|
|
|
|
const [loginInterval, setLoginInterval] = useState<number | ''>('');
|
|
const [loginInterval, setLoginInterval] = useState<number | ''>('');
|
|
|
|
|
+ const [userPreferencesStr, setUserPreferencesStr] = useState('{}');
|
|
|
|
|
|
|
|
// Booker specifics
|
|
// Booker specifics
|
|
|
const [bookerAccountSource, setBookerAccountSource] = useState('');
|
|
const [bookerAccountSource, setBookerAccountSource] = useState('');
|
|
@@ -89,10 +87,10 @@ export default function NodeConfigEditModal({
|
|
|
setOrderId(config.order_id || '');
|
|
setOrderId(config.order_id || '');
|
|
|
setAccountUsername(config.account?.username || '');
|
|
setAccountUsername(config.account?.username || '');
|
|
|
setAccountPassword(config.account?.password || '');
|
|
setAccountPassword(config.account?.password || '');
|
|
|
- setSupportPta(!!config.user_preferences?.support_pta);
|
|
|
|
|
- setExpectedStartDate(config.user_preferences?.expected_start_date || '');
|
|
|
|
|
- setExpectedEndDate(config.user_preferences?.expected_end_date || '');
|
|
|
|
|
setLoginInterval(config.login_interval !== undefined ? config.login_interval : '');
|
|
setLoginInterval(config.login_interval !== undefined ? config.login_interval : '');
|
|
|
|
|
+ setUserPreferencesStr(
|
|
|
|
|
+ config.user_preferences ? JSON.stringify(config.user_preferences, null, 2) : '{}'
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
setBookerAccountSource(config.booker?.account_source || 'built-in');
|
|
setBookerAccountSource(config.booker?.account_source || 'built-in');
|
|
|
setBookerAccountPoolId(config.booker?.account_pool_id || '');
|
|
setBookerAccountPoolId(config.booker?.account_pool_id || '');
|
|
@@ -213,11 +211,15 @@ export default function NodeConfigEditModal({
|
|
|
if (entryType === 'standalone') {
|
|
if (entryType === 'standalone') {
|
|
|
if (orderId !== (config.order_id || '')) setObj['order_id'] = orderId;
|
|
if (orderId !== (config.order_id || '')) setObj['order_id'] = orderId;
|
|
|
if (accountUsername !== (config.account?.username || '')) setObj['account.username'] = accountUsername;
|
|
if (accountUsername !== (config.account?.username || '')) setObj['account.username'] = accountUsername;
|
|
|
- if (accountPassword && accountPassword !== (config.account?.password || '')) setObj['account.password'] = accountPassword;
|
|
|
|
|
|
|
+ if (accountPassword !== (config.account?.password || '')) setObj['account.password'] = accountPassword;
|
|
|
if (loginInterval !== '' && loginInterval !== config.login_interval) setObj['login_interval'] = Number(loginInterval);
|
|
if (loginInterval !== '' && loginInterval !== config.login_interval) setObj['login_interval'] = Number(loginInterval);
|
|
|
- if (supportPta !== !!config.user_preferences?.support_pta) setObj['user_preferences.support_pta'] = supportPta;
|
|
|
|
|
- if (expectedStartDate !== (config.user_preferences?.expected_start_date || '')) setObj['user_preferences.expected_start_date'] = expectedStartDate;
|
|
|
|
|
- if (expectedEndDate !== (config.user_preferences?.expected_end_date || '')) setObj['user_preferences.expected_end_date'] = expectedEndDate;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const parsedUserPref = userPreferencesStr.trim() ? JSON.parse(userPreferencesStr) : {};
|
|
|
|
|
+ if (JSON.stringify(parsedUserPref) !== JSON.stringify(config.user_preferences || {})) {
|
|
|
|
|
+ setObj['user_preferences'] = parsedUserPref;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (JSON.stringify(pluginConfig) !== JSON.stringify(config.plugin_config || {})) {
|
|
if (JSON.stringify(pluginConfig) !== JSON.stringify(config.plugin_config || {})) {
|
|
@@ -272,6 +274,17 @@ export default function NodeConfigEditModal({
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ if (entryType === 'standalone') {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (userPreferencesStr.trim()) {
|
|
|
|
|
+ JSON.parse(userPreferencesStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ toast.error('用户偏好 (user_preferences) JSON 格式错误,请检查语法');
|
|
|
|
|
+ setSaving(false);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
payload = calculateSparsePayload();
|
|
payload = calculateSparsePayload();
|
|
|
if (!payload.set && (!payload.clear || payload.clear.length === 0)) {
|
|
if (!payload.set && (!payload.clear || payload.clear.length === 0)) {
|
|
|
toast('未检测到任何字段变更', { icon: 'ℹ️' });
|
|
toast('未检测到任何字段变更', { icon: 'ℹ️' });
|
|
@@ -571,7 +584,7 @@ export default function NodeConfigEditModal({
|
|
|
<span className="font-black text-black uppercase">[ 02 // Standalone 偏好与凭证 ]</span>
|
|
<span className="font-black text-black uppercase">[ 02 // Standalone 偏好与凭证 ]</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
|
|
|
|
|
|
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
|
<div>
|
|
<div>
|
|
|
<label className="block text-[11px] font-bold text-black mb-1">关联订单号 (order_id)</label>
|
|
<label className="block text-[11px] font-bold text-black mb-1">关联订单号 (order_id)</label>
|
|
|
<input
|
|
<input
|
|
@@ -599,6 +612,30 @@ export default function NodeConfigEditModal({
|
|
|
className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-[11px] font-bold text-black mb-1">抢签密码 (password)</label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ placeholder="输入抢签密码"
|
|
|
|
|
+ value={accountPassword}
|
|
|
|
|
+ onChange={(e) => setAccountPassword(e.target.value)}
|
|
|
|
|
+ className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div className="pt-2 border-t border-black/20 space-y-1.5">
|
|
|
|
|
+ <div className="flex items-center justify-between">
|
|
|
|
|
+ <label className="block text-[11px] font-bold text-black">用户偏好 (user_preferences JSON)</label>
|
|
|
|
|
+ <span className="text-[10px] text-neutral-500 font-mono">支持自定义键值与可变结构</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <textarea
|
|
|
|
|
+ rows={3}
|
|
|
|
|
+ value={userPreferencesStr}
|
|
|
|
|
+ onChange={(e) => setUserPreferencesStr(e.target.value)}
|
|
|
|
|
+ placeholder="{}"
|
|
|
|
|
+ className="w-full p-2.5 font-mono text-xs border-2 border-black bg-neutral-50 focus:bg-white text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|