334 lines
13 KiB
React
334 lines
13 KiB
React
// src/pages/Register/RegForm.jsx
|
||
// Left panel: start parameters. Email channel is multi-select only —
|
||
// per-provider secrets/domains live on Resources → Почта; pipeline pool
|
||
// on Settings. State is lifted to RegisterPage so the 4s poll never wipes edits.
|
||
import { useEffect } from "preact/hooks";
|
||
import { Field, Select, ProviderPoolStatus } from "../../ui/index.js";
|
||
import { regFormDirty } from "../../store/run.js";
|
||
import {
|
||
EMAIL_PROVIDERS,
|
||
normalizeProvidersList,
|
||
} from "../../lib/providers.js";
|
||
|
||
const DEFAULTS = {
|
||
email_providers: [],
|
||
target: 100,
|
||
threads: 1,
|
||
mode: "ordinary",
|
||
tag: "batch_web",
|
||
chunk: 3,
|
||
turnstile: 150,
|
||
probeChat: false,
|
||
ssoOnly: true,
|
||
batchEndInject: false,
|
||
importEvery: 100,
|
||
importSize: "",
|
||
importPause: "",
|
||
proxyMode: "clash",
|
||
proxy: "",
|
||
proxyList: "",
|
||
kind: "grok_supervisor",
|
||
product: "grok",
|
||
skipPreflight: false,
|
||
nodeScore: "",
|
||
syncMailEnv: true,
|
||
};
|
||
|
||
export function RegForm({
|
||
value,
|
||
onChange,
|
||
advancedOpen,
|
||
onToggleAdvanced,
|
||
residualPrimary = "",
|
||
}) {
|
||
useEffect(() => {
|
||
// dirty handling is done in field onChange below
|
||
}, []);
|
||
|
||
const v = { ...DEFAULTS, ...value };
|
||
const isSupervisor = (v.kind || "grok_supervisor") === "grok_supervisor";
|
||
const selected = normalizeProvidersList(v.email_providers);
|
||
|
||
function set(partial) {
|
||
regFormDirty.value = true;
|
||
onChange({ ...v, ...partial });
|
||
}
|
||
|
||
function toggleProvider(name) {
|
||
const cur = new Set(selected);
|
||
if (cur.has(name)) cur.delete(name);
|
||
else cur.add(name);
|
||
// preserve EMAIL_PROVIDERS order
|
||
set({ email_providers: EMAIL_PROVIDERS.filter((p) => cur.has(p)) });
|
||
}
|
||
|
||
return (
|
||
<form class="stack-form" onSubmit={(e) => e.preventDefault()}>
|
||
<div class="field-grid">
|
||
<Field label="Почтовые сервисы (мультивыбор)" span2>
|
||
<div class="provider-multi mail-domain-chips">
|
||
{EMAIL_PROVIDERS.map((p) => (
|
||
<label key={p} class="check chip">
|
||
<input
|
||
type="checkbox"
|
||
checked={selected.includes(p)}
|
||
onChange={() => toggleProvider(p)}
|
||
/>{" "}
|
||
{p}
|
||
</label>
|
||
))}
|
||
</div>
|
||
<ProviderPoolStatus
|
||
selected={selected}
|
||
primaryProvider={residualPrimary}
|
||
canClear={false}
|
||
/>
|
||
<p class="hint tight">
|
||
Выбор каналов только для этого батча (общий с настройками <code>email_providers</code>). Ключи / домены →{" "}
|
||
<a href="#/resources?tab=mail">Ресурсы · Почта</a>; стратегия опроса →{" "}
|
||
<a href="#/settings">Настройки</a>
|
||
</p>
|
||
{!selected.length ? (
|
||
<p class="hint warn tight">
|
||
Отметьте хотя бы один для запуска
|
||
{residualPrimary ? `(страница регистрации не отмечает автоматически остаточный одиночный канал)` : ""}。
|
||
</p>
|
||
) : null}
|
||
</Field>
|
||
<Field label="Количество target">
|
||
<input
|
||
type="number"
|
||
min="1"
|
||
value={v.target}
|
||
onInput={(e) =>
|
||
set({ target: e.currentTarget.value === "" ? "" : Number(e.currentTarget.value) })
|
||
}
|
||
/>
|
||
</Field>
|
||
<Field label="Потоки threads">
|
||
<input
|
||
type="number"
|
||
min="1"
|
||
max="32"
|
||
value={v.threads}
|
||
onInput={(e) =>
|
||
set({ threads: e.currentTarget.value === "" ? "" : Number(e.currentTarget.value) })
|
||
}
|
||
/>
|
||
</Field>
|
||
<Field label="Режим">
|
||
<Select
|
||
options={[
|
||
{ value: "ordinary", label: "ordinary · Clash (дата-центр)" },
|
||
{ value: "residential", label: "residential · резидентные" },
|
||
]}
|
||
value={v.mode}
|
||
onChange={(val) => set({ mode: val })}
|
||
/>
|
||
</Field>
|
||
<Field label="tag">
|
||
<input value={v.tag} onInput={(e) => set({ tag: e.currentTarget.value })} />
|
||
</Field>
|
||
</div>
|
||
|
||
<div class="info-box">По умолчанию disk-first: без mid-tebi инъекции. Полные логи на странице «Логи».</div>
|
||
|
||
<details class="advanced" open={advancedOpen} onToggle={onToggleAdvanced}>
|
||
<summary>Расширенный запуск · параметры батча / прокси / kind / product / SKIP_CLASH / NODE_SCORE</summary>
|
||
<div class="field-grid">
|
||
<Field label="SUPERVISOR_CHUNK" class={isSupervisor ? "" : "hidden"}>
|
||
<input
|
||
type="number"
|
||
min="1"
|
||
max="20"
|
||
value={v.chunk}
|
||
disabled={!isSupervisor}
|
||
onInput={(e) =>
|
||
set({ chunk: e.currentTarget.value === "" ? "" : Number(e.currentTarget.value) })
|
||
}
|
||
/>
|
||
</Field>
|
||
<Field label="Таймаут зависания Turnstile (сек)">
|
||
<input
|
||
type="number"
|
||
min="5"
|
||
value={v.turnstile}
|
||
onInput={(e) =>
|
||
set({
|
||
turnstile: e.currentTarget.value === "" ? "" : Number(e.currentTarget.value),
|
||
})
|
||
}
|
||
/>
|
||
</Field>
|
||
<label class="check muted" title="Supervisor жёстко задаёт CPA_PROBE_CHAT=false">
|
||
<input type="checkbox" checked={false} disabled /> Chat-проба после регистрации (принудительно выкл)
|
||
</label>
|
||
<label
|
||
class="check"
|
||
title="Инфо: mid-mint никогда не инжектится в tebi (контракт disk-first); снятие галочки не включает mid-mint inject"
|
||
>
|
||
<input
|
||
type="checkbox"
|
||
checked={v.ssoOnly}
|
||
onChange={(e) => set({ ssoOnly: e.currentTarget.checked })}
|
||
/>{" "}
|
||
Только запись auth на диск (по умолчанию · инфо)
|
||
</label>
|
||
<label class="check" title="только граница батча CPA_BATCH_END_INJECT">
|
||
<input
|
||
type="checkbox"
|
||
checked={v.batchEndInject}
|
||
disabled={!isSupervisor}
|
||
onChange={(e) => set({ batchEndInject: e.currentTarget.checked })}
|
||
/>{" "}
|
||
Авто-импорт CPA на границе батча
|
||
</label>
|
||
<Field label="CPA_BATCH_IMPORT_EVERY" class={isSupervisor ? "" : "hidden"}>
|
||
<input
|
||
type="number"
|
||
min="1"
|
||
value={v.importEvery}
|
||
disabled={!isSupervisor}
|
||
onInput={(e) =>
|
||
set({
|
||
importEvery: e.currentTarget.value === "" ? "" : Number(e.currentTarget.value),
|
||
})
|
||
}
|
||
/>
|
||
</Field>
|
||
|
||
<Field label="Стратегия прокси proxy_rotate_mode">
|
||
<Select
|
||
options={[
|
||
{ value: "clash", label: "clash · ротация встроенного пула узлов" },
|
||
{ value: "list", label: "list · PROXY_LIST / proxy_list" },
|
||
{ value: "off", label: "off · фиксированный выход" },
|
||
]}
|
||
value={v.proxyMode}
|
||
onChange={(val) => set({ proxyMode: val })}
|
||
/>
|
||
</Field>
|
||
<Field label="Фиксированный proxy URL">
|
||
<input
|
||
placeholder="http://127.0.0.1:7897"
|
||
value={v.proxy}
|
||
onInput={(e) => set({ proxy: e.currentTarget.value })}
|
||
/>
|
||
</Field>
|
||
<Field label="Пул прокси proxy_list / PROXY_LIST" span2>
|
||
<textarea
|
||
rows="4"
|
||
placeholder="По одному прокси на строку; запись только непустых; очистка — на странице настроек"
|
||
value={v.proxyList}
|
||
onInput={(e) => set({ proxyList: e.currentTarget.value })}
|
||
/>
|
||
<p class="hint tight">
|
||
Пустое поле здесь <strong>НЕ</strong> очищает серверный <code>PROXY_LIST</code>
|
||
(очистка clearable в
|
||
<a href="#/settings">Настройки</a>)。
|
||
</p>
|
||
</Field>
|
||
|
||
<Field label="kind">
|
||
<Select
|
||
options={[
|
||
{ value: "grok_supervisor", label: "grok_supervisor · пакетный надзор" },
|
||
{ value: "register_sh", label: "register_sh · одиночная оболочка" },
|
||
]}
|
||
value={v.kind}
|
||
onChange={(val) =>
|
||
set({ kind: val, product: val === "grok_supervisor" ? "grok" : v.product })
|
||
}
|
||
/>
|
||
</Field>
|
||
<Field label="product">
|
||
<Select
|
||
options={[
|
||
{ value: "grok", label: "grok (оригинал)" },
|
||
{ value: "mimo", label: "mimo (оригинал)" },
|
||
{ value: "chatgpt", label: "chatgpt (оригинал)" },
|
||
{ value: "typesafe", label: "typesafe (оригинал)" },
|
||
{ value: "vip7891", label: "⚡ vip7891 · new-api GH-OAuth" },
|
||
{ value: "agentrouter", label: "⚡ agentrouter · GH-OAuth" },
|
||
{ value: "conol", label: "⚡ conol.ai · 600cr" },
|
||
{ value: "vani", label: "⚡ vani.ai" },
|
||
{ value: "notion", label: "⚡ notion · Opus-ферма" },
|
||
{ value: "kiro", label: "⚡ kiro · BuilderID" },
|
||
{ value: "type", label: "⚡ type.com · voidash+SMS" },
|
||
{ value: "llmtr", label: "⚡ llmtr.com" },
|
||
{ value: "xkiro", label: "⚡ xkiro · TG-верификация" },
|
||
{ value: "omnirush", label: "⚡ omnirush.ai" },
|
||
{ value: "gname", label: "⚡ gname.com · слайдер" },
|
||
{ value: "abliteration", label: "⚡ abliteration.ai · квесты" },
|
||
{ value: "terrapolis", label: "⚡ terrapolis.xyz · 15M" },
|
||
{ value: "cleanapis", label: "⚡ cleanapis.com · GH-OAuth" },
|
||
{ value: "miarouter", label: "⚡ miarouter.online · TG-miniapp" },
|
||
{ value: "treg", label: "⚡ treg.to · voidash $1" },
|
||
]}
|
||
value={isSupervisor ? "grok" : v.product}
|
||
disabled={isSupervisor}
|
||
onChange={(val) =>
|
||
set(
|
||
["grok", "mimo", "chatgpt", "typesafe"].includes(val)
|
||
? { product: val }
|
||
: { product: val, kind: "register_sh" }
|
||
)
|
||
}
|
||
/>
|
||
</Field>
|
||
<label class="check" title="SKIP_CLASH_PREFLIGHT=1 пропускает пред-проверку Clash перед батчем; по умолчанию выкл">
|
||
<input
|
||
type="checkbox"
|
||
checked={v.skipPreflight}
|
||
onChange={(e) => set({ skipPreflight: e.currentTarget.checked })}
|
||
/>{" "}
|
||
Пропустить пред-проверку Clash перед батчем
|
||
</label>
|
||
<Field label="NODE_SCORE">
|
||
<Select
|
||
options={[
|
||
{ value: "", label: "(не передаётся, берётся из env)" },
|
||
{ value: "1", label: "1 · сортировка по скору" },
|
||
{ value: "0", label: "0 · скоринг выкл" },
|
||
]}
|
||
value={v.nodeScore}
|
||
onChange={(val) => set({ nodeScore: val })}
|
||
/>
|
||
</Field>
|
||
<Field label="CPA_BATCH_IMPORT_SIZE" class={isSupervisor ? "" : "hidden"}>
|
||
<input
|
||
type="number"
|
||
min="1"
|
||
placeholder="100"
|
||
value={v.importSize}
|
||
disabled={!isSupervisor}
|
||
onInput={(e) => set({ importSize: e.currentTarget.value })}
|
||
/>
|
||
</Field>
|
||
<Field label="CPA_BATCH_IMPORT_PAUSE" class={isSupervisor ? "" : "hidden"}>
|
||
<input
|
||
type="number"
|
||
min="0"
|
||
placeholder="3"
|
||
value={v.importPause}
|
||
disabled={!isSupervisor}
|
||
onInput={(e) => set({ importPause: e.currentTarget.value })}
|
||
/>
|
||
</Field>
|
||
<label
|
||
class="check span2"
|
||
title="При старте синхронизировать отмеченные EMAIL_PROVIDERS в extra_env (перекрывает одиночный канал .env)"
|
||
>
|
||
<input
|
||
type="checkbox"
|
||
checked={v.syncMailEnv}
|
||
onChange={(e) => set({ syncMailEnv: e.currentTarget.checked })}
|
||
/>{" "}
|
||
Синхронизировать EMAIL_PROVIDERS в extra_env
|
||
</label>
|
||
</div>
|
||
</details>
|
||
</form>
|
||
);
|
||
}
|