| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187 |
- // src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx
- 'use client';
- import React, { useState, useEffect } from 'react';
- import { toast } from 'react-hot-toast';
- import {
- NodeConfigEntryType,
- ProviderItem,
- AppointmentTypeItem,
- PluginConfig,
- NodeConfigurationItem,
- } from '@/types';
- import { providerService } from '@/lib/services/providerService';
- import { nodeConfigService } from '@/lib/services/nodeConfigService';
- import { accountService } from '@/lib/services/accountService';
- import { proxyService } from '@/lib/services/proxyService';
- import AppointmentTypeEditor from './AppointmentTypeEditor';
- import RegisteredNodeSelect from '@/components/admin/node-configurations/RegisteredNodeSelect';
- import { LOCAL_PROXY_POOLS, COMMON_WEBSITES } from './nodeConfigConstants';
- interface NodeConfigCreateWizardModalProps {
- isOpen: boolean;
- onClose: () => void;
- entryType: NodeConfigEntryType;
- onSuccess: () => void;
- }
- export default function NodeConfigCreateWizardModal({
- isOpen,
- onClose,
- entryType,
- onSuccess,
- }: NodeConfigCreateWizardModalProps) {
- const [step, setStep] = useState<1 | 2 | 3>(1);
- const [providers, setProviders] = useState<ProviderItem[]>([]);
- const [selectedProviderName, setSelectedProviderName] = useState<string>('');
- const [loadingProviders, setLoadingProviders] = useState(false);
- const [submitting, setSubmitting] = useState(false);
- // 数据库获取的账号池与代理池
- const [accountPools, setAccountPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
- const [cloudProxyPools, setCloudProxyPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
- const [customBookerAccountPool, setCustomBookerAccountPool] = useState(false);
- const [customSentinelAccountPool, setCustomSentinelAccountPool] = useState(false);
- // Step 1: Base & Identity
- const [nodeId, setNodeId] = useState('node01');
- const [identifier, setIdentifier] = useState('');
- const [website, setWebsite] = useState('');
- const [needAccount, setNeedAccount] = useState(1);
- const [needProxy, setNeedProxy] = useState(1);
- const [proxyPoolStr, setProxyPoolStr] = useState('cloud:proxy-cheap');
- const [proxyCd, setProxyCd] = useState(300);
- const [sessionMaxLife, setSessionMaxLife] = useState(1800);
- const [activeTimeStart, setActiveTimeStart] = useState('00:00');
- const [activeTimeEnd, setActiveTimeEnd] = useState('23:59');
- // Standalone specifics
- const [orderId, setOrderId] = useState('');
- const [accountUsername, setAccountUsername] = useState('');
- const [accountPassword, setAccountPassword] = useState('');
- const [supportPta, setSupportPta] = useState(false);
- const [expectedStartDate, setExpectedStartDate] = useState('');
- const [expectedEndDate, setExpectedEndDate] = useState('');
- const [loginInterval, setLoginInterval] = useState(1800);
- // Booker specifics
- const [bookerAccountSource, setBookerAccountSource] = useState('built-in');
- const [bookerAccountPoolId, setBookerAccountPoolId] = useState('');
- const [bookerTargetInstances, setBookerTargetInstances] = useState(1);
- const [bookerAccountCd, setBookerAccountCd] = useState(10800);
- const [bookerCooldown, setBookerCooldown] = useState(30);
- const [bookerMaxBookings, setBookerMaxBookings] = useState(8);
- // Sentinel specifics
- const [sentinelAccountSource, setSentinelAccountSource] = useState('built-in');
- const [sentinelAccountPoolId, setSentinelAccountPoolId] = useState('');
- const [sentinelTargetInstances, setSentinelTargetInstances] = useState(1);
- const [sentinelSignalTtl, setSentinelSignalTtl] = useState(30);
- // Query Wait
- const [queryWaitMode, setQueryWaitMode] = useState<'Random' | 'Fixed'>('Random');
- const [fixedWait, setFixedWait] = useState(10);
- const [randomMin, setRandomMin] = useState(60);
- const [randomMax, setRandomMax] = useState(300);
- // Plugin config
- const [pluginConfig, setPluginConfig] = useState<PluginConfig>({
- lib_path: 'plugins',
- plugin_name: '',
- plugin_bin: '',
- plugin_class: '',
- plugin_proto: 'IPlugin',
- });
- // Appointment types & free config
- const [appointmentTypes, setAppointmentTypes] = useState<AppointmentTypeItem[]>([]);
- const [freeConfigStr, setFreeConfigStr] = useState('{}');
- useEffect(() => {
- if (isOpen) {
- setStep(1);
- fetchEnabledProviders();
- fetchDbPools();
- resetForm();
- }
- }, [isOpen, entryType]);
- const fetchDbPools = async () => {
- try {
- const [accRes, proxyRes] = await Promise.allSettled([
- accountService.getPools(),
- proxyService.getPools(),
- ]);
- if (accRes.status === 'fulfilled' && accRes.value?.data) {
- setAccountPools(Array.isArray(accRes.value.data) ? accRes.value.data : []);
- }
- if (proxyRes.status === 'fulfilled' && proxyRes.value?.data) {
- setCloudProxyPools(Array.isArray(proxyRes.value.data) ? proxyRes.value.data : []);
- }
- } catch (err) {
- console.error('Failed to fetch pools from DB:', err);
- }
- };
- const addProxyPoolTag = (tagToAdd: string) => {
- if (!tagToAdd) return;
- const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
- if (!current.includes(tagToAdd)) {
- current.push(tagToAdd);
- setProxyPoolStr(current.join(', '));
- }
- };
- const removeProxyPoolTag = (tagToRemove: string) => {
- const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
- const updated = current.filter((t) => t !== tagToRemove);
- setProxyPoolStr(updated.join(', '));
- };
- // 仅筛选出支持当前 entryType 角色的服务商模板
- const eligibleProviders = providers.filter(
- (p) => p.role_templates && Boolean(p.role_templates[entryType])
- );
- const fetchEnabledProviders = async () => {
- setLoadingProviders(true);
- try {
- const res = await providerService.getList({ enabled_only: true });
- if (res.code === 0 && res.data) {
- const list = Array.isArray(res.data) ? res.data : [];
- setProviders(list);
- const matching = list.filter(
- (p) => p.role_templates && Boolean(p.role_templates[entryType])
- );
- if (matching.length > 0 && !selectedProviderName) {
- handleProviderSelect(matching[0].name, list, false);
- }
- }
- } catch (e) {
- console.error('Failed to fetch providers:', e);
- } finally {
- setLoadingProviders(false);
- }
- };
- const resetForm = () => {
- setSelectedProviderName('');
- setNodeId('');
- setIdentifier('');
- setWebsite('');
- setNeedAccount(1);
- setNeedProxy(1);
- setProxyPoolStr('');
- setProxyCd(300);
- setSessionMaxLife(1800);
- setActiveTimeStart('00:00');
- setActiveTimeEnd('23:59');
- setOrderId('');
- setAccountUsername('');
- setAccountPassword('');
- setSupportPta(false);
- setExpectedStartDate('');
- setExpectedEndDate('');
- setLoginInterval(1800);
- setBookerAccountSource('built-in');
- setBookerAccountPoolId('');
- setBookerTargetInstances(1);
- setBookerAccountCd(10800);
- setBookerCooldown(300);
- setBookerMaxBookings(8);
- setCustomBookerAccountPool(false);
- setSentinelAccountSource('built-in');
- setSentinelAccountPoolId('');
- setSentinelTargetInstances(1);
- setSentinelSignalTtl(30);
- setCustomSentinelAccountPool(false);
- setQueryWaitMode('Random');
- setFixedWait(10);
- setRandomMin(60);
- setRandomMax(300);
- setPluginConfig({
- lib_path: 'plugins',
- plugin_name: '',
- plugin_bin: '',
- plugin_proto: 'IPlugin',
- });
- setAppointmentTypes([]);
- setFreeConfigStr('{}');
- };
- const handleProviderSelect = (providerName: string, providerList = providers, showToast = true) => {
- setSelectedProviderName(providerName);
- const p = providerList.find((item) => item.name === providerName);
- if (!p) return;
- if (p.plugin_config) {
- setPluginConfig({
- lib_path: p.plugin_config.lib_path || 'plugins',
- plugin_name: p.plugin_config.plugin_name || '',
- plugin_bin: p.plugin_config.plugin_bin || '',
- plugin_class: p.plugin_config.plugin_class || '',
- plugin_proto: p.plugin_config.plugin_proto || 'IPlugin',
- });
- }
- const roleTpl = p.role_templates?.[entryType];
- if (roleTpl) {
- if (roleTpl.proxy_cd !== undefined) setProxyCd(Number(roleTpl.proxy_cd));
- if (roleTpl.session_max_life !== undefined) setSessionMaxLife(Number(roleTpl.session_max_life));
- if (roleTpl.login_interval !== undefined) setLoginInterval(Number(roleTpl.login_interval));
- if (entryType === 'booker') {
- if (roleTpl['booker.account_source'] !== undefined) setBookerAccountSource(roleTpl['booker.account_source']);
- if (roleTpl['booker.account_pool_id'] !== undefined) setBookerAccountPoolId(roleTpl['booker.account_pool_id']);
- if (roleTpl['booker.account_cd'] !== undefined) setBookerAccountCd(Number(roleTpl['booker.account_cd']));
- if (roleTpl['booker.target_instances'] !== undefined) setBookerTargetInstances(Number(roleTpl['booker.target_instances']));
- if (roleTpl['booker.booking_cooldown'] !== undefined) setBookerCooldown(Number(roleTpl['booker.booking_cooldown']));
- if (roleTpl['booker.max_bookings_per_account'] !== undefined) setBookerMaxBookings(Number(roleTpl['booker.max_bookings_per_account']));
- } else if (entryType === 'sentinel') {
- if (roleTpl['sentinel.account_source'] !== undefined) setSentinelAccountSource(roleTpl['sentinel.account_source']);
- if (roleTpl['sentinel.account_pool_id'] !== undefined) setSentinelAccountPoolId(roleTpl['sentinel.account_pool_id']);
- if (roleTpl['sentinel.target_instances'] !== undefined) setSentinelTargetInstances(Number(roleTpl['sentinel.target_instances']));
- if (roleTpl['sentinel.signal_ttl'] !== undefined) setSentinelSignalTtl(Number(roleTpl['sentinel.signal_ttl']));
- if (roleTpl['sentinel.query_wait.mode'] !== undefined) setQueryWaitMode(roleTpl['sentinel.query_wait.mode']);
- }
- }
- if (showToast) {
- toast.success(`已从服务商模板 [${providerName}] 继承参数与插件驱动`);
- }
- };
- const buildPayload = (): Partial<NodeConfigurationItem> => {
- const proxyList = proxyPoolStr
- .split(',')
- .map((s) => s.trim())
- .filter(Boolean);
- let parsedFreeConfig = {};
- try {
- if (freeConfigStr.trim()) parsedFreeConfig = JSON.parse(freeConfigStr);
- } catch {}
- const base: any = {
- node_id: nodeId.trim(),
- identifier: identifier.trim(),
- website: website.trim(),
- plugin_config: pluginConfig,
- appointment_types: appointmentTypes,
- free_config: parsedFreeConfig,
- };
- if (entryType === 'booker') {
- base.need_account = needAccount;
- base.need_proxy = needProxy;
- base.proxy_pool = proxyList;
- base.proxy_cd = proxyCd;
- base.session_max_life = sessionMaxLife;
- base.active_time_start = activeTimeStart;
- base.active_time_end = activeTimeEnd;
- base.booker = {
- account_source: bookerAccountSource,
- account_pool_id: bookerAccountPoolId.trim(),
- target_instances: Number(bookerTargetInstances),
- account_cd: Number(bookerAccountCd),
- booking_cooldown: Number(bookerCooldown),
- max_bookings_per_account: Number(bookerMaxBookings),
- };
- } else if (entryType === 'sentinel') {
- base.sentinel = {
- account_source: sentinelAccountSource,
- account_pool_id: sentinelAccountPoolId.trim(),
- target_instances: Number(sentinelTargetInstances),
- signal_ttl: Number(sentinelSignalTtl),
- query_wait: {
- mode: queryWaitMode,
- ...(queryWaitMode === 'Fixed'
- ? { fixed_wait: Number(fixedWait) }
- : { random_min: Number(randomMin), random_max: Number(randomMax) }),
- },
- };
- } else if (entryType === 'standalone') {
- base.order_id = orderId.trim();
- base.account = {
- username: accountUsername.trim(),
- password: accountPassword,
- };
- base.proxy_pool = proxyList;
- base.login_interval = Number(loginInterval);
- base.session_max_life = Number(sessionMaxLife);
- base.query_wait = {
- mode: queryWaitMode,
- ...(queryWaitMode === 'Fixed'
- ? { fixed_wait: Number(fixedWait) }
- : { random_min: Number(randomMin), random_max: Number(randomMax) }),
- };
- base.user_preferences = {
- support_pta: supportPta,
- expected_start_date: expectedStartDate,
- expected_end_date: expectedEndDate,
- };
- }
- return base;
- };
- const handleNext = () => {
- if (step === 1) {
- if (!selectedProviderName) {
- toast.error('新建任务必须选择一个服务商模板以继承配置与插件');
- return;
- }
- if (!nodeId.trim()) {
- toast.error('请选择已注册的目标集群节点 (node_id)');
- return;
- }
- if (!identifier.trim()) {
- toast.error('任务标识 (identifier) 不能为空');
- return;
- }
- setStep(2);
- } else if (step === 2) {
- try {
- if (freeConfigStr.trim()) JSON.parse(freeConfigStr);
- } catch {
- toast.error('自定义 Free Config JSON 格式错误');
- return;
- }
- setStep(3);
- }
- };
- const handleSubmit = async () => {
- const payload = buildPayload();
- setSubmitting(true);
- try {
- const res = await nodeConfigService.create(entryType, payload);
- if (res.code === 0) {
- toast.success(`[${entryType.toUpperCase()}] 节点任务配置创建成功 (默认已停用)`);
- onSuccess();
- onClose();
- } else {
- toast.error(res.message || '创建失败');
- }
- } catch (err: any) {
- console.error('Create node config error:', err);
- const msg = err?.response?.data?.message || err.message || '创建异常';
- toast.error(msg);
- } finally {
- setSubmitting(false);
- }
- };
- if (!isOpen) return null;
- return (
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-grayscale p-4 font-mono">
- <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">
- {/* Header */}
- <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">
- <div className="flex items-center gap-2">
- <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
- <h3 className="font-black text-black text-xs md:text-sm uppercase tracking-wider">
- [ CREATE {entryType.toUpperCase()} WIZARD // 新建{entryType.toUpperCase()}任务向导 ]
- </h3>
- </div>
- {/* Stepper Tabs */}
- <div className="flex items-center gap-1">
- {[
- { num: 1, label: '01. 模板与标识' },
- { num: 2, label: '02. 策略与参数' },
- { num: 3, label: '03. 核对与提交' },
- ].map((s) => (
- <span
- key={s.num}
- className={`px-2 py-0.5 border border-black text-[11px] font-black uppercase ${
- step === s.num
- ? 'bg-amber-300 text-black shadow-[1px_1px_0px_#000]'
- : step > s.num
- ? 'bg-emerald-300 text-black'
- : 'bg-white text-neutral-500'
- }`}
- >
- {s.label}
- </span>
- ))}
- </div>
- <button
- type="button"
- onClick={onClose}
- 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"
- >
- ✕
- </button>
- </div>
- {/* Wizard Body */}
- <div className="flex-1 overflow-y-auto p-5 space-y-5 bg-white text-xs">
- {/* STEP 1 */}
- {step === 1 && (
- <div className="space-y-5">
- {/* Provider Selection (Mandatory) */}
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
- <div className="flex items-center gap-2">
- <span className="w-2 h-2 bg-amber-300 border border-black inline-block" />
- <span className="font-black text-black uppercase">[ PROVIDER TEMPLATE // 选择预设服务商模板 (必须继承) ]</span>
- </div>
- <span className="text-[11px] text-red-600 font-bold">* 必须选择服务商模板以继承参数与插件驱动</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3 items-center">
- <select
- value={selectedProviderName}
- onChange={(e) => handleProviderSelect(e.target.value)}
- disabled={loadingProviders || eligibleProviders.length === 0}
- 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]"
- >
- {eligibleProviders.length === 0 ? (
- <option value="">-- 无支持 [{entryType.toUpperCase()}] 角色的服务商模板 --</option>
- ) : (
- <option value="">-- 请选择要继承的服务商模板 (共 {eligibleProviders.length} 个支持 {entryType.toUpperCase()}) --</option>
- )}
- {eligibleProviders.map((p) => {
- const rolesStr = p.role_templates ? Object.keys(p.role_templates).join('/') : '';
- return (
- <option key={p.id || p.name} value={p.name}>
- {p.name.toUpperCase()} (插件: {p.plugin_config?.plugin_name || '内置'}, 支持角色: {rolesStr})
- </option>
- );
- })}
- </select>
- {selectedProviderName ? (
- <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">
- ✓ 已继承 [{selectedProviderName.toUpperCase()}] 模板参数 & 插件驱动 [{pluginConfig.plugin_name || '内置'}]
- </div>
- ) : eligibleProviders.length === 0 ? (
- <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
- ⚠️ 暂无支持 [{entryType.toUpperCase()}] 的模板,请在「服务商模板」中开启此角色
- </div>
- ) : (
- <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
- ⚠️ 新建 {entryType.toUpperCase()} 任务必须选择一个服务商模板
- </div>
- )}
- </div>
- </div>
- {/* Node Identity */}
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ IDENTITY // 任务与节点标识 ]</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <div>
- <RegisteredNodeSelect
- value={nodeId}
- onChange={setNodeId}
- label="目标集群节点 (NODE_ID)"
- badgeText="严格单选"
- placeholder="-- 请选择已注册的集群节点 --"
- required
- />
- </div>
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">
- 任务唯一标识符 (identifier) <span className="text-red-500">*</span>
- </label>
- <input
- type="text"
- placeholder="vfs.ie.nl"
- value={identifier}
- onChange={(e) => setIdentifier(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] placeholder:text-neutral-400"
- />
- </div>
- <div className="md:col-span-2 space-y-1.5">
- <div className="flex justify-between items-center">
- <label className="block text-[11px] font-bold text-black">使馆/登录网址 (website)</label>
- <span className="text-[10px] text-neutral-500">支持直接输入或点击推荐使馆</span>
- </div>
- <input
- type="text"
- list="wizard-common-websites-list"
- placeholder="https://visa.vfsglobal.com/..."
- value={website}
- onChange={(e) => setWebsite(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] placeholder:text-neutral-400"
- />
- <datalist id="wizard-common-websites-list">
- {COMMON_WEBSITES.map((item) => (
- <option key={item.value} value={item.value}>
- {item.label}
- </option>
- ))}
- </datalist>
- <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
- <span className="text-[10px] text-neutral-500 font-bold">推荐使馆:</span>
- {COMMON_WEBSITES.map((item) => (
- <button
- key={item.value}
- type="button"
- onClick={() => setWebsite(item.value)}
- className={`px-2 py-0.5 text-[10px] font-mono font-bold border transition ${
- website === item.value
- ? 'bg-amber-300 text-black border-black shadow-[1px_1px_0px_#000]'
- : 'bg-white text-neutral-700 border-neutral-300 hover:border-black hover:bg-neutral-100'
- }`}
- >
- {item.label}
- </button>
- ))}
- </div>
- </div>
- </div>
- </div>
- {/* Standalone special */}
- {entryType === 'standalone' && (
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ STANDALONE CREDENTIALS // 订单与账号凭证 ]</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">关联订单号 (order_id)</label>
- <input
- type="text"
- placeholder="ORD-20260823-001"
- value={orderId}
- onChange={(e) => setOrderId(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>
- <label className="block text-[11px] font-bold text-black mb-1">抢签账号 (username)</label>
- <input
- type="text"
- placeholder="user@example.com"
- value={accountUsername}
- onChange={(e) => setAccountUsername(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>
- <label className="block text-[11px] font-bold text-black mb-1">抢签密码 (password)</label>
- <input
- type="password"
- 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>
- )}
- </div>
- )}
- {/* STEP 2 */}
- {step === 2 && (
- <div className="space-y-5">
- {/* Booker fields */}
- {entryType === 'booker' && (
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ BOOKER PARAMS // 占位调度与池参数 ]</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
- {/* Account Pool ID - dropdown from DB */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
- {customBookerAccountPool ? (
- <div className="flex gap-1">
- <input
- type="text"
- value={bookerAccountPoolId}
- onChange={(e) => setBookerAccountPoolId(e.target.value)}
- placeholder="输入自定义池 ID"
- 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]"
- />
- <button
- type="button"
- onClick={() => { setCustomBookerAccountPool(false); setBookerAccountPoolId(''); }}
- className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
- title="切换回下拉选择"
- >
- ✕
- </button>
- </div>
- ) : (
- <select
- value={bookerAccountPoolId}
- onChange={(e) => {
- if (e.target.value === '__CUSTOM__') {
- setCustomBookerAccountPool(true);
- setBookerAccountPoolId('');
- } else {
- setBookerAccountPoolId(e.target.value);
- }
- }}
- 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]"
- >
- <option value="">-- 请选择账号池 --</option>
- {accountPools.map((p) => (
- <option key={p.pool_name} value={p.pool_name}>
- {p.pool_name} ({p.total_count ?? 0} 个账号)
- </option>
- ))}
- <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
- </select>
- )}
- </div>
- {/* Target Instances - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">目标并发实例 (target_instances)</label>
- <select
- value={bookerTargetInstances}
- onChange={(e) => setBookerTargetInstances(Number(e.target.value))}
- 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]"
- >
- {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
- <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- {/* Account CD - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">账号冷却 (account_cd / 秒)</label>
- <select
- value={bookerAccountCd}
- onChange={(e) => setBookerAccountCd(Number(e.target.value))}
- 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]"
- >
- {[
- { v: 1800, label: '30 分钟' },
- { v: 3600, label: '1 小时' },
- { v: 7200, label: '2 小时' },
- { v: 10800, label: '3 小时 (默认)' },
- { v: 14400, label: '4 小时' },
- { v: 21600, label: '6 小时' },
- { v: 43200, label: '12 小时' },
- { v: 86400, label: '24 小时' },
- ].map((opt) => (
- <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
- ))}
- </select>
- </div>
- {/* Booking Cooldown - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">下单间隔冷却 (booking_cooldown / 秒)</label>
- <select
- value={bookerCooldown}
- onChange={(e) => setBookerCooldown(Number(e.target.value))}
- 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]"
- >
- {[
- { v: 10, label: '10 秒' },
- { v: 30, label: '30 秒' },
- { v: 60, label: '1 分钟' },
- { v: 120, label: '2 分钟' },
- { v: 300, label: '5 分钟 (默认)' },
- { v: 600, label: '10 分钟' },
- { v: 900, label: '15 分钟' },
- { v: 1800, label: '30 分钟' },
- ].map((opt) => (
- <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
- ))}
- </select>
- </div>
- {/* Max Bookings - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">单号最大占位次数</label>
- <select
- value={bookerMaxBookings}
- onChange={(e) => setBookerMaxBookings(Number(e.target.value))}
- 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]"
- >
- {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 50].map((v) => (
- <option key={v} value={v}>{v} 次{v === 8 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- {/* Proxy CD - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">代理冷却时间 (proxy_cd / 秒)</label>
- <select
- value={proxyCd}
- onChange={(e) => setProxyCd(Number(e.target.value))}
- 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]"
- >
- {[
- { v: 0, label: '无冷却' },
- { v: 60, label: '1 分钟' },
- { v: 120, label: '2 分钟' },
- { v: 180, label: '3 分钟' },
- { v: 300, label: '5 分钟 (默认)' },
- { v: 600, label: '10 分钟' },
- { v: 900, label: '15 分钟' },
- { v: 1800, label: '30 分钟' },
- ].map((opt) => (
- <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
- ))}
- </select>
- </div>
- {/* Proxy Pool - tag-based multi-select from DB */}
- <div className="md:col-span-2">
- <label className="block text-[11px] font-bold text-black mb-1">网络代理池 (proxy_pool)</label>
- {/* Selected tags */}
- <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]">
- {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).length === 0 && (
- <span className="text-neutral-400 text-[10px] italic">尚未选择代理池...</span>
- )}
- {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).map((tag) => (
- <span
- key={tag}
- className={`inline-flex items-center gap-1 px-2 py-0.5 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] ${
- tag.startsWith('cloud:') ? 'bg-sky-200 text-sky-900' : 'bg-emerald-200 text-emerald-900'
- }`}
- >
- {tag.startsWith('cloud:') ? '☁' : '⊙'} {tag}
- <button
- type="button"
- onClick={() => removeProxyPoolTag(tag)}
- className="ml-0.5 hover:text-red-600 font-black"
- >
- ✕
- </button>
- </span>
- ))}
- </div>
- {/* Add tag dropdown */}
- <select
- value=""
- onChange={(e) => {
- if (e.target.value) addProxyPoolTag(e.target.value);
- }}
- 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]"
- >
- <option value="">+ 添加代理池标签...</option>
- <optgroup label="☁ 云端代理池 (cloud:)">
- {cloudProxyPools.map((p) => (
- <option key={`cloud:${p.pool_name}`} value={`cloud:${p.pool_name}`}>
- cloud:{p.pool_name} ({p.total_count ?? 0} 条代理)
- </option>
- ))}
- </optgroup>
- <optgroup label="⊙ 本地代理池 (local:)">
- {LOCAL_PROXY_POOLS.map((p) => (
- <option key={`local:${p.value}`} value={`local:${p.value}`}>
- local:{p.value} — {p.label}
- </option>
- ))}
- </optgroup>
- </select>
- </div>
- {/* Session Max Life - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">Session 最长存活 (秒)</label>
- <select
- value={sessionMaxLife}
- onChange={(e) => setSessionMaxLife(Number(e.target.value))}
- 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]"
- >
- {[
- { v: 300, label: '5 分钟' },
- { v: 600, label: '10 分钟' },
- { v: 900, label: '15 分钟' },
- { v: 1200, label: '20 分钟' },
- { v: 1800, label: '30 分钟 (默认)' },
- { v: 2700, label: '45 分钟' },
- { v: 3600, label: '1 小时' },
- { v: 7200, label: '2 小时' },
- ].map((opt) => (
- <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
- ))}
- </select>
- </div>
- </div>
- </div>
- )}
- {/* Sentinel fields */}
- {entryType === 'sentinel' && (
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ SENTINEL PARAMS // 监控与等待策略 ]</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
- {/* Account Pool ID - dropdown from DB */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
- {customSentinelAccountPool ? (
- <div className="flex gap-1">
- <input
- type="text"
- value={sentinelAccountPoolId}
- onChange={(e) => setSentinelAccountPoolId(e.target.value)}
- placeholder="输入自定义池 ID"
- 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]"
- />
- <button
- type="button"
- onClick={() => { setCustomSentinelAccountPool(false); setSentinelAccountPoolId(''); }}
- className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
- title="切换回下拉选择"
- >
- ✕
- </button>
- </div>
- ) : (
- <select
- value={sentinelAccountPoolId}
- onChange={(e) => {
- if (e.target.value === '__CUSTOM__') {
- setCustomSentinelAccountPool(true);
- setSentinelAccountPoolId('');
- } else {
- setSentinelAccountPoolId(e.target.value);
- }
- }}
- 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]"
- >
- <option value="">-- 请选择账号池 --</option>
- {accountPools.map((p) => (
- <option key={p.pool_name} value={p.pool_name}>
- {p.pool_name} ({p.total_count ?? 0} 个账号)
- </option>
- ))}
- <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
- </select>
- )}
- </div>
- {/* Target Instances - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">监控并发实例数</label>
- <select
- value={sentinelTargetInstances}
- onChange={(e) => setSentinelTargetInstances(Number(e.target.value))}
- 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]"
- >
- {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
- <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- {/* Signal TTL - preset dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">放位信号 TTL 持续 (秒)</label>
- <select
- value={sentinelSignalTtl}
- onChange={(e) => setSentinelSignalTtl(Number(e.target.value))}
- 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]"
- >
- {[
- { v: 10, label: '10 秒' },
- { v: 15, label: '15 秒' },
- { v: 20, label: '20 秒' },
- { v: 30, label: '30 秒 (默认)' },
- { v: 45, label: '45 秒' },
- { v: 60, label: '1 分钟' },
- { v: 90, label: '90 秒' },
- { v: 120, label: '2 分钟' },
- ].map((opt) => (
- <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
- ))}
- </select>
- </div>
- {/* Query Wait Mode - dropdown */}
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">扫位轮询模式 (query_wait.mode)</label>
- <select
- value={queryWaitMode}
- onChange={(e) => setQueryWaitMode(e.target.value as any)}
- 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]"
- >
- <option value="Random">Random (随机等待)</option>
- <option value="Fixed">Fixed (固定等待)</option>
- </select>
- </div>
- {queryWaitMode === 'Fixed' ? (
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">固定等待 (秒)</label>
- <select
- value={fixedWait}
- onChange={(e) => setFixedWait(Number(e.target.value))}
- 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]"
- >
- {[5, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
- <option key={v} value={v}>{v}s{v === 10 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- ) : (
- <>
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">随机最小等待 (秒)</label>
- <select
- value={randomMin}
- onChange={(e) => setRandomMin(Number(e.target.value))}
- 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]"
- >
- {[10, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
- <option key={v} value={v}>{v}s{v === 60 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">随机最大等待 (秒)</label>
- <select
- value={randomMax}
- onChange={(e) => setRandomMax(Number(e.target.value))}
- 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]"
- >
- {[30, 60, 120, 180, 300, 450, 600, 900, 1200].map((v) => (
- <option key={v} value={v}>{v}s{v === 300 ? ' (默认)' : ''}</option>
- ))}
- </select>
- </div>
- </>
- )}
- </div>
- </div>
- )}
- {/* Standalone fields */}
- {entryType === 'standalone' && (
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ STANDALONE PARAMS // 偏好与轮询策略 ]</span>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
- <div>
- <label className="block text-[11px] font-bold text-black mb-1">登录重试间隔 (秒)</label>
- <input
- type="number"
- value={loginInterval}
- onChange={(e) => setLoginInterval(Number(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>
- <label className="block text-[11px] font-bold text-black mb-1">期望最早日期 (start_date)</label>
- <input
- type="date"
- value={expectedStartDate}
- onChange={(e) => setExpectedStartDate(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>
- <label className="block text-[11px] font-bold text-black mb-1">期望最晚日期 (end_date)</label>
- <input
- type="date"
- value={expectedEndDate}
- onChange={(e) => setExpectedEndDate(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>
- )}
- {/* Appointment Types */}
- <AppointmentTypeEditor
- items={appointmentTypes}
- onChange={setAppointmentTypes}
- />
- {/* Plugin (Inherited from Template, read-only) & Free Config */}
- <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
- <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
- <div className="flex items-center gap-2">
- <span className="w-2 h-2 bg-black inline-block" />
- <span className="font-black text-black uppercase">[ PLUGIN DRIVER // 插件运行时 (已由模板绑定) ]</span>
- </div>
- <span className="text-[10px] text-emerald-800 bg-emerald-100 border border-emerald-500 px-1.5 py-0.5 font-bold">
- ✓ 自动从模板 [{selectedProviderName || '未选'}] 继承,无需手动配置
- </span>
- </div>
- {/* Readonly info bar */}
- <div className="bg-white border-2 border-black p-3 shadow-[1px_1px_0px_#000] space-y-2">
- <div className="flex flex-wrap items-center justify-between gap-2">
- <div className="flex items-center gap-2">
- <span className="font-bold text-neutral-500 text-[11px]">绑定插件:</span>
- <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]">
- {pluginConfig.plugin_name || '默认内置驱动'}
- </span>
- </div>
- <div className="text-[11px] font-mono text-neutral-700">
- 执行脚本: <code className="font-bold text-black bg-neutral-100 px-1 py-0.5 border border-neutral-300">{pluginConfig.plugin_bin || '(内置脚本)'}</code>
- </div>
- </div>
- <div className="flex flex-wrap items-center justify-between text-[10px] text-neutral-500 border-t border-neutral-200 pt-1.5">
- <span>接口协议: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_proto || 'IPlugin'}</span></span>
- <span>加载目录: <span className="font-mono font-bold text-neutral-700">{pluginConfig.lib_path || 'plugins'}</span></span>
- {pluginConfig.plugin_class && (
- <span>入口类: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_class}</span></span>
- )}
- </div>
- </div>
- {/* Free Config */}
- <div className="pt-1">
- <label className="block text-[11px] font-bold text-black mb-1">
- 自定义扩展 JSON (free_config, 可选)
- </label>
- <textarea
- rows={3}
- value={freeConfigStr}
- onChange={(e) => setFreeConfigStr(e.target.value)}
- placeholder="{}"
- 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]"
- />
- </div>
- </div>
- </div>
- )}
- {/* STEP 3 */}
- {step === 3 && (
- <div className="space-y-5">
- {/* Notice Stamp */}
- <div className="p-3 bg-amber-100 border-2 border-black shadow-[2px_2px_0px_#000] text-black font-bold text-xs leading-relaxed">
- ⚠️ [ 落库安全提示 ]:新建的节点任务配置将一律以 <span className="bg-rose-200 border border-black px-1 py-0.2 font-black">[ 已停用 (enable: 0) ]</span> 状态落库。创建成功后可在列表中核实并随时开启。
- </div>
- {/* Summary Cards */}
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <div className="p-4 bg-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 text-xs">
- <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 基础信息核对 ]</div>
- <div className="flex justify-between">
- <span className="text-neutral-600">目标节点:</span>
- <span className="font-bold text-black">{nodeId}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">任务标识:</span>
- <span className="font-black text-black">{identifier}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">角色类型:</span>
- <span className="font-bold text-black uppercase">{entryType}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">规则数量:</span>
- <span className="font-bold text-black">{appointmentTypes.length} 条</span>
- </div>
- </div>
- <div className="p-4 bg-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 text-xs">
- <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 插件运行时 (由模板锁定) ]</div>
- <div className="flex justify-between">
- <span className="text-neutral-600">继承模板:</span>
- <span className="font-bold text-black bg-amber-200 border border-black px-1.5">{selectedProviderName || '无'}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">插件驱动:</span>
- <span className="font-bold text-black">{pluginConfig.plugin_name || '默认内置'}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">执行脚本:</span>
- <span className="font-mono font-bold text-black">{pluginConfig.plugin_bin || '(内置脚本)'}</span>
- </div>
- <div className="flex justify-between">
- <span className="text-neutral-600">协议/目录:</span>
- <span className="font-mono text-neutral-600">{pluginConfig.plugin_proto || 'IPlugin'} / {pluginConfig.lib_path || 'plugins'}</span>
- </div>
- </div>
- </div>
- {/* JSON Terminal Preview */}
- <div className="space-y-1">
- <div className="text-[11px] font-black text-black uppercase">[ JSON TERMINAL // 最终提交负载 ]</div>
- <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
- <pre className="p-4 bg-neutral-900 text-amber-300 font-mono text-xs overflow-x-auto max-h-60 leading-relaxed">
- {JSON.stringify(buildPayload(), null, 2)}
- </pre>
- </div>
- </div>
- </div>
- )}
- </div>
- {/* Footer */}
- <div className="px-5 py-3 bg-neutral-200 border-t-2 border-black flex justify-between items-center shrink-0">
- <div>
- {step > 1 && (
- <button
- type="button"
- onClick={() => setStep((prev) => (prev - 1) as any)}
- 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"
- >
- [ ← 上一步 ]
- </button>
- )}
- </div>
- <div className="flex items-center gap-2">
- <button
- type="button"
- onClick={onClose}
- 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"
- >
- [ 取消 ]
- </button>
- {step < 3 ? (
- <button
- type="button"
- onClick={handleNext}
- 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"
- >
- [ 下一步 → ]
- </button>
- ) : (
- <button
- type="button"
- onClick={handleSubmit}
- disabled={submitting}
- 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"
- >
- {submitting ? '[ 提交中... ]' : '[ 确认提交落库 ]'}
- </button>
- )}
- </div>
- </div>
- </div>
- </div>
- );
- }
|