NodeConfigCreateWizardModal.tsx 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. // src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx
  2. 'use client';
  3. import React, { useState, useEffect } from 'react';
  4. import { toast } from 'react-hot-toast';
  5. import {
  6. NodeConfigEntryType,
  7. ProviderItem,
  8. AppointmentTypeItem,
  9. PluginConfig,
  10. NodeConfigurationItem,
  11. } from '@/types';
  12. import { providerService } from '@/lib/services/providerService';
  13. import { nodeConfigService } from '@/lib/services/nodeConfigService';
  14. import { accountService } from '@/lib/services/accountService';
  15. import { proxyService } from '@/lib/services/proxyService';
  16. import AppointmentTypeEditor from './AppointmentTypeEditor';
  17. import RegisteredNodeSelect from '@/components/admin/node-configurations/RegisteredNodeSelect';
  18. import { LOCAL_PROXY_POOLS, COMMON_WEBSITES } from './nodeConfigConstants';
  19. interface NodeConfigCreateWizardModalProps {
  20. isOpen: boolean;
  21. onClose: () => void;
  22. entryType: NodeConfigEntryType;
  23. onSuccess: () => void;
  24. }
  25. export default function NodeConfigCreateWizardModal({
  26. isOpen,
  27. onClose,
  28. entryType,
  29. onSuccess,
  30. }: NodeConfigCreateWizardModalProps) {
  31. const [step, setStep] = useState<1 | 2 | 3>(1);
  32. const [providers, setProviders] = useState<ProviderItem[]>([]);
  33. const [selectedProviderName, setSelectedProviderName] = useState<string>('');
  34. const [loadingProviders, setLoadingProviders] = useState(false);
  35. const [submitting, setSubmitting] = useState(false);
  36. // 数据库获取的账号池与代理池
  37. const [accountPools, setAccountPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
  38. const [cloudProxyPools, setCloudProxyPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
  39. const [customBookerAccountPool, setCustomBookerAccountPool] = useState(false);
  40. const [customSentinelAccountPool, setCustomSentinelAccountPool] = useState(false);
  41. // Step 1: Base & Identity
  42. const [nodeId, setNodeId] = useState('node01');
  43. const [identifier, setIdentifier] = useState('');
  44. const [website, setWebsite] = useState('');
  45. const [needAccount, setNeedAccount] = useState(1);
  46. const [needProxy, setNeedProxy] = useState(1);
  47. const [proxyPoolStr, setProxyPoolStr] = useState('cloud:proxy-cheap');
  48. const [proxyCd, setProxyCd] = useState(300);
  49. const [sessionMaxLife, setSessionMaxLife] = useState(1800);
  50. const [activeTimeStart, setActiveTimeStart] = useState('00:00');
  51. const [activeTimeEnd, setActiveTimeEnd] = useState('23:59');
  52. // Standalone specifics
  53. const [orderId, setOrderId] = useState('');
  54. const [accountUsername, setAccountUsername] = useState('');
  55. const [accountPassword, setAccountPassword] = useState('');
  56. const [supportPta, setSupportPta] = useState(false);
  57. const [expectedStartDate, setExpectedStartDate] = useState('');
  58. const [expectedEndDate, setExpectedEndDate] = useState('');
  59. const [loginInterval, setLoginInterval] = useState(1800);
  60. // Booker specifics
  61. const [bookerAccountSource, setBookerAccountSource] = useState('built-in');
  62. const [bookerAccountPoolId, setBookerAccountPoolId] = useState('');
  63. const [bookerTargetInstances, setBookerTargetInstances] = useState(1);
  64. const [bookerAccountCd, setBookerAccountCd] = useState(10800);
  65. const [bookerCooldown, setBookerCooldown] = useState(30);
  66. const [bookerMaxBookings, setBookerMaxBookings] = useState(8);
  67. // Sentinel specifics
  68. const [sentinelAccountSource, setSentinelAccountSource] = useState('built-in');
  69. const [sentinelAccountPoolId, setSentinelAccountPoolId] = useState('');
  70. const [sentinelTargetInstances, setSentinelTargetInstances] = useState(1);
  71. const [sentinelSignalTtl, setSentinelSignalTtl] = useState(30);
  72. // Query Wait
  73. const [queryWaitMode, setQueryWaitMode] = useState<'Random' | 'Fixed'>('Random');
  74. const [fixedWait, setFixedWait] = useState(10);
  75. const [randomMin, setRandomMin] = useState(60);
  76. const [randomMax, setRandomMax] = useState(300);
  77. // Plugin config
  78. const [pluginConfig, setPluginConfig] = useState<PluginConfig>({
  79. lib_path: 'plugins',
  80. plugin_name: '',
  81. plugin_bin: '',
  82. plugin_class: '',
  83. plugin_proto: 'IPlugin',
  84. });
  85. // Appointment types & free config
  86. const [appointmentTypes, setAppointmentTypes] = useState<AppointmentTypeItem[]>([]);
  87. const [freeConfigStr, setFreeConfigStr] = useState('{}');
  88. useEffect(() => {
  89. if (isOpen) {
  90. setStep(1);
  91. fetchEnabledProviders();
  92. fetchDbPools();
  93. resetForm();
  94. }
  95. }, [isOpen, entryType]);
  96. const fetchDbPools = async () => {
  97. try {
  98. const [accRes, proxyRes] = await Promise.allSettled([
  99. accountService.getPools(),
  100. proxyService.getPools(),
  101. ]);
  102. if (accRes.status === 'fulfilled' && accRes.value?.data) {
  103. setAccountPools(Array.isArray(accRes.value.data) ? accRes.value.data : []);
  104. }
  105. if (proxyRes.status === 'fulfilled' && proxyRes.value?.data) {
  106. setCloudProxyPools(Array.isArray(proxyRes.value.data) ? proxyRes.value.data : []);
  107. }
  108. } catch (err) {
  109. console.error('Failed to fetch pools from DB:', err);
  110. }
  111. };
  112. const addProxyPoolTag = (tagToAdd: string) => {
  113. if (!tagToAdd) return;
  114. const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
  115. if (!current.includes(tagToAdd)) {
  116. current.push(tagToAdd);
  117. setProxyPoolStr(current.join(', '));
  118. }
  119. };
  120. const removeProxyPoolTag = (tagToRemove: string) => {
  121. const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
  122. const updated = current.filter((t) => t !== tagToRemove);
  123. setProxyPoolStr(updated.join(', '));
  124. };
  125. // 仅筛选出支持当前 entryType 角色的服务商模板
  126. const eligibleProviders = providers.filter(
  127. (p) => p.role_templates && Boolean(p.role_templates[entryType])
  128. );
  129. const fetchEnabledProviders = async () => {
  130. setLoadingProviders(true);
  131. try {
  132. const res = await providerService.getList({ enabled_only: true });
  133. if (res.code === 0 && res.data) {
  134. const list = Array.isArray(res.data) ? res.data : [];
  135. setProviders(list);
  136. const matching = list.filter(
  137. (p) => p.role_templates && Boolean(p.role_templates[entryType])
  138. );
  139. if (matching.length > 0 && !selectedProviderName) {
  140. handleProviderSelect(matching[0].name, list, false);
  141. }
  142. }
  143. } catch (e) {
  144. console.error('Failed to fetch providers:', e);
  145. } finally {
  146. setLoadingProviders(false);
  147. }
  148. };
  149. const resetForm = () => {
  150. setSelectedProviderName('');
  151. setNodeId('');
  152. setIdentifier('');
  153. setWebsite('');
  154. setNeedAccount(1);
  155. setNeedProxy(1);
  156. setProxyPoolStr('');
  157. setProxyCd(300);
  158. setSessionMaxLife(1800);
  159. setActiveTimeStart('00:00');
  160. setActiveTimeEnd('23:59');
  161. setOrderId('');
  162. setAccountUsername('');
  163. setAccountPassword('');
  164. setSupportPta(false);
  165. setExpectedStartDate('');
  166. setExpectedEndDate('');
  167. setLoginInterval(1800);
  168. setBookerAccountSource('built-in');
  169. setBookerAccountPoolId('');
  170. setBookerTargetInstances(1);
  171. setBookerAccountCd(10800);
  172. setBookerCooldown(300);
  173. setBookerMaxBookings(8);
  174. setCustomBookerAccountPool(false);
  175. setSentinelAccountSource('built-in');
  176. setSentinelAccountPoolId('');
  177. setSentinelTargetInstances(1);
  178. setSentinelSignalTtl(30);
  179. setCustomSentinelAccountPool(false);
  180. setQueryWaitMode('Random');
  181. setFixedWait(10);
  182. setRandomMin(60);
  183. setRandomMax(300);
  184. setPluginConfig({
  185. lib_path: 'plugins',
  186. plugin_name: '',
  187. plugin_bin: '',
  188. plugin_proto: 'IPlugin',
  189. });
  190. setAppointmentTypes([]);
  191. setFreeConfigStr('{}');
  192. };
  193. const handleProviderSelect = (providerName: string, providerList = providers, showToast = true) => {
  194. setSelectedProviderName(providerName);
  195. const p = providerList.find((item) => item.name === providerName);
  196. if (!p) return;
  197. if (p.plugin_config) {
  198. setPluginConfig({
  199. lib_path: p.plugin_config.lib_path || 'plugins',
  200. plugin_name: p.plugin_config.plugin_name || '',
  201. plugin_bin: p.plugin_config.plugin_bin || '',
  202. plugin_class: p.plugin_config.plugin_class || '',
  203. plugin_proto: p.plugin_config.plugin_proto || 'IPlugin',
  204. });
  205. }
  206. const roleTpl = p.role_templates?.[entryType];
  207. if (roleTpl) {
  208. if (roleTpl.proxy_cd !== undefined) setProxyCd(Number(roleTpl.proxy_cd));
  209. if (roleTpl.session_max_life !== undefined) setSessionMaxLife(Number(roleTpl.session_max_life));
  210. if (roleTpl.login_interval !== undefined) setLoginInterval(Number(roleTpl.login_interval));
  211. if (entryType === 'booker') {
  212. if (roleTpl['booker.account_source'] !== undefined) setBookerAccountSource(roleTpl['booker.account_source']);
  213. if (roleTpl['booker.account_pool_id'] !== undefined) setBookerAccountPoolId(roleTpl['booker.account_pool_id']);
  214. if (roleTpl['booker.account_cd'] !== undefined) setBookerAccountCd(Number(roleTpl['booker.account_cd']));
  215. if (roleTpl['booker.target_instances'] !== undefined) setBookerTargetInstances(Number(roleTpl['booker.target_instances']));
  216. if (roleTpl['booker.booking_cooldown'] !== undefined) setBookerCooldown(Number(roleTpl['booker.booking_cooldown']));
  217. if (roleTpl['booker.max_bookings_per_account'] !== undefined) setBookerMaxBookings(Number(roleTpl['booker.max_bookings_per_account']));
  218. } else if (entryType === 'sentinel') {
  219. if (roleTpl['sentinel.account_source'] !== undefined) setSentinelAccountSource(roleTpl['sentinel.account_source']);
  220. if (roleTpl['sentinel.account_pool_id'] !== undefined) setSentinelAccountPoolId(roleTpl['sentinel.account_pool_id']);
  221. if (roleTpl['sentinel.target_instances'] !== undefined) setSentinelTargetInstances(Number(roleTpl['sentinel.target_instances']));
  222. if (roleTpl['sentinel.signal_ttl'] !== undefined) setSentinelSignalTtl(Number(roleTpl['sentinel.signal_ttl']));
  223. if (roleTpl['sentinel.query_wait.mode'] !== undefined) setQueryWaitMode(roleTpl['sentinel.query_wait.mode']);
  224. }
  225. }
  226. if (showToast) {
  227. toast.success(`已从服务商模板 [${providerName}] 继承参数与插件驱动`);
  228. }
  229. };
  230. const buildPayload = (): Partial<NodeConfigurationItem> => {
  231. const proxyList = proxyPoolStr
  232. .split(',')
  233. .map((s) => s.trim())
  234. .filter(Boolean);
  235. let parsedFreeConfig = {};
  236. try {
  237. if (freeConfigStr.trim()) parsedFreeConfig = JSON.parse(freeConfigStr);
  238. } catch {}
  239. const base: any = {
  240. node_id: nodeId.trim(),
  241. identifier: identifier.trim(),
  242. website: website.trim(),
  243. plugin_config: pluginConfig,
  244. appointment_types: appointmentTypes,
  245. free_config: parsedFreeConfig,
  246. };
  247. if (entryType === 'booker') {
  248. base.need_account = needAccount;
  249. base.need_proxy = needProxy;
  250. base.proxy_pool = proxyList;
  251. base.proxy_cd = proxyCd;
  252. base.session_max_life = sessionMaxLife;
  253. base.active_time_start = activeTimeStart;
  254. base.active_time_end = activeTimeEnd;
  255. base.booker = {
  256. account_source: bookerAccountSource,
  257. account_pool_id: bookerAccountPoolId.trim(),
  258. target_instances: Number(bookerTargetInstances),
  259. account_cd: Number(bookerAccountCd),
  260. booking_cooldown: Number(bookerCooldown),
  261. max_bookings_per_account: Number(bookerMaxBookings),
  262. };
  263. } else if (entryType === 'sentinel') {
  264. base.sentinel = {
  265. account_source: sentinelAccountSource,
  266. account_pool_id: sentinelAccountPoolId.trim(),
  267. target_instances: Number(sentinelTargetInstances),
  268. signal_ttl: Number(sentinelSignalTtl),
  269. query_wait: {
  270. mode: queryWaitMode,
  271. ...(queryWaitMode === 'Fixed'
  272. ? { fixed_wait: Number(fixedWait) }
  273. : { random_min: Number(randomMin), random_max: Number(randomMax) }),
  274. },
  275. };
  276. } else if (entryType === 'standalone') {
  277. base.order_id = orderId.trim();
  278. base.account = {
  279. username: accountUsername.trim(),
  280. password: accountPassword,
  281. };
  282. base.proxy_pool = proxyList;
  283. base.login_interval = Number(loginInterval);
  284. base.session_max_life = Number(sessionMaxLife);
  285. base.query_wait = {
  286. mode: queryWaitMode,
  287. ...(queryWaitMode === 'Fixed'
  288. ? { fixed_wait: Number(fixedWait) }
  289. : { random_min: Number(randomMin), random_max: Number(randomMax) }),
  290. };
  291. base.user_preferences = {
  292. support_pta: supportPta,
  293. expected_start_date: expectedStartDate,
  294. expected_end_date: expectedEndDate,
  295. };
  296. }
  297. return base;
  298. };
  299. const handleNext = () => {
  300. if (step === 1) {
  301. if (!selectedProviderName) {
  302. toast.error('新建任务必须选择一个服务商模板以继承配置与插件');
  303. return;
  304. }
  305. if (!nodeId.trim()) {
  306. toast.error('请选择已注册的目标集群节点 (node_id)');
  307. return;
  308. }
  309. if (!identifier.trim()) {
  310. toast.error('任务标识 (identifier) 不能为空');
  311. return;
  312. }
  313. setStep(2);
  314. } else if (step === 2) {
  315. try {
  316. if (freeConfigStr.trim()) JSON.parse(freeConfigStr);
  317. } catch {
  318. toast.error('自定义 Free Config JSON 格式错误');
  319. return;
  320. }
  321. setStep(3);
  322. }
  323. };
  324. const handleSubmit = async () => {
  325. const payload = buildPayload();
  326. setSubmitting(true);
  327. try {
  328. const res = await nodeConfigService.create(entryType, payload);
  329. if (res.code === 0) {
  330. toast.success(`[${entryType.toUpperCase()}] 节点任务配置创建成功 (默认已停用)`);
  331. onSuccess();
  332. onClose();
  333. } else {
  334. toast.error(res.message || '创建失败');
  335. }
  336. } catch (err: any) {
  337. console.error('Create node config error:', err);
  338. const msg = err?.response?.data?.message || err.message || '创建异常';
  339. toast.error(msg);
  340. } finally {
  341. setSubmitting(false);
  342. }
  343. };
  344. if (!isOpen) return null;
  345. return (
  346. <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-grayscale p-4 font-mono">
  347. <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-4xl max-h-[92vh] flex flex-col overflow-hidden animate-in zoom-in-95 duration-150">
  348. {/* Header */}
  349. <div className="px-5 py-3.5 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black select-none shrink-0">
  350. <div className="flex items-center gap-2">
  351. <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
  352. <h3 className="font-black text-black text-xs md:text-sm uppercase tracking-wider">
  353. [ CREATE {entryType.toUpperCase()} WIZARD // 新建{entryType.toUpperCase()}任务向导 ]
  354. </h3>
  355. </div>
  356. {/* Stepper Tabs */}
  357. <div className="flex items-center gap-1">
  358. {[
  359. { num: 1, label: '01. 模板与标识' },
  360. { num: 2, label: '02. 策略与参数' },
  361. { num: 3, label: '03. 核对与提交' },
  362. ].map((s) => (
  363. <span
  364. key={s.num}
  365. className={`px-2 py-0.5 border border-black text-[11px] font-black uppercase ${
  366. step === s.num
  367. ? 'bg-amber-300 text-black shadow-[1px_1px_0px_#000]'
  368. : step > s.num
  369. ? 'bg-emerald-300 text-black'
  370. : 'bg-white text-neutral-500'
  371. }`}
  372. >
  373. {s.label}
  374. </span>
  375. ))}
  376. </div>
  377. <button
  378. type="button"
  379. onClick={onClose}
  380. className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-black text-xs transition shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
  381. >
  382. ✕
  383. </button>
  384. </div>
  385. {/* Wizard Body */}
  386. <div className="flex-1 overflow-y-auto p-5 space-y-5 bg-white text-xs">
  387. {/* STEP 1 */}
  388. {step === 1 && (
  389. <div className="space-y-5">
  390. {/* Provider Selection (Mandatory) */}
  391. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  392. <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
  393. <div className="flex items-center gap-2">
  394. <span className="w-2 h-2 bg-amber-300 border border-black inline-block" />
  395. <span className="font-black text-black uppercase">[ PROVIDER TEMPLATE // 选择预设服务商模板 (必须继承) ]</span>
  396. </div>
  397. <span className="text-[11px] text-red-600 font-bold">* 必须选择服务商模板以继承参数与插件驱动</span>
  398. </div>
  399. <div className="grid grid-cols-1 md:grid-cols-2 gap-3 items-center">
  400. <select
  401. value={selectedProviderName}
  402. onChange={(e) => handleProviderSelect(e.target.value)}
  403. disabled={loadingProviders || eligibleProviders.length === 0}
  404. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  405. >
  406. {eligibleProviders.length === 0 ? (
  407. <option value="">-- 无支持 [{entryType.toUpperCase()}] 角色的服务商模板 --</option>
  408. ) : (
  409. <option value="">-- 请选择要继承的服务商模板 (共 {eligibleProviders.length} 个支持 {entryType.toUpperCase()}) --</option>
  410. )}
  411. {eligibleProviders.map((p) => {
  412. const rolesStr = p.role_templates ? Object.keys(p.role_templates).join('/') : '';
  413. return (
  414. <option key={p.id || p.name} value={p.name}>
  415. {p.name.toUpperCase()} (插件: {p.plugin_config?.plugin_name || '内置'}, 支持角色: {rolesStr})
  416. </option>
  417. );
  418. })}
  419. </select>
  420. {selectedProviderName ? (
  421. <div className="text-[11px] font-black text-black bg-amber-300 border border-black px-2 py-1 shadow-[1px_1px_0px_#000] inline-block">
  422. ✓ 已继承 [{selectedProviderName.toUpperCase()}] 模板参数 & 插件驱动 [{pluginConfig.plugin_name || '内置'}]
  423. </div>
  424. ) : eligibleProviders.length === 0 ? (
  425. <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
  426. ⚠️ 暂无支持 [{entryType.toUpperCase()}] 的模板,请在「服务商模板」中开启此角色
  427. </div>
  428. ) : (
  429. <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
  430. ⚠️ 新建 {entryType.toUpperCase()} 任务必须选择一个服务商模板
  431. </div>
  432. )}
  433. </div>
  434. </div>
  435. {/* Node Identity */}
  436. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  437. <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
  438. <span className="w-2 h-2 bg-black inline-block" />
  439. <span className="font-black text-black uppercase">[ IDENTITY // 任务与节点标识 ]</span>
  440. </div>
  441. <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
  442. <div>
  443. <RegisteredNodeSelect
  444. value={nodeId}
  445. onChange={setNodeId}
  446. label="目标集群节点 (NODE_ID)"
  447. badgeText="严格单选"
  448. placeholder="-- 请选择已注册的集群节点 --"
  449. required
  450. />
  451. </div>
  452. <div>
  453. <label className="block text-[11px] font-bold text-black mb-1">
  454. 任务唯一标识符 (identifier) <span className="text-red-500">*</span>
  455. </label>
  456. <input
  457. type="text"
  458. placeholder="vfs.ie.nl"
  459. value={identifier}
  460. onChange={(e) => setIdentifier(e.target.value)}
  461. 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] placeholder:text-neutral-400"
  462. />
  463. </div>
  464. <div className="md:col-span-2 space-y-1.5">
  465. <div className="flex justify-between items-center">
  466. <label className="block text-[11px] font-bold text-black">使馆/登录网址 (website)</label>
  467. <span className="text-[10px] text-neutral-500">支持直接输入或点击推荐使馆</span>
  468. </div>
  469. <input
  470. type="text"
  471. list="wizard-common-websites-list"
  472. placeholder="https://visa.vfsglobal.com/..."
  473. value={website}
  474. onChange={(e) => setWebsite(e.target.value)}
  475. 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] placeholder:text-neutral-400"
  476. />
  477. <datalist id="wizard-common-websites-list">
  478. {COMMON_WEBSITES.map((item) => (
  479. <option key={item.value} value={item.value}>
  480. {item.label}
  481. </option>
  482. ))}
  483. </datalist>
  484. <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
  485. <span className="text-[10px] text-neutral-500 font-bold">推荐使馆:</span>
  486. {COMMON_WEBSITES.map((item) => (
  487. <button
  488. key={item.value}
  489. type="button"
  490. onClick={() => setWebsite(item.value)}
  491. className={`px-2 py-0.5 text-[10px] font-mono font-bold border transition ${
  492. website === item.value
  493. ? 'bg-amber-300 text-black border-black shadow-[1px_1px_0px_#000]'
  494. : 'bg-white text-neutral-700 border-neutral-300 hover:border-black hover:bg-neutral-100'
  495. }`}
  496. >
  497. {item.label}
  498. </button>
  499. ))}
  500. </div>
  501. </div>
  502. </div>
  503. </div>
  504. {/* Standalone special */}
  505. {entryType === 'standalone' && (
  506. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  507. <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
  508. <span className="w-2 h-2 bg-black inline-block" />
  509. <span className="font-black text-black uppercase">[ STANDALONE CREDENTIALS // 订单与账号凭证 ]</span>
  510. </div>
  511. <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
  512. <div>
  513. <label className="block text-[11px] font-bold text-black mb-1">关联订单号 (order_id)</label>
  514. <input
  515. type="text"
  516. placeholder="ORD-20260823-001"
  517. value={orderId}
  518. onChange={(e) => setOrderId(e.target.value)}
  519. 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]"
  520. />
  521. </div>
  522. <div>
  523. <label className="block text-[11px] font-bold text-black mb-1">抢签账号 (username)</label>
  524. <input
  525. type="text"
  526. placeholder="user@example.com"
  527. value={accountUsername}
  528. onChange={(e) => setAccountUsername(e.target.value)}
  529. 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]"
  530. />
  531. </div>
  532. <div>
  533. <label className="block text-[11px] font-bold text-black mb-1">抢签密码 (password)</label>
  534. <input
  535. type="password"
  536. placeholder="••••••••"
  537. value={accountPassword}
  538. onChange={(e) => setAccountPassword(e.target.value)}
  539. 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]"
  540. />
  541. </div>
  542. </div>
  543. </div>
  544. )}
  545. </div>
  546. )}
  547. {/* STEP 2 */}
  548. {step === 2 && (
  549. <div className="space-y-5">
  550. {/* Booker fields */}
  551. {entryType === 'booker' && (
  552. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  553. <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
  554. <span className="w-2 h-2 bg-black inline-block" />
  555. <span className="font-black text-black uppercase">[ BOOKER PARAMS // 占位调度与池参数 ]</span>
  556. </div>
  557. <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
  558. {/* Account Pool ID - dropdown from DB */}
  559. <div>
  560. <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
  561. {customBookerAccountPool ? (
  562. <div className="flex gap-1">
  563. <input
  564. type="text"
  565. value={bookerAccountPoolId}
  566. onChange={(e) => setBookerAccountPoolId(e.target.value)}
  567. placeholder="输入自定义池 ID"
  568. className="flex-1 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]"
  569. />
  570. <button
  571. type="button"
  572. onClick={() => { setCustomBookerAccountPool(false); setBookerAccountPoolId(''); }}
  573. className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
  574. title="切换回下拉选择"
  575. >
  576. ✕
  577. </button>
  578. </div>
  579. ) : (
  580. <select
  581. value={bookerAccountPoolId}
  582. onChange={(e) => {
  583. if (e.target.value === '__CUSTOM__') {
  584. setCustomBookerAccountPool(true);
  585. setBookerAccountPoolId('');
  586. } else {
  587. setBookerAccountPoolId(e.target.value);
  588. }
  589. }}
  590. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  591. >
  592. <option value="">-- 请选择账号池 --</option>
  593. {accountPools.map((p) => (
  594. <option key={p.pool_name} value={p.pool_name}>
  595. {p.pool_name} ({p.total_count ?? 0} 个账号)
  596. </option>
  597. ))}
  598. <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
  599. </select>
  600. )}
  601. </div>
  602. {/* Target Instances - preset dropdown */}
  603. <div>
  604. <label className="block text-[11px] font-bold text-black mb-1">目标并发实例 (target_instances)</label>
  605. <select
  606. value={bookerTargetInstances}
  607. onChange={(e) => setBookerTargetInstances(Number(e.target.value))}
  608. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  609. >
  610. {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
  611. <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
  612. ))}
  613. </select>
  614. </div>
  615. {/* Account CD - preset dropdown */}
  616. <div>
  617. <label className="block text-[11px] font-bold text-black mb-1">账号冷却 (account_cd / 秒)</label>
  618. <select
  619. value={bookerAccountCd}
  620. onChange={(e) => setBookerAccountCd(Number(e.target.value))}
  621. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  622. >
  623. {[
  624. { v: 1800, label: '30 分钟' },
  625. { v: 3600, label: '1 小时' },
  626. { v: 7200, label: '2 小时' },
  627. { v: 10800, label: '3 小时 (默认)' },
  628. { v: 14400, label: '4 小时' },
  629. { v: 21600, label: '6 小时' },
  630. { v: 43200, label: '12 小时' },
  631. { v: 86400, label: '24 小时' },
  632. ].map((opt) => (
  633. <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
  634. ))}
  635. </select>
  636. </div>
  637. {/* Booking Cooldown - preset dropdown */}
  638. <div>
  639. <label className="block text-[11px] font-bold text-black mb-1">下单间隔冷却 (booking_cooldown / 秒)</label>
  640. <select
  641. value={bookerCooldown}
  642. onChange={(e) => setBookerCooldown(Number(e.target.value))}
  643. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  644. >
  645. {[
  646. { v: 10, label: '10 秒' },
  647. { v: 30, label: '30 秒' },
  648. { v: 60, label: '1 分钟' },
  649. { v: 120, label: '2 分钟' },
  650. { v: 300, label: '5 分钟 (默认)' },
  651. { v: 600, label: '10 分钟' },
  652. { v: 900, label: '15 分钟' },
  653. { v: 1800, label: '30 分钟' },
  654. ].map((opt) => (
  655. <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
  656. ))}
  657. </select>
  658. </div>
  659. {/* Max Bookings - preset dropdown */}
  660. <div>
  661. <label className="block text-[11px] font-bold text-black mb-1">单号最大占位次数</label>
  662. <select
  663. value={bookerMaxBookings}
  664. onChange={(e) => setBookerMaxBookings(Number(e.target.value))}
  665. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  666. >
  667. {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 50].map((v) => (
  668. <option key={v} value={v}>{v} 次{v === 8 ? ' (默认)' : ''}</option>
  669. ))}
  670. </select>
  671. </div>
  672. {/* Proxy CD - preset dropdown */}
  673. <div>
  674. <label className="block text-[11px] font-bold text-black mb-1">代理冷却时间 (proxy_cd / 秒)</label>
  675. <select
  676. value={proxyCd}
  677. onChange={(e) => setProxyCd(Number(e.target.value))}
  678. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  679. >
  680. {[
  681. { v: 0, label: '无冷却' },
  682. { v: 60, label: '1 分钟' },
  683. { v: 120, label: '2 分钟' },
  684. { v: 180, label: '3 分钟' },
  685. { v: 300, label: '5 分钟 (默认)' },
  686. { v: 600, label: '10 分钟' },
  687. { v: 900, label: '15 分钟' },
  688. { v: 1800, label: '30 分钟' },
  689. ].map((opt) => (
  690. <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
  691. ))}
  692. </select>
  693. </div>
  694. {/* Proxy Pool - tag-based multi-select from DB */}
  695. <div className="md:col-span-2">
  696. <label className="block text-[11px] font-bold text-black mb-1">网络代理池 (proxy_pool)</label>
  697. {/* Selected tags */}
  698. <div className="flex flex-wrap gap-1.5 mb-2 min-h-[28px] p-2 bg-white border-2 border-black shadow-[2px_2px_0px_#000]">
  699. {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).length === 0 && (
  700. <span className="text-neutral-400 text-[10px] italic">尚未选择代理池...</span>
  701. )}
  702. {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).map((tag) => (
  703. <span
  704. key={tag}
  705. className={`inline-flex items-center gap-1 px-2 py-0.5 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] ${
  706. tag.startsWith('cloud:') ? 'bg-sky-200 text-sky-900' : 'bg-emerald-200 text-emerald-900'
  707. }`}
  708. >
  709. {tag.startsWith('cloud:') ? '☁' : '⊙'} {tag}
  710. <button
  711. type="button"
  712. onClick={() => removeProxyPoolTag(tag)}
  713. className="ml-0.5 hover:text-red-600 font-black"
  714. >
  715. ✕
  716. </button>
  717. </span>
  718. ))}
  719. </div>
  720. {/* Add tag dropdown */}
  721. <select
  722. value=""
  723. onChange={(e) => {
  724. if (e.target.value) addProxyPoolTag(e.target.value);
  725. }}
  726. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  727. >
  728. <option value="">+ 添加代理池标签...</option>
  729. <optgroup label="☁ 云端代理池 (cloud:)">
  730. {cloudProxyPools.map((p) => (
  731. <option key={`cloud:${p.pool_name}`} value={`cloud:${p.pool_name}`}>
  732. cloud:{p.pool_name} ({p.total_count ?? 0} 条代理)
  733. </option>
  734. ))}
  735. </optgroup>
  736. <optgroup label="⊙ 本地代理池 (local:)">
  737. {LOCAL_PROXY_POOLS.map((p) => (
  738. <option key={`local:${p.value}`} value={`local:${p.value}`}>
  739. local:{p.value} — {p.label}
  740. </option>
  741. ))}
  742. </optgroup>
  743. </select>
  744. </div>
  745. {/* Session Max Life - preset dropdown */}
  746. <div>
  747. <label className="block text-[11px] font-bold text-black mb-1">Session 最长存活 (秒)</label>
  748. <select
  749. value={sessionMaxLife}
  750. onChange={(e) => setSessionMaxLife(Number(e.target.value))}
  751. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  752. >
  753. {[
  754. { v: 300, label: '5 分钟' },
  755. { v: 600, label: '10 分钟' },
  756. { v: 900, label: '15 分钟' },
  757. { v: 1200, label: '20 分钟' },
  758. { v: 1800, label: '30 分钟 (默认)' },
  759. { v: 2700, label: '45 分钟' },
  760. { v: 3600, label: '1 小时' },
  761. { v: 7200, label: '2 小时' },
  762. ].map((opt) => (
  763. <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
  764. ))}
  765. </select>
  766. </div>
  767. </div>
  768. </div>
  769. )}
  770. {/* Sentinel fields */}
  771. {entryType === 'sentinel' && (
  772. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  773. <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
  774. <span className="w-2 h-2 bg-black inline-block" />
  775. <span className="font-black text-black uppercase">[ SENTINEL PARAMS // 监控与等待策略 ]</span>
  776. </div>
  777. <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
  778. {/* Account Pool ID - dropdown from DB */}
  779. <div>
  780. <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
  781. {customSentinelAccountPool ? (
  782. <div className="flex gap-1">
  783. <input
  784. type="text"
  785. value={sentinelAccountPoolId}
  786. onChange={(e) => setSentinelAccountPoolId(e.target.value)}
  787. placeholder="输入自定义池 ID"
  788. className="flex-1 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]"
  789. />
  790. <button
  791. type="button"
  792. onClick={() => { setCustomSentinelAccountPool(false); setSentinelAccountPoolId(''); }}
  793. className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
  794. title="切换回下拉选择"
  795. >
  796. ✕
  797. </button>
  798. </div>
  799. ) : (
  800. <select
  801. value={sentinelAccountPoolId}
  802. onChange={(e) => {
  803. if (e.target.value === '__CUSTOM__') {
  804. setCustomSentinelAccountPool(true);
  805. setSentinelAccountPoolId('');
  806. } else {
  807. setSentinelAccountPoolId(e.target.value);
  808. }
  809. }}
  810. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  811. >
  812. <option value="">-- 请选择账号池 --</option>
  813. {accountPools.map((p) => (
  814. <option key={p.pool_name} value={p.pool_name}>
  815. {p.pool_name} ({p.total_count ?? 0} 个账号)
  816. </option>
  817. ))}
  818. <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
  819. </select>
  820. )}
  821. </div>
  822. {/* Target Instances - preset dropdown */}
  823. <div>
  824. <label className="block text-[11px] font-bold text-black mb-1">监控并发实例数</label>
  825. <select
  826. value={sentinelTargetInstances}
  827. onChange={(e) => setSentinelTargetInstances(Number(e.target.value))}
  828. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  829. >
  830. {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
  831. <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
  832. ))}
  833. </select>
  834. </div>
  835. {/* Signal TTL - preset dropdown */}
  836. <div>
  837. <label className="block text-[11px] font-bold text-black mb-1">放位信号 TTL 持续 (秒)</label>
  838. <select
  839. value={sentinelSignalTtl}
  840. onChange={(e) => setSentinelSignalTtl(Number(e.target.value))}
  841. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  842. >
  843. {[
  844. { v: 10, label: '10 秒' },
  845. { v: 15, label: '15 秒' },
  846. { v: 20, label: '20 秒' },
  847. { v: 30, label: '30 秒 (默认)' },
  848. { v: 45, label: '45 秒' },
  849. { v: 60, label: '1 分钟' },
  850. { v: 90, label: '90 秒' },
  851. { v: 120, label: '2 分钟' },
  852. ].map((opt) => (
  853. <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
  854. ))}
  855. </select>
  856. </div>
  857. {/* Query Wait Mode - dropdown */}
  858. <div>
  859. <label className="block text-[11px] font-bold text-black mb-1">扫位轮询模式 (query_wait.mode)</label>
  860. <select
  861. value={queryWaitMode}
  862. onChange={(e) => setQueryWaitMode(e.target.value as any)}
  863. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  864. >
  865. <option value="Random">Random (随机等待)</option>
  866. <option value="Fixed">Fixed (固定等待)</option>
  867. </select>
  868. </div>
  869. {queryWaitMode === 'Fixed' ? (
  870. <div>
  871. <label className="block text-[11px] font-bold text-black mb-1">固定等待 (秒)</label>
  872. <select
  873. value={fixedWait}
  874. onChange={(e) => setFixedWait(Number(e.target.value))}
  875. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  876. >
  877. {[5, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
  878. <option key={v} value={v}>{v}s{v === 10 ? ' (默认)' : ''}</option>
  879. ))}
  880. </select>
  881. </div>
  882. ) : (
  883. <>
  884. <div>
  885. <label className="block text-[11px] font-bold text-black mb-1">随机最小等待 (秒)</label>
  886. <select
  887. value={randomMin}
  888. onChange={(e) => setRandomMin(Number(e.target.value))}
  889. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  890. >
  891. {[10, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
  892. <option key={v} value={v}>{v}s{v === 60 ? ' (默认)' : ''}</option>
  893. ))}
  894. </select>
  895. </div>
  896. <div>
  897. <label className="block text-[11px] font-bold text-black mb-1">随机最大等待 (秒)</label>
  898. <select
  899. value={randomMax}
  900. onChange={(e) => setRandomMax(Number(e.target.value))}
  901. className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
  902. >
  903. {[30, 60, 120, 180, 300, 450, 600, 900, 1200].map((v) => (
  904. <option key={v} value={v}>{v}s{v === 300 ? ' (默认)' : ''}</option>
  905. ))}
  906. </select>
  907. </div>
  908. </>
  909. )}
  910. </div>
  911. </div>
  912. )}
  913. {/* Standalone fields */}
  914. {entryType === 'standalone' && (
  915. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  916. <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
  917. <span className="w-2 h-2 bg-black inline-block" />
  918. <span className="font-black text-black uppercase">[ STANDALONE PARAMS // 偏好与轮询策略 ]</span>
  919. </div>
  920. <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
  921. <div>
  922. <label className="block text-[11px] font-bold text-black mb-1">登录重试间隔 (秒)</label>
  923. <input
  924. type="number"
  925. value={loginInterval}
  926. onChange={(e) => setLoginInterval(Number(e.target.value))}
  927. 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]"
  928. />
  929. </div>
  930. <div>
  931. <label className="block text-[11px] font-bold text-black mb-1">期望最早日期 (start_date)</label>
  932. <input
  933. type="date"
  934. value={expectedStartDate}
  935. onChange={(e) => setExpectedStartDate(e.target.value)}
  936. 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]"
  937. />
  938. </div>
  939. <div>
  940. <label className="block text-[11px] font-bold text-black mb-1">期望最晚日期 (end_date)</label>
  941. <input
  942. type="date"
  943. value={expectedEndDate}
  944. onChange={(e) => setExpectedEndDate(e.target.value)}
  945. 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]"
  946. />
  947. </div>
  948. </div>
  949. </div>
  950. )}
  951. {/* Appointment Types */}
  952. <AppointmentTypeEditor
  953. items={appointmentTypes}
  954. onChange={setAppointmentTypes}
  955. />
  956. {/* Plugin (Inherited from Template, read-only) & Free Config */}
  957. <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
  958. <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
  959. <div className="flex items-center gap-2">
  960. <span className="w-2 h-2 bg-black inline-block" />
  961. <span className="font-black text-black uppercase">[ PLUGIN DRIVER // 插件运行时 (已由模板绑定) ]</span>
  962. </div>
  963. <span className="text-[10px] text-emerald-800 bg-emerald-100 border border-emerald-500 px-1.5 py-0.5 font-bold">
  964. ✓ 自动从模板 [{selectedProviderName || '未选'}] 继承,无需手动配置
  965. </span>
  966. </div>
  967. {/* Readonly info bar */}
  968. <div className="bg-white border-2 border-black p-3 shadow-[1px_1px_0px_#000] space-y-2">
  969. <div className="flex flex-wrap items-center justify-between gap-2">
  970. <div className="flex items-center gap-2">
  971. <span className="font-bold text-neutral-500 text-[11px]">绑定插件:</span>
  972. <span className="font-mono font-black text-black bg-amber-200 border border-black px-2 py-0.5 text-xs shadow-[1px_1px_0px_#000]">
  973. {pluginConfig.plugin_name || '默认内置驱动'}
  974. </span>
  975. </div>
  976. <div className="text-[11px] font-mono text-neutral-700">
  977. 执行脚本: <code className="font-bold text-black bg-neutral-100 px-1 py-0.5 border border-neutral-300">{pluginConfig.plugin_bin || '(内置脚本)'}</code>
  978. </div>
  979. </div>
  980. <div className="flex flex-wrap items-center justify-between text-[10px] text-neutral-500 border-t border-neutral-200 pt-1.5">
  981. <span>接口协议: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_proto || 'IPlugin'}</span></span>
  982. <span>加载目录: <span className="font-mono font-bold text-neutral-700">{pluginConfig.lib_path || 'plugins'}</span></span>
  983. {pluginConfig.plugin_class && (
  984. <span>入口类: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_class}</span></span>
  985. )}
  986. </div>
  987. </div>
  988. {/* Free Config */}
  989. <div className="pt-1">
  990. <label className="block text-[11px] font-bold text-black mb-1">
  991. 自定义扩展 JSON (free_config, 可选)
  992. </label>
  993. <textarea
  994. rows={3}
  995. value={freeConfigStr}
  996. onChange={(e) => setFreeConfigStr(e.target.value)}
  997. placeholder="{}"
  998. className="w-full p-2.5 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000]"
  999. />
  1000. </div>
  1001. </div>
  1002. </div>
  1003. )}
  1004. {/* STEP 3 */}
  1005. {step === 3 && (
  1006. <div className="space-y-5">
  1007. {/* Notice Stamp */}
  1008. <div className="p-3 bg-amber-100 border-2 border-black shadow-[2px_2px_0px_#000] text-black font-bold text-xs leading-relaxed">
  1009. ⚠️ [ 落库安全提示 ]:新建的节点任务配置将一律以 <span className="bg-rose-200 border border-black px-1 py-0.2 font-black">[ 已停用 (enable: 0) ]</span> 状态落库。创建成功后可在列表中核实并随时开启。
  1010. </div>
  1011. {/* Summary Cards */}
  1012. <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
  1013. <div className="p-4 bg-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 text-xs">
  1014. <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 基础信息核对 ]</div>
  1015. <div className="flex justify-between">
  1016. <span className="text-neutral-600">目标节点:</span>
  1017. <span className="font-bold text-black">{nodeId}</span>
  1018. </div>
  1019. <div className="flex justify-between">
  1020. <span className="text-neutral-600">任务标识:</span>
  1021. <span className="font-black text-black">{identifier}</span>
  1022. </div>
  1023. <div className="flex justify-between">
  1024. <span className="text-neutral-600">角色类型:</span>
  1025. <span className="font-bold text-black uppercase">{entryType}</span>
  1026. </div>
  1027. <div className="flex justify-between">
  1028. <span className="text-neutral-600">规则数量:</span>
  1029. <span className="font-bold text-black">{appointmentTypes.length} 条</span>
  1030. </div>
  1031. </div>
  1032. <div className="p-4 bg-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 text-xs">
  1033. <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 插件运行时 (由模板锁定) ]</div>
  1034. <div className="flex justify-between">
  1035. <span className="text-neutral-600">继承模板:</span>
  1036. <span className="font-bold text-black bg-amber-200 border border-black px-1.5">{selectedProviderName || '无'}</span>
  1037. </div>
  1038. <div className="flex justify-between">
  1039. <span className="text-neutral-600">插件驱动:</span>
  1040. <span className="font-bold text-black">{pluginConfig.plugin_name || '默认内置'}</span>
  1041. </div>
  1042. <div className="flex justify-between">
  1043. <span className="text-neutral-600">执行脚本:</span>
  1044. <span className="font-mono font-bold text-black">{pluginConfig.plugin_bin || '(内置脚本)'}</span>
  1045. </div>
  1046. <div className="flex justify-between">
  1047. <span className="text-neutral-600">协议/目录:</span>
  1048. <span className="font-mono text-neutral-600">{pluginConfig.plugin_proto || 'IPlugin'} / {pluginConfig.lib_path || 'plugins'}</span>
  1049. </div>
  1050. </div>
  1051. </div>
  1052. {/* JSON Terminal Preview */}
  1053. <div className="space-y-1">
  1054. <div className="text-[11px] font-black text-black uppercase">[ JSON TERMINAL // 最终提交负载 ]</div>
  1055. <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
  1056. <pre className="p-4 bg-neutral-900 text-amber-300 font-mono text-xs overflow-x-auto max-h-60 leading-relaxed">
  1057. {JSON.stringify(buildPayload(), null, 2)}
  1058. </pre>
  1059. </div>
  1060. </div>
  1061. </div>
  1062. )}
  1063. </div>
  1064. {/* Footer */}
  1065. <div className="px-5 py-3 bg-neutral-200 border-t-2 border-black flex justify-between items-center shrink-0">
  1066. <div>
  1067. {step > 1 && (
  1068. <button
  1069. type="button"
  1070. onClick={() => setStep((prev) => (prev - 1) as any)}
  1071. className="px-4 py-1.5 bg-white hover:bg-neutral-100 text-black border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
  1072. >
  1073. [ ← 上一步 ]
  1074. </button>
  1075. )}
  1076. </div>
  1077. <div className="flex items-center gap-2">
  1078. <button
  1079. type="button"
  1080. onClick={onClose}
  1081. className="px-4 py-1.5 bg-white hover:bg-neutral-100 text-black border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
  1082. >
  1083. [ 取消 ]
  1084. </button>
  1085. {step < 3 ? (
  1086. <button
  1087. type="button"
  1088. onClick={handleNext}
  1089. className="px-5 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
  1090. >
  1091. [ 下一步 → ]
  1092. </button>
  1093. ) : (
  1094. <button
  1095. type="button"
  1096. onClick={handleSubmit}
  1097. disabled={submitting}
  1098. className="px-5 py-1.5 bg-emerald-300 hover:bg-emerald-400 text-black border-2 border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition disabled:opacity-50"
  1099. >
  1100. {submitting ? '[ 提交中... ]' : '[ 确认提交落库 ]'}
  1101. </button>
  1102. )}
  1103. </div>
  1104. </div>
  1105. </div>
  1106. </div>
  1107. );
  1108. }