|
|
@@ -18,7 +18,15 @@ 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';
|
|
|
+import {
|
|
|
+ LOCAL_PROXY_POOLS,
|
|
|
+ COMMON_WEBSITES,
|
|
|
+ ACTIVE_TIME_PRESETS,
|
|
|
+ getBrowserTimezoneDisplay,
|
|
|
+ localToUtcTime,
|
|
|
+ convertActiveTimeLocalToUtc,
|
|
|
+ convertActiveTimeUtcToLocal,
|
|
|
+} from './nodeConfigConstants';
|
|
|
|
|
|
interface NodeConfigCreateWizardModalProps {
|
|
|
isOpen: boolean;
|
|
|
@@ -237,6 +245,11 @@ export default function NodeConfigCreateWizardModal({
|
|
|
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 (roleTpl.active_time_start !== undefined || roleTpl.active_time_end !== undefined) {
|
|
|
+ const { startLocal, endLocal } = convertActiveTimeUtcToLocal(roleTpl.active_time_start, roleTpl.active_time_end);
|
|
|
+ setActiveTimeStart(startLocal);
|
|
|
+ setActiveTimeEnd(endLocal);
|
|
|
+ }
|
|
|
|
|
|
if (entryType === 'booker') {
|
|
|
const accSource = roleTpl['account_source'] ?? roleTpl['booker.account_source'];
|
|
|
@@ -299,10 +312,13 @@ export default function NodeConfigCreateWizardModal({
|
|
|
if (freeConfigStr.trim()) parsedFreeConfig = JSON.parse(freeConfigStr);
|
|
|
} catch {}
|
|
|
|
|
|
+ const { startUtc, endUtc } = convertActiveTimeLocalToUtc(activeTimeStart, activeTimeEnd);
|
|
|
const base: any = {
|
|
|
node_id: nodeId.trim(),
|
|
|
identifier: identifier.trim(),
|
|
|
website: website.trim(),
|
|
|
+ active_time_start: startUtc,
|
|
|
+ active_time_end: endUtc,
|
|
|
plugin_config: pluginConfig,
|
|
|
appointment_types: appointmentTypes,
|
|
|
free_config: parsedFreeConfig,
|
|
|
@@ -314,8 +330,6 @@ export default function NodeConfigCreateWizardModal({
|
|
|
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(),
|
|
|
@@ -580,6 +594,82 @@ export default function NodeConfigCreateWizardModal({
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ {/* Active Time Window */}
|
|
|
+ <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">[ TIME WINDOW // 每日生效时间窗口 ]</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="space-y-2">
|
|
|
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-1">
|
|
|
+ <label className="block text-[11px] font-bold text-black">
|
|
|
+ 每日任务运行时间窗口 (本地时区: {getBrowserTimezoneDisplay()},系统自动转为 UTC 存储)
|
|
|
+ </label>
|
|
|
+ <span className="text-[10px] text-neutral-500 font-mono">
|
|
|
+ {activeTimeStart === '00:00' && activeTimeEnd === '23:59'
|
|
|
+ ? '全天 24H (底层存储 UTC: 00:00 ~ 23:59)'
|
|
|
+ : `底层存储 UTC: ${localToUtcTime(activeTimeStart)} ~ ${localToUtcTime(activeTimeEnd)}`}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
|
+ <div>
|
|
|
+ <label className="block text-[10px] font-bold text-neutral-600 mb-1">开始时间 (时:分)</label>
|
|
|
+ <input
|
|
|
+ type="time"
|
|
|
+ value={activeTimeStart}
|
|
|
+ onChange={(e) => setActiveTimeStart(e.target.value)}
|
|
|
+ className="w-full px-3 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[1px_1px_0px_#000]"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label className="block text-[10px] font-bold text-neutral-600 mb-1">结束时间 (时:分)</label>
|
|
|
+ <input
|
|
|
+ type="time"
|
|
|
+ value={activeTimeEnd}
|
|
|
+ onChange={(e) => setActiveTimeEnd(e.target.value)}
|
|
|
+ className="w-full px-3 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[1px_1px_0px_#000]"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* Preset chips */}
|
|
|
+ <div className="flex flex-wrap items-center gap-1.5 pt-1">
|
|
|
+ <span className="text-[10px] text-neutral-500 font-bold">常用时段预设:</span>
|
|
|
+ {ACTIVE_TIME_PRESETS.map((t) => (
|
|
|
+ <button
|
|
|
+ key={t.label}
|
|
|
+ type="button"
|
|
|
+ onClick={() => {
|
|
|
+ setActiveTimeStart(t.start);
|
|
|
+ setActiveTimeEnd(t.end);
|
|
|
+ }}
|
|
|
+ className={`px-2 py-0.5 text-[10px] font-mono font-bold border transition ${
|
|
|
+ activeTimeStart === t.start && activeTimeEnd === t.end
|
|
|
+ ? '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'
|
|
|
+ }`}
|
|
|
+ >
|
|
|
+ {t.label}
|
|
|
+ </button>
|
|
|
+ ))}
|
|
|
+ {(activeTimeStart !== '00:00' || activeTimeEnd !== '23:59') && (
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ onClick={() => {
|
|
|
+ setActiveTimeStart('00:00');
|
|
|
+ setActiveTimeEnd('23:59');
|
|
|
+ }}
|
|
|
+ className="px-2 py-0.5 text-[10px] font-mono font-bold text-red-600 border border-red-300 hover:bg-red-50 hover:border-red-600 transition"
|
|
|
+ >
|
|
|
+ [ 重置为全天 24H ]
|
|
|
+ </button>
|
|
|
+ )}
|
|
|
+ </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">
|