Kaynağa Gözat

feat: update

jerry 1 ay önce
ebeveyn
işleme
20e6847400
56 değiştirilmiş dosya ile 6176 ekleme ve 2231 silme
  1. 1188 90
      package-lock.json
  2. 3 1
      package.json
  3. 2 262
      src/app/admin/agent/page.tsx
  4. 15 6
      src/app/admin/layout.tsx
  5. 57 25
      src/app/admin/node-configurations/page.tsx
  6. 349 173
      src/app/admin/page.tsx
  7. 106 46
      src/app/admin/tasks/page.tsx
  8. 43 1
      src/app/dashboard/page.tsx
  9. 28 179
      src/app/page.tsx
  10. 1 1
      src/app/refund-policy/page.tsx
  11. 0 13
      src/app/slots/page.tsx
  12. 2 2
      src/app/terms/page.tsx
  13. 3 3
      src/components/Footer.tsx
  14. 1 1
      src/components/Navbar.tsx
  15. 295 179
      src/components/ServiceList.tsx
  16. 7 6
      src/components/admin/AdminSidebar.tsx
  17. 0 41
      src/components/admin/DataStats.tsx
  18. 25 29
      src/components/admin/agent/AgentActionConfirmCard.tsx
  19. 249 233
      src/components/admin/agent/AgentChatBox.tsx
  20. 61 45
      src/components/admin/agent/AgentToolStepCard.tsx
  21. 256 0
      src/components/admin/agent/CliMarkdownRenderer.tsx
  22. 0 165
      src/components/admin/dashboard/OverviewCharts.tsx
  23. 0 55
      src/components/admin/dashboard/RecentActivities.tsx
  24. 436 79
      src/components/admin/node-configurations/AppointmentTypeEditor.tsx
  25. 671 0
      src/components/admin/node-configurations/CoordinateTutorialPanel.tsx
  26. 16 1
      src/components/admin/node-configurations/NodeClusterTelemetryBar.tsx
  27. 40 11
      src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx
  28. 1 1
      src/components/admin/node-configurations/NodeConfigDetailDrawer.tsx
  29. 236 25
      src/components/admin/node-configurations/NodeConfigEditModal.tsx
  30. 1 1
      src/components/admin/node-configurations/NodeConfigTable.tsx
  31. 239 41
      src/components/admin/node-configurations/ProviderModal.tsx
  32. 1 1
      src/components/admin/orders/OrderEditModal.tsx
  33. 12 7
      src/components/admin/payments/ProviderModal.tsx
  34. 564 104
      src/components/admin/products/ProductModal.tsx
  35. 8 8
      src/components/admin/settlement/CostRecordsTab.tsx
  36. 77 15
      src/components/admin/settlement/SettlementEngineTab.tsx
  37. 15 2
      src/components/admin/settlement/SettlementPeriodDetailModal.tsx
  38. 207 51
      src/components/admin/tasks/TaskTable.tsx
  39. 227 77
      src/components/admin/tickets/TicketDetailModal.tsx
  40. 169 0
      src/components/common/ImageUploadField.tsx
  41. 192 83
      src/components/common/ProductTutorialBanner.tsx
  42. 25 9
      src/components/dashboard/OrderList.tsx
  43. 1 1
      src/components/dashboard/Sidebar.tsx
  44. 24 4
      src/components/dashboard/TicketModal.tsx
  45. 159 18
      src/components/dashboard/UserTicketDetailModal.tsx
  46. 38 80
      src/components/services/ServicePoster.tsx
  47. 8 39
      src/components/slots/CitySlotCard.tsx
  48. 1 3
      src/components/slots/SlotGrid.tsx
  49. 29 7
      src/lib/i18n/locales/en.ts
  50. 29 7
      src/lib/i18n/locales/zh.ts
  51. 37 0
      src/lib/services/storageService.ts
  52. 4 0
      src/lib/services/taskService.ts
  53. 4 0
      src/types/product.ts
  54. 3 0
      src/types/settlement.ts
  55. 9 0
      src/types/task.ts
  56. 2 0
      src/types/ticket.ts

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1188 - 90
package-lock.json


+ 3 - 1
package.json

@@ -1,5 +1,5 @@
 {
-    "name": "textskin-frontend",
+    "name": "strata-frontend",
     "version": "0.1.0",
     "private": true,
     "scripts": {
@@ -18,7 +18,9 @@
         "react-dom": "^18",
         "react-hot-toast": "^2.6.0",
         "react-is": "^19.2.3",
+        "react-markdown": "^10.1.0",
         "recharts": "^3.6.0",
+        "remark-gfm": "^4.0.1",
         "use-debounce": "^10.0.6"
     },
     "devDependencies": {

+ 2 - 262
src/app/admin/agent/page.tsx

@@ -1,266 +1,6 @@
 // src/app/admin/agent/page.tsx
 'use client';
 
-import { useState } from 'react';
-import { useAgentChat } from '@/hooks/useAgentChat';
-import AgentChatBox from '@/components/admin/agent/AgentChatBox';
-import AgentToolsModal from '@/components/admin/agent/AgentToolsModal';
-import { 
-  Bot, Plus, Trash2, Clock, Sparkles, 
-  Wrench, Activity, ShieldCheck, ChevronRight, RefreshCw 
-} from 'lucide-react';
-import { format } from 'date-fns';
+import AdminOpsPage from '../page';
 
-export default function AdminAgentPage() {
-  const [isToolsModalOpen, setIsToolsModalOpen] = useState(false);
-
-  const {
-    sessions,
-    currentSessionId,
-    messages,
-    isLoading,
-    currentThinking,
-    tools,
-    toolsLoading,
-    sendMessage,
-    abortStream,
-    createNewSession,
-    switchSession,
-    deleteSession,
-    clearCurrentSession,
-    handleConfirmDangerousAction,
-    loadTools,
-  } = useAgentChat();
-
-  const activeSession = sessions.find((s) => s.id === currentSessionId);
-
-  const quickPrompts = [
-    { label: '查待支付订单', prompt: '帮我查询最近的订单,并告诉我有没有待支付的' },
-    { label: '检索法国签证', prompt: '帮我查一下法国相关的签证服务' },
-    { label: '列出最新 5 笔订单', prompt: '查询最近的 5 笔订单详情与状态' },
-    { label: '查看系统开放工具', prompt: '告诉我你目前掌握了哪些系统运维工具?' },
-  ];
-
-  return (
-    <div className="space-y-4 font-mono select-none">
-      
-      {/* 顶部标题栏与面包屑 */}
-      <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000]">
-        <div className="flex items-center gap-3">
-          <div className="w-10 h-10 bg-amber-300 border-2 border-black flex items-center justify-center shadow-[2px_2px_0px_#000] shrink-0">
-            <Bot size={22} className="text-black" />
-          </div>
-          <div>
-            <h1 className="font-black text-sm sm:text-base text-black uppercase tracking-wider flex items-center gap-2">
-              <span>[ AI-OPS // 智能运维调度中枢 ]</span>
-              <span className="text-[10px] bg-emerald-200 text-emerald-900 border border-black px-1.5 py-0.5 font-bold">
-                SYSTEM ONLINE
-              </span>
-            </h1>
-            <p className="text-xs text-neutral-600 font-bold">
-              自然语言需求智能拆解、工具自主决策执行与运维审计监控
-            </p>
-          </div>
-        </div>
-
-        <div className="flex items-center gap-2">
-          <button
-            type="button"
-            onClick={() => setIsToolsModalOpen(true)}
-            className="flex items-center gap-1.5 px-3 py-2 bg-neutral-100 hover:bg-amber-300 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
-          >
-            <Wrench size={13} />
-            <span>[ 技能能力库 ({tools.length}) ]</span>
-          </button>
-
-          <button
-            type="button"
-            onClick={() => createNewSession()}
-            className="flex items-center gap-1.5 px-3.5 py-2 bg-amber-300 hover:bg-amber-400 border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
-          >
-            <Plus size={14} />
-            <span>[ 新建对话 ]</span>
-          </button>
-        </div>
-      </div>
-
-      {/* 主工作区:三栏或双栏布局 */}
-      <div className="grid grid-cols-1 lg:grid-cols-12 gap-4 h-[calc(100vh-230px)] min-h-[580px]">
-        
-        {/* 左栏:会话历史列表 (3 cols) */}
-        <div className="hidden lg:flex lg:col-span-3 flex-col bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
-          <div className="p-3 border-b-2 border-black bg-neutral-100 flex items-center justify-between">
-            <div className="flex items-center gap-1.5 font-black text-xs uppercase">
-              <Clock size={14} />
-              <span>历史运维会话 ({sessions.length})</span>
-            </div>
-            <button
-              type="button"
-              onClick={() => createNewSession()}
-              className="p-1 bg-white hover:bg-amber-300 border border-black shadow-[1px_1px_0px_#000]"
-              title="新建会话"
-            >
-              <Plus size={12} />
-            </button>
-          </div>
-
-          <div className="flex-1 overflow-y-auto p-2 space-y-1.5 scrollbar-thin">
-            {sessions.map((s) => {
-              const isActive = s.id === currentSessionId;
-              return (
-                <div
-                  key={s.id}
-                  onClick={() => switchSession(s.id)}
-                  className={`
-                    p-2.5 border-2 text-xs cursor-pointer transition select-none group relative
-                    ${isActive
-                      ? 'bg-amber-300 border-black shadow-[2px_2px_0px_#000]'
-                      : 'bg-neutral-50 border-neutral-200 hover:border-black hover:bg-white'
-                    }
-                  `}
-                >
-                  <div className="flex items-center justify-between mb-1">
-                    <span className="font-black truncate flex-1 pr-2">
-                      {s.title}
-                    </span>
-                    <button
-                      type="button"
-                      onClick={(e) => {
-                        e.stopPropagation();
-                        deleteSession(s.id);
-                      }}
-                      className="opacity-0 group-hover:opacity-100 p-0.5 hover:bg-rose-200 border border-transparent hover:border-black text-black transition"
-                      title="删除该会话"
-                    >
-                      <Trash2 size={11} />
-                    </button>
-                  </div>
-                  <div className="flex items-center justify-between text-[10px] text-neutral-500 font-bold">
-                    <span>{format(new Date(s.updatedAt), 'MM-dd HH:mm')}</span>
-                    <span>{s.messageCount} 条互动</span>
-                  </div>
-                </div>
-              );
-            })}
-          </div>
-        </div>
-
-        {/* 中栏:核心聊天视窗 (6 cols on large, 9 on medium) */}
-        <div className="col-span-1 lg:col-span-6 bg-white border-2 border-black shadow-[4px_4px_0px_#000] flex flex-col overflow-hidden">
-          <AgentChatBox
-            messages={messages}
-            isLoading={isLoading}
-            currentThinking={currentThinking}
-            onSendMessage={sendMessage}
-            onAbort={abortStream}
-            onClearSession={clearCurrentSession}
-            onOpenToolsModal={() => setIsToolsModalOpen(true)}
-            tools={tools}
-            quickPrompts={quickPrompts}
-            onConfirmAction={handleConfirmDangerousAction}
-            className="h-full"
-          />
-        </div>
-
-        {/* 右栏:系统技能速览与能力透视 (3 cols) */}
-        <div className="hidden lg:flex lg:col-span-3 flex-col bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
-          <div className="p-3 border-b-2 border-black bg-neutral-100 flex items-center justify-between">
-            <div className="flex items-center gap-1.5 font-black text-xs uppercase">
-              <Activity size={14} />
-              <span>智能体系统状态</span>
-            </div>
-            <button
-              type="button"
-              onClick={loadTools}
-              disabled={toolsLoading}
-              className="p-1 bg-white hover:bg-amber-300 border border-black shadow-[1px_1px_0px_#000]"
-              title="刷新工具列表"
-            >
-              <RefreshCw size={12} className={toolsLoading ? 'animate-spin' : ''} />
-            </button>
-          </div>
-
-          <div className="flex-1 overflow-y-auto p-3 space-y-4 scrollbar-thin">
-            {/* 系统指标卡 */}
-            <div className="bg-neutral-50 p-3 border border-black space-y-2 text-xs">
-              <div className="flex justify-between">
-                <span className="text-neutral-500 font-bold">执行引擎:</span>
-                <span className="font-black text-black">SSE Autonomous Loop</span>
-              </div>
-              <div className="flex justify-between">
-                <span className="text-neutral-500 font-bold">单轮工具上限:</span>
-                <span className="font-black text-black">8 STEPS</span>
-              </div>
-              <div className="flex justify-between">
-                <span className="text-neutral-500 font-bold">高危操作拦截:</span>
-                <span className="font-black text-emerald-700 flex items-center gap-1">
-                  <ShieldCheck size={12} />
-                  已启用
-                </span>
-              </div>
-            </div>
-
-            {/* 可用工具一览 */}
-            <div className="space-y-2">
-              <div className="flex items-center justify-between">
-                <span className="text-xs font-black uppercase text-neutral-800">
-                  ▶ 已注册工具 ({tools.length})
-                </span>
-                <button
-                  type="button"
-                  onClick={() => setIsToolsModalOpen(true)}
-                  className="text-[10px] font-bold text-neutral-600 hover:text-black underline"
-                >
-                  查看全部
-                </button>
-              </div>
-
-              <div className="space-y-1.5">
-                {tools.map((t) => (
-                  <div
-                    key={t.name}
-                    onClick={() => {
-                      if (t.name.includes('order')) {
-                        sendMessage('帮我查一下最近的待支付订单');
-                      } else if (t.name.includes('product') || t.name.includes('search')) {
-                        sendMessage('查一下法国相关的签证服务');
-                      }
-                    }}
-                    className="p-2 bg-neutral-50 hover:bg-amber-100 border border-neutral-300 hover:border-black cursor-pointer transition text-xs group"
-                  >
-                    <div className="flex items-center justify-between mb-0.5">
-                      <span className="font-bold text-black text-[11px] truncate group-hover:text-black">
-                        {t.name}
-                      </span>
-                      {t.is_dangerous ? (
-                        <span className="text-[9px] font-black text-rose-800 bg-rose-200 border border-black px-1">
-                          高危
-                        </span>
-                      ) : (
-                        <span className="text-[9px] text-neutral-500">只读</span>
-                      )}
-                    </div>
-                    <div className="text-[10px] text-neutral-500 truncate">
-                      {t.description}
-                    </div>
-                  </div>
-                ))}
-              </div>
-            </div>
-          </div>
-        </div>
-
-      </div>
-
-      {/* 工具库弹窗 */}
-      <AgentToolsModal
-        isOpen={isToolsModalOpen}
-        onClose={() => setIsToolsModalOpen(false)}
-        tools={tools}
-        loading={toolsLoading}
-        onRefresh={loadTools}
-        onSelectPrompt={(p) => sendMessage(p)}
-      />
-    </div>
-  );
-}
+export default AdminOpsPage;

+ 15 - 6
src/app/admin/layout.tsx

@@ -1,7 +1,7 @@
 'use client';
 
 import { useEffect, useState } from 'react';
-import { useRouter } from 'next/navigation';
+import { useRouter, usePathname } from 'next/navigation';
 import Link from 'next/link';
 import AdminSidebar from '@/components/admin/AdminSidebar';
 import AgentDrawer from '@/components/admin/agent/AgentDrawer';
@@ -12,6 +12,7 @@ import { toast } from 'react-hot-toast';
 
 export default function AdminLayout({ children }: { children: React.ReactNode }) {
   const router = useRouter();
+  const pathname = usePathname();
   const [isAuthorized, setIsAuthorized] = useState(false);
   const [user, setUser] = useState<any>(null);
   const [isCopilotOpen, setIsCopilotOpen] = useState(false);
@@ -105,12 +106,20 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
           </div>
         </header>
 
-        {/* 页面内容滚动区 */}
-        <div className="flex-1 overflow-y-auto p-4 md:p-6 scroll-smooth bg-neutral-100">
-          <div className="max-w-7xl mx-auto space-y-6">
-            {children}
+        {/* 页面内容区 (智能运维全屏沉浸,其他管理页保持标准边距) */}
+        {pathname === '/admin' || pathname === '/admin/agent' ? (
+          <div className="flex-1 overflow-hidden p-2 sm:p-3 bg-neutral-100 flex flex-col">
+            <div className="w-full h-full flex-1 flex flex-col">
+              {children}
+            </div>
+          </div>
+        ) : (
+          <div className="flex-1 overflow-y-auto p-4 md:p-6 scroll-smooth bg-neutral-100">
+            <div className="max-w-7xl mx-auto space-y-6">
+              {children}
+            </div>
           </div>
-        </div>
+        )}
       </main>
 
       {/* 全局 Copilot 抽屉与浮动按钮 (一般时候保持隐藏) */}

+ 57 - 25
src/app/admin/node-configurations/page.tsx

@@ -6,6 +6,9 @@ import React, { useState, useEffect, useCallback } from 'react';
 import {
   RefreshCw,
   Search,
+  Activity,
+  ChevronDown,
+  ChevronUp,
 } from 'lucide-react';
 import { toast } from 'react-hot-toast';
 import {
@@ -61,6 +64,7 @@ export default function NodeConfigurationsPage() {
   const [loadingTelemetry, setLoadingTelemetry] = useState(false);
   const [autoRefreshTelemetry, setAutoRefreshTelemetry] = useState(true);
   const [lastTelemetryTime, setLastTelemetryTime] = useState<string>('');
+  const [showTelemetry, setShowTelemetry] = useState(false);
 
   // Live Instances Modal state
   const [isInstancesModalOpen, setIsInstancesModalOpen] = useState(false);
@@ -274,16 +278,19 @@ export default function NodeConfigurationsPage() {
   };
 
   const totalPages = Math.ceil(total / pageSize) || 1;
+  const totalNodes = runtimeNodes.length;
+  const onlineNodes = runtimeNodes.filter((n) => n.is_online).length;
 
   return (
-    <div className="space-y-6 font-mono">
-      {/* 顶部标头 (Industrial Ops Header Banner) */}
-      <div className="bg-neutral-100 border-2 border-black p-6 shadow-[6px_6px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
+    <div className="space-y-4 font-mono">
+      {/* 顶部标头 (Compact Industrial Ops Header) */}
+      <div className="bg-white border-2 border-black p-4 shadow-[4px_4px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
         <div>
-          <div className="text-[10px] font-bold text-neutral-500 uppercase tracking-widest">
-            [ NODE-CLUSTER-CONFIGS // 节点任务与服务商中枢 ]
+          <div className="text-[10px] font-black text-neutral-500 uppercase tracking-widest flex items-center gap-1.5">
+            <span className="w-2 h-2 bg-amber-400 border border-black inline-block" />
+            <span>[ NODE-CLUSTER-CONFIGS // 节点任务与服务商中枢 ]</span>
           </div>
-          <h1 className="text-xl sm:text-2xl font-black text-black uppercase mt-1">
+          <h1 className="text-lg sm:text-xl font-black text-black uppercase mt-0.5">
             节点集群与服务商配置中心
           </h1>
           <p className="text-xs text-neutral-600 font-sans mt-0.5">
@@ -293,29 +300,49 @@ export default function NodeConfigurationsPage() {
 
         {/* 顶部右侧主要操作 */}
         <div className="flex flex-wrap items-center gap-2">
+          {/* 实时状态监控折叠切换按钮 (可收起,不霸占顶部空间) */}
+          <button
+            type="button"
+            onClick={() => setShowTelemetry(!showTelemetry)}
+            className={`flex items-center gap-1.5 px-3 py-1.5 border-2 border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 cursor-pointer ${
+              showTelemetry
+                ? 'bg-amber-300 text-black'
+                : 'bg-neutral-50 hover:bg-neutral-100 text-black'
+            }`}
+            title={showTelemetry ? '收起集群状态监控看板' : '展开集群状态监控看板'}
+          >
+            <Activity size={13} className={onlineNodes > 0 ? 'text-emerald-700' : 'text-neutral-500'} />
+            <span>实时监控 ({onlineNodes}/{totalNodes})</span>
+            {showTelemetry ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
+          </button>
+
           <button
             onClick={() => {
               handleRefresh();
               fetchTelemetry();
             }}
             disabled={loadingProviders || loadingConfigs || loadingTelemetry}
-            className="p-2 bg-neutral-50 hover:bg-neutral-200 border-2 border-black text-black transition shadow-[2px_2px_0px_#000]"
+            className="p-1.5 bg-neutral-50 hover:bg-neutral-200 border-2 border-black text-black transition shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 cursor-pointer"
             title="刷新配置与遥测数据"
           >
             <RefreshCw size={14} className={loadingProviders || loadingConfigs || loadingTelemetry ? 'animate-spin' : ''} />
           </button>
 
+          {/* 新建动作按键:当处于 nodes 标签时彻底删除无效的「新建node任务」按钮 */}
           {activeTab === 'provider' ? (
             <button
               onClick={handleOpenCreateProvider}
-              className="px-4 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
+              className="px-3.5 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 cursor-pointer"
             >
               [ + 新建服务商模板 ]
             </button>
+          ) : activeTab === 'nodes' ? (
+            // 用户明确要求删除「新建node任务」按钮 (节点档案自身已有独立注册逻辑)
+            null
           ) : (
             <button
               onClick={handleOpenCreateConfig}
-              className="px-4 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
+              className="px-3.5 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 cursor-pointer"
             >
               [ + 新建 {activeTab.toUpperCase()} 任务 ]
             </button>
@@ -323,22 +350,27 @@ export default function NodeConfigurationsPage() {
         </div>
       </div>
 
-      {/* 节点集群实时状态监控看板 (Cluster Telemetry Bar) */}
-      <NodeClusterTelemetryBar
-        nodes={runtimeNodes}
-        loading={loadingTelemetry}
-        autoRefresh={autoRefreshTelemetry}
-        onToggleAutoRefresh={() => setAutoRefreshTelemetry(!autoRefreshTelemetry)}
-        onRefresh={fetchTelemetry}
-        onInspectInstances={handleOpenInstancesModal}
-        lastUpdatedTime={lastTelemetryTime}
-        registeredNodeIds={registeredNodeIds}
-        onQuickRegisterNode={(nodeId) => {
-          setEditingNode(null);
-          setPresetRegisterNodeId(nodeId);
-          setIsNodeModalOpen(true);
-        }}
-      />
+      {/* 节点集群实时状态监控看板 (可收起展开,不再强制固定在顶部霸屏) */}
+      {showTelemetry && (
+        <div className="animate-in fade-in slide-in-from-top-2 duration-150">
+          <NodeClusterTelemetryBar
+            nodes={runtimeNodes}
+            loading={loadingTelemetry}
+            autoRefresh={autoRefreshTelemetry}
+            onToggleAutoRefresh={() => setAutoRefreshTelemetry(!autoRefreshTelemetry)}
+            onRefresh={fetchTelemetry}
+            onInspectInstances={handleOpenInstancesModal}
+            lastUpdatedTime={lastTelemetryTime}
+            registeredNodeIds={registeredNodeIds}
+            onQuickRegisterNode={(nodeId) => {
+              setEditingNode(null);
+              setPresetRegisterNodeId(nodeId);
+              setIsNodeModalOpen(true);
+            }}
+            onClose={() => setShowTelemetry(false)}
+          />
+        </div>
+      )}
 
       {/* 顶部 Tab 栏 (Retro Brutalist Tabs) */}
       <div className="flex flex-wrap gap-2">

+ 349 - 173
src/app/admin/page.tsx

@@ -1,193 +1,369 @@
+// src/app/admin/page.tsx
 'use client';
 
-import { useState, useEffect } from 'react';
-import DataStats from '@/components/admin/DataStats'; 
-import OverviewCharts from '@/components/admin/dashboard/OverviewCharts'; 
-import RecentActivities, { ActivityItem } from '@/components/admin/dashboard/RecentActivities';
-import { ShoppingBag, AlertCircle, CheckCircle, Wallet, ArrowRight, ShieldAlert, Cpu } from 'lucide-react';
-import Link from 'next/link';
-import { statsService } from '@/lib/services';
-
-interface DashboardStats {
-  totalOrders: number;
-  totalOrdersTrend: number;
-  totalRevenue: number;
-  totalRevenueTrend: number;
-  activeUsers: number;
-  pendingTickets: number;
-  successRate: string;
-}
-
-interface TaskDistItem {
-  routing_key: string;
-  count: number;
-}
-
-export default function AdminDashboard() {
-  const [loading, setLoading] = useState(true);
-  
-  const [stats, setStats] = useState<DashboardStats>({
-    totalOrders: 0,
-    totalOrdersTrend: 0,
-    totalRevenue: 0,
-    totalRevenueTrend: 0,
-    activeUsers: 0,
-    pendingTickets: 0,
-    successRate: '0%',
-  });
-
-  const [chartData, setChartData] = useState<{
-    revenue: any[];
-    products: any[];
-    tasks: TaskDistItem[];
-  }>({ revenue: [], products: [], tasks: [] });
-
-  const [recentActivities, setRecentActivities] = useState<ActivityItem[]>([]);
-
-  useEffect(() => {
-    fetchDashboardData();
-  }, []);
-
-  const fetchDashboardData = async () => {
-    setLoading(true);
-    try {
-      const res = await statsService.getOverview();
-      const data = res?.data;
-
-      if (data) {
-        setStats(data.stats);
-
-        setChartData({ 
-          revenue: data.revenue_trend || [], 
-          products: data.product_dist || [],
-          tasks: data.active_tasks_dist || [],
-        });
-
-        setRecentActivities(data.recent_activities || []);
-      }
-    } catch (error) {
-      console.error('Failed to load dashboard data', error);
-    } finally {
-      setLoading(false);
-    }
-  };
-
-  const formatTrend = (val: number) => {
-    if (val === undefined || val === null || isNaN(val)) return '0.0%';
-    const absVal = Math.abs(val);
-    const sign = val >= 0 ? '+' : '-';
-    return `${sign}${absVal.toFixed(1)}%`;
-  };
+import { useState } from 'react';
+import { useAgentChat } from '@/hooks/useAgentChat';
+import AgentChatBox from '@/components/admin/agent/AgentChatBox';
+import AgentToolsModal from '@/components/admin/agent/AgentToolsModal';
+import { 
+  Bot, Plus, Trash2, Clock, 
+  Wrench, Activity, ShieldCheck, RefreshCw,
+  PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen,
+  Sparkles, Zap, ChevronDown, ChevronUp, X
+} from 'lucide-react';
+import { format } from 'date-fns';
+
+export default function AdminOpsPage() {
+  const [isToolsModalOpen, setIsToolsModalOpen] = useState(false);
+  const [isHistoryOpen, setIsHistoryOpen] = useState(false);
+  const [isStatusOpen, setIsStatusOpen] = useState(false);
+  const [showQuickPrompts, setShowQuickPrompts] = useState(false);
+
+  const {
+    sessions,
+    currentSessionId,
+    messages,
+    isLoading,
+    currentThinking,
+    tools,
+    toolsLoading,
+    sendMessage,
+    abortStream,
+    createNewSession,
+    switchSession,
+    deleteSession,
+    clearCurrentSession,
+    handleConfirmDangerousAction,
+    loadTools,
+  } = useAgentChat();
+
+  const activeSession = sessions.find((s) => s.id === currentSessionId);
+
+  const quickPrompts = [
+    { label: '查待支付订单', prompt: '帮我查询最近的订单,并告诉我有没有待支付的' },
+    { label: '检索法国签证', prompt: '帮我查一下法国相关的签证服务' },
+    { label: '列出最新 5 笔订单', prompt: '查询最近的 5 笔订单详情与状态' },
+    { label: '检查待处理工单', prompt: '帮我检查目前有没有未处理或处于打开状态的客服工单' },
+    { label: '检查节点集群状态', prompt: '查询当前的节点集群配置与各节点运行状态' },
+    { label: '查询使馆账号池', prompt: '查询目前有哪些使馆预约账号,是否有被锁定的账号?' },
+    { label: '财务与营收概览', prompt: '查看全站近 30 天的财务营收数据与总支付笔数' },
+    { label: '查看系统开放工具', prompt: '告诉我你目前掌握了哪些系统运维工具与能力?' },
+  ];
 
   return (
-    <div className="space-y-6 font-mono">
+    <div className="flex-1 h-full flex flex-col min-h-0 font-mono select-none space-y-2">
       
-      {/* 顶部中枢看板标头 */}
-      <div className="bg-neutral-100 border-2 border-black p-6 shadow-[6px_6px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-4">
-        <div>
-          <div className="text-[10px] font-bold text-neutral-500 uppercase tracking-widest">[ SYSTEM-MONITOR // 自动化控制台 ]</div>
-          <h1 className="text-xl sm:text-2xl font-black text-black uppercase mt-1">系统全景运行监控总览</h1>
+      {/* 顶部紧凑控制栏 (所有非对话框侧栏均可折叠,最大化留白给核心会话) */}
+      <div className="bg-white border-2 border-black p-2 sm:px-3 sm:py-2 shadow-[3px_3px_0px_#000] flex flex-wrap items-center justify-between gap-2 shrink-0">
+        
+        {/* 左侧:会话抽屉折叠开关 & 智能体标识 */}
+        <div className="flex items-center gap-2">
+          <button
+            type="button"
+            onClick={() => setIsHistoryOpen(!isHistoryOpen)}
+            className={`flex items-center gap-1.5 px-2.5 py-1 border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 cursor-pointer uppercase ${
+              isHistoryOpen ? 'bg-amber-300 text-black' : 'bg-neutral-100 hover:bg-amber-200 text-neutral-800'
+            }`}
+            title={isHistoryOpen ? '收起会话历史面板' : '展开会话历史面板'}
+          >
+            {isHistoryOpen ? <PanelLeftClose size={13} /> : <PanelLeftOpen size={13} />}
+            <span>历史会话 ({sessions.length})</span>
+          </button>
+
+          <div className="hidden sm:flex items-center gap-2 pl-1 border-l-2 border-neutral-300">
+            <div className="w-5 h-5 bg-amber-300 border border-black flex items-center justify-center shadow-[1px_1px_0px_#000]">
+              <Bot size={13} className="text-black" />
+            </div>
+            <span className="font-black text-xs text-black uppercase tracking-wider">
+              [ AI-OPS // 全能运维智能中枢 ]
+            </span>
+            <span className="px-1.5 py-0.2 bg-emerald-100 border border-black text-[9px] font-black text-emerald-900 uppercase">
+              ● {tools.length} 项管理能力全开
+            </span>
+          </div>
         </div>
 
-        <div className="flex items-center gap-2">
-          <span className="px-2.5 py-1 bg-amber-300 border-2 border-black text-xs font-black text-black shadow-[2px_2px_0px_#000]">
-            ★ NODE: 100% OPERATIONAL
-          </span>
+        {/* 右侧动作栏:快捷指令、技能库、系统状态监控与新建会话 */}
+        <div className="flex items-center gap-1.5 sm:gap-2">
+          {/* 快捷指令折叠开关 */}
+          <button
+            type="button"
+            onClick={() => setShowQuickPrompts(!showQuickPrompts)}
+            className={`flex items-center gap-1 px-2.5 py-1 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase cursor-pointer ${
+              showQuickPrompts ? 'bg-amber-300 text-black' : 'bg-neutral-50 hover:bg-neutral-100 text-black'
+            }`}
+          >
+            <Zap size={12} />
+            <span className="hidden md:inline">快捷指令</span>
+            {showQuickPrompts ? <ChevronUp size={12} /> : <ChevronDown size={12} />}
+          </button>
+
+          {/* 完整技能能力库 Modal */}
+          <button
+            type="button"
+            onClick={() => setIsToolsModalOpen(true)}
+            className="flex items-center gap-1 px-2.5 py-1 bg-white hover:bg-amber-100 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase cursor-pointer"
+            title="查看当前已注册开放给 AI 的 41 项管理工具"
+          >
+            <Wrench size={12} />
+            <span>技能库 ({tools.length})</span>
+          </button>
+
+          {/* 右侧状态监控栏折叠开关 */}
+          <button
+            type="button"
+            onClick={() => setIsStatusOpen(!isStatusOpen)}
+            className={`flex items-center gap-1 px-2.5 py-1 border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase cursor-pointer ${
+              isStatusOpen ? 'bg-amber-300 text-black' : 'bg-neutral-100 hover:bg-amber-200 text-neutral-800'
+            }`}
+            title={isStatusOpen ? '收起系统监控面板' : '展开系统监控面板'}
+          >
+            {isStatusOpen ? <PanelRightClose size={13} /> : <PanelRightOpen size={13} />}
+            <span className="hidden lg:inline">监控状态</span>
+          </button>
+
+          {/* 新建会话按键 */}
+          <button
+            type="button"
+            onClick={() => createNewSession()}
+            className="flex items-center gap-1 px-3 py-1 bg-amber-300 hover:bg-amber-400 border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase cursor-pointer"
+          >
+            <Plus size={13} />
+            <span>新建对话</span>
+          </button>
         </div>
       </div>
-      
-      {/* 1. 核心指标卡片区域 */}
-      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-5">
-        <DataStats 
-          title="总营收 // 本月结算" 
-          value={`¥${(stats.totalRevenue / 100).toLocaleString()}`} 
-          icon={Wallet} 
-          trend={formatTrend(stats.totalRevenueTrend)} 
-          trendUp={stats.totalRevenueTrend >= 0} 
-        />
-        
-        <DataStats 
-          title="本月订单总数" 
-          value={stats.totalOrders} 
-          icon={ShoppingBag} 
-          trend={formatTrend(stats.totalOrdersTrend)} 
-          trendUp={stats.totalOrdersTrend >= 0} 
-        />
-        
-        <DataStats 
-          title="待处理客服工单" 
-          value={stats.pendingTickets} 
-          icon={AlertCircle} 
-          trend={stats.pendingTickets > 0 ? '需人工干预' : '良好'} 
-          trendUp={stats.pendingTickets === 0}
-        />
+
+      {/* 快捷指令折叠浮条 (可收起) */}
+      {showQuickPrompts && (
+        <div className="bg-amber-50 border-2 border-black p-2.5 shadow-[3px_3px_0px_#000] flex flex-wrap items-center gap-2 animate-in fade-in duration-100 shrink-0">
+          <span className="text-[10px] font-black uppercase text-neutral-600 block sm:inline">
+            [ 常用运维指令速点 ]:
+          </span>
+          {quickPrompts.map((item, idx) => (
+            <button
+              key={idx}
+              type="button"
+              onClick={() => {
+                sendMessage(item.prompt);
+                setShowQuickPrompts(false);
+              }}
+              className="px-2 py-0.5 bg-white hover:bg-amber-300 border border-black font-bold text-xs text-neutral-800 shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
+            >
+              {item.label}
+            </button>
+          ))}
+          <button
+            type="button"
+            onClick={() => setShowQuickPrompts(false)}
+            className="ml-auto text-[11px] text-neutral-500 hover:text-black font-bold underline cursor-pointer"
+          >
+            [ 收起 ]
+          </button>
+        </div>
+      )}
+
+      {/* 主工作区:核心对话框拥有绝大部分空间,两侧面板皆可一键收起 */}
+      <div className="flex-1 flex overflow-hidden gap-2 min-h-0">
         
-        <DataStats 
-          title="机器人成功锁位率" 
-          value={stats.successRate} 
-          icon={CheckCircle} 
-          trend="全自动保障"
-          trendUp={true}
-        />
-      </div>
+        {/* 1. 可收起左栏:历史会话列表 */}
+        {isHistoryOpen && (
+          <div className="w-64 sm:w-72 shrink-0 h-full flex flex-col bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden animate-in slide-in-from-left duration-150">
+            <div className="p-2.5 border-b-2 border-black bg-neutral-100 flex items-center justify-between">
+              <div className="flex items-center gap-1.5 font-black text-xs uppercase">
+                <Clock size={13} />
+                <span>历史会话 ({sessions.length})</span>
+              </div>
+              <div className="flex items-center gap-1">
+                <button
+                  type="button"
+                  onClick={() => createNewSession()}
+                  className="p-1 bg-white hover:bg-amber-300 border border-black shadow-[1px_1px_0px_#000] cursor-pointer"
+                  title="新建会话"
+                >
+                  <Plus size={11} />
+                </button>
+                <button
+                  type="button"
+                  onClick={() => setIsHistoryOpen(false)}
+                  className="p-1 bg-white hover:bg-neutral-200 border border-black shadow-[1px_1px_0px_#000] cursor-pointer"
+                  title="收起此面板"
+                >
+                  <X size={11} />
+                </button>
+              </div>
+            </div>
 
-      {/* 2. 图表区域 */}
-      <OverviewCharts 
-        revenueData={chartData.revenue} 
-        productData={chartData.products} 
-        taskData={chartData.tasks} 
-      />
+            <div className="flex-1 overflow-y-auto p-2 space-y-1.5 scrollbar-thin">
+              {sessions.map((s) => {
+                const isActive = s.id === currentSessionId;
+                return (
+                  <div
+                    key={s.id}
+                    onClick={() => switchSession(s.id)}
+                    className={`
+                      p-2 border-2 text-xs cursor-pointer transition select-none group relative
+                      ${isActive
+                        ? 'bg-amber-300 border-black shadow-[2px_2px_0px_#000]'
+                        : 'bg-neutral-50 border-neutral-200 hover:border-black hover:bg-white'
+                      }
+                    `}
+                  >
+                    <div className="flex items-center justify-between mb-1">
+                      <span className="font-black truncate flex-1 pr-1 text-xs">
+                        {s.title}
+                      </span>
+                      <button
+                        type="button"
+                        onClick={(e) => {
+                          e.stopPropagation();
+                          deleteSession(s.id);
+                        }}
+                        className="opacity-0 group-hover:opacity-100 p-0.5 hover:bg-rose-200 border border-transparent hover:border-black text-black transition cursor-pointer"
+                        title="删除该会话"
+                      >
+                        <Trash2 size={11} />
+                      </button>
+                    </div>
+                    <div className="flex items-center justify-between text-[10px] text-neutral-500 font-bold">
+                      <span>{format(new Date(s.updatedAt), 'MM-dd HH:mm')}</span>
+                      <span>{s.messageCount} 条互动</span>
+                    </div>
+                  </div>
+                );
+              })}
+            </div>
+          </div>
+        )}
 
-      {/* 3. 底部:最新动态与快捷入口 */}
-      <div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
-        <RecentActivities activities={recentActivities} loading={loading} />
+        {/* 2. 核心全屏对话主视窗 (当两侧收起时独占 100% 空间) */}
+        <div className="flex-1 h-full min-w-0 bg-white border-2 border-black shadow-[4px_4px_0px_#000] flex flex-col overflow-hidden">
+          <AgentChatBox
+            messages={messages}
+            isLoading={isLoading}
+            currentThinking={currentThinking}
+            onSendMessage={sendMessage}
+            onAbort={abortStream}
+            onClearSession={clearCurrentSession}
+            onOpenToolsModal={() => setIsToolsModalOpen(true)}
+            tools={tools}
+            quickPrompts={quickPrompts}
+            onConfirmAction={handleConfirmDangerousAction}
+            className="h-full flex-1"
+          />
+        </div>
 
-        {/* 快捷操作区 */}
-        <div className="bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] flex flex-col justify-between space-y-4">
-          <div className="space-y-3">
-            <div className="border-b-2 border-black pb-2.5 flex items-center justify-between">
-              <h3 className="font-black text-xs uppercase text-black">[ 05 // QUICK ACTIONS ]</h3>
-              <span className="text-[10px] text-neutral-500 font-bold">SHORTCUTS</span>
+        {/* 3. 可收起右栏:系统能力状态与全量工具透视 */}
+        {isStatusOpen && (
+          <div className="w-72 sm:w-80 shrink-0 h-full flex flex-col bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden animate-in slide-in-from-right duration-150">
+            <div className="p-2.5 border-b-2 border-black bg-neutral-100 flex items-center justify-between">
+              <div className="flex items-center gap-1.5 font-black text-xs uppercase">
+                <Activity size={13} />
+                <span>运维系统状态监控</span>
+              </div>
+              <div className="flex items-center gap-1">
+                <button
+                  type="button"
+                  onClick={loadTools}
+                  disabled={toolsLoading}
+                  className="p-1 bg-white hover:bg-amber-300 border border-black shadow-[1px_1px_0px_#000] cursor-pointer"
+                  title="刷新工具列表"
+                >
+                  <RefreshCw size={11} className={toolsLoading ? 'animate-spin' : ''} />
+                </button>
+                <button
+                  type="button"
+                  onClick={() => setIsStatusOpen(false)}
+                  className="p-1 bg-white hover:bg-neutral-200 border border-black shadow-[1px_1px_0px_#000] cursor-pointer"
+                  title="收起此面板"
+                >
+                  <X size={11} />
+                </button>
+              </div>
             </div>
-            
-            <div className="space-y-2">
-              <Link 
-                href="/admin/tickets" 
-                className="bg-neutral-50 hover:bg-amber-300 border-2 border-black p-2.5 transition active:translate-x-0.5 active:translate-y-0.5 shadow-[2px_2px_0px_#000] flex justify-between items-center text-xs font-bold uppercase"
-              >
-                <span>[ 处理售后工单 ]</span>
-                <ArrowRight size={14} />
-              </Link>
-              <Link 
-                href="/admin/products" 
-                className="bg-neutral-50 hover:bg-amber-300 border-2 border-black p-2.5 transition active:translate-x-0.5 active:translate-y-0.5 shadow-[2px_2px_0px_#000] flex justify-between items-center text-xs font-bold uppercase"
-              >
-                <span>[ 配置签证服务商品 ]</span>
-                <ArrowRight size={14} />
-              </Link>
-              <Link 
-                href="/admin/tasks" 
-                className="bg-neutral-50 hover:bg-amber-300 border-2 border-black p-2.5 transition active:translate-x-0.5 active:translate-y-0.5 shadow-[2px_2px_0px_#000] flex justify-between items-center text-xs font-bold uppercase"
-              >
-                <span>[ 监控自动化并发任务 ]</span>
-                <ArrowRight size={14} />
-              </Link>
-              <Link 
-                href="/admin/payments" 
-                className="bg-neutral-50 hover:bg-amber-300 border-2 border-black p-2.5 transition active:translate-x-0.5 active:translate-y-0.5 shadow-[2px_2px_0px_#000] flex justify-between items-center text-xs font-bold uppercase"
-              >
-                <span>[ 支付网关与流水核销 ]</span>
-                <ArrowRight size={14} />
-              </Link>
+
+            <div className="flex-1 overflow-y-auto p-3 space-y-3.5 scrollbar-thin">
+              {/* 系统指标卡 */}
+              <div className="bg-neutral-50 p-2.5 border-2 border-black shadow-[2px_2px_0px_#000] space-y-1.5 text-xs">
+                <div className="flex justify-between">
+                  <span className="text-neutral-500 font-bold">调度引擎:</span>
+                  <span className="font-black text-black">Autonomous Loop</span>
+                </div>
+                <div className="flex justify-between">
+                  <span className="text-neutral-500 font-bold">单轮工具上限:</span>
+                  <span className="font-black text-black">8 STEPS</span>
+                </div>
+                <div className="flex justify-between">
+                  <span className="text-neutral-500 font-bold">高危二次确认:</span>
+                  <span className="font-black text-emerald-700 flex items-center gap-1">
+                    <ShieldCheck size={12} />
+                    已启用
+                  </span>
+                </div>
+                <div className="flex justify-between">
+                  <span className="text-neutral-500 font-bold">开放工具总数:</span>
+                  <span className="font-black text-black">{tools.length} TOOLS</span>
+                </div>
+              </div>
+
+              {/* 已注册全域管理工具一览 */}
+              <div className="space-y-2">
+                <div className="flex items-center justify-between">
+                  <span className="text-xs font-black uppercase text-black">
+                    ▶ 已就绪工具 ({tools.length})
+                  </span>
+                  <button
+                    type="button"
+                    onClick={() => setIsToolsModalOpen(true)}
+                    className="text-[10px] font-bold text-neutral-600 hover:text-black underline cursor-pointer"
+                  >
+                    查看详情
+                  </button>
+                </div>
+
+                <div className="space-y-1.5 max-h-[calc(100vh-340px)] overflow-y-auto pr-1 scrollbar-thin">
+                  {tools.map((t) => (
+                    <div
+                      key={t.name}
+                      onClick={() => {
+                        sendMessage(`请使用 ${t.name} 工具帮我查看当前业务数据与状态`);
+                      }}
+                      className="p-2 bg-neutral-50 hover:bg-amber-100 border border-neutral-300 hover:border-black cursor-pointer transition text-xs group"
+                    >
+                      <div className="flex items-center justify-between mb-0.5">
+                        <span className="font-bold text-black text-[11px] truncate group-hover:text-black font-mono">
+                          {t.name}
+                        </span>
+                        {t.is_dangerous ? (
+                          <span className="text-[9px] font-black text-rose-800 bg-rose-200 border border-black px-1 shrink-0">
+                            高危
+                          </span>
+                        ) : (
+                          <span className="text-[9px] text-neutral-500 shrink-0">只读</span>
+                        )}
+                      </div>
+                      <div className="text-[10px] text-neutral-500 truncate">
+                        {t.description}
+                      </div>
+                    </div>
+                  ))}
+                </div>
+              </div>
             </div>
           </div>
-          
-          <div className="pt-3 border-t-2 border-dashed border-neutral-300 text-[10px] text-neutral-500 uppercase flex justify-between items-center">
-            <span>DISPATCH STATUS:</span>
-            <span className="font-black text-black bg-amber-100 border border-black px-1.5 py-0.5">READY</span>
-          </div>
-        </div>
+        )}
+
       </div>
+
+      {/* 技能能力库弹窗 */}
+      <AgentToolsModal
+        isOpen={isToolsModalOpen}
+        onClose={() => setIsToolsModalOpen(false)}
+        tools={tools}
+        loading={toolsLoading}
+        onRefresh={loadTools}
+        onSelectPrompt={(p) => sendMessage(p)}
+      />
     </div>
   );
 }

+ 106 - 46
src/app/admin/tasks/page.tsx

@@ -21,7 +21,7 @@ import Pagination from '@/components/common/Pagination';
 import { toast } from 'react-hot-toast';
 import { retroConfirm } from '@/lib/dialog';
 import { VasTask } from '@/types';
-import { taskService } from '@/lib/services';
+import { taskService, productService } from '@/lib/services';
 
 export default function AdminTasksPage() {
   const [tasks, setTasks] = useState<VasTask[]>([]);
@@ -33,9 +33,12 @@ export default function AdminTasksPage() {
   const [keyword, setKeyword] = useState('');
   const [statusFilter, setStatusFilter] = useState('all');
   const [routingKeyFilter, setRoutingKeyFilter] = useState('all');
+  const [productIdFilter, setProductIdFilter] = useState<number | 'all'>('all');
+  const [productsList, setProductsList] = useState<{ id: number; title: string }[]>([]);
   const [retryFilter, setRetryFilter] = useState<'all' | 'has_retry' | 'no_retry'>('all');
 
-  const [sortField, setSortField] = useState<string>('updated_at');
+  // 默认排序机制:最新建单入队优先 (created_at desc)
+  const [sortField, setSortField] = useState<string>('created_at');
   const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
 
   const [pollingInterval, setPollingInterval] = useState<number>(0);
@@ -44,6 +47,17 @@ export default function AdminTasksPage() {
   const [isDetailOpen, setIsDetailOpen] = useState(false);
   const [isEditOpen, setIsEditOpen] = useState(false);
 
+  // 初始化加载商品列表,用于商品路由任务筛选
+  useEffect(() => {
+    productService
+      .listAll({ page: 1, size: 100 })
+      .then((res: any) => {
+        const list = res?.data?.items || res?.data?.list || (Array.isArray(res?.data) ? res.data : []);
+        setProductsList(list.map((p: any) => ({ id: p.id, title: p.title || p.name })));
+      })
+      .catch(() => {});
+  }, []);
+
   const fetchTasks = useCallback(
     async (targetPage: number = page, silent: boolean = false) => {
       if (!silent) setLoading(true);
@@ -52,12 +66,22 @@ export default function AdminTasksPage() {
           keyword: keyword.trim() || undefined,
           page: targetPage,
           size: pageSize,
+          sort_by: sortField,
+          sort_order: sortOrder,
         };
 
         if (statusFilter !== 'all') {
           params.status = statusFilter;
         }
 
+        if (routingKeyFilter !== 'all') {
+          params.routing_key = routingKeyFilter;
+        }
+
+        if (productIdFilter !== 'all') {
+          params.product_id = productIdFilter;
+        }
+
         const res = await taskService.listAll(params);
         const data = res?.data || {};
 
@@ -79,12 +103,12 @@ export default function AdminTasksPage() {
         if (!silent) setLoading(false);
       }
     },
-    [keyword, page, pageSize, statusFilter]
+    [keyword, page, pageSize, statusFilter, routingKeyFilter, productIdFilter, sortField, sortOrder]
   );
 
   useEffect(() => {
     fetchTasks(1);
-  }, [statusFilter]);
+  }, [statusFilter, routingKeyFilter, productIdFilter, sortField, sortOrder]);
 
   useEffect(() => {
     if (pollingInterval <= 0) return;
@@ -107,53 +131,14 @@ export default function AdminTasksPage() {
   const processedTasks = useMemo(() => {
     let result = [...tasks];
 
-    if (routingKeyFilter !== 'all') {
-      result = result.filter((t) => t.routing_key === routingKeyFilter);
-    }
-
     if (retryFilter === 'has_retry') {
       result = result.filter((t) => t.attempt_count > 0);
     } else if (retryFilter === 'no_retry') {
       result = result.filter((t) => t.attempt_count === 0);
     }
 
-    if (keyword.trim()) {
-      const lower = keyword.trim().toLowerCase();
-      result = result.filter((t) => {
-        const idMatch = String(t.id).includes(lower);
-        const orderIdMatch = String(t.order_id).toLowerCase().includes(lower);
-        const routingMatch = (t.routing_key || '').toLowerCase().includes(lower);
-        const scriptMatch = (t.script_version || '').toLowerCase().includes(lower);
-        return idMatch || orderIdMatch || routingMatch || scriptMatch;
-      });
-    }
-
-    result.sort((a: any, b: any) => {
-      let valA = a[sortField];
-      let valB = b[sortField];
-
-      if (valA === null || valA === undefined) return 1;
-      if (valB === null || valB === undefined) return -1;
-
-      if (sortField.includes('at') || sortField.includes('time')) {
-        const timeA = new Date(valA).getTime() || 0;
-        const timeB = new Date(valB).getTime() || 0;
-        return sortOrder === 'asc' ? timeA - timeB : timeB - timeA;
-      }
-
-      if (typeof valA === 'number' && typeof valB === 'number') {
-        return sortOrder === 'asc' ? valA - valB : valB - valA;
-      }
-
-      const strA = String(valA).toLowerCase();
-      const strB = String(valB).toLowerCase();
-      if (strA < strB) return sortOrder === 'asc' ? -1 : 1;
-      if (strA > strB) return sortOrder === 'asc' ? 1 : -1;
-      return 0;
-    });
-
     return result;
-  }, [tasks, routingKeyFilter, retryFilter, keyword, sortField, sortOrder]);
+  }, [tasks, retryFilter]);
 
   const [metrics, setMetrics] = useState({
     total: 0,
@@ -411,6 +396,7 @@ export default function AdminTasksPage() {
         </div>
       </div>
 
+      {/* 增强筛选与多维控制工具栏 */}
       {/* 增强筛选与多维控制工具栏 */}
       <div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] flex flex-col lg:flex-row items-center justify-between gap-3">
         <div className="relative w-full lg:w-72">
@@ -419,13 +405,28 @@ export default function AdminTasksPage() {
             value={keyword}
             onChange={(e) => setKeyword(e.target.value)}
             onKeyDown={handleKeyDown}
-            placeholder="搜索 Order ID / Task ID / 账号..."
+            placeholder="搜索 任务ID / 订单号 / 路由 / 商品 / 客户..."
             className="w-full pl-9 pr-4 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
           />
           <Search size={14} className="absolute left-3 top-2 text-black pointer-events-none" />
         </div>
 
         <div className="flex flex-wrap items-center gap-2 w-full lg:w-auto justify-start lg:justify-end text-xs">
+          {/* 所属商品筛选 */}
+          <select
+            value={productIdFilter}
+            onChange={(e) => setProductIdFilter(e.target.value === 'all' ? 'all' : Number(e.target.value))}
+            className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000] max-w-[200px] truncate"
+          >
+            <option value="all">[ 全部关联商品 (ALL) ]</option>
+            {productsList.map((prod) => (
+              <option key={prod.id} value={prod.id}>
+                #{prod.id} {prod.title}
+              </option>
+            ))}
+          </select>
+
+          {/* 状态筛选 */}
           <select
             value={statusFilter}
             onChange={(e) => setStatusFilter(e.target.value)}
@@ -439,11 +440,12 @@ export default function AdminTasksPage() {
             <option value="failed">失败/异常 (Failed)</option>
           </select>
 
+          {/* 路由筛选 */}
           {uniqueRoutingKeys.length > 0 && (
             <select
               value={routingKeyFilter}
               onChange={(e) => setRoutingKeyFilter(e.target.value)}
-              className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+              className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000] max-w-[190px] truncate"
             >
               <option value="all">[ 全部路由 Routing Key ]</option>
               {uniqueRoutingKeys.map((key) => (
@@ -454,6 +456,7 @@ export default function AdminTasksPage() {
             </select>
           )}
 
+          {/* 重试筛选 */}
           <select
             value={retryFilter}
             onChange={(e) => setRetryFilter(e.target.value as any)}
@@ -466,6 +469,63 @@ export default function AdminTasksPage() {
         </div>
       </div>
 
+      {/* 任务队列排序机制与全局排队模式 */}
+      <div className="bg-neutral-100 p-3.5 border-2 border-black shadow-[4px_4px_0px_#000] flex flex-col md:flex-row items-start md:items-center justify-between gap-3 text-xs">
+        <div className="flex items-center gap-2 flex-wrap">
+          <span className="w-2.5 h-2.5 bg-amber-400 border border-black inline-block" />
+          <span className="font-black text-black uppercase">
+            [ 队列排序机制 // QUEUE DISPATCH ORDER ]:
+          </span>
+          <span className="bg-white px-2 py-0.5 border border-black font-bold text-neutral-800">
+            {sortField === 'created_at' && sortOrder === 'desc' && '🕒 最新入队优先 (创建时间倒序)'}
+            {sortField === 'created_at' && sortOrder === 'asc' && '⏳ 队列先进先出 (FIFO 经典排队)'}
+            {sortField === 'priority' && '⚡ 调度优先级最高优先 (P-20/P-10/同级FIFO)'}
+            {sortField === 'updated_at' && '🔄 最近活跃更新优先 (最新心跳运行)'}
+            {sortField === 'order_id' && '📦 关联主订单号聚合 (同一订单任务归拢)'}
+            {sortField === 'id' && '🔢 任务编号 ID 序列排序'}
+          </span>
+        </div>
+
+        {/* 预设排序快捷按键 */}
+        <div className="flex items-center gap-1.5 flex-wrap">
+          {[
+            { label: '最新入队', field: 'created_at', order: 'desc' as const },
+            { label: '队列FIFO', field: 'created_at', order: 'asc' as const },
+            { label: '最高优先级', field: 'priority', order: 'desc' as const },
+            { label: '最近活跃', field: 'updated_at', order: 'desc' as const },
+            { label: '主订单聚合', field: 'order_id', order: 'desc' as const },
+          ].map((preset) => {
+            const isActive = sortField === preset.field && sortOrder === preset.order;
+            return (
+              <button
+                key={`${preset.field}-${preset.order}`}
+                type="button"
+                onClick={() => {
+                  setSortField(preset.field);
+                  setSortOrder(preset.order);
+                }}
+                className={`px-2.5 py-1 text-xs border border-black font-bold uppercase transition active:translate-x-0.5 active:translate-y-0.5 ${
+                  isActive
+                    ? 'bg-amber-300 text-black shadow-[2px_2px_0px_#000] font-black'
+                    : 'bg-white hover:bg-neutral-50 text-neutral-700'
+                }`}
+              >
+                {preset.label}
+              </button>
+            );
+          })}
+
+          <button
+            type="button"
+            onClick={() => setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc')}
+            className="px-2 py-1 bg-white hover:bg-neutral-200 border border-black font-black text-xs uppercase shadow-[1px_1px_0px_#000]"
+            title="切换当前排序方向"
+          >
+            {sortOrder === 'desc' ? '▼ 降序' : '▲ 升序'}
+          </button>
+        </div>
+      </div>
+
       {/* 结构化重构任务表格 */}
       <TaskTable
         tasks={processedTasks}

+ 43 - 1
src/app/dashboard/page.tsx

@@ -14,6 +14,7 @@ import UserTicketDetailModal from '@/components/dashboard/UserTicketDetailModal'
 import BindEmailModal from '@/components/BindEmailModal';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import { Order, UserTicket } from '@/types';
+import { ticketService } from '@/lib/services';
 
 import ConfirmModal from '@/components/common/ConfirmModal';
 import MessageModal from '@/components/common/MessageModal';
@@ -32,6 +33,7 @@ export default function DashboardPage() {
   const [isTicketDetailOpen, setIsTicketDetailOpen] = useState<boolean>(false);
   const [selectedTicket, setSelectedTicket] = useState<UserTicket | null>(null);
   const [refreshTickets, setRefreshTickets] = useState<number>(0);
+  const [openTicketsMap, setOpenTicketsMap] = useState<Record<string, UserTicket>>({});
   
   // 强制绑定邮箱状态
   const [isForceBindEmailOpen, setIsForceBindEmailOpen] = useState(false);
@@ -91,8 +93,42 @@ export default function DashboardPage() {
     checkUserStatus();
   }, [router]);
 
+  // 获取并跟踪当前用户处于开启状态(待处理/需补充材料)的工单
+  useEffect(() => {
+    const fetchOpenTickets = async () => {
+      try {
+        const res = await ticketService.listByUser({ page: 1, size: 50 });
+        const items: UserTicket[] = res?.data?.items || [];
+        const map: Record<string, UserTicket> = {};
+        items.forEach((t: UserTicket) => {
+          if (t.order_id && (t.status === 'pending' || t.status === 'info_required')) {
+            map[String(t.order_id)] = t;
+          }
+        });
+        setOpenTicketsMap(map);
+      } catch (e) {
+        console.warn('Failed to load open tickets map', e);
+      }
+    };
+
+    fetchOpenTickets();
+  }, [refreshTickets]);
+
   const handleCreateTicket = (orderId?: string) => {
-    setTicketDefaultOrderId(orderId || '');
+    const targetOrderId = (orderId || '').trim();
+    if (targetOrderId && openTicketsMap[targetOrderId]) {
+      const activeTicket = openTicketsMap[targetOrderId];
+      showMessage(
+        t('ticket.already_has_open_ticket') || '该订单已有正在处理中的工单,已为您打开现有工单。',
+        'info',
+        () => {
+          setSelectedTicket(activeTicket);
+          setIsTicketDetailOpen(true);
+        }
+      );
+      return;
+    }
+    setTicketDefaultOrderId(targetOrderId);
     setIsTicketModalOpen(true);
   };
 
@@ -216,6 +252,11 @@ export default function DashboardPage() {
               </div>
 
               <OrderList 
+                openTicketsMap={openTicketsMap}
+                onViewTicket={(ticket) => {
+                  setSelectedTicket(ticket);
+                  setIsTicketDetailOpen(true);
+                }}
                 onRequestTicket={handleCreateTicket}
                 onViewDetail={handleViewOrder}
               />
@@ -264,6 +305,7 @@ export default function DashboardPage() {
         onClose={() => setIsTicketModalOpen(false)}
         onSuccess={handleTicketSuccess}
         defaultOrderId={ticketDefaultOrderId}
+        openTicketsMap={openTicketsMap}
       />
 
       <UserOrderDetailModal 

+ 28 - 179
src/app/page.tsx

@@ -1,194 +1,43 @@
 'use client';
 
 import Link from "next/link";
-import { ArrowRight, Globe, CheckCircle, Zap, FileText, Bot, Plane, Activity, ShieldCheck, Sparkles } from "lucide-react";
+import { ArrowRight, CalendarSearch } from "lucide-react";
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 
 export default function Home() {
   const { t } = useLanguage();
 
-  const steps = [
-    {
-      step: '01',
-      icon: Globe,
-      title: t('home.step_1_title') || '1. 选择服务',
-      desc: t('home.step_1_desc') || '在服务列表中找到您需要办理的国家和签证类型(如日本旅游签、法国申根签)。'
-    },
-    {
-      step: '02',
-      icon: FileText,
-      title: t('home.step_2_title') || '2. 提交资料',
-      desc: t('home.step_2_desc') || '填写简单的申请表单(支持 JSON 动态表单),无需繁琐的手写文件。'
-    },
-    {
-      step: '03',
-      icon: Bot,
-      title: t('home.step_3_title') || '3. 智能托管',
-      desc: t('home.step_3_desc') || '我们的 24/7 机器人系统会自动为您监控名额并锁定预约,无需人工守候。'
-    },
-    {
-      step: '04',
-      icon: CheckCircle,
-      title: t('home.step_4_title') || '4. 成功出签',
-      desc: t('home.step_4_desc') || '预约成功后支付费用(支持随机立减),获取确认函,准备递签。'
-    }
-  ];
-
-  const popularDestinations = [
-    { name: 'France', code: 'FR', label: '法国 / France' },
-    { name: 'Germany', code: 'DE', label: '德国 / Germany' },
-    { name: 'Italy', code: 'IT', label: '意大利 / Italy' },
-    { name: 'Spain', code: 'ES', label: '西班牙 / Spain' },
-    { name: 'United Kingdom', code: 'UK', label: '英国 / UK' },
-    { name: 'United States', code: 'US', label: '美国 / USA' },
-    { name: 'Japan', code: 'JP', label: '日本 / Japan' },
-  ];
-
   return (
-    <div className="min-h-screen bg-neutral-100 py-8 px-4 sm:px-6 md:py-12 md:px-8 space-y-10 max-w-7xl mx-auto">
-      
-      {/* === 1. Hero 工业铭牌大厅 === */}
-      <section className="bg-white border-2 border-black p-6 sm:p-10 md:p-14 shadow-[8px_8px_0px_#000] text-black">
-        {/* 顶部元数据 */}
-        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-3 mb-6 font-mono text-xs font-bold select-none">
-          <div className="flex items-center gap-2">
-            <span className="w-3 h-3 bg-amber-300 border border-black inline-block" />
-            <span className="tracking-widest uppercase">[ VAS-OS // GLOBAL VISA DIRECTORY ]</span>
-          </div>
-          <div className="text-neutral-500 font-mono">
-            SYS.NODE: ONLINE // 2026-RELEASE
-          </div>
-        </div>
-
-        {/* 标题区域 */}
-        <div className="max-w-4xl space-y-4">
-          <h1 className="text-3xl sm:text-4xl md:text-6xl font-black tracking-tight text-black uppercase leading-tight">
-            {t('home.hero_title_prefix')} <span className="bg-amber-300 px-2 py-0.5 border-2 border-black shadow-[2px_2px_0px_#000] inline-block">{t('home.hero_title_highlight')}</span>
-          </h1>
-          
-          <p className="text-xs sm:text-sm md:text-base text-neutral-600 font-mono leading-relaxed max-w-2xl">
-            {t('home.hero_subtitle')}
-          </p>
-
-          {/* CTA 实体按键组 */}
-          <div className="pt-4 flex flex-col sm:flex-row gap-4 font-mono select-none">
-            <Link 
-              href="/services" 
-              className="px-8 py-4 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-sm sm:text-base shadow-[4px_4px_0px_#000] flex items-center justify-center gap-2 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase"
-            >
-              <span>[ {t('home.cta_start')} ]</span>
-              <ArrowRight size={18} />
-            </Link>
-            <Link 
-              href="/slots" 
-              className="px-8 py-4 bg-white hover:bg-neutral-50 text-black border-2 border-black font-black text-sm sm:text-base shadow-[4px_4px_0px_#000] flex items-center justify-center gap-2 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase"
-            >
-              <Activity size={18} />
-              <span>[ {t('home.cta_check_slots')} ]</span>
-            </Link>
-          </div>
-        </div>
-
-        {/* 底部实时状态条 */}
-        <div className="mt-8 pt-6 border-t-2 border-dashed border-neutral-300 grid grid-cols-1 sm:grid-cols-2 gap-3 font-mono text-xs">
-          <div className="p-2.5 bg-neutral-50 border border-black">
-            <div className="font-bold text-neutral-500 uppercase text-[10px]">MONITORING</div>
-            <div className="font-black text-black text-sm mt-0.5">{t('home.stat_monitoring_val')}</div>
-          </div>
-          <div className="p-2.5 bg-neutral-50 border border-black">
-            <div className="font-bold text-neutral-500 uppercase text-[10px]">{t('footer.refund_policy')}</div>
-            <div className="font-black text-black text-sm mt-0.5">{t('home.stat_security_val')}</div>
-          </div>
-        </div>
-      </section>
-
-      {/* === 2. 4 步工单办理流程 === */}
-      <section className="bg-white border-2 border-black p-6 sm:p-8 shadow-[6px_6px_0px_#000] space-y-6">
-        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-3 font-mono">
-          <div>
-            <span className="text-xs font-bold text-neutral-500 uppercase">[ 01 // WORKFLOW ]</span>
-            <h2 className="text-xl sm:text-2xl font-black text-black uppercase mt-0.5">{t('home.process_title')}</h2>
-          </div>
-          <p className="text-xs text-neutral-600 font-sans">{t('home.process_subtitle')}</p>
-        </div>
-
-        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 font-mono">
-          {steps.map((step, index) => {
-            const Icon = step.icon;
-            return (
-              <div 
-                key={index} 
-                className="bg-neutral-50 border-2 border-black p-5 shadow-[3px_3px_0px_#000] hover:shadow-[5px_5px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition flex flex-col justify-between space-y-4"
-              >
-                <div>
-                  <div className="flex items-center justify-between border-b-2 border-black pb-2 mb-3">
-                    <span className="px-2 py-0.5 bg-black text-white font-mono font-bold text-[10px]">
-                      STEP {step.step}
-                    </span>
-                    <div className="w-7 h-7 bg-amber-300 border border-black flex items-center justify-center text-black font-bold">
-                      <Icon size={16} />
-                    </div>
-                  </div>
-                  <h3 className="text-sm sm:text-base font-black text-black mb-2">{step.title}</h3>
-                  <p className="text-xs text-neutral-700 font-sans leading-relaxed">
-                    {step.desc}
-                  </p>
-                </div>
-                <div className="pt-2 border-t border-dashed border-neutral-300 text-[10px] text-neutral-500 font-mono uppercase">
-                  STATUS: VERIFIED
-                </div>
-              </div>
-            );
-          })}
-        </div>
-      </section>
-
-      {/* === 3. 热门目的地快速直达通道 === */}
-      <section className="bg-neutral-100 border-2 border-black p-6 sm:p-8 shadow-[6px_6px_0px_#000] space-y-4 font-mono">
-        <div className="flex items-center justify-between border-b-2 border-black pb-2.5">
-          <h2 className="text-xs sm:text-sm font-black text-black uppercase flex items-center gap-1.5">
-            <Plane size={15} className="-rotate-45" />
-            <span>[ 02 // FAST-TRACK {t('home.fast_track_title')} ]</span>
-          </h2>
-          <Link href="/services" className="text-xs font-bold text-neutral-700 hover:underline">
-            [ {t('home.view_all_services')} → ]
+    <div className="min-h-[calc(100vh-4rem-160px)] flex items-center justify-center py-12 px-4 sm:px-6 md:px-8">
+      <div className="w-full max-w-3xl bg-white border-2 border-black p-8 sm:p-14 md:p-16 shadow-[8px_8px_0px_#000] text-center space-y-10">
+        
+        {/* 大标题 */}
+        <h1 className="text-3xl sm:text-5xl md:text-6xl font-black tracking-tight text-black uppercase leading-tight select-none">
+          {t('home.hero_title_prefix')}{' '}
+          <span className="bg-amber-300 px-3 py-1 border-2 border-black shadow-[3px_3px_0px_#000] inline-block mt-2 sm:mt-0">
+            {t('home.hero_title_highlight')}
+          </span>
+        </h1>
+
+        {/* 下单与查询slot按钮组 */}
+        <div className="flex flex-col sm:flex-row items-center justify-center gap-5 font-mono select-none">
+          <Link 
+            href="/services" 
+            className="w-full sm:w-auto min-w-[200px] px-8 py-4 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-sm sm:text-base shadow-[4px_4px_0px_#000] flex items-center justify-center gap-2.5 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase group"
+          >
+            <span>[ {t('home.cta_order') || '下单'} ]</span>
+            <ArrowRight size={18} className="group-hover:translate-x-1 transition-transform" />
+          </Link>
+          <Link 
+            href="/slots" 
+            className="w-full sm:w-auto min-w-[200px] px-8 py-4 bg-white hover:bg-neutral-50 text-black border-2 border-black font-black text-sm sm:text-base shadow-[4px_4px_0px_#000] flex items-center justify-center gap-2.5 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase group"
+          >
+            <CalendarSearch size={18} className="group-hover:scale-110 transition-transform" />
+            <span>[ {t('home.cta_check_slots') || '查询 Slot'} ]</span>
           </Link>
         </div>
 
-        <div className="flex flex-wrap gap-2.5 pt-1">
-          {popularDestinations.map((d) => (
-            <Link
-              key={d.code}
-              href="/services"
-              className="px-4 py-2 bg-white border-2 border-black text-black font-bold text-xs shadow-[2px_2px_0px_#000] hover:bg-amber-300 hover:shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none flex items-center gap-1.5"
-            >
-              <span className="w-2 h-2 bg-black inline-block" />
-              <span>{d.label}</span>
-            </Link>
-          ))}
-        </div>
-      </section>
-
-      {/* === 4. 服务规范 === */}
-      <section className="bg-white border-2 border-black p-6 sm:p-8 shadow-[6px_6px_0px_#000] space-y-6">
-        <div className="border-b-2 border-black pb-3 font-mono">
-          <span className="text-xs font-bold text-neutral-500 uppercase">[ 03 // SPECIFICATIONS ]</span>
-          <h2 className="text-xl sm:text-2xl font-black text-black uppercase mt-0.5">{t('home.spec_title')}</h2>
-        </div>
-
-        <div className="grid grid-cols-1 gap-5 font-mono">
-          {/* 服务处理方式 */}
-          <div className="bg-neutral-50 border-2 border-black p-6 shadow-[4px_4px_0px_#000] space-y-3">
-            <div className="flex items-center justify-between border-b-2 border-black pb-2.5">
-              <span className="font-bold text-xs uppercase text-neutral-600">[ 01 // FAST-API ]</span>
-              <Zap size={18} className="text-black" />
-            </div>
-            <h3 className="text-base font-black text-black">{t('home.feat_fast_title')}</h3>
-            <p className="text-xs text-neutral-700 font-sans leading-relaxed">{t('home.feat_fast_desc')}</p>
-          </div>
-        </div>
-      </section>
-
+      </div>
     </div>
   );
 }

+ 1 - 1
src/app/refund-policy/page.tsx

@@ -18,7 +18,7 @@ const WhatsAppIcon = ({ className }: { className?: string }) => (
 export default function RefundPolicyPage() {
   const { t } = useLanguage();
 
-  const TELEGRAM_USERNAME = "TextSkin Support";
+  const TELEGRAM_USERNAME = "STRATA Support";
   const TELEGRAM_NUMBER = "+8617386033451"; 
   const WHATSAPP_NUMBER = "8617386033451";  
 

+ 0 - 13
src/app/slots/page.tsx

@@ -8,18 +8,6 @@ import SlotGrid from '@/components/slots/SlotGrid';
 import { SlotSnapshot } from '@/types';
 import { statsService } from '@/lib/services';
 
-const SUBSCRIPTION_BLACKLIST = [
-  { city: 'Dublin', country: 'France' },
-];
-
-const isBlacklisted = (slot: SlotSnapshot) => {
-  return SUBSCRIPTION_BLACKLIST.some(
-    (item) =>
-      item.city.toLowerCase() === slot.city?.toLowerCase() &&
-      item.country.toLowerCase() === slot.country?.toLowerCase()
-  );
-};
-
 export default function SlotDashboardPage() {
   const { t } = useLanguage();
   const [loading, setLoading] = useState(true);
@@ -114,7 +102,6 @@ export default function SlotDashboardPage() {
         loading={loading}
         snapshots={snapshots}
         selectedCity={selectedCity}
-        isBlacklisted={isBlacklisted}
       />
     </div>
   );

+ 2 - 2
src/app/terms/page.tsx

@@ -27,7 +27,7 @@ export default function TermsPage() {
             {t('terms.title') || '用户服务协议与使用条款'}
           </h1>
           <p className="text-xs sm:text-sm text-neutral-600 font-mono">
-            {t('terms.subtitle') || '使用 TEXTSKIN 签证自动化与名额监控系统需遵循的法律规范。'}
+            {t('terms.subtitle') || '使用 STRATA 签证自动化与名额监控系统需遵循的法律规范。'}
           </p>
         </div>
       </div>
@@ -37,7 +37,7 @@ export default function TermsPage() {
         
         <div className="bg-neutral-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000]">
           <p className="text-xs text-neutral-700 font-sans leading-relaxed">
-            {t('terms.description') || '欢迎访问 TextSkin 全球签证自动化系统。在您使用本平台提供的名额监控、代办提交及相关增值服务前,请审慎阅读以下条款。'}
+            {t('terms.description') || '欢迎访问 STRATA 全球签证自动化系统。在您使用本平台提供的名额监控、代办提交及相关增值服务前,请审慎阅读以下条款。'}
           </p>
         </div>
 

+ 3 - 3
src/components/Footer.tsx

@@ -27,13 +27,13 @@ export default function Footer() {
               <div className="w-7 h-7 bg-amber-300 border-2 border-black flex items-center justify-center text-black shadow-[1px_1px_0px_#000]">
                 <Plane className="-rotate-45" size={14} />
               </div>
-              <span className="text-lg font-black text-black tracking-tight uppercase">TextSkin</span>
+              <span className="text-lg font-black text-black tracking-tight uppercase">STRATA</span>
               <span className="text-[10px] bg-neutral-100 border border-black px-1.5 py-0.5 font-bold uppercase text-neutral-600">
                 [ VAS DIRECTORY ]
               </span>
             </div>
             <p className="text-xs text-neutral-600 max-w-sm font-sans leading-relaxed">
-              {t('footer.description') || 'TextSkin 全球签证自动化处理与名额监控系统,为您提供官方保障、极速预约与隐私加密服务。'}
+              {t('footer.description') || 'STRATA 全球签证自动化处理与名额监控系统,为您提供官方保障、极速预约与隐私加密服务。'}
             </p>
           </div>
 
@@ -89,7 +89,7 @@ export default function Footer() {
         {/* Bottom Bar */}
         <div className="border-t-2 border-dashed border-neutral-300 pt-6 flex flex-col md:flex-row justify-between items-center text-xs text-neutral-500 gap-3">
           <p className="text-center md:text-left">
-            &copy; {currentYear} TEXTSKIN INC. [ ALL RIGHTS RESERVED // 签证工单管理系统 ]
+            &copy; {currentYear} STRATA INC. [ ALL RIGHTS RESERVED // 签证工单管理系统 ]
           </p>
           <div className="flex gap-4 text-xs font-bold">
             <Link href="/privacy" className="text-neutral-700 hover:text-black hover:underline">[ {t('footer.privacy')} ]</Link>

+ 1 - 1
src/components/Navbar.tsx

@@ -72,7 +72,7 @@ export default function Navbar() {
             </div>
             <div className="flex flex-col leading-none">
               <span className="text-base font-black text-black tracking-tight uppercase">
-                TEXTSKIN
+                STRATA
               </span>
               <span className="text-[9px] font-bold text-neutral-500 tracking-widest uppercase">
                 [ VAS DIRECTORY ]

+ 295 - 179
src/components/ServiceList.tsx

@@ -5,8 +5,12 @@ import { useEffect, useState, useMemo } from 'react';
 import { useRouter } from 'next/navigation';
 import {
   Plane,
-  ShieldCheck,
+  BookOpen,
+  ExternalLink,
+  ChevronDown,
+  ChevronUp,
   Zap,
+  ShieldCheck,
 } from 'lucide-react';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import { Product } from '@/types';
@@ -17,7 +21,7 @@ import { productService } from '@/lib/services';
 
 export default function ServiceList() {
   const router = useRouter();
-  const { t } = useLanguage();
+  const { t, lang } = useLanguage();
 
   const [allProducts, setAllProducts] = useState<Product[]>([]);
   const [loading, setLoading] = useState<boolean>(true);
@@ -29,6 +33,8 @@ export default function ServiceList() {
 
   // 教程预览弹窗状态
   const [activeTutorialProduct, setActiveTutorialProduct] = useState<Product | null>(null);
+  // 内嵌教程卡片展开状态 (productId)
+  const [expandedTutorialId, setExpandedTutorialId] = useState<number | null>(null);
 
   useEffect(() => {
     fetchProducts();
@@ -80,20 +86,15 @@ export default function ServiceList() {
     setIsDetailOpen(true);
   };
 
-  // 辅助解析描述文本
-  const renderDescription = (text: string) => {
-    const lines = (text || '')
+  // 辅助解析描述文本 (仅当后端配置了描述文本时展示)
+  const renderDescription = (text?: string) => {
+    if (!text) return null;
+    const lines = text
       .split('\n')
       .map((line) => line.trim())
       .filter((line) => line.length > 0);
 
-    if (lines.length === 0) {
-      return (
-        <p className="text-neutral-600 text-xs sm:text-sm font-sans leading-relaxed">
-          官方直连极速通道,分布式集群 24 小时毫秒级抢位,预约失败无条件全额退款。
-        </p>
-      );
-    }
+    if (lines.length === 0) return null;
 
     return (
       <div className="space-y-1 text-neutral-600 text-xs sm:text-sm font-sans leading-relaxed">
@@ -116,20 +117,24 @@ export default function ServiceList() {
           <div className="flex items-center gap-2">
             <span className="w-3 h-3 bg-amber-300 border border-black inline-block shadow-[1px_1px_0px_#000]" />
             <span className="tracking-widest uppercase text-black">
-              [ VAS-CATALOG // 官方成熟签证直连服务展厅 ]
+              {t('services.hero_badge')}
             </span>
           </div>
           <div className="text-neutral-600 font-mono text-[11px] font-bold">
-            SYS.NODE: ONLINE // 当前已上线 <span className="text-black font-black underline decoration-amber-400 decoration-2">{allProducts.length}</span> 款成熟服务 · 上架即交付
+            {t('services.sys_node_prefix')}{' '}
+            <span className="text-black font-black underline decoration-amber-400 decoration-2">
+              {allProducts.length}
+            </span>{' '}
+            {t('services.sys_node_suffix')}
           </div>
         </div>
 
         <div className="max-w-3xl space-y-3">
           <h1 className="text-2xl sm:text-3xl md:text-5xl font-black tracking-tight text-black uppercase leading-tight">
-            {t('services.hero_title') || '全球签证官方通道直连与自动化预约'}
+            {t('services.hero_title')}
           </h1>
           <p className="text-xs sm:text-sm md:text-base text-neutral-600 font-mono leading-relaxed">
-            严格实行成熟产品准入制,上架即交付。每项服务均配套明确的操作指引、自动化监控策略与失败全额退款保障。
+            {t('services.hero_desc')}
           </p>
         </div>
 
@@ -141,10 +146,10 @@ export default function ServiceList() {
             </div>
             <div>
               <div className="text-xs font-black text-black font-mono uppercase tracking-wide">
-                7×24H 官方通道毫秒级并发巡检
+                {t('services.benefit_patrol_title')}
               </div>
               <div className="text-[11px] text-neutral-600 mt-1 font-mono leading-relaxed">
-                分布式集群高频巡检,一旦放出即刻精准代抢,全自动提交预约。
+                {t('services.benefit_patrol_desc')}
               </div>
             </div>
           </div>
@@ -155,10 +160,10 @@ export default function ServiceList() {
             </div>
             <div>
               <div className="text-xs font-black text-black font-mono uppercase tracking-wide">
-                官方全额资金托管与退款承诺
+                {t('services.benefit_escrow_title')}
               </div>
               <div className="text-[11px] text-neutral-600 mt-1 font-mono leading-relaxed">
-                预约不成功无条件原路全额退费,资金安全透明可追溯。
+                {t('services.benefit_escrow_desc')}
               </div>
             </div>
           </div>
@@ -201,179 +206,290 @@ export default function ServiceList() {
         <div className="space-y-6">
           {sortedProducts.map((item) => {
             const formattedPrice = (item.price_amount / 100).toLocaleString();
-            const tutorial = item.extra_fields?.tutorial;
-            const cardConfig = item.extra_fields?.card_config;
-            const salesCount = item.recommend_score ? item.recommend_score * 15 + 42 : 77;
-            const officialTag = cardConfig?.official_tag ?? '官方直连';
-            const statusTag = cardConfig?.status_tag ?? 'New';
-            const salesText = cardConfig?.sales_text || `实时监控中 · 已售 ${salesCount}`;
-            const buyButtonText = cardConfig?.buy_button_text || '立即购买';
-            const sublinkText = cardConfig?.sublink_text || '查阅服务细则 →';
-            const pillText = cardConfig?.pill_text || (tutorial && tutorial.enabled ? (tutorial.modal_title || '查看办理教程与材料指引') : null);
-
-            return (
-              <div
-                key={item.id}
-                className="group bg-white border-2 border-black shadow-[6px_6px_0px_#000] hover:shadow-[8px_8px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition-all duration-200 p-5 sm:p-6 flex flex-col lg:flex-row items-stretch lg:items-center justify-between gap-5 sm:gap-6"
-              >
-                {/* 1. 左侧 16:9 视觉海报区 */}
-                <ServicePoster product={item} />
-
-                {/* 2. 中间信息区 */}
-                <div className="flex-1 min-w-0 flex flex-col justify-between py-0.5 space-y-3">
-                  {/* 分类标签 */}
-                  <div className="flex items-center gap-2 text-xs font-mono font-bold tracking-wider">
-                    <span className="w-2.5 h-2.5 bg-emerald-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
-                    <span className="uppercase bg-neutral-100 border border-black px-2 py-0.5 text-black font-black text-[11px] shadow-[1px_1px_0px_#000]">
-                      {item.country} {item.provider ? `// ${item.provider}` : ''}
-                    </span>
-                  </div>
+              const tutorial = item.extra_fields?.tutorial;
+              const tutorialEnabled = Boolean(tutorial && tutorial.enabled);
+              const tutorialDisplayType = tutorial?.display_type || 'modal';
+              const isTutorialExpanded = expandedTutorialId === item.id;
+              const cardConfig = item.extra_fields?.card_config;
+              const officialTag = cardConfig?.official_tag;
+              const statusTag = cardConfig?.status_tag;
+              const salesText = cardConfig?.sales_text;
+              const statusText = cardConfig?.status_text;
+              const buyButtonText = cardConfig?.buy_button_text || (lang === 'zh' ? '立即购买' : 'Order Now');
+              const sublinkText = cardConfig?.sublink_text;
+              const pillText = cardConfig?.pill_text || (tutorialEnabled ? (tutorial?.modal_title || tutorial?.button_text) : null);
+              const descElement = renderDescription(item.description);
+
+              return (
+                <div
+                  key={item.id}
+                  className="group bg-white border-2 border-black shadow-[6px_6px_0px_#000] hover:shadow-[8px_8px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition-all duration-200 p-5 sm:p-6 flex flex-col justify-between gap-5 sm:gap-6"
+                >
+                  <div className="flex flex-col lg:flex-row items-stretch lg:items-center justify-between gap-5 sm:gap-6">
+                    {/* 1. 左侧 16:9 视觉海报区 */}
+                    <ServicePoster product={item} />
+
+                    {/* 2. 中间信息区 */}
+                    <div className="flex-1 min-w-0 flex flex-col justify-between py-0.5 space-y-3">
+                      {/* 分类标签 */}
+                      <div className="flex items-center gap-2 text-xs font-mono font-bold tracking-wider">
+                        <span className="w-2.5 h-2.5 bg-emerald-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+                        <span className="uppercase bg-neutral-100 border border-black px-2 py-0.5 text-black font-black text-[11px] shadow-[1px_1px_0px_#000]">
+                          {item.country} {item.provider ? `// ${item.provider}` : ''}
+                        </span>
+                      </div>
 
-                  {/* 标题行与标贴 */}
-                  <div className="flex flex-wrap items-center gap-2">
-                    <Plane size={16} className="-rotate-45 text-black inline shrink-0 self-center" />
-                    <h2
-                      onClick={() => handleOpenDetail(item)}
-                      className="text-lg sm:text-xl font-black text-black hover:text-amber-600 cursor-pointer transition font-sans tracking-tight"
-                    >
-                      {item.title}
-                    </h2>
-                    {officialTag && (
-                      <span className="bg-teal-100 text-teal-900 border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
-                        {officialTag}
-                      </span>
-                    )}
-                    {statusTag && (
-                      <span className="bg-amber-300 text-black border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
-                        {statusTag}
-                      </span>
-                    )}
-                  </div>
+                      {/* 标题行与标贴 */}
+                      <div className="flex flex-wrap items-center gap-2">
+                        <Plane size={16} className="-rotate-45 text-black inline shrink-0 self-center" />
+                        <h2
+                          onClick={() => handleOpenDetail(item)}
+                          className="text-lg sm:text-xl font-black text-black hover:text-amber-600 cursor-pointer transition font-sans tracking-tight"
+                        >
+                          {item.title}
+                        </h2>
+                        {officialTag && (
+                          <span className="bg-teal-100 text-teal-900 border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                            {officialTag}
+                          </span>
+                        )}
+                        {statusTag && (
+                          <span className="bg-amber-300 text-black border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                            {statusTag}
+                          </span>
+                        )}
+                      </div>
 
-                  {/* 描述信息 */}
-                  <div className="max-w-xl">
-                    {renderDescription(item.description || '')}
-                  </div>
+                      {/* 描述信息 (仅当后端配置了有效描述时展示) */}
+                      {descElement && (
+                        <div className="max-w-xl">
+                          {descElement}
+                        </div>
+                      )}
+
+                      {/* 辅助胶囊按键 (支持 modal, link, both, embedded 多种形态) */}
+                      {(pillText || tutorialEnabled) && (
+                        <div className="flex flex-wrap items-center gap-2">
+                          {tutorialEnabled ? (
+                            <>
+                              {/* 模式 A: 纯外部超链接 (link) */}
+                              {tutorialDisplayType === 'link' && (
+                                <button
+                                  type="button"
+                                  onClick={() => {
+                                    if (tutorial?.link_url?.trim()) {
+                                      window.open(tutorial.link_url.trim(), '_blank', 'noopener,noreferrer');
+                                    } else {
+                                      setActiveTutorialProduct(item);
+                                    }
+                                  }}
+                                  className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                                  title="在新标签页中打开官方外部使用指南"
+                                >
+                                  <ExternalLink size={12} />
+                                  <span>[ {tutorial?.button_text || tutorial?.link_text || pillText || (lang === 'zh' ? '查阅使用指引 ↗' : 'View Guide ↗')} ]</span>
+                                </button>
+                              )}
+
+                              {/* 模式 B: 内嵌折叠展开卡片 (embedded) */}
+                              {tutorialDisplayType === 'embedded' && (
+                                <button
+                                  type="button"
+                                  onClick={() => {
+                                    setExpandedTutorialId(isTutorialExpanded ? null : item.id);
+                                  }}
+                                  className={`inline-flex items-center gap-1.5 px-3 py-1 border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer ${
+                                    isTutorialExpanded
+                                      ? 'bg-amber-300 text-black'
+                                      : 'bg-amber-50 hover:bg-amber-100 text-black'
+                                  }`}
+                                  title={isTutorialExpanded ? '收起内嵌使用指引' : '展开内嵌使用指引'}
+                                >
+                                  {isTutorialExpanded ? <ChevronUp size={12} /> : <ChevronDown size={12} />}
+                                  <span>
+                                    [ {isTutorialExpanded
+                                      ? (lang === 'zh' ? '收起使用指引 ↑' : 'Collapse Guide ↑')
+                                      : (tutorial?.button_text || tutorial?.modal_title || pillText || (lang === 'zh' ? '展开使用指引 ↓' : 'View Guide ↓'))} ]
+                                  </span>
+                                </button>
+                              )}
+
+                              {/* 模式 C: 弹窗对话框模式 (modal) */}
+                              {tutorialDisplayType === 'modal' && (
+                                <button
+                                  type="button"
+                                  onClick={() => setActiveTutorialProduct(item)}
+                                  className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                                >
+                                  <BookOpen size={12} />
+                                  <span>[ {tutorial?.button_text || tutorial?.modal_title || pillText || (lang === 'zh' ? '查看办理教程 →' : 'View Guide →')} ]</span>
+                                </button>
+                              )}
+
+                              {/* 模式 D: 组合模式 (both - 弹窗 + 外部超链接) */}
+                              {tutorialDisplayType === 'both' && (
+                                <>
+                                  <button
+                                    type="button"
+                                    onClick={() => setActiveTutorialProduct(item)}
+                                    className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                                  >
+                                    <BookOpen size={12} />
+                                    <span>[ {tutorial?.button_text || tutorial?.modal_title || pillText || (lang === 'zh' ? '查看办理教程 →' : 'View Guide →')} ]</span>
+                                  </button>
+
+                                  {tutorial?.link_url?.trim() && (
+                                    <a
+                                      href={tutorial.link_url.trim()}
+                                      target="_blank"
+                                      rel="noopener noreferrer"
+                                      className="inline-flex items-center gap-1.5 px-3 py-1 bg-white hover:bg-neutral-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                                      title="在新标签页中打开官方文档"
+                                    >
+                                      <ExternalLink size={12} />
+                                      <span>[ {tutorial?.link_text || (lang === 'zh' ? '官方文档 ↗' : 'Docs ↗')} ]</span>
+                                    </a>
+                                  )}
+                                </>
+                              )}
+                            </>
+                          ) : (
+                            pillText && (
+                              <button
+                                type="button"
+                                onClick={() => handleOpenDetail(item)}
+                                className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                              >
+                                <span>[ {pillText} → ]</span>
+                              </button>
+                            )
+                          )}
+                        </div>
+                      )}
+
+                      {/* 底部属性与服务信息 (仅当后端配置了相关信息时展示) */}
+                      {(salesText || item.city || item.visa_type || statusText) && (
+                        <div className="text-neutral-500 text-xs font-mono flex flex-wrap items-center gap-3 pt-1 border-t border-neutral-200">
+                          {salesText && (
+                            <span className="font-bold text-neutral-800">
+                              {salesText}
+                            </span>
+                          )}
+                          {item.city && (
+                            <span className="text-neutral-500">
+                              {salesText ? '· ' : ''}{lang === 'zh' ? '适用领区' : 'Jurisdiction'}: {item.city}
+                            </span>
+                          )}
+                          {item.visa_type && (
+                            <span className="text-neutral-500">
+                              · {lang === 'zh' ? '类型' : 'Type'}: {item.visa_type}
+                            </span>
+                          )}
+                          {statusText && (
+                            <>
+                              <span className="text-neutral-300">|</span>
+                              <span className="text-emerald-700 font-bold flex items-center gap-1">
+                                <span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
+                                {statusText}
+                              </span>
+                            </>
+                          )}
+                        </div>
+                      )}
+                    </div>
+
+                    {/* 3. 右侧价格卡与购买按键区 */}
+                    <div className="lg:w-48 xl:w-52 shrink-0 flex flex-row lg:flex-col items-center lg:items-end justify-between lg:justify-center gap-3 pt-4 lg:pt-0 border-t-2 border-neutral-200 lg:border-t-0 lg:border-l-2 lg:border-neutral-200 lg:pl-6">
+                      {/* 价格展示 */}
+                      <div className="font-mono text-left lg:text-right">
+                        <div className="text-[10px] font-bold uppercase tracking-wider text-neutral-500">
+                          TOTAL SERVICE FEE
+                        </div>
+                        <div className="flex items-baseline justify-end gap-1 mt-0.5">
+                          <span className="text-lg font-bold text-black font-mono">
+                            {item.price_currency === 'CNY' ? '¥' : item.price_currency}
+                          </span>
+                          <span className="text-3xl sm:text-4xl font-black text-black font-mono tracking-tight">
+                            {formattedPrice}
+                          </span>
+                        </div>
+                      </div>
 
-                  {/* 辅助胶囊按键 (教程与指引) */}
-                  <div>
-                    {pillText ? (
+                      {/* 立即购买按键 (Neo-Brutalist 粗野派实体按钮) */}
                       <button
-                        type="button"
-                        onClick={() => {
-                          if (tutorial && tutorial.enabled) {
-                            setActiveTutorialProduct(item);
-                          } else {
-                            handleOpenDetail(item);
-                          }
-                        }}
-                        className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                        onClick={() => handleOrderClick(item.id)}
+                        className="w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black font-mono text-sm shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all uppercase flex items-center justify-center gap-2 cursor-pointer"
                       >
-                        <span>[ {pillText} → ]</span>
+                        <span>[ {buyButtonText} ]</span>
                       </button>
-                    ) : (
-                      <div className="inline-flex items-center gap-1.5 px-3 py-1 bg-neutral-50 text-neutral-700 border border-black font-mono text-xs font-bold shadow-[1px_1px_0px_#000]">
-                        <ShieldCheck size={13} className="text-emerald-600" />
-                        <span>7×24H 官方通道毫秒级代抢 · 失败全额退款保障</span>
-                      </div>
-                    )}
-                  </div>
-
-                  {/* 底部库存与服务统计 */}
-                  <div className="text-neutral-500 text-xs font-mono flex items-center gap-3 pt-1 border-t border-neutral-200">
-                    <span className="font-bold text-neutral-800">
-                      {salesText}
-                    </span>
-                    {item.city && (
-                      <span className="text-neutral-500">· 适用领区: {item.city}</span>
-                    )}
-                    <span className="text-neutral-300">|</span>
-                    <span className="text-emerald-700 font-bold flex items-center gap-1">
-                      <span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
-                      直连就绪
-                    </span>
-                  </div>
-                </div>
 
-                {/* 3. 右侧价格卡与购买按键区 */}
-                <div className="lg:w-48 xl:w-52 shrink-0 flex flex-row lg:flex-col items-center lg:items-end justify-between lg:justify-center gap-3 pt-4 lg:pt-0 border-t-2 border-neutral-200 lg:border-t-0 lg:border-l-2 lg:border-neutral-200 lg:pl-6">
-                  {/* 价格展示 */}
-                  <div className="font-mono text-left lg:text-right">
-                    <div className="text-[10px] font-bold uppercase tracking-wider text-neutral-500">
-                      TOTAL SERVICE FEE
-                    </div>
-                    <div className="flex items-baseline justify-end gap-1 mt-0.5">
-                      <span className="text-lg font-bold text-black font-mono">¥</span>
-                      <span className="text-3xl sm:text-4xl font-black text-black font-mono tracking-tight">
-                        {formattedPrice}
-                      </span>
+                      {/* 次级链接 (仅当后端配置了 sublink_text 时显示) */}
+                      {sublinkText && (
+                        <button
+                          onClick={() => handleOpenDetail(item)}
+                          className="text-xs font-mono font-bold text-neutral-600 hover:text-black underline underline-offset-4 transition inline-flex items-center gap-1 mt-0.5 cursor-pointer"
+                        >
+                          <span>{sublinkText}</span>
+                        </button>
+                      )}
                     </div>
                   </div>
 
-                  {/* 立即购买按键 (Neo-Brutalist 粗野派实体按钮) */}
-                  <button
-                    onClick={() => handleOrderClick(item.id)}
-                    className="w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black font-mono text-sm shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all uppercase flex items-center justify-center gap-2 cursor-pointer"
-                  >
-                    <span>[ {buyButtonText} ]</span>
-                  </button>
-
-                  {/* 次级链接 */}
-                  <button
-                    onClick={() => handleOpenDetail(item)}
-                    className="text-xs font-mono font-bold text-neutral-600 hover:text-black underline underline-offset-4 transition inline-flex items-center gap-1 mt-0.5 cursor-pointer"
-                  >
-                    <span>{sublinkText}</span>
-                  </button>
+                  {/* 4. 内嵌模式展开区 (仅当 display_type === 'embedded' 且展开时显示) */}
+                  {tutorialEnabled && tutorialDisplayType === 'embedded' && isTutorialExpanded && (
+                    <div className="pt-4 border-t-2 border-dashed border-neutral-300">
+                      <ProductTutorialBanner
+                        tutorial={tutorial}
+                        productTitle={item.title}
+                        hideBanner={false}
+                      />
+                    </div>
+                  )}
                 </div>
-              </div>
-            );
-          })}
-        </div>
-      )}
-
-      {/* 空状态 */}
-      {!loading && !error && sortedProducts.length === 0 && (
-        <div className="text-center py-16 bg-white border-2 border-black shadow-[6px_6px_0px_#000] mt-4 font-mono">
-          <div className="mx-auto w-12 h-12 bg-amber-300 border-2 border-black flex items-center justify-center mb-3 font-black text-xl text-black shadow-[2px_2px_0px_#000]">
-            ?
+              );
+            })}
           </div>
-          <h3 className="text-black font-black text-base uppercase mb-1">
-            {t('services.no_result_title') || '暂无已上线的成熟服务'}
-          </h3>
-          <p className="text-neutral-600 text-xs max-w-sm mx-auto mb-4 font-mono">
-            官方服务正在陆续完成通道测试并准入上架,敬请期待。
-          </p>
-          <button
-            onClick={fetchProducts}
-            className="px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-mono text-xs font-black shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition cursor-pointer uppercase"
-          >
-            [ 刷新展厅服务 ]
-          </button>
-        </div>
-      )}
+        )}
 
-      {/* 专属服务细则全景弹窗 */}
-      <ServiceDetailModal
-        product={detailProduct}
-        isOpen={isDetailOpen}
-        onClose={() => setIsDetailOpen(false)}
-        onApply={(id) => handleOrderClick(id)}
-      />
-
-      {/* 专属教程查看器 (从商品卡片上点击教程直接弹出) */}
-      {activeTutorialProduct && activeTutorialProduct.extra_fields?.tutorial && (
-        <ProductTutorialBanner
-          tutorial={{
-            ...activeTutorialProduct.extra_fields.tutorial,
-            display_type: 'modal',
-          }}
-          productTitle={activeTutorialProduct.title}
-          defaultOpenModal={true}
-          hideBanner={true}
-          onCloseModal={() => setActiveTutorialProduct(null)}
+        {/* 空状态 */}
+        {!loading && !error && sortedProducts.length === 0 && (
+          <div className="text-center py-16 bg-white border-2 border-black shadow-[6px_6px_0px_#000] mt-4 font-mono">
+            <div className="mx-auto w-12 h-12 bg-amber-300 border-2 border-black flex items-center justify-center mb-3 font-black text-xl text-black shadow-[2px_2px_0px_#000]">
+              ?
+            </div>
+            <h3 className="text-black font-black text-base uppercase mb-1">
+              {t('services.no_services_title')}
+            </h3>
+            <p className="text-neutral-600 text-xs max-w-sm mx-auto mb-4 font-mono">
+              {t('services.no_services_desc')}
+            </p>
+            <button
+              onClick={fetchProducts}
+              className="px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-mono text-xs font-black shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition cursor-pointer uppercase"
+            >
+              [ {t('services.refresh_services')} ]
+            </button>
+          </div>
+        )}
+
+        {/* 专属服务细则全景弹窗 */}
+        <ServiceDetailModal
+          product={detailProduct}
+          isOpen={isDetailOpen}
+          onClose={() => setIsDetailOpen(false)}
+          onApply={(id) => handleOrderClick(id)}
         />
-      )}
+
+        {/* 专属教程查看器 (从商品卡片上点击教程直接弹出) */}
+        {activeTutorialProduct && activeTutorialProduct.extra_fields?.tutorial && (
+          <ProductTutorialBanner
+            tutorial={activeTutorialProduct.extra_fields.tutorial}
+            productTitle={activeTutorialProduct.title}
+            defaultOpenModal={true}
+            hideBanner={true}
+            onCloseModal={() => setActiveTutorialProduct(null)}
+          />
+        )}
 
     </div>
   );

+ 7 - 6
src/components/admin/AdminSidebar.tsx

@@ -5,7 +5,7 @@ import { usePathname, useRouter } from 'next/navigation';
 import Link from 'next/link';
 import { retroConfirm } from '@/lib/dialog';
 import { 
-  LayoutDashboard, ShoppingBag, LifeBuoy, Settings, LogOut, 
+  ShoppingBag, LifeBuoy, Settings, LogOut, 
   Activity, CreditCard, Users, ChevronLeft, ChevronRight, 
   Plane, LucideIcon, Coins,
   Menu, X, UserCog, Network, SlidersHorizontal, Puzzle, Cpu, Bot
@@ -26,8 +26,7 @@ export default function AdminSidebar() {
   const [mounted, setMounted] = useState(false);
 
   const menu: MenuItem[] = [
-    { name: '仪表盘概览', href: '/admin', icon: LayoutDashboard },
-    { name: 'AI 智能运维', href: '/admin/agent', icon: Bot },
+    { name: 'AI 智能运维', href: '/admin', icon: Bot },
     { name: '用户与权限', href: '/admin/users', icon: Users },
     { name: '工单客服处理', href: '/admin/tickets', icon: LifeBuoy },
     { name: '全站订单管理', href: '/admin/orders', icon: ShoppingBag },
@@ -82,7 +81,7 @@ export default function AdminSidebar() {
           <div className="w-6 h-6 bg-amber-300 border border-black flex items-center justify-center">
             <Plane className="-rotate-45" size={13} />
           </div>
-          <span>TextSkin Admin</span>
+          <span>STRATA Admin</span>
         </div>
         <button 
           onClick={() => setIsMobileOpen(!isMobileOpen)}
@@ -123,7 +122,7 @@ export default function AdminSidebar() {
             </div>
             {!isCollapsed && (
               <div className="flex flex-col leading-none">
-                <span className="font-black text-sm uppercase tracking-tight">TEXTSKIN</span>
+                <span className="font-black text-sm uppercase tracking-tight">STRATA</span>
                 <span className="text-[9px] text-neutral-500 font-bold tracking-widest">[ OPS-TERMINAL ]</span>
               </div>
             )}
@@ -143,7 +142,9 @@ export default function AdminSidebar() {
         <div className="flex-1 overflow-y-auto py-3 px-2 space-y-1.5 scrollbar-thin">
           {menu.map((item) => {
             const Icon = item.icon;
-            const isActive = pathname === item.href || (item.href !== '/admin' && pathname.startsWith(item.href));
+            const isActive = item.href === '/admin'
+              ? (pathname === '/admin' || pathname === '/admin/agent')
+              : (pathname === item.href || pathname.startsWith(item.href));
 
             return (
               <Link

+ 0 - 41
src/components/admin/DataStats.tsx

@@ -1,41 +0,0 @@
-'use client';
-
-import { ArrowUp, ArrowDown, LucideIcon } from 'lucide-react';
-
-interface StatCardProps {
-  title: string;
-  value: string | number;
-  icon: LucideIcon;
-  trend?: string;
-  trendUp?: boolean;
-  color?: string;
-}
-
-export default function DataStats({ title, value, icon: Icon, trend, trendUp, color = "blue" }: StatCardProps) {
-  return (
-    <div className="bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] font-mono flex flex-col justify-between space-y-3">
-      <div className="flex justify-between items-start border-b-2 border-black pb-2.5">
-        <p className="text-[11px] font-black text-neutral-600 uppercase tracking-wider">[ {title} ]</p>
-        <div className="w-7 h-7 bg-amber-300 border border-black flex items-center justify-center text-black">
-          <Icon size={15} />
-        </div>
-      </div>
-      
-      <div>
-        <h3 className="text-2xl font-black text-black tracking-tight">{value}</h3>
-      </div>
-      
-      {trend && (
-        <div className="pt-2 border-t border-dashed border-neutral-300 flex items-center justify-between text-[11px]">
-          <span className={`flex items-center font-bold px-1.5 py-0.5 border border-black ${
-            trendUp ? 'bg-amber-100 text-black' : 'bg-rose-100 text-rose-800'
-          }`}>
-            {trendUp ? <ArrowUp size={12} className="mr-0.5" /> : <ArrowDown size={12} className="mr-0.5" />}
-            {trend}
-          </span>
-          <span className="text-neutral-500 uppercase text-[10px]">VS LAST MONTH</span>
-        </div>
-      )}
-    </div>
-  );
-}

+ 25 - 29
src/components/admin/agent/AgentActionConfirmCard.tsx

@@ -3,7 +3,7 @@
 
 import { useState } from 'react';
 import { AgentDangerousAction } from '@/types/agent';
-import { ShieldAlert, Check, X, AlertTriangle } from 'lucide-react';
+import { ShieldAlert, Check, X } from 'lucide-react';
 
 interface AgentActionConfirmCardProps {
   action: AgentDangerousAction;
@@ -31,66 +31,62 @@ export default function AgentActionConfirmCard({
   };
 
   return (
-    <div className="my-3 p-3 bg-amber-50 border-2 border-dashed border-amber-600 shadow-[3px_3px_0px_#000] font-mono text-xs text-black">
-      <div className="flex items-center gap-2 mb-2 pb-1.5 border-b border-amber-300">
-        <div className="p-1 bg-amber-400 border border-black shrink-0">
+    <div className="my-2.5 p-3 bg-amber-50 border-2 border-dashed border-amber-600 shadow-[3px_3px_0px_#000] font-mono text-xs text-black">
+      <div className="flex items-center gap-2 mb-2 pb-1.5 border-b-2 border-amber-300">
+        <div className="p-1 bg-amber-400 border border-black shrink-0 shadow-[1px_1px_0px_#000]">
           <ShieldAlert size={14} className="text-black" />
         </div>
         <span className="font-black text-xs uppercase tracking-tight text-amber-950">
-          [ ⚠️ 高危写操作确认 // HUMAN-IN-THE-LOOP ]
+          [!] SECURITY ALERT // ELEVATED WRITE PERMISSION REQUIRED
         </span>
       </div>
 
-      <div className="text-neutral-700 text-xs mb-2 leading-relaxed">
-        Agent 准备执行具有写操作或破坏性影响的工具调用:
-        <span className="font-bold text-black bg-amber-200 px-1 mx-1 border border-black">
+      <div className="text-neutral-800 text-xs mb-2 leading-relaxed">
+        Agent 即将执行具有写操作或破坏性影响的系统工具指令:
+        <span className="font-black text-black bg-amber-200 px-1.5 py-0.5 mx-1 border border-black shadow-[1px_1px_0px_#000]">
           {action.tool}
         </span>
         {action.description && (
-          <span className="text-neutral-500 block text-[11px] mt-0.5">
-            (说明: {action.description})
+          <span className="text-neutral-600 block text-[11px] mt-1 font-bold">
+            说明: {action.description}
           </span>
         )}
       </div>
 
-      <div className="mb-3 bg-white p-2 border border-neutral-300 text-[11px]">
-        <span className="font-bold text-neutral-600 block mb-1">执行参数:</span>
-        <pre className="text-black overflow-x-auto whitespace-pre-wrap break-all">
+      <div className="mb-3 bg-white p-2 border-2 border-black text-[11px]">
+        <span className="font-black text-neutral-600 block mb-1 text-[10px] uppercase">
+          // ARGUMENTS PAYLOAD:
+        </span>
+        <pre className="text-black font-mono font-medium overflow-x-auto whitespace-pre-wrap break-all max-h-32 scrollbar-thin">
           {JSON.stringify(action.arguments, null, 2)}
         </pre>
       </div>
 
       {handled === null ? (
-        <div className="flex items-center gap-2">
+        <div className="flex items-center gap-2 pt-1 border-t border-amber-300/80">
           <button
             type="button"
             onClick={handleConfirm}
-            className="flex items-center gap-1.5 px-3 py-1.5 bg-amber-400 hover:bg-amber-300 border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+            className="flex items-center gap-1.5 px-3 py-1 bg-amber-400 hover:bg-amber-300 text-black font-black text-xs border-2 border-black shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
           >
-            <Check size={13} />
-            <span>[ 确认执行 ]</span>
+            <Check size={12} className="stroke-[3]" />
+            <span>[ Y: 授权并执行 ]</span>
           </button>
           <button
             type="button"
             onClick={handleCancel}
-            className="flex items-center gap-1 px-3 py-1.5 bg-white hover:bg-rose-100 border-2 border-black font-bold text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+            className="flex items-center gap-1.5 px-3 py-1 bg-white hover:bg-neutral-100 text-black font-black text-xs border-2 border-black shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
           >
-            <X size={13} />
-            <span>[ 终止放弃 ]</span>
+            <X size={12} className="stroke-[3]" />
+            <span>[ N: 拒绝并终止 ]</span>
           </button>
         </div>
       ) : (
-        <div className="flex items-center gap-1.5 font-bold text-xs py-1">
+        <div className="text-[11px] font-black py-1">
           {handled === 'confirmed' ? (
-            <span className="text-emerald-800 bg-emerald-100 border border-emerald-500 px-2 py-0.5 flex items-center gap-1">
-              <Check size={12} />
-              管理员已确认执行下发
-            </span>
+            <span className="text-emerald-700">✓ [已人工授权确认] 指令已派发执行</span>
           ) : (
-            <span className="text-rose-800 bg-rose-100 border border-rose-500 px-2 py-0.5 flex items-center gap-1">
-              <X size={12} />
-              管理员已终止该操作
-            </span>
+            <span className="text-rose-700">✗ [已人工拦截拒绝] 操作已取消</span>
           )}
         </div>
       )}

+ 249 - 233
src/components/admin/agent/AgentChatBox.tsx

@@ -2,15 +2,15 @@
 'use client';
 
 import { useState, useRef, useEffect } from 'react';
-import { AgentMessage, AgentToolMetadata, ToolStep, AgentDangerousAction } from '@/types/agent';
+import { AgentMessage, AgentToolMetadata, AgentDangerousAction } from '@/types/agent';
 import AgentToolStepCard from './AgentToolStepCard';
 import AgentActionConfirmCard from './AgentActionConfirmCard';
+import CliMarkdownRenderer from './CliMarkdownRenderer';
 import { 
-  Send, Square, Sparkles, Bot, User, Trash2, 
-  Wrench, ArrowUpRight, Copy, Check, Terminal, Loader2 
+  Send, Square, Bot, Terminal, Loader2, 
+  Trash2, Wrench, Sparkles, CornerDownLeft
 } from 'lucide-react';
-import { toast } from 'react-hot-toast';
-import Link from 'next/link';
+import { format } from 'date-fns';
 
 interface QuickPrompt {
   label: string;
@@ -32,90 +32,6 @@ interface AgentChatBoxProps {
   compact?: boolean;
 }
 
-// 辅助渲染:高亮单号 ORD-xxxx 与商品并转换为操作超链接或可复制徽标
-function FormattedMessageContent({ content }: { content: string }) {
-  if (!content) return null;
-
-  // 分行与基础 Markdown 表格、加粗、单号正则匹配
-  const lines = content.split('\n');
-
-  return (
-    <div className="space-y-1.5 text-xs text-black leading-relaxed select-text">
-      {lines.map((line, idx) => {
-        const trimmed = line.trim();
-
-        // 识别表格行
-        if (trimmed.startsWith('|') && trimmed.endsWith('|')) {
-          const cells = trimmed.split('|').slice(1, -1);
-          const isHeaderDivider = cells.every((c) => c.trim().match(/^:?-+:?$/));
-          if (isHeaderDivider) {
-            return <hr key={idx} className="border-t border-black my-1" />;
-          }
-          return (
-            <div key={idx} className="flex gap-2 py-0.5 border-b border-neutral-200 overflow-x-auto text-[11px] font-mono">
-              {cells.map((c, i) => (
-                <div key={i} className="min-w-[70px] flex-1 font-medium truncate">
-                  {c.trim()}
-                </div>
-              ))}
-            </div>
-          );
-        }
-
-        // 识别代码块标识 ```
-        if (trimmed.startsWith('```')) {
-          return null;
-        }
-
-        // 识别列表行
-        const isBullet = trimmed.startsWith('- ') || trimmed.startsWith('* ') || /^\d+\.\s/.test(trimmed);
-
-        // 正则替换订单号为高亮标签
-        const orderRegex = /(ORD-[A-Za-z0-9-]+)/g;
-        const parts = line.split(orderRegex);
-
-        return (
-          <div key={idx} className={`${isBullet ? 'pl-2 border-l-2 border-amber-400 my-0.5' : ''}`}>
-            {parts.map((part, pIdx) => {
-              if (orderRegex.test(part)) {
-                return (
-                  <span
-                    key={pIdx}
-                    className="inline-flex items-center gap-1 mx-1 px-1.5 py-0.2 bg-amber-200 border border-black font-black text-black group relative"
-                  >
-                    <span>{part}</span>
-                    <Link
-                      href={`/admin/orders?keyword=${encodeURIComponent(part)}`}
-                      className="text-neutral-700 hover:text-black hover:scale-110 transition"
-                      title="在后台订单列表过滤该订单"
-                      target="_blank"
-                    >
-                      <ArrowUpRight size={10} />
-                    </Link>
-                  </span>
-                );
-              }
-              // 加粗转换 **xxx**
-              const boldRegex = /\*\*(.*?)\*\*/g;
-              if (boldRegex.test(part)) {
-                const subParts = part.split(boldRegex);
-                return (
-                  <span key={pIdx}>
-                    {subParts.map((sp, sIdx) =>
-                      sIdx % 2 === 1 ? <strong key={sIdx} className="font-black text-black">{sp}</strong> : sp
-                    )}
-                  </span>
-                );
-              }
-              return <span key={pIdx}>{part}</span>;
-            })}
-          </div>
-        );
-      })}
-    </div>
-  );
-}
-
 export default function AgentChatBox({
   messages,
   isLoading,
@@ -134,7 +50,7 @@ export default function AgentChatBox({
   const messagesEndRef = useRef<HTMLDivElement | null>(null);
   const textareaRef = useRef<HTMLTextAreaElement | null>(null);
 
-  // 滚动到底部
+  // 自动滚动到底部
   useEffect(() => {
     messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
   }, [messages, currentThinking, isLoading]);
@@ -162,24 +78,41 @@ export default function AgentChatBox({
   };
 
   return (
-    <div className={`flex flex-col h-full bg-neutral-100 font-mono text-black select-none ${className}`}>
+    <div className={`flex flex-col h-full bg-neutral-100 font-mono text-black select-text ${className}`}>
       
-      {/* 顶部工具栏 */}
-      <div className="h-10 bg-white border-b-2 border-black px-3 flex items-center justify-between shrink-0">
-        <div className="flex items-center gap-2">
-          <div className="w-2.5 h-2.5 bg-amber-400 border border-black animate-pulse" />
-          <span className="font-black text-xs uppercase tracking-wider text-black">
-            [ AGENT-TERMINAL // 需求调度台 ]
-          </span>
+      {/* 终端控制窗口顶栏 (复古 Mac/Linux 命令行 + 全站黑白黄 Neo-brutalism 主题) */}
+      <div className="h-10 bg-white border-b-2 border-black px-3.5 flex items-center justify-between shrink-0 select-none">
+        
+        {/* 左侧:复古终端交通灯红黄绿三色圆点 + 命令行标志 */}
+        <div className="flex items-center gap-3">
+          <div className="flex items-center gap-1.5">
+            <span className="w-3 h-3 rounded-full bg-rose-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+            <span className="w-3 h-3 rounded-full bg-amber-300 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+            <span className="w-3 h-3 rounded-full bg-emerald-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+          </div>
+
+          <div className="flex items-center gap-2 pl-2 border-l-2 border-black">
+            <div className="p-0.5 bg-amber-300 border border-black shadow-[1px_1px_0px_#000]">
+              <Terminal size={12} className="text-black" />
+            </div>
+            <span className="font-black text-xs text-black tracking-wide">
+              root@strata-ops:~ #
+            </span>
+            <span className="hidden sm:inline-flex items-center gap-1 px-1.5 py-0.2 bg-emerald-100 border border-black text-[10px] text-emerald-950 font-black">
+              <span className="w-1.5 h-1.5 rounded-full bg-emerald-600 animate-pulse" />
+              ONLINE
+            </span>
+          </div>
         </div>
 
+        {/* 右侧动作工具栏:查看技能库、清空命令行 */}
         <div className="flex items-center gap-1.5">
           {onOpenToolsModal && (
             <button
               type="button"
               onClick={onOpenToolsModal}
-              className="flex items-center gap-1 px-2 py-1 bg-neutral-50 hover:bg-amber-300 border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
-              title="查看系统开放的工具技能库"
+              className="flex items-center gap-1 px-2.5 py-1 bg-white hover:bg-amber-300 border-2 border-black text-[11px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+              title="查看已开放的系统运维工具技能"
             >
               <Wrench size={11} />
               <span className="hidden sm:inline">技能库 ({tools.length})</span>
@@ -190,117 +123,174 @@ export default function AgentChatBox({
             type="button"
             onClick={onClearSession}
             disabled={isLoading || messages.length === 0}
-            className="flex items-center gap-1 px-2 py-1 bg-white hover:bg-rose-100 disabled:opacity-40 disabled:hover:bg-white border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
-            title="清空对话记忆并重置会话"
+            className="flex items-center gap-1 px-2.5 py-1 bg-white hover:bg-rose-100 disabled:opacity-40 disabled:hover:bg-white border-2 border-black text-[11px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+            title="清空当前终端并重置会话"
           >
             <Trash2 size={11} />
-            <span className="hidden sm:inline">清空重置</span>
+            <span className="hidden sm:inline">清屏 (clear)</span>
           </button>
         </div>
       </div>
 
-      {/* 消息滚动主区域 */}
-      <div className="flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin bg-neutral-100 select-text">
+      {/* 终端屏幕滚动主区域 */}
+      <div className="flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin bg-neutral-100 text-black">
+        
+        {/* 终端欢迎 MOTD (空会话状态) */}
         {messages.length === 0 ? (
-          <div className="h-full flex flex-col items-center justify-center text-center p-6 space-y-4 select-none">
-            <div className="w-14 h-14 bg-amber-300 border-2 border-black flex items-center justify-center shadow-[4px_4px_0px_#000]">
-              <Bot size={28} className="text-black" />
-            </div>
-            <div className="space-y-1">
-              <div className="font-black text-sm uppercase text-black">
-                [ 智能运维助理就绪 // STANDBY ]
+          <div className="h-full flex flex-col items-center justify-center p-3 select-none">
+            <div className="max-w-xl w-full border-2 border-black bg-white p-5 shadow-[4px_4px_0px_#000] space-y-4">
+              
+              {/* ASCII / CLI 欢迎 Header */}
+              <div className="text-black font-black leading-tight select-none">
+                <pre className="font-mono text-[11px] text-black hidden sm:block">
+{`   _____ _______ _____         _______       ____  _____   _____ 
+  / ____|__   __|  __ \\     /\\|__   __|/\\   / __ \\|  __ \\ / ____|
+ | (___    | |  | |__) |   /  \\  | |  /  \\ | |  | | |__) | (___  
+  \\___ \\   | |  |  _  /   / /\\ \\ | | / /\\ \\| |  | |  ___/ \\___ \\ 
+  ____) |  | |  | | \\ \\  / ____ \\| |/ ____ \\ |__| | |     ____) |
+ |_____/   |_|  |_|  \\_\\/_/    \\_\\_/_/    \\_\\____/|_|    |_____/ `}
+                </pre>
+                <div className="sm:hidden text-sm font-black text-black uppercase">
+                  [ STRATA AI-OPS INTELLIGENT TERMINAL v4.2 ]
+                </div>
               </div>
-              <p className="text-xs text-neutral-600 max-w-sm leading-relaxed">
-                无需复杂的表单操作,直接以自然语言告知您的管理意图。AI Agent 会自主规划步骤、调用后台系统工具并完成操作汇报。
-              </p>
-            </div>
 
-            {/* 初始场景快捷推荐 */}
-            {quickPrompts.length > 0 && (
-              <div className="w-full max-w-md pt-2 space-y-1.5">
-                <div className="text-[11px] font-black text-neutral-500 uppercase tracking-widest text-left">
-                  ▶ 场景常用指令:
-                </div>
-                <div className="flex flex-wrap gap-2">
-                  {quickPrompts.map((item, idx) => (
-                    <button
-                      key={idx}
-                      type="button"
-                      onClick={() => onSendMessage(item.prompt)}
-                      className="px-2.5 py-1.5 bg-white hover:bg-amber-300 border-2 border-black font-bold text-xs text-left shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
-                    >
-                      {item.label}
-                    </button>
-                  ))}
-                </div>
+              <div className="space-y-1.5 text-xs text-neutral-800 border-t-2 border-black pt-3">
+                <p className="flex items-center gap-2">
+                  <span className="px-1 bg-emerald-200 border border-black font-black text-[10px]">
+                    CLUSTER: OK
+                  </span>
+                  <span>节点集群健康正常,管理权限已就绪</span>
+                </p>
+                <p className="flex items-center gap-2">
+                  <span className="px-1 bg-amber-300 border border-black font-black text-[10px]">
+                    CAPABILITIES
+                  </span>
+                  <span>已开放 <strong>{tools.length || 41}</strong> 项全站后台系统操作工具</span>
+                </p>
+                <p className="flex items-center gap-2">
+                  <span className="px-1 bg-neutral-200 border border-black font-black text-[10px]">
+                    PROTOCOL
+                  </span>
+                  <span>DeepSeek / OpenAI 协议智能规划调度中枢</span>
+                </p>
+                <p className="text-neutral-600 text-[11px] pt-1 leading-relaxed">
+                  ▶ 直接输入自然语言描述意图,AI Agent 将自主制定步骤、调度后台系统工具并呈现执行结果。
+                </p>
               </div>
-            )}
+
+              {/* 常用命令行快速点选 */}
+              {quickPrompts.length > 0 && (
+                <div className="space-y-2 pt-2 border-t-2 border-black">
+                  <div className="text-[11px] font-black text-neutral-600 uppercase tracking-wider">
+                    ▶ QUICK COMMAND SUGGESTIONS (常用指令快捷触发):
+                  </div>
+                  <div className="flex flex-wrap gap-2">
+                    {quickPrompts.map((item, idx) => (
+                      <button
+                        key={idx}
+                        type="button"
+                        onClick={() => onSendMessage(item.prompt)}
+                        className="px-2.5 py-1 bg-white hover:bg-amber-300 text-black border-2 border-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 text-xs font-mono font-bold transition text-left"
+                      >
+                        <span className="text-black font-black mr-1">$</span>
+                        <span>{item.label}</span>
+                      </button>
+                    ))}
+                  </div>
+                </div>
+              )}
+            </div>
           </div>
         ) : (
           messages.map((msg) => {
             const isUser = msg.role === 'user';
-            return (
-              <div
-                key={msg.id}
-                className={`flex gap-2.5 ${isUser ? 'justify-end' : 'justify-start'}`}
-              >
-                {!isUser && (
-                  <div className="w-8 h-8 bg-amber-300 border-2 border-black flex items-center justify-center shrink-0 shadow-[2px_2px_0px_#000] mt-0.5">
-                    <Bot size={16} className="text-black" />
+            const timeStr = format(new Date(msg.timestamp), 'HH:mm:ss');
+
+            if (isUser) {
+              // 用户消息:纯粹的命令行交互风格 (prompt + command) - 亮黄底色匹配全局主题
+              return (
+                <div 
+                  key={msg.id} 
+                  className="rounded-none border-2 border-black bg-amber-300 p-3 shadow-[3px_3px_0px_#000] text-black"
+                >
+                  <div className="flex items-center justify-between text-[11px] pb-1.5 mb-1.5 border-b border-black/20 select-none">
+                    <div className="flex items-center gap-1.5">
+                      <span className="font-black text-black">admin@strata-ops</span>
+                      <span className="font-bold">:</span>
+                      <span className="font-bold text-neutral-800">~</span>
+                      <span className="font-black text-black">$</span>
+                      <span className="text-[10px] font-black uppercase text-neutral-800 bg-amber-200 px-1 border border-black ml-1">
+                        [COMMAND_INPUT]
+                      </span>
+                    </div>
+                    <span className="font-mono text-[10px] text-neutral-800 font-bold">
+                      [{timeStr}]
+                    </span>
                   </div>
-                )}
 
-                <div
-                  className={`
-                    max-w-[85%] sm:max-w-[78%] p-3 border-2 border-black
-                    ${isUser
-                      ? 'bg-amber-300 shadow-[3px_3px_0px_#000] text-black font-bold'
-                      : 'bg-white shadow-[3px_3px_0px_#000] text-black'
-                    }
-                  `}
-                >
-                  <div className="flex items-center justify-between pb-1.5 mb-1.5 border-b border-black/20 text-[10px] uppercase font-bold text-neutral-600 select-none">
-                    <span>{isUser ? 'HUMAN // 管理员' : 'AGENT // 运维助理'}</span>
-                    <span>
-                      {new Date(msg.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
+                  {/* 用户输入的指令内容 */}
+                  <div className="text-xs text-black font-mono font-black pl-0.5 leading-relaxed break-words whitespace-pre-wrap select-text">
+                    {msg.content}
+                  </div>
+                </div>
+              );
+            }
+
+            // Agent 消息:命令输出终端格式 - 白色背景 + 2px 粗黑边框 + 硬阴影
+            return (
+              <div 
+                key={msg.id} 
+                className="border-2 border-black bg-white p-3.5 shadow-[4px_4px_0px_#000] space-y-2.5 text-black"
+              >
+                
+                {/* Agent 输出头信息 */}
+                <div className="flex items-center justify-between text-[11px] pb-2 border-b-2 border-black/10 select-none">
+                  <div className="flex items-center gap-2">
+                    <div className="w-2.5 h-2.5 bg-amber-400 border border-black shadow-[1px_1px_0px_#000]" />
+                    <span className="font-black text-black text-xs uppercase">
+                      OPS-AGENT // EXECUTION_REPORT
+                    </span>
+                    <span className="text-[10px] font-black text-neutral-700 bg-neutral-100 border border-black px-1">
+                      PID: {msg.id.slice(-4) || '4021'}
                     </span>
                   </div>
+                  <span className="font-mono text-[10px] text-neutral-500 font-bold">
+                    [{timeStr}]
+                  </span>
+                </div>
 
-                  {/* 工具调用轨迹步骤 */}
-                  {msg.steps && msg.steps.length > 0 && (
-                    <div className="mb-2">
-                      <div className="text-[10px] font-black text-neutral-500 uppercase tracking-widest mb-1 select-none flex items-center gap-1">
-                        <Terminal size={11} />
-                        <span>工具调用轨迹 ({msg.steps.length} STEPS):</span>
-                      </div>
-                      {msg.steps.map((step, sIdx) => (
-                        <AgentToolStepCard key={sIdx} step={step} />
-                      ))}
+                {/* 工具调用步骤轨迹 */}
+                {msg.steps && msg.steps.length > 0 && (
+                  <div className="space-y-1">
+                    <div className="text-[10px] font-black text-neutral-600 uppercase tracking-wider flex items-center gap-1 select-none">
+                      <Terminal size={11} className="text-black" />
+                      <span>DISPATCHED TOOLS ({msg.steps.length} CALLS):</span>
                     </div>
-                  )}
-
-                  {/* 高危操作确认卡片 */}
-                  {msg.dangerousAction && onConfirmAction && (
-                    <AgentActionConfirmCard
-                      action={msg.dangerousAction}
-                      onConfirm={onConfirmAction}
-                    />
-                  )}
+                    {msg.steps.map((step, sIdx) => (
+                      <AgentToolStepCard key={sIdx} step={step} />
+                    ))}
+                  </div>
+                )}
 
-                  {/* 正文或流式文字 */}
-                  <FormattedMessageContent content={msg.content} />
+                {/* 高危操作二次确认卡片 */}
+                {msg.dangerousAction && onConfirmAction && (
+                  <AgentActionConfirmCard
+                    action={msg.dangerousAction}
+                    onConfirm={onConfirmAction}
+                  />
+                )}
 
-                  {/* 异常错误提示 */}
-                  {msg.error && (
-                    <div className="mt-2 p-2 bg-rose-100 border border-rose-500 text-rose-800 text-xs font-bold">
-                      [异常报错]: {msg.error}
-                    </div>
-                  )}
+                {/* 规范的 Markdown 输出渲染 (无原生Markdown符号外泄) */}
+                <div className="pt-0.5">
+                  <CliMarkdownRenderer content={msg.content} />
                 </div>
 
-                {isUser && (
-                  <div className="w-8 h-8 bg-neutral-900 border-2 border-black flex items-center justify-center shrink-0 shadow-[2px_2px_0px_#000] mt-0.5">
-                    <User size={16} className="text-white" />
+                {/* 异常报错条 */}
+                {msg.error && (
+                  <div className="p-2.5 bg-rose-100 border-2 border-rose-600 text-rose-900 text-xs font-mono font-bold">
+                    <span className="mr-1.5">[ERROR: EXECUTION_FAILURE]</span>
+                    <span>{msg.error}</span>
                   </div>
                 )}
               </div>
@@ -308,12 +298,20 @@ export default function AgentChatBox({
           })
         )}
 
-        {/* 思考中动效状态 */}
+        {/* 规划与执行中的终端动画指示器 */}
         {isLoading && currentThinking && (
-          <div className="flex items-center gap-2 p-2 bg-amber-50 border-2 border-dashed border-black text-xs font-mono select-none">
-            <Loader2 size={14} className="animate-spin text-amber-700" />
-            <span className="font-black text-black">
-              [ AI 思考规划中: 步骤 {currentThinking.step || 1} - 意图识别与工具决策... ]
+          <div className="flex items-center gap-2.5 p-3 bg-amber-100 border-2 border-dashed border-black text-xs font-mono select-none shadow-[2px_2px_0px_#000]">
+            <Loader2 size={14} className="animate-spin text-black shrink-0" />
+            <div className="flex-1 overflow-hidden">
+              <span className="font-black text-black">
+                [AGENT_PLANNER // STEP {currentThinking.step || 1}]:
+              </span>{' '}
+              <span className="text-neutral-800 font-medium">
+                {currentThinking.status || 'Analysing intent & reasoning tool invocation...'}
+              </span>
+            </div>
+            <span className="text-[10px] font-black text-amber-900 bg-amber-200 border border-black px-1.5 py-0.5 shrink-0">
+              EXECUTING...
             </span>
           </div>
         )}
@@ -321,64 +319,82 @@ export default function AgentChatBox({
         <div ref={messagesEndRef} />
       </div>
 
-      {/* 底部快捷 Prompt 气泡(在有消息时继续保留便利入口) */}
+      {/* 终端底部快捷指令条(有消息时快速注入命令) */}
       {quickPrompts.length > 0 && messages.length > 0 && (
         <div className="px-3 py-1.5 bg-neutral-200 border-t-2 border-black flex items-center gap-1.5 overflow-x-auto scrollbar-none select-none">
-          <span className="text-[10px] font-black uppercase text-neutral-600 shrink-0">快捷需求:</span>
+          <span className="text-[10px] font-black uppercase text-neutral-700 shrink-0 mr-1">
+            CLI-SHORTCUTS:
+          </span>
           {quickPrompts.map((item, idx) => (
             <button
               key={idx}
               type="button"
               disabled={isLoading}
               onClick={() => onSendMessage(item.prompt)}
-              className="px-2 py-0.5 bg-white hover:bg-amber-300 disabled:opacity-50 border border-black text-[11px] font-bold shrink-0 transition"
+              className="px-2 py-0.5 bg-white hover:bg-amber-300 disabled:opacity-40 text-black border border-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 text-[11px] font-mono font-bold shrink-0 transition"
             >
-              {item.label}
+              <span className="text-neutral-700 mr-1 font-black">$</span>
+              <span>{item.label}</span>
             </button>
           ))}
         </div>
       )}
 
-      {/* 输入与操作底栏 */}
+      {/* 命令行输入交互底栏 */}
       <div className="p-3 bg-white border-t-2 border-black select-none">
-        <div className="flex gap-2">
-          <div className="flex-1 relative">
-            <textarea
-              ref={textareaRef}
-              rows={1}
-              value={inputText}
-              onChange={handleTextareaChange}
-              onKeyDown={handleKeyDown}
-              disabled={isLoading}
-              placeholder="用自然语言描述需求,例如:'查一下待支付订单' 或 '帮我把订单 ORD-xxx 取消掉'..."
-              className="w-full bg-neutral-50 border-2 border-black p-2 text-xs font-mono text-black resize-none focus:outline-none focus:bg-white focus:shadow-[2px_2px_0px_#000] disabled:bg-neutral-200 placeholder:text-neutral-400 select-text"
-            />
-            <span className="absolute right-2 bottom-2 text-[10px] text-neutral-400 hidden sm:inline select-none">
-              Enter 发送 / Shift+Enter 换行
-            </span>
+        <div className="flex items-end gap-2 bg-neutral-50 border-2 border-black shadow-[3px_3px_0px_#000] focus-within:bg-white focus-within:shadow-[4px_4px_0px_#000] transition p-2">
+          
+          {/* 终端 Prompt 前缀 */}
+          <div className="flex items-center gap-1 text-xs font-mono font-black select-none pb-1 pl-1 shrink-0 text-black">
+            <span>admin@ops</span>
+            <span className="text-neutral-500">:</span>
+            <span className="text-neutral-700">~</span>
+            <span>$</span>
           </div>
 
-          {isLoading ? (
-            <button
-              type="button"
-              onClick={onAbort}
-              className="px-4 bg-rose-500 hover:bg-rose-600 text-white border-2 border-black font-black text-xs flex items-center gap-1.5 shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase shrink-0"
-              title="终止当前 Agent 执行"
-            >
-              <Square size={13} />
-              <span>[ 终止 ]</span>
-            </button>
-          ) : (
-            <button
-              type="button"
-              onClick={handleSend}
-              disabled={!inputText.trim()}
-              className="px-4 bg-amber-300 hover:bg-amber-400 disabled:opacity-40 disabled:hover:bg-amber-300 text-black border-2 border-black font-black text-xs flex items-center gap-1.5 shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase shrink-0"
-            >
-              <Send size={13} />
-              <span>[ 发送 ]</span>
-            </button>
-          )}
+          {/* 命令行输入框 */}
+          <textarea
+            ref={textareaRef}
+            rows={1}
+            value={inputText}
+            onChange={handleTextareaChange}
+            onKeyDown={handleKeyDown}
+            disabled={isLoading}
+            placeholder="输入自然语言或运维指令,按 Enter 键执行调度..."
+            className="flex-1 bg-transparent text-xs font-mono text-black placeholder:text-neutral-400 resize-none focus:outline-none p-1 leading-relaxed select-text font-medium"
+          />
+
+          {/* 按钮区域:运行或中断 */}
+          <div className="flex items-center gap-1.5 pb-0.5 shrink-0">
+            {isLoading ? (
+              <button
+                type="button"
+                onClick={onAbort}
+                className="flex items-center gap-1 px-3 py-1.5 bg-rose-500 hover:bg-rose-600 text-white border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+                title="终止正在执行的任务 (SIGINT ^C)"
+              >
+                <Square size={11} className="fill-current" />
+                <span>SIGINT ^C</span>
+              </button>
+            ) : (
+              <button
+                type="button"
+                onClick={handleSend}
+                disabled={!inputText.trim()}
+                className="flex items-center gap-1 px-3 py-1.5 bg-amber-300 hover:bg-amber-400 disabled:opacity-40 disabled:hover:bg-amber-300 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+                title="执行指令 (Enter)"
+              >
+                <span>EXEC</span>
+                <CornerDownLeft size={11} className="stroke-[2.5]" />
+              </button>
+            )}
+          </div>
+        </div>
+
+        {/* 快捷键提示条 */}
+        <div className="flex items-center justify-between text-[10px] text-neutral-500 font-mono mt-1.5 px-1 font-bold">
+          <span>Enter: 执行指令 | Shift+Enter: 换行</span>
+          <span>OpenAI-compatible Agent Protocol // DeepSeek</span>
         </div>
       </div>
     </div>

+ 61 - 45
src/components/admin/agent/AgentToolStepCard.tsx

@@ -35,24 +35,24 @@ export default function AgentToolStepCard({ step }: AgentToolStepCardProps) {
   const isCompleted = step.status === 'completed' && !step.is_error;
 
   return (
-    <div className="my-2 border-2 border-black bg-neutral-50 shadow-[2px_2px_0px_#000] text-xs font-mono select-text transition-all">
-      {/* 头部标题与状态栏 */}
+    <div className="my-1.5 border-2 border-black bg-neutral-50 shadow-[2px_2px_0px_#000] text-xs font-mono select-text transition-all overflow-hidden">
+      {/* 终端工具调用条 (符合全站黑黄边框硬核风格) */}
       <div 
         onClick={() => setIsOpen(!isOpen)}
         className={`
-          flex items-center justify-between px-3 py-2 cursor-pointer select-none transition
-          ${isOpen ? 'border-b-2 border-black bg-neutral-100' : 'hover:bg-neutral-100'}
+          flex items-center justify-between px-2.5 py-1.5 cursor-pointer select-none transition
+          ${isOpen ? 'bg-neutral-200 border-b-2 border-black' : 'hover:bg-neutral-100'}
         `}
       >
         <div className="flex items-center gap-2 overflow-hidden">
-          <div className="p-1 bg-amber-300 border border-black shrink-0">
-            <Terminal size={12} className="text-black" />
-          </div>
-          <span className="font-bold text-black uppercase tracking-tight truncate">
-            TOOL: {step.tool}
+          <span className="px-1 bg-amber-300 border border-black font-black text-black select-none text-[10px]">
+            $ EXEC
+          </span>
+          <span className="font-black text-black truncate text-[11.5px]">
+            {step.tool}
           </span>
           {step.call_id && (
-            <span className="hidden sm:inline-block text-[10px] text-neutral-500 truncate">
+            <span className="hidden sm:inline-block text-[10px] text-neutral-500 font-mono truncate">
               ({step.call_id})
             </span>
           )}
@@ -60,67 +60,83 @@ export default function AgentToolStepCard({ step }: AgentToolStepCardProps) {
 
         <div className="flex items-center gap-2 shrink-0">
           {isRunning && (
-            <span className="flex items-center gap-1 text-[11px] font-bold text-amber-700 bg-amber-200 border border-black px-1.5 py-0.5">
-              <Loader2 size={10} className="animate-spin" />
-              <span>[ 调度中... ]</span>
+            <span className="flex items-center gap-1 text-[10px] font-black text-black bg-amber-200 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
+              <Loader2 size={10} className="animate-spin text-black" />
+              <span>RUNNING</span>
             </span>
           )}
           {isCompleted && (
-            <span className="flex items-center gap-1 text-[11px] font-bold text-emerald-800 bg-emerald-200 border border-black px-1.5 py-0.5">
-              <CheckCircle2 size={10} />
-              <span>[ 执行完毕 ]</span>
+            <span className="flex items-center gap-1 text-[10px] font-black text-emerald-950 bg-emerald-200 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
+              <CheckCircle2 size={10} className="text-emerald-800" />
+              <span>EXIT 0</span>
             </span>
           )}
           {isFailed && (
-            <span className="flex items-center gap-1 text-[11px] font-bold text-rose-800 bg-rose-200 border border-black px-1.5 py-0.5">
-              <AlertTriangle size={10} />
-              <span>[ 执行异常 ]</span>
+            <span className="flex items-center gap-1 text-[10px] font-black text-rose-950 bg-rose-200 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
+              <AlertTriangle size={10} className="text-rose-800" />
+              <span>FAILED</span>
             </span>
           )}
 
-          <button 
-            type="button"
-            className="p-0.5 text-black hover:bg-neutral-200 transition"
-          >
-            {isOpen ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
-          </button>
+          <div className="text-black transition">
+            {isOpen ? <ChevronDown size={13} /> : <ChevronRight size={13} />}
+          </div>
         </div>
       </div>
 
       {/* 展开的入参与响应报文 JSON 详情 */}
       {isOpen && (
-        <div className="p-3 bg-white space-y-2 border-t-0">
-          <div className="flex items-center justify-between">
-            <span className="text-[10px] text-neutral-500 font-bold uppercase tracking-wider">
-              PAYLOAD & EXECUTION TRACE:
+        <div className="p-2.5 bg-white space-y-2 border-t-0 font-mono text-black">
+          <div className="flex items-center justify-between text-[10px] text-neutral-600">
+            <span className="font-black uppercase tracking-wider">
+              TRACE_PAYLOAD & EXECUTION:
             </span>
             <button
               onClick={handleCopy}
-              className="flex items-center gap-1 px-1.5 py-0.5 bg-neutral-100 hover:bg-amber-300 border border-black text-[10px] font-bold transition shadow-[1px_1px_0px_#000]"
+              className="flex items-center gap-1 px-1.5 py-0.5 bg-neutral-100 hover:bg-amber-300 text-black border border-black text-[10px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
               title="复制参数与结果 JSON"
             >
-              {copied ? <Check size={10} className="text-emerald-700" /> : <Copy size={10} />}
-              <span>{copied ? '已复制' : '复制数据'}</span>
+              {copied ? (
+                <>
+                  <Check size={10} className="text-emerald-700 stroke-[3]" />
+                  <span>已复制</span>
+                </>
+              ) : (
+                <>
+                  <Copy size={10} />
+                  <span>复制 JSON</span>
+                </>
+              )}
             </button>
           </div>
 
-          <div className="space-y-1.5">
-            <div>
-              <div className="text-[10px] font-bold text-neutral-600 mb-0.5">▶ 入参 Arguments:</div>
-              <pre className="bg-neutral-900 text-neutral-100 p-2 text-[11px] overflow-x-auto rounded-none border border-black scrollbar-thin">
-                {JSON.stringify(step.arguments, null, 2)}
+          {/* 入参 */}
+          {step.arguments && (
+            <div className="bg-neutral-50 p-2 border border-neutral-300">
+              <div className="text-[10px] text-neutral-700 font-black mb-1">
+                // ARGUMENTS 入参
+              </div>
+              <pre className="text-[11px] text-neutral-900 overflow-x-auto whitespace-pre-wrap break-all max-h-36 scrollbar-thin font-mono font-medium">
+                {typeof step.arguments === 'string'
+                  ? step.arguments
+                  : JSON.stringify(step.arguments, null, 2)}
               </pre>
             </div>
+          )}
 
-            {step.result !== undefined && (
-              <div>
-                <div className="text-[10px] font-bold text-neutral-600 mb-0.5">◀ 结果 Result:</div>
-                <pre className="bg-neutral-900 text-emerald-300 p-2 text-[11px] overflow-x-auto rounded-none border border-black scrollbar-thin max-h-48">
-                  {JSON.stringify(step.result, null, 2)}
-                </pre>
+          {/* 出参 */}
+          {step.result && (
+            <div className="bg-neutral-50 p-2 border border-neutral-300">
+              <div className="text-[10px] text-neutral-700 font-black mb-1">
+                // EXECUTION_RESULT 响应
               </div>
-            )}
-          </div>
+              <pre className="text-[11px] text-neutral-800 overflow-x-auto whitespace-pre-wrap break-all max-h-48 scrollbar-thin font-mono font-medium">
+                {typeof step.result === 'string'
+                  ? step.result
+                  : JSON.stringify(step.result, null, 2)}
+              </pre>
+            </div>
+          )}
         </div>
       )}
     </div>

+ 256 - 0
src/components/admin/agent/CliMarkdownRenderer.tsx

@@ -0,0 +1,256 @@
+// src/components/admin/agent/CliMarkdownRenderer.tsx
+'use client';
+
+import React, { useState } from 'react';
+import ReactMarkdown from 'react-markdown';
+import remarkGfm from 'remark-gfm';
+import { Copy, Check, Terminal, ExternalLink } from 'lucide-react';
+import Link from 'next/link';
+
+// 识别订单编号 (ORD-xxxx) 并转化为后台快捷查询链接 (匹配 Neo-brutalism 主题风格)
+function renderFormattedText(text: string) {
+  if (typeof text !== 'string') return text;
+  const orderRegex = /(ORD-[A-Za-z0-9-]+)/g;
+  if (!orderRegex.test(text)) return text;
+
+  const parts = text.split(orderRegex);
+  return parts.map((part, i) => {
+    if (orderRegex.test(part)) {
+      return (
+        <Link
+          key={i}
+          href={`/admin/orders?keyword=${encodeURIComponent(part)}`}
+          target="_blank"
+          className="inline-flex items-center gap-1 px-1.5 py-0.5 mx-1 bg-amber-300 hover:bg-amber-400 text-black font-black border border-black text-[11px] font-mono shadow-[1px_1px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
+          title={`在管理后台检索订单: ${part}`}
+        >
+          <span>{part}</span>
+          <ExternalLink size={10} className="stroke-[2.5]" />
+        </Link>
+      );
+    }
+    return part;
+  });
+}
+
+// 递归遍历子节点中的字符串进行订单号增强
+function transformChildren(children: React.ReactNode): React.ReactNode {
+  return React.Children.map(children, (child) => {
+    if (typeof child === 'string') {
+      return renderFormattedText(child);
+    }
+    return child;
+  });
+}
+
+// 命令行风格代码块组件 (匹配主题 Neo-brutalism:黑边框 + 亮黄顶栏 + 硬阴影)
+function CliCodeBlock({ language, code }: { language: string; code: string }) {
+  const [copied, setCopied] = useState(false);
+
+  const handleCopy = () => {
+    navigator.clipboard.writeText(code);
+    setCopied(true);
+    setTimeout(() => setCopied(false), 2000);
+  };
+
+  return (
+    <div className="my-2.5 border-2 border-black bg-neutral-900 shadow-[2px_2px_0px_#000] overflow-hidden font-mono">
+      {/* 终端代码顶栏:黑黄高对比 */}
+      <div className="flex items-center justify-between px-3 py-1.5 bg-amber-300 border-b-2 border-black text-black text-xs select-none">
+        <div className="flex items-center gap-1.5 font-black">
+          <Terminal size={12} className="stroke-[2.5]" />
+          <span className="uppercase tracking-wider text-[11px]">
+            {language || 'TERMINAL OUTPUT'}
+          </span>
+        </div>
+        <button
+          type="button"
+          onClick={handleCopy}
+          className="flex items-center gap-1 px-2 py-0.5 bg-white hover:bg-neutral-100 text-black border border-black text-[10px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+          title="复制代码"
+        >
+          {copied ? (
+            <>
+              <Check size={11} className="text-emerald-700 stroke-[3]" />
+              <span className="text-emerald-800">已复制</span>
+            </>
+          ) : (
+            <>
+              <Copy size={11} />
+              <span>复制</span>
+            </>
+          )}
+        </button>
+      </div>
+
+      {/* 代码内容 */}
+      <div className="p-3 overflow-x-auto text-[11.5px] leading-relaxed text-neutral-100 font-mono scrollbar-thin">
+        <pre className="m-0 whitespace-pre font-mono">{code}</pre>
+      </div>
+    </div>
+  );
+}
+
+interface CliMarkdownRendererProps {
+  content: string;
+  className?: string;
+}
+
+export default function CliMarkdownRenderer({ content, className = '' }: CliMarkdownRendererProps) {
+  if (!content) return null;
+
+  return (
+    <div className={`cli-markdown font-mono text-xs leading-relaxed text-neutral-900 select-text ${className}`}>
+      <ReactMarkdown
+        remarkPlugins={[remarkGfm]}
+        components={{
+          // 标题渲染:黑体 + 黄色提示标 + 下划线
+          h1: ({ children }) => (
+            <h1 className="text-sm font-black text-black border-b-2 border-black pb-1.5 mt-3 mb-2 flex items-center gap-1.5 uppercase">
+              <span className="px-1 bg-amber-300 border border-black text-[10px] select-none">#</span>
+              <span>{transformChildren(children)}</span>
+            </h1>
+          ),
+          h2: ({ children }) => (
+            <h2 className="text-xs font-black text-black border-b border-black pb-1 mt-2.5 mb-1.5 flex items-center gap-1.5 uppercase">
+              <span className="px-1 bg-amber-200 border border-black text-[9px] select-none">##</span>
+              <span>{transformChildren(children)}</span>
+            </h2>
+          ),
+          h3: ({ children }) => (
+            <h3 className="text-xs font-black text-neutral-900 mt-2 mb-1 flex items-center gap-1">
+              <span className="text-amber-500 font-black select-none">▶</span>
+              <span>{transformChildren(children)}</span>
+            </h3>
+          ),
+          h4: ({ children }) => (
+            <h4 className="text-xs font-bold text-neutral-800 mt-1.5 mb-1 flex items-center gap-1">
+              <span className="text-neutral-500 select-none">●</span>
+              <span>{transformChildren(children)}</span>
+            </h4>
+          ),
+
+          // 段落渲染
+          p: ({ children }) => (
+            <p className="my-1.5 text-xs text-neutral-900 leading-relaxed break-words font-medium">
+              {transformChildren(children)}
+            </p>
+          ),
+
+          // 强调:加粗带有柔和的主题淡黄色背景突出显示
+          strong: ({ children }) => (
+            <strong className="font-black text-black bg-amber-200/90 px-1 border border-black/20 mx-0.5">
+              {children}
+            </strong>
+          ),
+          em: ({ children }) => (
+            <em className="text-neutral-800 not-italic font-bold underline decoration-amber-400 decoration-2">
+              {children}
+            </em>
+          ),
+
+          // 列表
+          ul: ({ children }) => (
+            <ul className="my-1.5 pl-1.5 space-y-1 list-none">{children}</ul>
+          ),
+          ol: ({ children }) => (
+            <ol className="my-1.5 pl-4 space-y-1 list-decimal text-neutral-900 text-xs font-bold">{children}</ol>
+          ),
+          li: ({ children }) => (
+            <li className="text-xs text-neutral-900 flex items-start gap-1.5 leading-relaxed">
+              <span className="text-amber-500 select-none shrink-0 font-black mt-0.5">❯</span>
+              <span className="flex-1 break-words font-medium">{transformChildren(children)}</span>
+            </li>
+          ),
+
+          // 表格 (GFM Table) 主题化:经典黑白黄 Neo-brutalism 风格表格
+          table: ({ children }) => (
+            <div className="my-2.5 overflow-x-auto border-2 border-black bg-white shadow-[2px_2px_0px_#000] scrollbar-thin">
+              <table className="w-full text-left text-xs border-collapse font-mono min-w-full">
+                {children}
+              </table>
+            </div>
+          ),
+          thead: ({ children }) => (
+            <thead className="bg-amber-300 text-black uppercase text-[11px] border-b-2 border-black select-none font-black">
+              {children}
+            </thead>
+          ),
+          tbody: ({ children }) => (
+            <tbody className="divide-y divide-neutral-200 text-neutral-900">
+              {children}
+            </tbody>
+          ),
+          tr: ({ children }) => (
+            <tr className="hover:bg-amber-50 transition-colors">
+              {children}
+            </tr>
+          ),
+          th: ({ children }) => (
+            <th className="px-3 py-1.5 font-black text-black whitespace-nowrap border-r border-black last:border-r-0">
+              {children}
+            </th>
+          ),
+          td: ({ children }) => (
+            <td className="px-3 py-1.5 text-neutral-900 border-r border-neutral-200 last:border-r-0 whitespace-nowrap font-medium">
+              {transformChildren(children)}
+            </td>
+          ),
+
+          // 引用块
+          blockquote: ({ children }) => (
+            <blockquote className="my-2 border-l-4 border-amber-400 bg-amber-50 p-2.5 border border-black/30 text-xs text-neutral-800 font-mono shadow-[1px_1px_0px_#000]">
+              {transformChildren(children)}
+            </blockquote>
+          ),
+
+          // 分割线
+          hr: () => (
+            <hr className="border-t-2 border-black my-2" />
+          ),
+
+          // 链接
+          a: ({ href, children }) => (
+            <a
+              href={href}
+              target="_blank"
+              rel="noopener noreferrer"
+              className="text-black hover:text-amber-800 font-bold underline decoration-amber-400 decoration-2 underline-offset-2 inline-flex items-center gap-0.5"
+            >
+              <span>{children}</span>
+              <ExternalLink size={10} className="inline opacity-80" />
+            </a>
+          ),
+
+          // 代码与代码块
+          code({ node, className, children, ...props }: any) {
+            const match = /language-(\w+)/.exec(className || '');
+            const codeText = String(children).replace(/\n$/, '');
+            const isMultiLine = codeText.includes('\n');
+
+            if (match || isMultiLine) {
+              return (
+                <CliCodeBlock
+                  language={match ? match[1] : 'text'}
+                  code={codeText}
+                />
+              );
+            }
+
+            // 单行内联代码:主题浅黄底黑字小边框药丸
+            return (
+              <code
+                className="bg-neutral-100 text-black border border-black px-1.5 py-0.5 text-[11px] font-mono font-bold mx-0.5 inline-block select-text shadow-[1px_1px_0px_#000]"
+                {...props}
+              >
+                {children}
+              </code>
+            );
+          },
+        }}
+      >
+        {content}
+      </ReactMarkdown>
+    </div>
+  );
+}

+ 0 - 165
src/components/admin/dashboard/OverviewCharts.tsx

@@ -1,165 +0,0 @@
-'use client';
-
-import { 
-  LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, 
-  PieChart, Pie, Cell 
-} from 'recharts';
-import { Layers, Zap, TrendingUp, PieChart as PieIcon } from 'lucide-react';
-
-interface OverviewChartsProps {
-  revenueData: { date: string; amount: number; orders: number }[];
-  productData: { name: string; value: number }[];
-  taskData: { routing_key: string; count: number }[];
-}
-
-const COLORS = ['#f59e0b', '#000000', '#737373', '#d4d4d4', '#fbbf24', '#a3a3a3'];
-
-export default function OverviewCharts({ revenueData, productData, taskData }: OverviewChartsProps) {
-  const totalTasks = taskData.reduce((acc, cur) => acc + cur.count, 0);
-
-  const formatRoutingKey = (key: string) => {
-    const parts = key.split('.');
-    if (parts.length > 3) {
-      return '...' + parts.slice(-3).join('.');
-    }
-    return key;
-  };
-
-  const RevenueTooltip = ({ active, payload, label }: any) => {
-    if (active && payload && payload.length) {
-      return (
-        <div className="bg-white p-3 border-2 border-black shadow-[3px_3px_0px_#000] text-xs font-mono">
-          <p className="font-bold text-black border-b border-black pb-1 mb-1">[ {label} ]</p>
-          <p className="text-black font-black">营收: ¥{payload[0].value.toLocaleString()}</p>
-          {payload[1] && <p className="text-neutral-600">订单: {payload[1].value} 单</p>}
-        </div>
-      );
-    }
-    return null;
-  };
-
-  return (
-    <div className="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6 font-mono">
-      
-      {/* 营收趋势 (2/3) */}
-      <div className="lg:col-span-2 bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] flex flex-col justify-between">
-        <div className="flex items-center justify-between border-b-2 border-black pb-2.5 mb-4">
-          <h3 className="text-xs font-black text-black uppercase flex items-center gap-1.5">
-            <TrendingUp size={15} />
-            <span>[ 01 // 7-DAY REVENUE TREND // 近 7 天营收结算趋势 ]</span>
-          </h3>
-          <span className="text-[10px] text-neutral-500 font-bold">MONETARY-TELEMETRY</span>
-        </div>
-
-        <div className="h-[280px] w-full pt-2">
-          <ResponsiveContainer width="100%" height="100%">
-            <LineChart data={revenueData} margin={{ top: 5, right: 20, bottom: 5, left: 0 }}>
-              <CartesianGrid strokeDasharray="2 2" vertical={false} stroke="#d4d4d4" />
-              <XAxis 
-                dataKey="date" 
-                axisLine={{ stroke: '#000', strokeWidth: 1.5 }} 
-                tickLine={false} 
-                tick={{ fontSize: 10, fill: '#000', fontFamily: 'monospace' }} 
-                dy={8}
-              />
-              <YAxis 
-                axisLine={{ stroke: '#000', strokeWidth: 1.5 }} 
-                tickLine={false} 
-                tick={{ fontSize: 10, fill: '#000', fontFamily: 'monospace' }} 
-                tickFormatter={(value) => `¥${value}`}
-              />
-              <Tooltip content={<RevenueTooltip />} />
-              <Line 
-                type="monotone" 
-                dataKey="amount" 
-                stroke="#000" 
-                strokeWidth={2.5} 
-                dot={{ r: 4, fill: '#f59e0b', strokeWidth: 2, stroke: '#000' }} 
-                activeDot={{ r: 6, fill: '#f59e0b', stroke: '#000', strokeWidth: 2 }} 
-              />
-            </LineChart>
-          </ResponsiveContainer>
-        </div>
-      </div>
-
-      {/* 销量占比 (1/3) */}
-      <div className="lg:col-span-1 bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] flex flex-col justify-between">
-        <div className="flex items-center justify-between border-b-2 border-black pb-2.5 mb-2">
-          <h3 className="text-xs font-black text-black uppercase flex items-center gap-1.5">
-            <PieIcon size={15} />
-            <span>[ 02 // VAS PRODUCT MIX ]</span>
-          </h3>
-        </div>
-
-        <div className="flex-1 min-h-[240px] relative">
-          <ResponsiveContainer width="100%" height="100%">
-            <PieChart>
-              <Pie
-                data={productData}
-                cx="50%"
-                cy="50%"
-                innerRadius={50}
-                outerRadius={80}
-                paddingAngle={3}
-                dataKey="value"
-              >
-                {productData.map((entry, index) => (
-                  <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} stroke="#000" strokeWidth={1.5} />
-                ))}
-              </Pie>
-              <Tooltip />
-            </PieChart>
-          </ResponsiveContainer>
-          <div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center pointer-events-none font-mono">
-            <p className="text-[10px] font-black uppercase text-black">TOP SALES</p>
-          </div>
-        </div>
-      </div>
-
-      {/* 底部:活跃任务分布网格 */}
-      <div className="lg:col-span-3 bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000]">
-        <div className="flex items-center justify-between border-b-2 border-black pb-2.5 mb-4">
-          <div className="flex items-center gap-2">
-            <Layers size={16} className="text-black" />
-            <h3 className="text-xs font-black text-black uppercase">
-              [ 03 // ACTIVE TELEMETRY QUEUE // 活跃任务队列分布 ]
-            </h3>
-          </div>
-          <span className="text-[11px] font-bold text-black bg-amber-300 border border-black px-2 py-0.5 shadow-[1px_1px_0px_#000]">
-            TOTAL: {totalTasks} JOBS RUNNING
-          </span>
-        </div>
-
-        {taskData.length === 0 ? (
-          <div className="text-center py-6 text-neutral-400 text-xs border-2 border-dashed border-neutral-300">
-            [ 暂无正在运行中的并发轮询任务 ]
-          </div>
-        ) : (
-          <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
-            {taskData.map((item, index) => {
-              return (
-                <div 
-                  key={index} 
-                  className="border-2 border-black bg-neutral-50 p-3 shadow-[2px_2px_0px_#000] hover:bg-amber-100 transition space-y-1.5"
-                  title={item.routing_key}
-                >
-                  <div className="flex justify-between items-start">
-                    <span className="text-[10px] bg-black text-white px-1 font-bold">JOB</span>
-                    <span className="text-xl font-black text-black font-mono">
-                      {item.count}
-                    </span>
-                  </div>
-
-                  <div className="text-[11px] text-neutral-800 font-bold truncate">
-                    {formatRoutingKey(item.routing_key)}
-                  </div>
-                </div>
-              );
-            })}
-          </div>
-        )}
-      </div>
-
-    </div>
-  );
-}

+ 0 - 55
src/components/admin/dashboard/RecentActivities.tsx

@@ -1,55 +0,0 @@
-'use client';
-
-export interface ActivityItem {
-  id: string;
-  text: string;
-  time: string;
-  type: 'order' | 'money' | 'ticket' | 'system';
-}
-
-interface RecentActivitiesProps {
-  activities: ActivityItem[];
-  loading: boolean;
-}
-
-export default function RecentActivities({ activities, loading }: RecentActivitiesProps) {
-  return (
-    <div className="lg:col-span-2 bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] font-mono">
-      <div className="flex justify-between items-center border-b-2 border-black pb-2.5 mb-4">
-        <h3 className="text-xs font-black text-black uppercase">[ 04 // SYSTEM EVENT LOGS // 最新系统流转动态 ]</h3>
-        <span className="text-[10px] text-neutral-500 font-bold">[ TELEMETRY-STREAM ]</span>
-      </div>
-
-      {loading && activities.length === 0 ? (
-        <div className="py-10 text-center text-neutral-500 text-xs">[ LOADING EVENT LOGS... ]</div>
-      ) : activities.length === 0 ? (
-        <div className="py-10 text-center text-neutral-400 text-xs border border-dashed border-neutral-300">[ 暂无最新动态事件记录 ]</div>
-      ) : (
-        <div className="space-y-2.5">
-          {activities.map((item) => (
-            <div
-              key={item.id}
-              className="flex items-start gap-2.5 p-2 bg-neutral-50 border border-black shadow-[1px_1px_0px_#000] text-xs"
-            >
-              <div
-                className={`mt-1 w-2 h-2 border border-black shrink-0 ${
-                  item.type === 'order'
-                    ? 'bg-amber-300'
-                    : item.type === 'money'
-                    ? 'bg-amber-400'
-                    : item.type === 'ticket'
-                    ? 'bg-rose-400'
-                    : 'bg-black'
-                }`}
-              />
-              <div className="flex-1 min-w-0 font-sans">
-                <p className="text-xs font-medium text-black leading-relaxed">{item.text}</p>
-                <p className="text-[10px] text-neutral-500 font-mono mt-0.5">{item.time}</p>
-              </div>
-            </div>
-          ))}
-        </div>
-      )}
-    </div>
-  );
-}

+ 436 - 79
src/components/admin/node-configurations/AppointmentTypeEditor.tsx

@@ -2,8 +2,8 @@
 
 'use client';
 
-import React from 'react';
-import { Plus, Trash2 } from 'lucide-react';
+import React, { useState } from 'react';
+import { Plus, Trash2, Sparkles, HelpCircle } from 'lucide-react';
 import { AppointmentTypeItem } from '@/types';
 
 interface AppointmentTypeEditorProps {
@@ -12,18 +12,97 @@ interface AppointmentTypeEditorProps {
   disabled?: boolean;
 }
 
+// 辅助函数:将字符串每个单词首字母大写(如 "france" -> "France", "united kingdom" -> "United Kingdom")
+export const formatCapitalized = (val: string): string => {
+  if (!val) return '';
+  return val
+    .trim()
+    .split(/\s+/)
+    .map((word) => (word ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : ''))
+    .join(' ');
+};
+
+// 常用固定签证类型预设(非缩写,首字母大写)
+const PRESET_VISA_TYPES = [
+  { label: '旅游签证 (Tourist)', value: 'Tourist' },
+  { label: '商务签证 (Business)', value: 'Business' },
+  { label: '探亲访友 (Family)', value: 'Family' },
+  { label: '留学签证 (Student)', value: 'Student' },
+  { label: '工作签证 (Work)', value: 'Work' },
+  { label: '短期停留 (ShortStay)', value: 'ShortStay' },
+  { label: '长期签证 (LongStay)', value: 'LongStay' },
+  { label: '过境签证 (Transit)', value: 'Transit' },
+  { label: '全部类型 (All)', value: 'All' },
+];
+
+// 常用固定城市预设(全称非缩写,首字母大写)
+const PRESET_CITIES = [
+  { label: 'London (伦敦)', value: 'London' },
+  { label: 'Manchester (曼彻斯特)', value: 'Manchester' },
+  { label: 'Edinburgh (爱丁堡)', value: 'Edinburgh' },
+  { label: 'Dublin (都柏林)', value: 'Dublin' },
+  { label: 'Belfast (贝尔法斯特)', value: 'Belfast' },
+  { label: 'Paris (巴黎)', value: 'Paris' },
+  { label: 'Marseille (马赛)', value: 'Marseille' },
+  { label: 'Amsterdam (阿姆斯特丹)', value: 'Amsterdam' },
+  { label: 'Berlin (柏林)', value: 'Berlin' },
+  { label: 'Frankfurt (法兰克福)', value: 'Frankfurt' },
+  { label: 'Rome (罗马)', value: 'Rome' },
+  { label: 'Milan (米兰)', value: 'Milan' },
+  { label: 'Madrid (马德里)', value: 'Madrid' },
+  { label: 'Barcelona (巴塞罗那)', value: 'Barcelona' },
+  { label: 'Beijing (北京)', value: 'Beijing' },
+  { label: 'Shanghai (上海)', value: 'Shanghai' },
+  { label: 'Guangzhou (广州)', value: 'Guangzhou' },
+  { label: 'Shenzhen (深圳)', value: 'Shenzhen' },
+  { label: 'Singapore (新加坡)', value: 'Singapore' },
+  { label: 'Sydney (悉尼)', value: 'Sydney' },
+  { label: 'Melbourne (墨尔本)', value: 'Melbourne' },
+  { label: 'Tokyo (东京)', value: 'Tokyo' },
+];
+
+// 常用固定国家预设(全称非缩写,首字母大写)
+const PRESET_COUNTRIES = [
+  { label: 'France (法国)', value: 'France' },
+  { label: 'United Kingdom (英国)', value: 'United Kingdom' },
+  { label: 'Netherlands (荷兰)', value: 'Netherlands' },
+  { label: 'Germany (德国)', value: 'Germany' },
+  { label: 'Italy (意大利)', value: 'Italy' },
+  { label: 'Spain (西班牙)', value: 'Spain' },
+  { label: 'Switzerland (瑞士)', value: 'Switzerland' },
+  { label: 'Ireland (爱尔兰)', value: 'Ireland' },
+  { label: 'United States (美国)', value: 'United States' },
+  { label: 'China (中国)', value: 'China' },
+  { label: 'Singapore (新加坡)', value: 'Singapore' },
+  { label: 'Australia (澳大利亚)', value: 'Australia' },
+  { label: 'Japan (日本)', value: 'Japan' },
+  { label: 'Canada (加拿大)', value: 'Canada' },
+];
+
+// 常用预设权重选项 (数值越大越容易命中)
+const PRESET_WEIGHTS = [
+  { label: '100 - 极高权重 (最高频调度 / 优先命中)', value: 100 },
+  { label: '80 - 高权重 (主力核心规则)', value: 80 },
+  { label: '50 - 中等权重 (常规默认推荐)', value: 50 },
+  { label: '20 - 低权重 (候补规则)', value: 20 },
+  { label: '10 - 基础兜底 (最低频次)', value: 10 },
+];
+
 export default function AppointmentTypeEditor({
   items = [],
   onChange,
   disabled = false,
 }: AppointmentTypeEditorProps) {
+  // 记录每一行是否开启了自定义字段输入模式
+  const [customMode, setCustomMode] = useState<{ [key: string]: boolean }>({});
+
   const handleAdd = () => {
     const newItem: AppointmentTypeItem = {
       routing_key: '',
-      city: '',
-      visa_type: '',
-      country: '',
-      weight: 10,
+      city: 'London',
+      country: 'France',
+      visa_type: 'Tourist',
+      weight: 50,
     };
     onChange([...items, newItem]);
   };
@@ -35,20 +114,47 @@ export default function AppointmentTypeEditor({
 
   const handleFieldChange = (index: number, field: keyof AppointmentTypeItem, value: any) => {
     const updated = [...items];
+    const prev = updated[index];
+    
+    let formattedVal = value;
+    if (field === 'weight') {
+      formattedVal = value === '' ? 50 : Number(value);
+    } else if (field === 'city' || field === 'country' || field === 'visa_type') {
+      // 保证首字母大写
+      if (typeof value === 'string' && value.length > 0) {
+        formattedVal = formatCapitalized(value);
+      }
+    }
+
     updated[index] = {
-      ...updated[index],
-      [field]: field === 'weight' ? (value === '' ? undefined : Number(value)) : value,
+      ...prev,
+      [field]: formattedVal,
     };
+
     onChange(updated);
   };
 
+  // 根据选中的城市、国家、签证类型自动生成 routing_key (如: slot.london.france.tourist)
+  const handleAutoGenerateRoutingKey = (index: number) => {
+    const item = items[index];
+    if (!item) return;
+
+    // 清理生成 routing_key 规范小写键名
+    const cityKey = (item.city || 'city').trim().toLowerCase().replace(/\s+/g, '_');
+    const countryKey = (item.country || 'country').trim().toLowerCase().replace(/\s+/g, '_');
+    const visaKey = (item.visa_type || 'all').trim().toLowerCase().replace(/\s+/g, '_');
+
+    const generated = `slot.${cityKey}.${countryKey}.${visaKey}`;
+    handleFieldChange(index, 'routing_key', generated);
+  };
+
   return (
     <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] font-mono space-y-3">
-      {/* Header */}
-      <div className="flex items-center justify-between border-b-2 border-black pb-2">
+      {/* 头部标题与添加操作 */}
+      <div className="flex flex-wrap items-center justify-between border-b-2 border-black pb-2 gap-2">
         <div className="flex items-center gap-2">
-          <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
-          <span className="text-xs font-black text-black uppercase">
+          <span className="w-2.5 h-2.5 bg-amber-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+          <span className="text-xs font-black text-black uppercase tracking-wide">
             [ APPOINTMENT TYPES // 预约类型规则列表 ({items.length}) ]
           </span>
         </div>
@@ -57,83 +163,334 @@ export default function AppointmentTypeEditor({
           <button
             type="button"
             onClick={handleAdd}
-            className="flex items-center gap-1 px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5"
+            className="flex items-center gap-1 px-3 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
           >
             <Plus className="w-3.5 h-3.5" />
-            <span>[ + 添加规则 ]</span>
+            <span>[ + 添加预约规则 ]</span>
           </button>
         )}
       </div>
 
-      {/* Rules List */}
+      {/* 权重与规则使用指引提示条 */}
+      <div className="bg-amber-50 border-2 border-black p-2.5 text-xs text-neutral-800 space-y-1 shadow-[1px_1px_0px_#000]">
+        <div className="flex items-center gap-1.5 font-black text-black">
+          <HelpCircle size={13} className="text-amber-600" />
+          <span>规则配置指南与规范说明:</span>
+        </div>
+        <div className="text-[11px] text-neutral-600 pl-4 space-y-0.5 leading-relaxed">
+          <p>
+            ● <strong className="text-black font-black">城市与国家规范</strong>:
+            城市与国家采用<strong className="text-black font-black">英文全称(非缩写,首字母大写)</strong>,如 <code>London</code>、<code>France</code>、<code>United Kingdom</code>。
+          </p>
+          <p>
+            ● <strong className="text-black font-black">调度权重 (Weight)</strong>:
+            <span className="bg-amber-200 px-1 border border-black/30 font-black text-black mx-1">数值越大表示越容易优先命中</span>
+            该查询规则。系统内置 5 档预设,主力领区建议设为 80~100,候补设为 10~20。
+          </p>
+          <p>
+            ● <strong className="text-black font-black">Routing Key</strong>:
+            执行队列的路由标识符,支持手工自定义录入,或选中城市/国家/类型后点击
+            <span className="bg-white px-1 border border-black font-bold mx-1">「⚡️ 依选项生成」</span>
+            一键智能生成标准路由键。
+          </p>
+        </div>
+      </div>
+
+      {/* 规则条目列表 */}
       {items.length === 0 ? (
-        <div className="p-4 border-2 border-dashed border-neutral-400 bg-white text-center text-xs font-bold text-neutral-500">
-          暂无预约类型规则,请点击上方按钮添加
+        <div className="p-6 border-2 border-dashed border-neutral-400 bg-white text-center text-xs font-bold text-neutral-500 space-y-2">
+          <p>暂无预约类型规则</p>
+          {!disabled && (
+            <button
+              type="button"
+              onClick={handleAdd}
+              className="px-3 py-1 bg-amber-300 hover:bg-amber-400 border border-black font-black text-xs uppercase shadow-[1px_1px_0px_#000] text-black cursor-pointer inline-block"
+            >
+              点击添加第一条预约规则
+            </button>
+          )}
         </div>
       ) : (
-        <div className="space-y-2 max-h-64 overflow-y-auto pr-1">
-          {items.map((item, idx) => (
-            <div
-              key={idx}
-              className="p-2.5 bg-white border-2 border-black shadow-[2px_2px_0px_#000] grid grid-cols-12 gap-2 items-center"
-            >
-              <div className="col-span-1 text-[11px] font-black text-black text-center bg-neutral-200 border border-black py-1">
-                #{idx + 1}
-              </div>
-              <div className="col-span-4">
-                <input
-                  type="text"
-                  placeholder="routing_key (必填,如 slot.dub.nl)"
-                  value={item.routing_key || ''}
-                  onChange={(e) => handleFieldChange(idx, 'routing_key', e.target.value)}
-                  disabled={disabled}
-                  className="w-full px-2 py-1 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black placeholder:text-neutral-400 outline-none shadow-[1px_1px_0px_#000]"
-                />
-              </div>
-              <div className="col-span-2">
-                <input
-                  type="text"
-                  placeholder="城市 (City)"
-                  value={item.city || ''}
-                  onChange={(e) => handleFieldChange(idx, 'city', e.target.value)}
-                  disabled={disabled}
-                  className="w-full px-2 py-1 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black placeholder:text-neutral-400 outline-none shadow-[1px_1px_0px_#000]"
-                />
-              </div>
-              <div className="col-span-2">
-                <input
-                  type="text"
-                  placeholder="签证类型 (Visa)"
-                  value={item.visa_type || ''}
-                  onChange={(e) => handleFieldChange(idx, 'visa_type', e.target.value)}
-                  disabled={disabled}
-                  className="w-full px-2 py-1 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black placeholder:text-neutral-400 outline-none shadow-[1px_1px_0px_#000]"
-                />
-              </div>
-              <div className="col-span-2">
-                <input
-                  type="number"
-                  placeholder="权重 (Weight)"
-                  value={item.weight ?? ''}
-                  onChange={(e) => handleFieldChange(idx, 'weight', e.target.value)}
-                  disabled={disabled}
-                  className="w-full px-2 py-1 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black placeholder:text-neutral-400 outline-none shadow-[1px_1px_0px_#000]"
-                />
-              </div>
-              <div className="col-span-1 text-center">
-                {!disabled && (
-                  <button
-                    type="button"
-                    onClick={() => handleRemove(idx)}
-                    className="p-1 bg-rose-100 hover:bg-rose-200 border border-black text-rose-950 shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
-                    title="删除此规则"
-                  >
-                    <Trash2 className="w-3.5 h-3.5" />
-                  </button>
-                )}
+        <div className="space-y-3 max-h-96 overflow-y-auto pr-1">
+          {items.map((item, idx) => {
+            const isPresetCity = PRESET_CITIES.some((c) => c.value.toLowerCase() === (item.city || '').toLowerCase());
+            const isPresetCountry = PRESET_COUNTRIES.some((c) => c.value.toLowerCase() === (item.country || '').toLowerCase());
+            const isPresetVisa = PRESET_VISA_TYPES.some((v) => v.value.toLowerCase() === (item.visa_type || '').toLowerCase());
+            const isPresetWeight = PRESET_WEIGHTS.some((w) => w.value === (item.weight ?? 50));
+
+            const isCustomCity = customMode[`city_${idx}`] || (!isPresetCity && !!item.city);
+            const isCustomCountry = customMode[`country_${idx}`] || (!isPresetCountry && !!item.country);
+            const isCustomVisa = customMode[`visa_${idx}`] || (!isPresetVisa && !!item.visa_type);
+            const isCustomWeight = customMode[`weight_${idx}`] || (!isPresetWeight && item.weight !== undefined);
+
+            return (
+              <div
+                key={idx}
+                className="p-3 bg-white border-2 border-black shadow-[3px_3px_0px_#000] space-y-2.5 transition"
+              >
+                {/* 规则头部行:序号、权重快捷选择、删除按键 */}
+                <div className="flex flex-wrap items-center justify-between gap-2 border-b border-neutral-200 pb-2">
+                  <div className="flex items-center gap-2">
+                    <span className="px-2 py-0.5 bg-neutral-900 text-white font-black text-xs border border-black">
+                      RULE #{idx + 1}
+                    </span>
+                    <span className="text-[11px] font-bold text-neutral-600">
+                      预约调度规则
+                    </span>
+                  </div>
+
+                  {/* 权重快捷选择器 */}
+                  <div className="flex items-center gap-1.5">
+                    <span className="text-xs font-black text-black">权重:</span>
+                    {isCustomWeight ? (
+                      <div className="flex items-center gap-1">
+                        <input
+                          type="number"
+                          min={1}
+                          max={1000}
+                          placeholder="权重数字"
+                          value={item.weight ?? ''}
+                          onChange={(e) => handleFieldChange(idx, 'weight', e.target.value)}
+                          disabled={disabled}
+                          className="w-20 px-2 py-0.5 bg-white border-2 border-black text-xs font-mono font-black text-black shadow-[1px_1px_0px_#000] outline-none"
+                        />
+                        <button
+                          type="button"
+                          onClick={() => {
+                            setCustomMode((prev) => ({ ...prev, [`weight_${idx}`]: false }));
+                            handleFieldChange(idx, 'weight', 50);
+                          }}
+                          className="text-[10px] text-neutral-600 hover:text-black underline cursor-pointer"
+                        >
+                          切换预设
+                        </button>
+                      </div>
+                    ) : (
+                      <div className="flex items-center gap-1">
+                        <select
+                          value={item.weight ?? 50}
+                          onChange={(e) => {
+                            if (e.target.value === '__custom__') {
+                              setCustomMode((prev) => ({ ...prev, [`weight_${idx}`]: true }));
+                            } else {
+                              handleFieldChange(idx, 'weight', Number(e.target.value));
+                            }
+                          }}
+                          disabled={disabled}
+                          className="px-2 py-0.5 bg-amber-100 border-2 border-black text-xs font-mono font-black text-black shadow-[1px_1px_0px_#000] outline-none cursor-pointer"
+                        >
+                          {PRESET_WEIGHTS.map((pw) => (
+                            <option key={pw.value} value={pw.value}>
+                              {pw.label}
+                            </option>
+                          ))}
+                          <option value="__custom__">⚙️ 自定义权重数值...</option>
+                        </select>
+                      </div>
+                    )}
+
+                    {!disabled && (
+                      <button
+                        type="button"
+                        onClick={() => handleRemove(idx)}
+                        className="p-1 bg-white hover:bg-rose-200 border border-black text-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition ml-1 cursor-pointer"
+                        title="删除该条预约规则"
+                      >
+                        <Trash2 className="w-3.5 h-3.5" />
+                      </button>
+                    )}
+                  </div>
+                </div>
+
+                {/* 规则参数选择区:城市、国家、签证类型 */}
+                <div className="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
+                  
+                  {/* 1. 城市 (City) - 非缩写,首字母大写 */}
+                  <div className="space-y-1">
+                    <div className="flex items-center justify-between text-[11px] font-black text-neutral-700">
+                      <span>城市 (City):</span>
+                      <button
+                        type="button"
+                        onClick={() => setCustomMode((prev) => ({ ...prev, [`city_${idx}`]: !isCustomCity }))}
+                        className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                      >
+                        {isCustomCity ? '选择预设城市' : '手工输入'}
+                      </button>
+                    </div>
+
+                    {isCustomCity ? (
+                      <input
+                        type="text"
+                        placeholder="如: London / Dublin / Paris"
+                        value={item.city || ''}
+                        onChange={(e) => handleFieldChange(idx, 'city', e.target.value)}
+                        onBlur={(e) => handleFieldChange(idx, 'city', formatCapitalized(e.target.value))}
+                        disabled={disabled}
+                        className="w-full px-2.5 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000]"
+                      />
+                    ) : (
+                      <select
+                        value={
+                          PRESET_CITIES.find((c) => c.value.toLowerCase() === (item.city || '').toLowerCase())?.value ||
+                          item.city ||
+                          'London'
+                        }
+                        onChange={(e) => {
+                          if (e.target.value === '__custom__') {
+                            setCustomMode((prev) => ({ ...prev, [`city_${idx}`]: true }));
+                          } else {
+                            handleFieldChange(idx, 'city', e.target.value);
+                          }
+                        }}
+                        disabled={disabled}
+                        className="w-full px-2 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000] cursor-pointer"
+                      >
+                        {PRESET_CITIES.map((c) => (
+                          <option key={c.value} value={c.value}>
+                            {c.label}
+                          </option>
+                        ))}
+                        <option value="__custom__">⚙️ 其他城市 (手工录入)...</option>
+                      </select>
+                    )}
+                  </div>
+
+                  {/* 2. 国家 (Country) - 非缩写,首字母大写 */}
+                  <div className="space-y-1">
+                    <div className="flex items-center justify-between text-[11px] font-black text-neutral-700">
+                      <span>国家 (Country):</span>
+                      <button
+                        type="button"
+                        onClick={() => setCustomMode((prev) => ({ ...prev, [`country_${idx}`]: !isCustomCountry }))}
+                        className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                      >
+                        {isCustomCountry ? '选择预设国家' : '手工输入'}
+                      </button>
+                    </div>
+
+                    {isCustomCountry ? (
+                      <input
+                        type="text"
+                        placeholder="如: France / United Kingdom"
+                        value={item.country || ''}
+                        onChange={(e) => handleFieldChange(idx, 'country', e.target.value)}
+                        onBlur={(e) => handleFieldChange(idx, 'country', formatCapitalized(e.target.value))}
+                        disabled={disabled}
+                        className="w-full px-2.5 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000]"
+                      />
+                    ) : (
+                      <select
+                        value={
+                          PRESET_COUNTRIES.find((c) => c.value.toLowerCase() === (item.country || '').toLowerCase())?.value ||
+                          item.country ||
+                          'France'
+                        }
+                        onChange={(e) => {
+                          if (e.target.value === '__custom__') {
+                            setCustomMode((prev) => ({ ...prev, [`country_${idx}`]: true }));
+                          } else {
+                            handleFieldChange(idx, 'country', e.target.value);
+                          }
+                        }}
+                        disabled={disabled}
+                        className="w-full px-2 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000] cursor-pointer"
+                      >
+                        {PRESET_COUNTRIES.map((c) => (
+                          <option key={c.value} value={c.value}>
+                            {c.label}
+                          </option>
+                        ))}
+                        <option value="__custom__">⚙️ 其他国家 (手工录入)...</option>
+                      </select>
+                    )}
+                  </div>
+
+                  {/* 3. 签证类型 (Visa Type) - 非缩写,首字母大写 */}
+                  <div className="space-y-1">
+                    <div className="flex items-center justify-between text-[11px] font-black text-neutral-700">
+                      <span>签证业务类型 (Visa):</span>
+                      <button
+                        type="button"
+                        onClick={() => setCustomMode((prev) => ({ ...prev, [`visa_${idx}`]: !isCustomVisa }))}
+                        className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                      >
+                        {isCustomVisa ? '选择预设类型' : '手工输入'}
+                      </button>
+                    </div>
+
+                    {isCustomVisa ? (
+                      <input
+                        type="text"
+                        placeholder="如: Tourist / Business"
+                        value={item.visa_type || ''}
+                        onChange={(e) => handleFieldChange(idx, 'visa_type', e.target.value)}
+                        onBlur={(e) => handleFieldChange(idx, 'visa_type', formatCapitalized(e.target.value))}
+                        disabled={disabled}
+                        className="w-full px-2.5 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000]"
+                      />
+                    ) : (
+                      <select
+                        value={
+                          PRESET_VISA_TYPES.find((v) => v.value.toLowerCase() === (item.visa_type || '').toLowerCase())?.value ||
+                          item.visa_type ||
+                          'Tourist'
+                        }
+                        onChange={(e) => {
+                          if (e.target.value === '__custom__') {
+                            setCustomMode((prev) => ({ ...prev, [`visa_${idx}`]: true }));
+                          } else {
+                            handleFieldChange(idx, 'visa_type', e.target.value);
+                          }
+                        }}
+                        disabled={disabled}
+                        className="w-full px-2 py-1.5 bg-neutral-50 focus:bg-white border-2 border-black text-xs font-mono text-black font-bold outline-none shadow-[1px_1px_0px_#000] cursor-pointer"
+                      >
+                        {PRESET_VISA_TYPES.map((v) => (
+                          <option key={v.value} value={v.value}>
+                            {v.label}
+                          </option>
+                        ))}
+                        <option value="__custom__">⚙️ 其他签证类型 (手工录入)...</option>
+                      </select>
+                    )}
+                  </div>
+                </div>
+
+                {/* Routing Key 路由键生成与手工编辑行 */}
+                <div className="pt-1 border-t border-dashed border-neutral-300">
+                  <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-1.5 mb-1 text-[11px]">
+                    <div className="flex items-center gap-1.5">
+                      <span className="font-black text-black">Routing Key (路由键):</span>
+                      <span className="text-[10px] text-neutral-500 font-sans">
+                        消息队列订阅键,如 slot.london.france.tourist
+                      </span>
+                    </div>
+
+                    {!disabled && (
+                      <button
+                        type="button"
+                        onClick={() => handleAutoGenerateRoutingKey(idx)}
+                        className="flex items-center gap-1 text-[10px] font-black text-black bg-amber-200 hover:bg-amber-300 border border-black px-2 py-0.5 shadow-[1px_1px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 cursor-pointer self-start sm:self-auto"
+                        title="依据上方所选的城市、国家、签证类型自动生成标准 routing_key"
+                      >
+                        <Sparkles size={11} className="text-amber-800" />
+                        <span>⚡️ 依选项自动生成</span>
+                      </button>
+                    )}
+                  </div>
+
+                  <input
+                    type="text"
+                    placeholder="输入或自动生成 routing_key (必填,如: slot.london.france.tourist)"
+                    value={item.routing_key || ''}
+                    onChange={(e) => handleFieldChange(idx, 'routing_key', e.target.value)}
+                    disabled={disabled}
+                    className="w-full px-2.5 py-1.5 bg-white border-2 border-black text-xs font-mono font-bold text-black placeholder:text-neutral-400 outline-none shadow-[1px_1px_0px_#000]"
+                  />
+                </div>
               </div>
-            </div>
-          ))}
+            );
+          })}
         </div>
       )}
     </div>

+ 671 - 0
src/components/admin/node-configurations/CoordinateTutorialPanel.tsx

@@ -0,0 +1,671 @@
+// src/components/admin/node-configurations/CoordinateTutorialPanel.tsx
+
+'use client';
+
+import React, { useState } from 'react';
+import { toast } from 'react-hot-toast';
+import {
+  BookOpen,
+  ChevronDown,
+  ChevronUp,
+  Sparkles,
+  Copy,
+  Plus,
+  HelpCircle,
+  Shield,
+  Zap,
+  Cpu,
+  Layers,
+  Info,
+  CheckCircle2,
+} from 'lucide-react';
+
+export type RoleType = 'booker' | 'sentinel' | 'standalone';
+
+export interface FieldDoc {
+  key: string;
+  type: string;
+  defaultVal: string | number;
+  recommendVal: string;
+  desc: string;
+  sample: any;
+  required?: boolean;
+}
+
+export interface PresetTemplate {
+  id: string;
+  name: string;
+  tag: string;
+  badgeColor: string;
+  desc: string;
+  jsonObj: Record<string, any>;
+}
+
+export const ROLE_PRESETS: Record<RoleType, PresetTemplate[]> = {
+  sentinel: [
+    {
+      id: 'sentinel-prod-random',
+      name: '🛡️ 稳健巡航 (推荐生产)',
+      tag: '随机抖动防风控',
+      badgeColor: 'bg-emerald-100 text-emerald-900 border-emerald-500',
+      desc: '使用 5~15s 随机抖动等待,内置账号池轮换,信号有效 30 秒,极大降低被封禁几率。',
+      jsonObj: {
+        target_instances: 1,
+        signal_ttl: 30,
+        account_source: 'built-in',
+        account_cd: 10800,
+        proxy_cd: 300,
+        session_max_life: 1800,
+        query_wait: {
+          mode: 'Random',
+          random_min: 5,
+          random_max: 15,
+        },
+      },
+    },
+    {
+      id: 'sentinel-fast-fixed',
+      name: '⚡ 高频极速 (放号高峰)',
+      tag: '3秒固定快速巡检',
+      badgeColor: 'bg-amber-100 text-amber-900 border-amber-500',
+      desc: '3 秒固定短间隔极速刷新,适用于使馆集中批量放号时间段,争分夺秒捕获放号信号。',
+      jsonObj: {
+        target_instances: 1,
+        signal_ttl: 30,
+        account_source: 'built-in',
+        account_cd: 7200,
+        proxy_cd: 120,
+        session_max_life: 1200,
+        query_wait: {
+          mode: 'Fixed',
+          fixed_wait: 3,
+        },
+      },
+    },
+    {
+      id: 'sentinel-loop-continuous',
+      name: '🔄 紧密连续轮询 (Loop)',
+      tag: '无间歇循环',
+      badgeColor: 'bg-blue-100 text-blue-900 border-blue-500',
+      desc: '查询请求完成后无额外等待立即进入下一次轮询,需配合优质长效代理与多账号池使用。',
+      jsonObj: {
+        target_instances: 1,
+        signal_ttl: 20,
+        account_source: 'built-in',
+        account_cd: 10800,
+        proxy_cd: 300,
+        session_max_life: 1800,
+        query_wait: {
+          mode: 'Loop',
+        },
+      },
+    },
+  ],
+  booker: [
+    {
+      id: 'booker-order-standard',
+      name: '🚀 客户订单代抢 (默认推荐)',
+      tag: '客户订单绑定模式',
+      badgeColor: 'bg-amber-100 text-amber-900 border-amber-500',
+      desc: '以用户订单中的客户账号登录并执行预约填单,60s 心跳保活待命,每次提交冷却 10 秒。',
+      jsonObj: {
+        target_instances: 1,
+        account_source: 'order',
+        keep_alive: 60,
+        booking_cooldown: 10.0,
+        max_bookings_per_account: 1,
+        proxy_cd: 300,
+        session_max_life: 1800,
+      },
+    },
+    {
+      id: 'booker-builtin-pool',
+      name: '🏛️ 公共账号池抢占模式',
+      tag: '内置常备账号池',
+      badgeColor: 'bg-purple-100 text-purple-900 border-purple-500',
+      desc: '使用系统内置的专属账号池进行占位,支持单账号多次预约,适合抢占后人工或二次改签。',
+      jsonObj: {
+        target_instances: 2,
+        account_source: 'built-in',
+        account_pool_id: 'default_vip_pool',
+        account_cd: 7200,
+        keep_alive: 30,
+        booking_cooldown: 5.0,
+        max_bookings_per_account: 3,
+        proxy_cd: 180,
+        session_max_life: 3600,
+      },
+    },
+  ],
+  standalone: [
+    {
+      id: 'standalone-standard',
+      name: '📦 独立单体全自闭环',
+      tag: '查号+抢号一体化',
+      badgeColor: 'bg-cyan-100 text-cyan-900 border-cyan-500',
+      desc: '单节点全自主运行,不需要 Sentinel 与 Booker 分布式协同,定期重新登录并定时保活。',
+      jsonObj: {
+        login_interval: 1800,
+        session_max_life: 3600,
+        keep_alive: 60,
+        proxy_cd: 300,
+        query_wait: {
+          mode: 'Random',
+          random_min: 10,
+          random_max: 30,
+        },
+      },
+    },
+  ],
+};
+
+export const CORE_TYPES_DOCS: Record<RoleType, FieldDoc[]> = {
+  sentinel: [
+    {
+      key: 'signal_ttl',
+      type: 'int (秒)',
+      defaultVal: 180,
+      recommendVal: '30 ~ 60',
+      desc: '放号广播信号生命周期。Sentinel 巡检查出空余放号后向 Redis 广播 Signal,Booker 在该有效期内唤醒抢号。超时未抢则信号失效。',
+      sample: 30,
+      required: true,
+    },
+    {
+      key: 'query_wait',
+      type: 'object (QueryWaitConfig)',
+      defaultVal: '{ mode: "Loop" }',
+      recommendVal: 'mode: "Random", min: 5, max: 15',
+      desc: '巡检查询等待策略。mode 支持 "Random" (随机区间防封)、"Fixed" (固定秒数) 或 "Loop" (连续不休眠)。',
+      sample: { mode: 'Random', random_min: 5, random_max: 15 },
+      required: true,
+    },
+    {
+      key: 'target_instances',
+      type: 'int',
+      defaultVal: 1,
+      recommendVal: '1 ~ 3',
+      desc: 'Sentinel 节点目标并发巡检实例数。通常 1 台实例即可完成高效巡检。',
+      sample: 1,
+    },
+    {
+      key: 'account_source',
+      type: 'string',
+      defaultVal: '"built-in"',
+      recommendVal: '"built-in"',
+      desc: '巡检账号来源。Sentinel 通常统一使用系统内置账号池 (built-in) 进行放号探测。',
+      sample: 'built-in',
+    },
+    {
+      key: 'account_pool_id',
+      type: 'string',
+      defaultVal: '""',
+      recommendVal: '例如: "vfs_sentinel_pool"',
+      desc: '绑定的内置账号池标识。留空则从该使馆全量可用内置账号池自动分配。',
+      sample: 'vfs_sentinel_pool',
+    },
+    {
+      key: 'account_cd',
+      type: 'int (秒)',
+      defaultVal: 10800,
+      recommendVal: '7200 ~ 10800 (2~3小时)',
+      desc: '账号使用后进入的冷却时间。用于规避使馆对同一账号频繁刷新的反爬限制。',
+      sample: 10800,
+    },
+    {
+      key: 'proxy_cd',
+      type: 'int (秒)',
+      defaultVal: 300,
+      recommendVal: '180 ~ 300 (3~5分钟)',
+      desc: '代理 IP 轮换/冷却时间。触发风控或达到寿命后自动更换代理。',
+      sample: 300,
+    },
+    {
+      key: 'session_max_life',
+      type: 'int (秒)',
+      defaultVal: 1800,
+      recommendVal: '1800 ~ 3600 (30~60分钟)',
+      desc: '浏览器/网络会话最大存活时间。超过后自动销毁并重建干净的会话环境。',
+      sample: 1800,
+    },
+  ],
+  booker: [
+    {
+      key: 'account_source',
+      type: 'string',
+      defaultVal: '"built-in"',
+      recommendVal: '"order" (代抢) 或 "built-in" (占位)',
+      desc: '抢号账号来源。"order" 会在放号时提取真实下单客户的预约账号;"built-in" 会从系统账号池抢占。',
+      sample: 'order',
+      required: true,
+    },
+    {
+      key: 'keep_alive',
+      type: 'int (秒)',
+      defaultVal: 60,
+      recommendVal: '30 ~ 120',
+      desc: '挂机待命状态下向使馆服务器发送会话保活心跳的间隔,确保收到信号瞬间会话保持在登录状态。',
+      sample: 60,
+      required: true,
+    },
+    {
+      key: 'booking_cooldown',
+      type: 'float (秒)',
+      defaultVal: 10.0,
+      recommendVal: '5.0 ~ 30.0',
+      desc: '单次预约动作提交的冷却防抖时间,防止并发重复提交导致使馆风控锁单。',
+      sample: 10.0,
+    },
+    {
+      key: 'max_bookings_per_account',
+      type: 'int',
+      defaultVal: 1,
+      recommendVal: '1 (客户订单) 或 3~8 (公共池)',
+      desc: '每个账号允许成功预约的最大数量。客户订单模式下必须为 1。',
+      sample: 1,
+    },
+    {
+      key: 'target_instances',
+      type: 'int',
+      defaultVal: 1,
+      recommendVal: '1 ~ 5',
+      desc: '抢号实例并发数。built-in 模式下为全局并发实例;order 模式下为单队列订单并发。',
+      sample: 1,
+    },
+    {
+      key: 'account_pool_id',
+      type: 'string',
+      defaultVal: '""',
+      recommendVal: '内置池标识 (仅 built-in 生效)',
+      desc: '当 account_source 为 built-in 时指定的账号池名称。',
+      sample: 'vip_pool_a',
+    },
+    {
+      key: 'account_cd',
+      type: 'int (秒)',
+      defaultVal: 10800,
+      recommendVal: '10800',
+      desc: '账号成功或失败后冷却时间。',
+      sample: 10800,
+    },
+    {
+      key: 'proxy_cd',
+      type: 'int (秒)',
+      defaultVal: 300,
+      recommendVal: '300',
+      desc: '代理 IP 轮换/冷却时间。',
+      sample: 300,
+    },
+    {
+      key: 'session_max_life',
+      type: 'int (秒)',
+      defaultVal: 1800,
+      recommendVal: '1800 ~ 7200',
+      desc: '会话最长保持时间。',
+      sample: 1800,
+    },
+  ],
+  standalone: [
+    {
+      key: 'login_interval',
+      type: 'int (秒)',
+      defaultVal: 1800,
+      recommendVal: '1800 ~ 3600',
+      desc: '自动重新登录或刷新登录态的时间间隔。',
+      sample: 1800,
+      required: true,
+    },
+    {
+      key: 'session_max_life',
+      type: 'int (秒)',
+      defaultVal: 1800,
+      recommendVal: '3600',
+      desc: '单体会话最长生命周期,超时重新初始化。',
+      sample: 3600,
+    },
+    {
+      key: 'keep_alive',
+      type: 'int (秒)',
+      defaultVal: 60,
+      recommendVal: '60',
+      desc: '心跳保活间隔。',
+      sample: 60,
+    },
+    {
+      key: 'query_wait',
+      type: 'object (QueryWaitConfig)',
+      defaultVal: '{ mode: "Random" }',
+      recommendVal: 'mode: "Random", min: 10, max: 25',
+      desc: '独立节点的查询等待间隔配置。',
+      sample: { mode: 'Random', random_min: 10, random_max: 25 },
+    },
+  ],
+};
+
+interface CoordinateTutorialPanelProps {
+  activeRole: RoleType;
+  onApplyPreset: (presetJson: string) => void;
+  onInsertField: (fieldKey: string, fieldSample: any) => void;
+}
+
+export default function CoordinateTutorialPanel({
+  activeRole,
+  onApplyPreset,
+  onInsertField,
+}: CoordinateTutorialPanelProps) {
+  const [isOpen, setIsOpen] = useState(false);
+  const [activeTab, setActiveTab] = useState<'presets' | 'dictionary' | 'workflow'>('presets');
+  const [copiedKey, setCopiedKey] = useState<string | null>(null);
+
+  const presets = ROLE_PRESETS[activeRole] || [];
+  const fields = CORE_TYPES_DOCS[activeRole] || [];
+
+  const handleCopyText = (text: string, label: string) => {
+    navigator.clipboard.writeText(text);
+    setCopiedKey(text);
+    toast.success(`已复制 ${label}: ${text}`);
+    setTimeout(() => setCopiedKey(null), 1500);
+  };
+
+  const roleMeta = {
+    booker: {
+      name: 'BOOKER (极速抢号节点)',
+      color: 'bg-amber-300 text-black border-black',
+      icon: <Zap className="w-4 h-4 text-amber-700" />,
+      desc: '待命监听放号信号 (Signal)。收到信号瞬间唤醒,以最快速度完成客户资料录入与使馆预约确认。',
+    },
+    sentinel: {
+      name: 'SENTINEL (哨兵巡检节点)',
+      color: 'bg-emerald-300 text-black border-black',
+      icon: <Shield className="w-4 h-4 text-emerald-800" />,
+      desc: '使用内置低权账号持续监控使馆 Slot 放号状态。一旦侦测到可用席位,立即向 Redis 发布 Signal 信号。',
+    },
+    standalone: {
+      name: 'STANDALONE (独立全自主节点)',
+      color: 'bg-cyan-300 text-black border-black',
+      icon: <Cpu className="w-4 h-4 text-cyan-800" />,
+      desc: '单机完成登录、查号、预约全流程,无需依赖 Sentinel/Booker 分布式通信,适合测试或简易站点。',
+    },
+  }[activeRole];
+
+  return (
+    <div className="mt-3 border-2 border-black bg-white shadow-[3px_3px_0px_#000] text-xs">
+      {/* Header Bar */}
+      <div
+        onClick={() => setIsOpen(!isOpen)}
+        className="px-3 py-2.5 bg-neutral-100 hover:bg-neutral-200 cursor-pointer flex items-center justify-between select-none border-b-2 border-black transition"
+      >
+        <div className="flex items-center gap-2">
+          <BookOpen className="w-4 h-4 text-neutral-800" />
+          <span className="font-black text-black tracking-wide uppercase">
+            [ Coordinate 核心架构指南与参数字典 // core_types.py ]
+          </span>
+          <span className="px-1.5 py-0.5 bg-amber-200 border border-black font-bold text-[10px] uppercase">
+            {activeRole}
+          </span>
+        </div>
+        <div className="flex items-center gap-2">
+          <span className="text-[11px] font-bold text-neutral-600">
+            {isOpen ? '点击收起教程' : '点击展开教程与预设'}
+          </span>
+          {isOpen ? (
+            <ChevronUp className="w-4 h-4 text-black" />
+          ) : (
+            <ChevronDown className="w-4 h-4 text-black" />
+          )}
+        </div>
+      </div>
+
+      {/* Collapsible Content */}
+      {isOpen && (
+        <div className="p-4 space-y-4 bg-neutral-50">
+          {/* Role Summary Banner */}
+          <div className="p-3 border-2 border-black bg-white shadow-[2px_2px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-3">
+            <div className="flex items-start gap-2.5">
+              <div className="p-2 border border-black bg-neutral-100 shrink-0">
+                {roleMeta.icon}
+              </div>
+              <div>
+                <div className="font-black text-black text-xs uppercase flex items-center gap-2">
+                  <span>{roleMeta.name}</span>
+                </div>
+                <div className="text-[11px] text-neutral-600 mt-0.5 leading-relaxed">
+                  {roleMeta.desc}
+                </div>
+              </div>
+            </div>
+            <div className="shrink-0 flex items-center gap-1.5 self-end md:self-center">
+              <span className="text-[10px] text-neutral-500 font-mono">coordinate/core_types.py</span>
+            </div>
+          </div>
+
+          {/* Sub Navigation Tabs */}
+          <div className="flex border-b-2 border-black gap-1">
+            <button
+              type="button"
+              onClick={() => setActiveTab('presets')}
+              className={`px-3 py-1.5 font-bold uppercase transition flex items-center gap-1.5 border-t-2 border-x-2 border-black -mb-[2px] ${
+                activeTab === 'presets'
+                  ? 'bg-amber-300 text-black font-black'
+                  : 'bg-white text-neutral-700 hover:bg-neutral-100'
+              }`}
+            >
+              <Sparkles className="w-3.5 h-3.5" />
+              <span>一键预设方案 ({presets.length})</span>
+            </button>
+            <button
+              type="button"
+              onClick={() => setActiveTab('dictionary')}
+              className={`px-3 py-1.5 font-bold uppercase transition flex items-center gap-1.5 border-t-2 border-x-2 border-black -mb-[2px] ${
+                activeTab === 'dictionary'
+                  ? 'bg-amber-300 text-black font-black'
+                  : 'bg-white text-neutral-700 hover:bg-neutral-100'
+              }`}
+            >
+              <Layers className="w-3.5 h-3.5" />
+              <span>字段字典速查 ({fields.length})</span>
+            </button>
+            <button
+              type="button"
+              onClick={() => setActiveTab('workflow')}
+              className={`px-3 py-1.5 font-bold uppercase transition flex items-center gap-1.5 border-t-2 border-x-2 border-black -mb-[2px] ${
+                activeTab === 'workflow'
+                  ? 'bg-amber-300 text-black font-black'
+                  : 'bg-white text-neutral-700 hover:bg-neutral-100'
+              }`}
+            >
+              <Info className="w-3.5 h-3.5" />
+              <span>Sentinel vs Booker 协同工作流</span>
+            </button>
+          </div>
+
+          {/* Tab 1: Presets */}
+          {activeTab === 'presets' && (
+            <div className="space-y-3">
+              <div className="text-[11px] text-neutral-600 font-medium">
+                💡 点击下方预设可直接将标准配置载入上方的代码编辑器,您也可以在载入后根据实际业务微调:
+              </div>
+              <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
+                {presets.map((preset) => (
+                  <div
+                    key={preset.id}
+                    className="p-3 bg-white border-2 border-black shadow-[2px_2px_0px_#000] flex flex-col justify-between hover:translate-x-0.5 hover:-translate-y-0.5 transition"
+                  >
+                    <div>
+                      <div className="flex items-center justify-between gap-1 mb-1">
+                        <span className="font-black text-black text-xs">{preset.name}</span>
+                        <span className={`text-[10px] font-bold px-1.5 py-0.2 border ${preset.badgeColor}`}>
+                          {preset.tag}
+                        </span>
+                      </div>
+                      <p className="text-[11px] text-neutral-600 mb-2 leading-relaxed">
+                        {preset.desc}
+                      </p>
+                    </div>
+                    <div className="pt-2 border-t border-dashed border-neutral-300 flex items-center justify-between gap-2">
+                      <button
+                        type="button"
+                        onClick={() => handleCopyText(JSON.stringify(preset.jsonObj, null, 2), preset.name)}
+                        className="px-2 py-1 bg-white hover:bg-neutral-100 border border-black text-[10px] font-bold flex items-center gap-1"
+                        title="复制该预设 JSON"
+                      >
+                        <Copy className="w-3 h-3" />
+                        <span>复制</span>
+                      </button>
+                      <button
+                        type="button"
+                        onClick={() => onApplyPreset(JSON.stringify(preset.jsonObj, null, 2))}
+                        className="flex-1 px-2.5 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-[10px] font-black uppercase shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center justify-center gap-1"
+                      >
+                        <Sparkles className="w-3 h-3" />
+                        <span>一键应用此预设</span>
+                      </button>
+                    </div>
+                  </div>
+                ))}
+              </div>
+            </div>
+          )}
+
+          {/* Tab 2: Field Dictionary */}
+          {activeTab === 'dictionary' && (
+            <div className="space-y-3">
+              <div className="flex items-center justify-between text-[11px] text-neutral-600">
+                <span>
+                  📚 严格对应 Python 调度引擎{' '}
+                  <code className="bg-neutral-200 px-1 font-mono font-bold text-black">
+                    coordinate/core_types.py
+                  </code>{' '}
+                  原生数据类定义:
+                </span>
+                <span className="text-[10px] text-neutral-500">点击「+ 插入」直接注入当前编辑器</span>
+              </div>
+
+              <div className="border-2 border-black overflow-x-auto bg-white shadow-[2px_2px_0px_#000]">
+                <table className="w-full text-left border-collapse text-xs">
+                  <thead>
+                    <tr className="bg-neutral-200 border-b-2 border-black font-black uppercase text-[11px]">
+                      <th className="p-2 border-r border-black w-40">字段名 (Field Key)</th>
+                      <th className="p-2 border-r border-black w-24">类型</th>
+                      <th className="p-2 border-r border-black w-28">默认 / 推荐值</th>
+                      <th className="p-2 border-r border-black">业务作用与 Coordinate 说明</th>
+                      <th className="p-2 w-24 text-center">操作</th>
+                    </tr>
+                  </thead>
+                  <tbody className="divide-y divide-black/20 font-sans">
+                    {fields.map((f) => (
+                      <tr key={f.key} className="hover:bg-amber-50/60 transition">
+                        <td className="p-2 border-r border-black font-mono font-bold text-neutral-900">
+                          <div className="flex items-center gap-1">
+                            <span className="text-blue-700 font-bold">{f.key}</span>
+                            {f.required && (
+                              <span className="text-[9px] bg-red-100 text-red-700 border border-red-400 px-1 font-bold">
+                                核心
+                              </span>
+                            )}
+                          </div>
+                        </td>
+                        <td className="p-2 border-r border-black font-mono text-neutral-600 text-[11px]">
+                          {f.type}
+                        </td>
+                        <td className="p-2 border-r border-black text-[11px]">
+                          <div className="text-neutral-500">默认: <code className="font-mono">{String(f.defaultVal)}</code></div>
+                          <div className="text-emerald-700 font-bold">推荐: {f.recommendVal}</div>
+                        </td>
+                        <td className="p-2 border-r border-black text-[11px] text-neutral-700 leading-relaxed">
+                          {f.desc}
+                        </td>
+                        <td className="p-2 text-center space-x-1 whitespace-nowrap">
+                          <button
+                            type="button"
+                            onClick={() => handleCopyText(f.key, f.key)}
+                            className="p-1 hover:bg-neutral-200 border border-black bg-white inline-flex items-center"
+                            title="复制字段名"
+                          >
+                            <Copy className="w-3 h-3 text-neutral-800" />
+                          </button>
+                          <button
+                            type="button"
+                            onClick={() => onInsertField(f.key, f.sample)}
+                            className="px-1.5 py-1 bg-amber-300 hover:bg-amber-400 border border-black font-bold text-[10px] inline-flex items-center gap-0.5"
+                            title="将此参数及范例值插入到 JSON 编辑器中"
+                          >
+                            <Plus className="w-3 h-3" />
+                            <span>插入</span>
+                          </button>
+                        </td>
+                      </tr>
+                    ))}
+                  </tbody>
+                </table>
+              </div>
+            </div>
+          )}
+
+          {/* Tab 3: Workflow */}
+          {activeTab === 'workflow' && (
+            <div className="p-4 bg-white border-2 border-black shadow-[2px_2px_0px_#000] space-y-4">
+              <div className="flex items-center gap-2 border-b border-black pb-2">
+                <span className="font-black text-black uppercase text-xs">
+                  [ Coordinate 分布式放号与抢号协同机制 ]
+                </span>
+              </div>
+
+              <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+                {/* Step 1 */}
+                <div className="p-3 border border-black bg-emerald-50 space-y-1.5">
+                  <div className="flex items-center gap-1.5 font-black text-emerald-900">
+                    <span className="w-4 h-4 rounded-full bg-emerald-300 text-black flex items-center justify-center text-[10px]">1</span>
+                    <span>Sentinel 巡检侦测</span>
+                  </div>
+                  <p className="text-[11px] text-emerald-800 leading-relaxed">
+                    巡检节点挂载内置低频账号,按 <code className="font-mono bg-white px-1">query_wait</code> 设定的节奏不间断轮询目标使馆。
+                  </p>
+                </div>
+
+                {/* Step 2 */}
+                <div className="p-3 border border-black bg-blue-50 space-y-1.5">
+                  <div className="flex items-center gap-1.5 font-black text-blue-900">
+                    <span className="w-4 h-4 rounded-full bg-blue-300 text-black flex items-center justify-center text-[10px]">2</span>
+                    <span>Redis 信号广播 (Signal)</span>
+                  </div>
+                  <p className="text-[11px] text-blue-800 leading-relaxed">
+                    侦测到可用 slot 放号时,Sentinel 立即向 Redis 广播信号,存活时间由 <code className="font-mono bg-white px-1">signal_ttl</code> 决定。
+                  </p>
+                </div>
+
+                {/* Step 3 */}
+                <div className="p-3 border border-black bg-amber-50 space-y-1.5">
+                  <div className="flex items-center gap-1.5 font-black text-amber-900">
+                    <span className="w-4 h-4 rounded-full bg-amber-300 text-black flex items-center justify-center text-[10px]">3</span>
+                    <span>Booker 瞬间唤醒与代抢</span>
+                  </div>
+                  <p className="text-[11px] text-amber-800 leading-relaxed">
+                    Booker 节点收到广播后瞬间激活,按 <code className="font-mono bg-white px-1">account_source</code> 绑定客户订单账号极速提交预约。
+                  </p>
+                </div>
+              </div>
+
+              <div className="p-2.5 bg-neutral-100 border border-black text-[11px] text-neutral-700 space-y-1">
+                <div className="font-bold text-black flex items-center gap-1">
+                  <CheckCircle2 className="w-3.5 h-3.5 text-emerald-600" />
+                  <span>防风控最佳实践技巧:</span>
+                </div>
+                <ul className="list-disc pl-5 space-y-0.5 text-neutral-600">
+                  <li>
+                    对于 <strong>VFS Global</strong> / <strong>TLScontact</strong>,强烈建议 Sentinel 使用 <code className="font-mono">Random (5~15s)</code>,避免规律性固定间隔触发使馆 IP 封禁。
+                  </li>
+                  <li>
+                    Booker 的 <code className="font-mono">keep_alive</code> 建议设置为 <code className="font-mono">60s</code>,维持 Cloudflare / Cookie 会话不掉线。
+                  </li>
+                  <li>
+                    设置合理的 <code className="font-mono">account_cd (10800s / 3小时)</code>,确保同一账号被使馆查号限频时有充分时间自动退避恢复。
+                  </li>
+                </ul>
+              </div>
+            </div>
+          )}
+        </div>
+      )}
+    </div>
+  );
+}

+ 16 - 1
src/components/admin/node-configurations/NodeClusterTelemetryBar.tsx

@@ -11,6 +11,7 @@ import {
   Layers,
   ChevronDown,
   ChevronUp,
+  X,
 } from 'lucide-react';
 import {
   NodeRuntimeStatus,
@@ -27,6 +28,7 @@ interface NodeClusterTelemetryBarProps {
   lastUpdatedTime?: string;
   registeredNodeIds?: Set<string>;
   onQuickRegisterNode?: (nodeId: string) => void;
+  onClose?: () => void;
 }
 
 export default function NodeClusterTelemetryBar({
@@ -39,6 +41,7 @@ export default function NodeClusterTelemetryBar({
   lastUpdatedTime,
   registeredNodeIds,
   onQuickRegisterNode,
+  onClose,
 }: NodeClusterTelemetryBarProps) {
   const [collapsed, setCollapsed] = useState(false);
   const [inspectingPluginsNode, setInspectingPluginsNode] = useState<NodeRuntimeStatus | null>(null);
@@ -130,10 +133,22 @@ export default function NodeClusterTelemetryBar({
             type="button"
             onClick={() => setCollapsed(!collapsed)}
             className="p-1 bg-white hover:bg-neutral-100 border border-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
-            title={collapsed ? '展开监控看板' : '收起监控看板'}
+            title={collapsed ? '展开监控看板内容' : '收起监控看板内容'}
           >
             {collapsed ? <ChevronDown className="w-3.5 h-3.5" /> : <ChevronUp className="w-3.5 h-3.5" />}
           </button>
+
+          {/* Close Panel Button */}
+          {onClose && (
+            <button
+              type="button"
+              onClick={onClose}
+              className="p-1 bg-white hover:bg-rose-200 border border-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 text-black"
+              title="收起并隐藏监控面板"
+            >
+              <X className="w-3.5 h-3.5" />
+            </button>
+          )}
         </div>
       </div>
 

+ 40 - 11
src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx

@@ -239,18 +239,47 @@ export default function NodeConfigCreateWizardModal({
       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']));
+        const accSource = roleTpl['account_source'] ?? roleTpl['booker.account_source'];
+        if (accSource !== undefined) setBookerAccountSource(accSource);
+
+        const poolId = roleTpl['account_pool_id'] ?? roleTpl['booker.account_pool_id'];
+        if (poolId !== undefined) setBookerAccountPoolId(poolId);
+
+        const accCd = roleTpl['account_cd'] ?? roleTpl['booker.account_cd'];
+        if (accCd !== undefined) setBookerAccountCd(Number(accCd));
+
+        const instances = roleTpl['target_instances'] ?? roleTpl['booker.target_instances'];
+        if (instances !== undefined) setBookerTargetInstances(Number(instances));
+
+        const cooldown = roleTpl['booking_cooldown'] ?? roleTpl['booker.booking_cooldown'];
+        if (cooldown !== undefined) setBookerCooldown(Number(cooldown));
+
+        const maxBookings = roleTpl['max_bookings_per_account'] ?? roleTpl['booker.max_bookings_per_account'];
+        if (maxBookings !== undefined) setBookerMaxBookings(Number(maxBookings));
       } 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']);
+        const accSource = roleTpl['account_source'] ?? roleTpl['sentinel.account_source'];
+        if (accSource !== undefined) setSentinelAccountSource(accSource);
+
+        const poolId = roleTpl['account_pool_id'] ?? roleTpl['sentinel.account_pool_id'];
+        if (poolId !== undefined) setSentinelAccountPoolId(poolId);
+
+        const instances = roleTpl['target_instances'] ?? roleTpl['sentinel.target_instances'];
+        if (instances !== undefined) setSentinelTargetInstances(Number(instances));
+
+        const signalTtl = roleTpl['signal_ttl'] ?? roleTpl['sentinel.signal_ttl'];
+        if (signalTtl !== undefined) setSentinelSignalTtl(Number(signalTtl));
+
+        const qwMode = roleTpl['query_wait']?.mode ?? roleTpl['query_wait.mode'] ?? roleTpl['sentinel.query_wait.mode'];
+        if (qwMode !== undefined) setQueryWaitMode(qwMode);
+
+        const fixedWait = roleTpl['query_wait']?.fixed_wait ?? roleTpl['query_wait.fixed_wait'] ?? roleTpl['sentinel.query_wait.fixed_wait'];
+        if (fixedWait !== undefined) setFixedWait(Number(fixedWait));
+
+        const randomMin = roleTpl['query_wait']?.random_min ?? roleTpl['query_wait.random_min'] ?? roleTpl['sentinel.query_wait.random_min'];
+        if (randomMin !== undefined) setRandomMin(Number(randomMin));
+
+        const randomMax = roleTpl['query_wait']?.random_max ?? roleTpl['query_wait.random_max'] ?? roleTpl['sentinel.query_wait.random_max'];
+        if (randomMax !== undefined) setRandomMax(Number(randomMax));
       }
     }
 

+ 1 - 1
src/components/admin/node-configurations/NodeConfigDetailDrawer.tsx

@@ -477,7 +477,7 @@ export default function NodeConfigDetailDrawer({
                       >
                         <span className="font-black text-black">{appt.routing_key}</span>
                         <span className="text-neutral-600 font-bold">
-                          {appt.city || '-'} / {appt.visa_type || '-'} (权重: {appt.weight ?? '-'})
+                          {appt.country ? `${appt.country} · ` : ''}{appt.city || '-'} / {appt.visa_type || '-'} (权重: {appt.weight ?? '-'})
                         </span>
                       </div>
                     ))}

+ 236 - 25
src/components/admin/node-configurations/NodeConfigEditModal.tsx

@@ -16,6 +16,7 @@ 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 CoordinateTutorialPanel from './CoordinateTutorialPanel';
 import {
   LOCAL_PROXY_POOLS,
   COMMON_WEBSITES,
@@ -176,16 +177,8 @@ export default function NodeConfigEditModal({
       setAppointmentTypes(config.appointment_types || []);
       setFreeConfigStr(config.free_config ? JSON.stringify(config.free_config, null, 2) : '{}');
 
-      setRawJsonStr(
-        JSON.stringify(
-          {
-            set: {},
-            clear: [],
-          },
-          null,
-          2
-        )
-      );
+      // 初始化完整配置 JSON 字符串
+      setRawJsonStr(JSON.stringify(config, null, 2));
     }
   }, [config, isOpen]);
 
@@ -319,6 +312,169 @@ export default function NodeConfigEditModal({
     };
   };
 
+  // 根据当前表单状态构建完整的最新配置 JSON 对象
+  const buildFullConfigFromState = () => {
+    const full: any = {
+      ...config,
+      website,
+      proxy_cd: proxyCd === '' ? undefined : Number(proxyCd),
+      session_max_life: sessionMaxLife === '' ? undefined : Number(sessionMaxLife),
+      active_time_start: activeTimeStart || undefined,
+      active_time_end: activeTimeEnd || undefined,
+      proxy_pool: proxyPoolStr
+        .split(',')
+        .map((s) => s.trim())
+        .filter(Boolean),
+    };
+
+    if (entryType === 'booker') {
+      full.booker = {
+        ...(config.booker || {}),
+        account_source: bookerAccountSource,
+        account_pool_id: bookerAccountPoolId || undefined,
+        target_instances: bookerTargetInstances === '' ? 1 : Number(bookerTargetInstances),
+        account_cd: bookerAccountCd === '' ? undefined : Number(bookerAccountCd),
+        booking_cooldown: bookerCooldown === '' ? undefined : Number(bookerCooldown),
+        max_bookings_per_account: bookerMaxBookings === '' ? undefined : Number(bookerMaxBookings),
+      };
+    }
+
+    if (entryType === 'sentinel') {
+      full.sentinel = {
+        ...(config.sentinel || {}),
+        account_source: sentinelAccountSource,
+        account_pool_id: sentinelAccountPoolId || undefined,
+        target_instances: sentinelTargetInstances === '' ? 1 : Number(sentinelTargetInstances),
+        signal_ttl: sentinelSignalTtl === '' ? undefined : Number(sentinelSignalTtl),
+        query_wait: {
+          mode: queryWaitMode,
+          fixed_wait: queryWaitMode === 'Fixed' && fixedWait !== '' ? Number(fixedWait) : undefined,
+          random_min: queryWaitMode === 'Random' && randomMin !== '' ? Number(randomMin) : undefined,
+          random_max: queryWaitMode === 'Random' && randomMax !== '' ? Number(randomMax) : undefined,
+        },
+      };
+    }
+
+    if (entryType === 'standalone') {
+      full.order_id = orderId || undefined;
+      full.account = {
+        ...(config.account || {}),
+        username: accountUsername,
+        password: accountPassword,
+      };
+      full.login_interval = loginInterval === '' ? undefined : Number(loginInterval);
+      try {
+        full.user_preferences = userPreferencesStr.trim() ? JSON.parse(userPreferencesStr) : {};
+      } catch {}
+    }
+
+    full.plugin_config = pluginConfig || {};
+    full.appointment_types = appointmentTypes || [];
+    try {
+      full.free_config = freeConfigStr.trim() ? JSON.parse(freeConfigStr) : {};
+    } catch {}
+
+    return full;
+  };
+
+  // 从完整的 JSON 对象反向同步回表单各个状态
+  const syncStateFromFullJson = (jsonObj: any) => {
+    if (!jsonObj || typeof jsonObj !== 'object') return;
+    if (jsonObj.website !== undefined) setWebsite(jsonObj.website);
+    if (jsonObj.proxy_cd !== undefined) setProxyCd(jsonObj.proxy_cd);
+    if (jsonObj.session_max_life !== undefined) setSessionMaxLife(jsonObj.session_max_life);
+    if (jsonObj.active_time_start !== undefined) setActiveTimeStart(jsonObj.active_time_start);
+    if (jsonObj.active_time_end !== undefined) setActiveTimeEnd(jsonObj.active_time_end);
+    if (jsonObj.proxy_pool !== undefined && Array.isArray(jsonObj.proxy_pool)) {
+      setProxyPoolStr(jsonObj.proxy_pool.join(', '));
+    }
+
+    if (entryType === 'booker' && jsonObj.booker) {
+      if (jsonObj.booker.account_source) setBookerAccountSource(jsonObj.booker.account_source);
+      if (jsonObj.booker.account_pool_id !== undefined) setBookerAccountPoolId(jsonObj.booker.account_pool_id);
+      if (jsonObj.booker.target_instances !== undefined) setBookerTargetInstances(jsonObj.booker.target_instances);
+      if (jsonObj.booker.account_cd !== undefined) setBookerAccountCd(jsonObj.booker.account_cd);
+      if (jsonObj.booker.booking_cooldown !== undefined) setBookerCooldown(jsonObj.booker.booking_cooldown);
+      if (jsonObj.booker.max_bookings_per_account !== undefined) setBookerMaxBookings(jsonObj.booker.max_bookings_per_account);
+    }
+
+    if (entryType === 'sentinel' && jsonObj.sentinel) {
+      if (jsonObj.sentinel.account_source) setSentinelAccountSource(jsonObj.sentinel.account_source);
+      if (jsonObj.sentinel.account_pool_id !== undefined) setSentinelAccountPoolId(jsonObj.sentinel.account_pool_id);
+      if (jsonObj.sentinel.target_instances !== undefined) setSentinelTargetInstances(jsonObj.sentinel.target_instances);
+      if (jsonObj.sentinel.signal_ttl !== undefined) setSentinelSignalTtl(jsonObj.sentinel.signal_ttl);
+      const qw = jsonObj.sentinel.query_wait;
+      if (qw) {
+        if (qw.mode) setQueryWaitMode(qw.mode);
+        if (qw.fixed_wait !== undefined) setFixedWait(qw.fixed_wait);
+        if (qw.random_min !== undefined) setRandomMin(qw.random_min);
+        if (qw.random_max !== undefined) setRandomMax(qw.random_max);
+      }
+    }
+
+    if (entryType === 'standalone') {
+      if (jsonObj.order_id !== undefined) setOrderId(jsonObj.order_id);
+      if (jsonObj.account?.username !== undefined) setAccountUsername(jsonObj.account.username);
+      if (jsonObj.account?.password !== undefined) setAccountPassword(jsonObj.account.password);
+      if (jsonObj.login_interval !== undefined) setLoginInterval(jsonObj.login_interval);
+      if (jsonObj.user_preferences !== undefined) {
+        setUserPreferencesStr(JSON.stringify(jsonObj.user_preferences, null, 2));
+      }
+    }
+
+    if (jsonObj.plugin_config !== undefined) setPluginConfig(jsonObj.plugin_config);
+    if (jsonObj.appointment_types !== undefined && Array.isArray(jsonObj.appointment_types)) {
+      setAppointmentTypes(jsonObj.appointment_types);
+    }
+    if (jsonObj.free_config !== undefined) {
+      setFreeConfigStr(JSON.stringify(jsonObj.free_config, null, 2));
+    }
+  };
+
+  // 对比完整 JSON 计算差异增量 (set / clear)
+  const calculateSparsePayloadFromFull = (edited: any, original: any): SparseUpdatePayload => {
+    const setObj: Record<string, any> = {};
+    const clearArr: string[] = [];
+
+    const ignoreKeys = ['id', 'node_id', 'identifier', 'entry_type', 'version', 'created_at', 'updated_at'];
+
+    // 1. 遍历编辑后的完整 JSON 对象
+    for (const [k, v] of Object.entries(edited)) {
+      if (ignoreKeys.includes(k)) continue;
+      if (JSON.stringify(v) !== JSON.stringify(original[k])) {
+        setObj[k] = v;
+      }
+    }
+
+    // 2. 检查被删除的键
+    for (const k of Object.keys(original)) {
+      if (ignoreKeys.includes(k)) continue;
+      if (original[k] !== undefined && original[k] !== null && edited[k] === undefined) {
+        clearArr.push(k);
+      }
+    }
+
+    return {
+      set: Object.keys(setObj).length > 0 ? setObj : undefined,
+      clear: clearArr.length > 0 ? clearArr : undefined,
+    };
+  };
+
+  // 模式切换处理器
+  const handleSwitchToVisual = () => {
+    try {
+      const parsed = JSON.parse(rawJsonStr);
+      syncStateFromFullJson(parsed);
+    } catch {}
+    setMode('visual');
+  };
+
+  const handleSwitchToJson = () => {
+    const full = buildFullConfigFromState();
+    setRawJsonStr(JSON.stringify(full, null, 2));
+    setMode('json');
+  };
+
   const handleFormatJson = () => {
     try {
       const parsed = JSON.parse(rawJsonStr);
@@ -342,13 +498,28 @@ export default function NodeConfigEditModal({
       let payload: SparseUpdatePayload;
 
       if (mode === 'json') {
+        let editedObj: any;
         try {
-          payload = JSON.parse(rawJsonStr);
+          editedObj = JSON.parse(rawJsonStr);
         } catch {
           toast.error('JSON 格式错误,请检查语法');
           setSaving(false);
           return;
         }
+
+        // 兼容支持直接传入 set/clear 或完整 JSON 对象自动比对
+        if (editedObj.set !== undefined || editedObj.clear !== undefined) {
+          payload = editedObj;
+        } else {
+          payload = calculateSparsePayloadFromFull(editedObj, config);
+        }
+
+        if (!payload.set && (!payload.clear || payload.clear.length === 0)) {
+          toast('未检测到任何字段变更', { icon: 'ℹ️' });
+          onClose();
+          setSaving(false);
+          return;
+        }
       } else {
         if (entryType === 'standalone') {
           try {
@@ -418,7 +589,7 @@ export default function NodeConfigEditModal({
             <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
             <div>
               <h3 className="font-black text-black text-xs md:text-sm uppercase tracking-wider">
-                [ EDIT {entryType.toUpperCase()} CONFIG // 稀疏编辑: {config.node_id} / {config.identifier} (v{config.version}) ]
+                [ EDIT {entryType.toUpperCase()} CONFIG // 配置编辑: {config.node_id} / {config.identifier} (v{config.version}) ]
               </h3>
             </div>
           </div>
@@ -428,8 +599,8 @@ export default function NodeConfigEditModal({
             <div className="flex border-2 border-black bg-white p-0.5 gap-1">
               <button
                 type="button"
-                onClick={() => setMode('visual')}
-                className={`px-3 py-1 text-xs font-mono uppercase transition border ${
+                onClick={handleSwitchToVisual}
+                className={`px-3 py-1 text-xs font-mono uppercase transition border cursor-pointer ${
                   mode === 'visual'
                     ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
                     : 'text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
@@ -439,14 +610,14 @@ export default function NodeConfigEditModal({
               </button>
               <button
                 type="button"
-                onClick={() => setMode('json')}
-                className={`px-3 py-1 text-xs font-mono uppercase transition border ${
+                onClick={handleSwitchToJson}
+                className={`px-3 py-1 text-xs font-mono uppercase transition border cursor-pointer ${
                   mode === 'json'
                     ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
                     : 'text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
                 }`}
               >
-                [ JSON 稀疏模式 ]
+                [ 完整 JSON 模式 ]
               </button>
             </div>
 
@@ -1298,25 +1469,25 @@ export default function NodeConfigEditModal({
               </div>
             </div>
           ) : (
-            /* JSON Sparse Mode */
+            /* Full Config JSON Mode */
             <div className="w-full font-mono text-xs select-none space-y-3">
               <div className="flex items-center justify-between px-3 py-2 bg-neutral-200 border-2 border-black">
                 <div className="flex items-center gap-2">
                   <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
-                  <span className="font-black text-black uppercase">[ SPARSE JSON TERMINAL // 稀疏更新视窗 ]</span>
+                  <span className="font-black text-black uppercase">[ FULL CONFIG JSON // 完整配置代码视窗 ]</span>
                 </div>
                 <div className="flex items-center gap-1">
                   <button
                     type="button"
                     onClick={handleFormatJson}
-                    className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase"
+                    className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase cursor-pointer"
                   >
                     [ 格式化 ]
                   </button>
                   <button
                     type="button"
                     onClick={handleCopyJson}
-                    className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase"
+                    className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase cursor-pointer"
                   >
                     [ 复制 ]
                   </button>
@@ -1325,13 +1496,53 @@ export default function NodeConfigEditModal({
 
               <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
                 <textarea
-                  rows={14}
+                  rows={18}
                   value={rawJsonStr}
                   onChange={(e) => setRawJsonStr(e.target.value)}
-                  placeholder='{\n  "set": {},\n  "clear": []\n}'
-                  className="w-full p-4 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y"
+                  placeholder="在此编辑完整的任务配置 JSON 对象..."
+                  className="w-full p-4 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y select-text"
                 />
               </div>
+
+              {/* Coordinate Engine Tutorials & Field Dictionary */}
+              <CoordinateTutorialPanel
+                activeRole={entryType}
+                onApplyPreset={(presetJson) => {
+                  try {
+                    const presetObj = JSON.parse(presetJson);
+                    const currentObj = rawJsonStr.trim() ? JSON.parse(rawJsonStr) : {};
+                    if (entryType === 'sentinel') {
+                      currentObj.sentinel = { ...(currentObj.sentinel || {}), ...presetObj };
+                    } else if (entryType === 'booker') {
+                      currentObj.booker = { ...(currentObj.booker || {}), ...presetObj };
+                    } else {
+                      Object.assign(currentObj, presetObj);
+                    }
+                    setRawJsonStr(JSON.stringify(currentObj, null, 2));
+                    toast.success(`已合并预设到当前 JSON 配置`);
+                  } catch {
+                    toast.error('当前 JSON 格式有误,无法合并预设');
+                  }
+                }}
+                onInsertField={(fieldKey, fieldSample) => {
+                  try {
+                    const currentObj = rawJsonStr.trim() ? JSON.parse(rawJsonStr) : {};
+                    if (entryType === 'sentinel') {
+                      currentObj.sentinel = currentObj.sentinel || {};
+                      currentObj.sentinel[fieldKey] = fieldSample;
+                    } else if (entryType === 'booker') {
+                      currentObj.booker = currentObj.booker || {};
+                      currentObj.booker[fieldKey] = fieldSample;
+                    } else {
+                      currentObj[fieldKey] = fieldSample;
+                    }
+                    setRawJsonStr(JSON.stringify(currentObj, null, 2));
+                    toast.success(`已向 JSON 注入参数: ${fieldKey}`);
+                  } catch {
+                    toast.error('当前 JSON 格式有误,无法注入字段');
+                  }
+                }}
+              />
             </div>
           )}
         </form>
@@ -1339,7 +1550,7 @@ export default function NodeConfigEditModal({
         {/* Footer */}
         <div className="px-5 py-3 bg-neutral-200 border-t-2 border-black flex justify-between items-center shrink-0">
           <div className="text-[11px] text-neutral-600 font-bold">
-            {mode === 'visual' ? '前端将在提交时自动比对生成 set / clear 稀疏负载' : '直接提交 JSON 负载'}
+            {mode === 'visual' ? '可视化表单编辑模式' : '完整配置 JSON 代码模式(保存时将自动比对增量生效)'}
           </div>
 
           <div className="flex items-center gap-2">

+ 1 - 1
src/components/admin/node-configurations/NodeConfigTable.tsx

@@ -346,7 +346,7 @@ export default function NodeConfigTable({
                         type="button"
                         onClick={() => onEdit(item)}
                         className="px-2 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-[10px] font-black uppercase shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
-                        title="编辑配置 (稀疏更新)"
+                        title="编辑配置详情"
                       >
                         [ 编辑 ]
                       </button>

+ 239 - 41
src/components/admin/node-configurations/ProviderModal.tsx

@@ -2,12 +2,61 @@
 
 'use client';
 
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useMemo } from 'react';
 import { toast } from 'react-hot-toast';
 import { Package, CheckCircle2, ChevronDown, Sparkles, RefreshCw } from 'lucide-react';
 import { ProviderItem, ProviderCreatePayload, ProviderUpdatePayload, PluginItem } from '@/types';
 import { providerService } from '@/lib/services/providerService';
 import { pluginService } from '@/lib/services/pluginService';
+import CoordinateTutorialPanel, { ROLE_PRESETS } from './CoordinateTutorialPanel';
+
+const DEFAULT_BOOKER_JSON = JSON.stringify(
+  {
+    target_instances: 1,
+    account_source: 'order',
+    keep_alive: 60,
+    booking_cooldown: 10.0,
+    max_bookings_per_account: 1,
+    proxy_cd: 300,
+    session_max_life: 1800,
+  },
+  null,
+  2
+);
+
+const DEFAULT_SENTINEL_JSON = JSON.stringify(
+  {
+    target_instances: 1,
+    signal_ttl: 30,
+    account_source: 'built-in',
+    account_cd: 10800,
+    proxy_cd: 300,
+    session_max_life: 1800,
+    query_wait: {
+      mode: 'Random',
+      random_min: 5,
+      random_max: 15,
+    },
+  },
+  null,
+  2
+);
+
+const DEFAULT_STANDALONE_JSON = JSON.stringify(
+  {
+    login_interval: 1800,
+    session_max_life: 3600,
+    keep_alive: 60,
+    proxy_cd: 300,
+    query_wait: {
+      mode: 'Random',
+      random_min: 10,
+      random_max: 25,
+    },
+  },
+  null,
+  2
+);
 
 interface ProviderModalProps {
   isOpen: boolean;
@@ -51,11 +100,74 @@ export default function ProviderModal({
   });
 
   const [activeRoleTab, setActiveRoleTab] = useState<'booker' | 'sentinel' | 'standalone'>('booker');
-  const [bookerJson, setBookerJson] = useState('{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
-  const [sentinelJson, setSentinelJson] = useState('{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
-  const [standaloneJson, setStandaloneJson] = useState('{\n  "login_interval": 1800,\n  "session_max_life": 3600\n}');
+  const [bookerJson, setBookerJson] = useState(DEFAULT_BOOKER_JSON);
+  const [sentinelJson, setSentinelJson] = useState(DEFAULT_SENTINEL_JSON);
+  const [standaloneJson, setStandaloneJson] = useState(DEFAULT_STANDALONE_JSON);
 
   const [saving, setSaving] = useState(false);
+  const [isEditorExpanded, setIsEditorExpanded] = useState(false);
+
+  // 应用推荐预设方案
+  const handleApplyPreset = (presetJson: string) => {
+    if (activeRoleTab === 'booker') setBookerJson(presetJson);
+    else if (activeRoleTab === 'sentinel') setSentinelJson(presetJson);
+    else setStandaloneJson(presetJson);
+    toast.success(`已载入 ${activeRoleTab.toUpperCase()} 预设模板`);
+  };
+
+  // 向当前编辑器中一键注入字段
+  const handleInsertField = (fieldKey: string, fieldSample: any) => {
+    const currentStr = activeRoleTab === 'booker' ? bookerJson : activeRoleTab === 'sentinel' ? sentinelJson : standaloneJson;
+    try {
+      const parsed = currentStr.trim() ? JSON.parse(currentStr) : {};
+      parsed[fieldKey] = fieldSample;
+      const formatted = JSON.stringify(parsed, null, 2);
+      if (activeRoleTab === 'booker') setBookerJson(formatted);
+      else if (activeRoleTab === 'sentinel') setSentinelJson(formatted);
+      else setStandaloneJson(formatted);
+      toast.success(`已向 ${activeRoleTab.toUpperCase()} 注入字段: ${fieldKey}`);
+    } catch {
+      toast.error('当前 JSON 格式有误,无法自动插入。请先修复语法错误');
+    }
+  };
+
+  // 格式化当前角色配置 JSON
+  const handleFormatRoleJson = (role: 'booker' | 'sentinel' | 'standalone') => {
+    const currentStr = role === 'booker' ? bookerJson : role === 'sentinel' ? sentinelJson : standaloneJson;
+    try {
+      const parsed = JSON.parse(currentStr);
+      const formatted = JSON.stringify(parsed, null, 2);
+      if (role === 'booker') setBookerJson(formatted);
+      else if (role === 'sentinel') setSentinelJson(formatted);
+      else setStandaloneJson(formatted);
+      toast.success(`${role.toUpperCase()} 配置 JSON 已格式化`);
+    } catch {
+      toast.error(`${role.toUpperCase()} 配置 JSON 语法错误,无法格式化`);
+    }
+  };
+
+  // 复制当前角色配置 JSON
+  const handleCopyRoleJson = (role: 'booker' | 'sentinel' | 'standalone') => {
+    const currentStr = role === 'booker' ? bookerJson : role === 'sentinel' ? sentinelJson : standaloneJson;
+    if (!currentStr.trim()) {
+      toast.error('当前配置内容为空');
+      return;
+    }
+    navigator.clipboard.writeText(currentStr);
+    toast.success(`${role.toUpperCase()} 配置已复制到剪贴板`);
+  };
+
+  // 实时检测当前角色 JSON 语法有效性
+  const isCurrentJsonValid = useMemo(() => {
+    const currentStr = activeRoleTab === 'booker' ? bookerJson : activeRoleTab === 'sentinel' ? sentinelJson : standaloneJson;
+    if (!currentStr.trim()) return true;
+    try {
+      JSON.parse(currentStr);
+      return true;
+    } catch {
+      return false;
+    }
+  }, [activeRoleTab, bookerJson, sentinelJson, standaloneJson]);
 
   // 加载云端插件中枢插件列表
   useEffect(() => {
@@ -116,9 +228,9 @@ export default function ProviderModal({
         standalone: anyConfigured ? hasStandalone : false,
       });
 
-      setBookerJson(rt.booker ? JSON.stringify(rt.booker, null, 2) : '{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
-      setSentinelJson(rt.sentinel ? JSON.stringify(rt.sentinel, null, 2) : '{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
-      setStandaloneJson(rt.standalone ? JSON.stringify(rt.standalone, null, 2) : '{\n  "login_interval": 1800,\n  "session_max_life": 3600\n}');
+      setBookerJson(rt.booker ? JSON.stringify(rt.booker, null, 2) : DEFAULT_BOOKER_JSON);
+      setSentinelJson(rt.sentinel ? JSON.stringify(rt.sentinel, null, 2) : DEFAULT_SENTINEL_JSON);
+      setStandaloneJson(rt.standalone ? JSON.stringify(rt.standalone, null, 2) : DEFAULT_STANDALONE_JSON);
 
       if (hasBooker) setActiveRoleTab('booker');
       else if (hasSentinel) setActiveRoleTab('sentinel');
@@ -139,9 +251,9 @@ export default function ProviderModal({
         standalone: false,
       });
       setActiveRoleTab('booker');
-      setBookerJson('{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
-      setSentinelJson('{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
-      setStandaloneJson('{\n  "login_interval": 1800,\n  "session_max_life": 3600\n}');
+      setBookerJson(DEFAULT_BOOKER_JSON);
+      setSentinelJson(DEFAULT_SENTINEL_JSON);
+      setStandaloneJson(DEFAULT_STANDALONE_JSON);
     }
   }, [provider, isOpen]);
 
@@ -309,7 +421,7 @@ export default function ProviderModal({
 
   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-3xl overflow-hidden flex flex-col max-h-[90vh] animate-in zoom-in-95 duration-150">
+      <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-4xl lg:max-w-5xl overflow-hidden flex flex-col max-h-[92vh] 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">
@@ -607,49 +719,135 @@ export default function ProviderModal({
               })}
             </div>
 
+            {/* Quick Preset Toolbar */}
+            {supportedRoles[activeRoleTab] && (
+              <div className="flex flex-wrap items-center gap-1.5 px-3 py-2 bg-neutral-100 border-2 border-black border-b-0 text-xs">
+                <span className="font-black text-black flex items-center gap-1 text-[11px] uppercase shrink-0">
+                  <Sparkles className="w-3.5 h-3.5 text-amber-500" />
+                  <span>推荐配置方案:</span>
+                </span>
+                <div className="flex flex-wrap items-center gap-1.5">
+                  {ROLE_PRESETS[activeRoleTab]?.map((preset) => (
+                    <button
+                      key={preset.id}
+                      type="button"
+                      onClick={() => handleApplyPreset(JSON.stringify(preset.jsonObj, null, 2))}
+                      className="px-2.5 py-0.5 bg-white hover:bg-amber-300 text-neutral-800 hover:text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1 cursor-pointer"
+                      title={preset.desc}
+                    >
+                      <span>{preset.name}</span>
+                    </button>
+                  ))}
+                </div>
+              </div>
+            )}
+
             {/* JSON Code Window */}
             {!supportedRoles[activeRoleTab] ? (
-              <div className="p-6 bg-neutral-100 border-2 border-black text-center space-y-2">
+              <div className="p-8 bg-neutral-100 border-2 border-black text-center space-y-3">
                 <div className="text-neutral-500 font-bold text-xs">
                   当前服务商模板未开启对 <span className="text-black font-black uppercase">[{activeRoleTab}]</span> 角色的支持
                 </div>
                 <button
                   type="button"
                   onClick={() => toggleRoleSupport(activeRoleTab)}
-                  className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
+                  className="px-4 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
                 >
                   + 立即开启对 [{activeRoleTab.toUpperCase()}] 的支持并编辑模板
                 </button>
               </div>
             ) : (
-              <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
-                {activeRoleTab === 'booker' && (
-                  <textarea
-                    rows={6}
-                    value={bookerJson}
-                    onChange={(e) => setBookerJson(e.target.value)}
-                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y"
-                    placeholder="{}"
-                  />
-                )}
-                {activeRoleTab === 'sentinel' && (
-                  <textarea
-                    rows={6}
-                    value={sentinelJson}
-                    onChange={(e) => setSentinelJson(e.target.value)}
-                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-emerald-300 resize-y"
-                    placeholder="{}"
-                  />
-                )}
-                {activeRoleTab === 'standalone' && (
-                  <textarea
-                    rows={6}
-                    value={standaloneJson}
-                    onChange={(e) => setStandaloneJson(e.target.value)}
-                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-cyan-300 resize-y"
-                    placeholder="{}"
-                  />
-                )}
+              <div className="space-y-0">
+                {/* Editor Header Toolbar */}
+                <div className="flex flex-wrap items-center justify-between px-3 py-2 bg-neutral-200 border-2 border-black border-b-0 gap-2">
+                  <div className="flex items-center gap-2">
+                    <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
+                    <span className="font-black text-black uppercase tracking-wider text-[11px]">
+                      [ {activeRoleTab.toUpperCase()} TEMPLATE // 角色配置代码编辑器 ]
+                    </span>
+                    {isCurrentJsonValid ? (
+                      <span className="text-[10px] font-bold text-emerald-800 bg-emerald-100 border border-emerald-500 px-1.5 py-0.5">
+                        ✓ 语法正常
+                      </span>
+                    ) : (
+                      <span className="text-[10px] font-bold text-red-800 bg-red-100 border border-red-500 px-1.5 py-0.5 animate-pulse">
+                        ✕ 语法错误
+                      </span>
+                    )}
+                  </div>
+                  <div className="flex items-center gap-1.5">
+                    <button
+                      type="button"
+                      onClick={() => setIsEditorExpanded(!isEditorExpanded)}
+                      className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase cursor-pointer"
+                      title={isEditorExpanded ? '还原默认高度' : '放大编辑区域'}
+                    >
+                      {isEditorExpanded ? '[ 收缩高度 ]' : '[ 放大高度 ]'}
+                    </button>
+                    <button
+                      type="button"
+                      onClick={() => handleFormatRoleJson(activeRoleTab)}
+                      className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase cursor-pointer"
+                      title="格式化当前角色配置 JSON"
+                    >
+                      [ 格式化 ]
+                    </button>
+                    <button
+                      type="button"
+                      onClick={() => handleCopyRoleJson(activeRoleTab)}
+                      className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase cursor-pointer"
+                      title="复制当前角色配置 JSON"
+                    >
+                      [ 复制 ]
+                    </button>
+                  </div>
+                </div>
+
+                <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
+                  {activeRoleTab === 'booker' && (
+                    <textarea
+                      rows={isEditorExpanded ? 24 : 14}
+                      value={bookerJson}
+                      onChange={(e) => setBookerJson(e.target.value)}
+                      className={`w-full p-4 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y select-text transition-all ${
+                        isEditorExpanded ? 'min-h-[460px]' : 'min-h-[280px]'
+                      }`}
+                      placeholder="{}"
+                      spellCheck={false}
+                    />
+                  )}
+                  {activeRoleTab === 'sentinel' && (
+                    <textarea
+                      rows={isEditorExpanded ? 24 : 14}
+                      value={sentinelJson}
+                      onChange={(e) => setSentinelJson(e.target.value)}
+                      className={`w-full p-4 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-emerald-300 resize-y select-text transition-all ${
+                        isEditorExpanded ? 'min-h-[460px]' : 'min-h-[280px]'
+                      }`}
+                      placeholder="{}"
+                      spellCheck={false}
+                    />
+                  )}
+                  {activeRoleTab === 'standalone' && (
+                    <textarea
+                      rows={isEditorExpanded ? 24 : 14}
+                      value={standaloneJson}
+                      onChange={(e) => setStandaloneJson(e.target.value)}
+                      className={`w-full p-4 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-cyan-300 resize-y select-text transition-all ${
+                        isEditorExpanded ? 'min-h-[460px]' : 'min-h-[280px]'
+                      }`}
+                      placeholder="{}"
+                      spellCheck={false}
+                    />
+                  )}
+                </div>
+
+                {/* Coordinate Engine Tutorials & Field Dictionary */}
+                <CoordinateTutorialPanel
+                  activeRole={activeRoleTab}
+                  onApplyPreset={handleApplyPreset}
+                  onInsertField={handleInsertField}
+                />
               </div>
             )}
           </div>

+ 1 - 1
src/components/admin/orders/OrderEditModal.tsx

@@ -239,7 +239,7 @@ export default function OrderEditModal({ isOpen, onClose, order, onSubmit }: Ord
                     <option value="">-- 请选择合作中介机构档案 --</option>
                     {agencies.map((agency) => (
                       <option key={agency.id} value={agency.id}>
-                        {agency.name} ({agency.code || agency.id}) - 底价 ¥{(agency.min_floor_price / 100).toFixed(2)} - 拓展人: {agency.owner_id || '无'}
+                        {agency.name} ({(agency as any).code || agency.id}) - 底价 ¥{(agency.min_floor_price / 100).toFixed(2)} - 拓展人: {agency.owner_id || '无'}
                       </option>
                     ))}
                   </select>

+ 12 - 7
src/components/admin/payments/ProviderModal.tsx

@@ -13,6 +13,9 @@ import {
 import { Provider } from '@/types';
 import { toast } from 'react-hot-toast';
 import { DEFAULT_PAYMENT_ICONS, getPaymentProviderIcon } from './paymentIcons';
+import { ImageUploadField } from '@/components/common/ImageUploadField';
+
+
 
 interface ProviderModalProps {
   isOpen: boolean;
@@ -255,16 +258,18 @@ export default function ProviderModal({ isOpen, onClose, provider, onSubmit }: P
           </div>
 
           <div className="space-y-1">
-            <label className="block text-xs font-bold text-black uppercase">[ 05 // 图标 URL 或 Data URI ]:</label>
-            <input
-              type="text"
-              placeholder="默认自动匹配内置矢量图标,也可填写自定义 URL"
-              value={form.icon}
-              onChange={(e) => setForm({ ...form, icon: e.target.value })}
-              className="w-full border-2 border-black bg-neutral-50 p-2 text-xs font-mono focus:bg-white outline-none text-black shadow-[2px_2px_0px_#000]"
+            <ImageUploadField
+              label="[ 05 // 渠道图标(本地上传至 R2) ]:"
+              value={form.icon || ''}
+              onChange={(url) => setForm({ ...form, icon: url })}
+              prefix="icons"
+              aspectRatio="1:1"
+              compact={true}
+              helperText="选择本地 PNG, SVG, JPG 图标 (最大 1MB),留空默认使用内置矢量图标"
             />
           </div>
 
+
           <div className="pt-2 flex justify-end gap-3 border-t-2 border-dashed border-neutral-300">
             <button
               type="button"

+ 564 - 104
src/components/admin/products/ProductModal.tsx

@@ -24,10 +24,16 @@ import {
   HelpCircle,
   Compass,
 } from 'lucide-react';
-import { SchemaItem, ProductTutorialConfig, TutorialStep, ProductCardConfig } from '@/types';
+import { SchemaItem, ProductTutorialConfig, TutorialStep, ProductCardConfig, PluginItem } from '@/types';
+
 import { toast } from 'react-hot-toast';
-import { productService } from '@/lib/services';
+import { productService, pluginService } from '@/lib/services';
 import ProductTutorialBanner from '@/components/common/ProductTutorialBanner';
+import { ImageUploadField } from '@/components/common/ImageUploadField';
+
+
+
+
 import ServicePoster from '@/components/services/ServicePoster';
 
 interface ProductModalProps {
@@ -38,6 +44,87 @@ interface ProductModalProps {
   onManageSchemas: () => void;
 }
 
+const formatCapitalized = (val: string): string => {
+  if (!val) return '';
+  return val
+    .trim()
+    .split(/\s+/)
+    .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
+    .join(' ');
+};
+
+const PRESET_COUNTRIES = [
+  'France',
+  'United Kingdom',
+  'United States',
+  'Germany',
+  'Italy',
+  'Spain',
+  'Switzerland',
+  'Netherlands',
+  'Ireland',
+  'Greece',
+  'Portugal',
+  'Austria',
+  'Belgium',
+  'Sweden',
+  'Norway',
+  'Denmark',
+  'Finland',
+  'Poland',
+  'Czech Republic',
+  'Hungary',
+  'Iceland',
+  'Japan',
+  'South Korea',
+  'Singapore',
+  'Australia',
+  'New Zealand',
+  'Canada',
+  'China',
+  'Thailand',
+  'Malaysia',
+  'United Arab Emirates',
+];
+
+const COUNTRY_CITY_MAP: Record<string, string[]> = {
+  France: ['Paris', 'Marseille', 'Lyon', 'Nice', 'Bordeaux', 'Toulouse'],
+  'United Kingdom': ['London', 'Manchester', 'Edinburgh', 'Belfast', 'Birmingham', 'Cardiff'],
+  'United States': ['New York', 'Los Angeles', 'San Francisco', 'Chicago', 'Washington', 'Boston', 'Seattle', 'Atlanta', 'Dallas', 'Houston', 'Miami'],
+  Germany: ['Berlin', 'Frankfurt', 'Munich', 'Hamburg', 'Cologne', 'Dusseldorf'],
+  Italy: ['Rome', 'Milan', 'Florence', 'Naples', 'Venice'],
+  Spain: ['Madrid', 'Barcelona', 'Valencia', 'Seville'],
+  Switzerland: ['Zurich', 'Geneva', 'Bern', 'Basel'],
+  Netherlands: ['Amsterdam', 'Rotterdam', 'The Hague', 'Utrecht'],
+  Ireland: ['Dublin', 'Cork', 'Galway', 'Limerick'],
+  China: ['Beijing', 'Shanghai', 'Guangzhou', 'Shenzhen', 'Chengdu', 'Wuhan', 'Hangzhou', 'Nanjing', 'Shenyang', 'Jinan', 'Kunming', 'Xi\'an', 'Chongqing', 'Changsha', 'Fuzhou', 'Hong Kong'],
+  Japan: ['Tokyo', 'Osaka', 'Nagoya', 'Fukuoka', 'Sapporo'],
+  'South Korea': ['Seoul', 'Busan', 'Incheon'],
+  Singapore: ['Singapore'],
+  Australia: ['Sydney', 'Melbourne', 'Brisbane', 'Perth', 'Adelaide', 'Canberra'],
+  'New Zealand': ['Auckland', 'Wellington', 'Christchurch'],
+  Canada: ['Toronto', 'Vancouver', 'Montreal', 'Ottawa', 'Calgary', 'Edmonton'],
+  Greece: ['Athens', 'Thessaloniki'],
+  Portugal: ['Lisbon', 'Porto'],
+  Austria: ['Vienna', 'Salzburg'],
+  Belgium: ['Brussels', 'Antwerp'],
+  Sweden: ['Stockholm', 'Gothenburg'],
+  Norway: ['Oslo', 'Bergen'],
+  Denmark: ['Copenhagen', 'Aarhus'],
+  Finland: ['Helsinki', 'Tampere'],
+  Poland: ['Warsaw', 'Krakow'],
+  'Czech Republic': ['Prague', 'Brno'],
+  Hungary: ['Budapest'],
+  Iceland: ['Reykjavik'],
+  'United Arab Emirates': ['Dubai', 'Abu Dhabi'],
+  Thailand: ['Bangkok', 'Chiang Mai', 'Phuket'],
+  Malaysia: ['Kuala Lumpur', 'Penang'],
+};
+
+const PRESET_CITIES = Array.from(
+  new Set(Object.values(COUNTRY_CITY_MAP).flat())
+).sort((a, b) => a.localeCompare(b));
+
 const POPULAR_COUNTRIES = [
   'France',
   'Germany',
@@ -154,6 +241,8 @@ export default function ProductModal({
   const [schemas, setSchemas] = useState<SchemaItem[]>([]);
   const [selectedSchemaDetail, setSelectedSchemaDetail] = useState<any | null>(null);
   const [loadingSchemaDetail, setLoadingSchemaDetail] = useState(false);
+  const [plugins, setPlugins] = useState<PluginItem[]>([]);
+  const [loadingPlugins, setLoadingPlugins] = useState(false);
 
   const [form, setForm] = useState({
     title: '',
@@ -167,8 +256,28 @@ export default function ProductModal({
     recommend_score: 0,
     enabled: 1,
     schema_id: 0,
+    plugin_id: 0,
+    plugin_name: '',
+    developer_id: '',
   });
 
+  const [isCustomCountry, setIsCustomCountry] = useState(false);
+  const [isCustomCity, setIsCustomCity] = useState(false);
+  const [isCustomVisaType, setIsCustomVisaType] = useState(false);
+
+  const currentSuggestedCities = useMemo(() => {
+    if (!form.country) return [];
+    const matchedKey = Object.keys(COUNTRY_CITY_MAP).find(
+      (k) => k.toLowerCase() === form.country.toLowerCase()
+    );
+    return matchedKey ? COUNTRY_CITY_MAP[matchedKey] : [];
+  }, [form.country]);
+
+  const otherCities = useMemo(() => {
+    const suggestedSet = new Set(currentSuggestedCities.map((c) => c.toLowerCase()));
+    return PRESET_CITIES.filter((c) => !suggestedSet.has(c.toLowerCase()));
+  }, [currentSuggestedCities]);
+
   // 使用教程配置状态
   const [tutorialConfig, setTutorialConfig] = useState<ProductTutorialConfig>({
     enabled: false,
@@ -202,9 +311,51 @@ export default function ProductModal({
   useEffect(() => {
     if (isOpen) {
       fetchSchemas();
+      fetchPlugins();
     }
   }, [isOpen]);
 
+  const fetchPlugins = async () => {
+    setLoadingPlugins(true);
+    try {
+      const res = await pluginService.getList({ page: 1, page_size: 100 });
+      const rawList =
+        res?.data?.list ??
+        res?.data?.items ??
+        (Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : []));
+      const items: PluginItem[] = Array.isArray(rawList) ? rawList : [];
+      setPlugins(items);
+
+      // 如果当前表单已有 plugin_id 或 plugin_name,自动补齐对应的插件与开发者ID
+      setForm((prev) => {
+        if (!prev.plugin_id && prev.plugin_name) {
+          const matched = items.find((p) => p.name === prev.plugin_name);
+          if (matched) {
+            return {
+              ...prev,
+              plugin_id: matched.id,
+              developer_id: prev.developer_id || matched.developer_id || '',
+            };
+          }
+        } else if (prev.plugin_id && !prev.developer_id) {
+          const matched = items.find((p) => p.id === prev.plugin_id);
+          if (matched?.developer_id) {
+            return {
+              ...prev,
+              developer_id: matched.developer_id,
+            };
+          }
+        }
+        return prev;
+      });
+    } catch (e) {
+      console.error('Failed to load plugins in ProductModal:', e);
+      setPlugins([]);
+    } finally {
+      setLoadingPlugins(false);
+    }
+  };
+
   const fetchSchemas = async () => {
     try {
       const res = await productService.listSchemas();
@@ -230,8 +381,26 @@ export default function ProductModal({
           recommend_score: product.recommend_score || 0,
           enabled: product.enabled !== undefined ? Number(product.enabled) : 1,
           schema_id: product.schema_id || 0,
+          plugin_id: product.plugin_id || 0,
+          plugin_name: product.plugin_name || '',
+          developer_id: product.developer_id || '',
         });
 
+        const isStandardCountry = PRESET_COUNTRIES.some(
+          (c) => c.toLowerCase() === (product.country || '').toLowerCase()
+        );
+        setIsCustomCountry(Boolean(product.country) && !isStandardCountry);
+
+        const isStandardCity = PRESET_CITIES.some(
+          (c) => c.toLowerCase() === (product.city || '').toLowerCase()
+        );
+        setIsCustomCity(Boolean(product.city) && !isStandardCity);
+
+        setIsCustomVisaType(
+          Boolean(product.visa_type) &&
+            !VISA_OPTIONS.some((o) => o.value.toLowerCase() === (product.visa_type || '').toLowerCase())
+        );
+
         if (product.extra_fields?.tutorial) {
           const t = product.extra_fields.tutorial;
           setTutorialConfig({
@@ -270,12 +439,13 @@ export default function ProductModal({
             poster_sub: c.poster_sub || '',
             poster_tag: c.poster_tag || '',
             poster_accent_color: c.poster_accent_color || '#2563eb',
-            official_tag: c.official_tag !== undefined ? c.official_tag : '官方直连',
-            status_tag: c.status_tag !== undefined ? c.status_tag : 'New',
+            official_tag: c.official_tag || '',
+            status_tag: c.status_tag || '',
             pill_text: c.pill_text || '',
             sales_text: c.sales_text || '',
-            buy_button_text: c.buy_button_text || '立即购买',
-            sublink_text: c.sublink_text || '查阅服务细则 →',
+            status_text: c.status_text || '',
+            buy_button_text: c.buy_button_text || '',
+            sublink_text: c.sublink_text || '',
           });
         } else {
           setCardConfig({
@@ -285,12 +455,13 @@ export default function ProductModal({
             poster_sub: '',
             poster_tag: '',
             poster_accent_color: '#2563eb',
-            official_tag: '官方直连',
-            status_tag: 'New',
+            official_tag: '',
+            status_tag: '',
             pill_text: '',
             sales_text: '',
-            buy_button_text: '立即购买',
-            sublink_text: '查阅服务细则 →',
+            status_text: '',
+            buy_button_text: '',
+            sublink_text: '',
           });
         }
 
@@ -312,7 +483,13 @@ export default function ProductModal({
           recommend_score: 10,
           enabled: 1,
           schema_id: 0,
+          plugin_id: 0,
+          plugin_name: '',
+          developer_id: '',
         });
+        setIsCustomCountry(false);
+        setIsCustomCity(false);
+        setIsCustomVisaType(false);
         setTutorialConfig({
           enabled: false,
           display_type: 'both',
@@ -365,6 +542,26 @@ export default function ProductModal({
     fetchSchemaDetail(newSchemaId);
   };
 
+  const handlePluginChange = (pluginIdNum: number) => {
+    if (!pluginIdNum) {
+      setForm((prev) => ({
+        ...prev,
+        plugin_id: 0,
+        plugin_name: '',
+      }));
+      return;
+    }
+    const found = plugins.find((p) => p.id === pluginIdNum);
+    if (found) {
+      setForm((prev) => ({
+        ...prev,
+        plugin_id: found.id,
+        plugin_name: found.name,
+        developer_id: found.developer_id || '',
+      }));
+    }
+  };
+
   const handleAddStep = () => {
     setTutorialConfig((prev) => ({
       ...prev,
@@ -414,10 +611,16 @@ export default function ProductModal({
     try {
       const payload: any = {
         ...form,
+        country: formatCapitalized(form.country),
+        city: formatCapitalized(form.city),
+        visa_type: formatCapitalized(form.visa_type),
         price_amount: Math.round(Number(form.price_amount) * 100),
         recommend_score: Number(form.recommend_score) || 0,
         enabled: Number(form.enabled),
         schema_id: form.schema_id > 0 ? Number(form.schema_id) : null,
+        plugin_id: form.plugin_id > 0 ? Number(form.plugin_id) : null,
+        plugin_name: form.plugin_name.trim() || null,
+        developer_id: form.developer_id.trim() || null,
         extra_fields: {
           ...(product?.extra_fields || {}),
           tutorial: tutorialConfig.enabled ? tutorialConfig : null,
@@ -547,60 +750,179 @@ export default function ProductModal({
                 </div>
               </div>
 
-              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+              <div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
+                {/* 1. 国家 / 地区 */}
                 <div className="space-y-1">
-                  <label className="font-bold text-black uppercase block">
-                    国家 / 地区 <span className="text-black">*</span>
-                  </label>
-                  <input
-                    type="text"
-                    required
-                    placeholder="如: France"
-                    className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
-                    value={form.country}
-                    onChange={(e) => setForm({ ...form, country: e.target.value })}
-                  />
+                  <div className="flex items-center justify-between">
+                    <label className="font-bold text-black uppercase block">
+                      国家 / 地区 <span className="text-black">*</span>
+                    </label>
+                    <button
+                      type="button"
+                      onClick={() => setIsCustomCountry(!isCustomCountry)}
+                      className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                    >
+                      {isCustomCountry ? '选择预设' : '手工输入'}
+                    </button>
+                  </div>
+                  {isCustomCountry ? (
+                    <input
+                      type="text"
+                      required
+                      placeholder="如: France"
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
+                      value={form.country}
+                      onChange={(e) => setForm({ ...form, country: e.target.value })}
+                      onBlur={(e) => setForm({ ...form, country: formatCapitalized(e.target.value) })}
+                    />
+                  ) : (
+                    <select
+                      required
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-bold text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000] cursor-pointer"
+                      value={form.country}
+                      onChange={(e) => {
+                        if (e.target.value === '__custom__') {
+                          setIsCustomCountry(true);
+                        } else {
+                          const newCountry = e.target.value;
+                          const recommendedCities = COUNTRY_CITY_MAP[newCountry] || [];
+                          setForm((prev) => ({
+                            ...prev,
+                            country: newCountry,
+                            city:
+                              recommendedCities.length > 0 && !recommendedCities.includes(prev.city)
+                                ? recommendedCities[0]
+                                : prev.city,
+                          }));
+                        }
+                      }}
+                    >
+                      <option value="" disabled>-- 请选择国家/地区 --</option>
+                      {PRESET_COUNTRIES.map((ctry) => (
+                        <option key={ctry} value={ctry}>
+                          {ctry}
+                        </option>
+                      ))}
+                      {!PRESET_COUNTRIES.some((c) => c.toLowerCase() === (form.country || '').toLowerCase()) && form.country && (
+                        <option value={form.country}>
+                          {form.country} (当前配置)
+                        </option>
+                      )}
+                      <option value="__custom__">⚙️ 其他国家 (手工录入)...</option>
+                    </select>
+                  )}
                 </div>
+
+                {/* 2. 城市 / 签证中心 */}
                 <div className="space-y-1">
-                  <label className="font-bold text-black uppercase block">
-                    城市 / 签证中心
-                  </label>
-                  <input
-                    type="text"
-                    placeholder="如: Paris / London / Shanghai"
-                    className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
-                    value={form.city}
-                    onChange={(e) => setForm({ ...form, city: e.target.value })}
-                  />
+                  <div className="flex items-center justify-between">
+                    <label className="font-bold text-black uppercase block">
+                      城市 / 签证中心 <span className="text-black">*</span>
+                    </label>
+                    <button
+                      type="button"
+                      onClick={() => setIsCustomCity(!isCustomCity)}
+                      className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                    >
+                      {isCustomCity ? '选择预设' : '手工输入'}
+                    </button>
+                  </div>
+                  {isCustomCity ? (
+                    <input
+                      type="text"
+                      placeholder="如: Paris / London / Shanghai"
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
+                      value={form.city}
+                      onChange={(e) => setForm({ ...form, city: e.target.value })}
+                      onBlur={(e) => setForm({ ...form, city: formatCapitalized(e.target.value) })}
+                    />
+                  ) : (
+                    <select
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-bold text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000] cursor-pointer"
+                      value={form.city}
+                      onChange={(e) => {
+                        if (e.target.value === '__custom__') {
+                          setIsCustomCity(true);
+                        } else {
+                          setForm({ ...form, city: e.target.value });
+                        }
+                      }}
+                    >
+                      <option value="">-- 请选择城市/签证中心 --</option>
+                      {currentSuggestedCities.length > 0 && (
+                        <optgroup label={`建议中心 (${form.country})`}>
+                          {currentSuggestedCities.map((city) => (
+                            <option key={city} value={city}>
+                              {city}
+                            </option>
+                          ))}
+                        </optgroup>
+                      )}
+                      <optgroup label="全部常用城市">
+                        {otherCities.map((city) => (
+                          <option key={city} value={city}>
+                            {city}
+                          </option>
+                        ))}
+                      </optgroup>
+                      {!PRESET_CITIES.some((c) => c.toLowerCase() === (form.city || '').toLowerCase()) && form.city && (
+                        <option value={form.city}>
+                          {form.city} (当前配置)
+                        </option>
+                      )}
+                      <option value="__custom__">⚙️ 其他城市 (手工录入)...</option>
+                    </select>
+                  )}
                 </div>
-              </div>
 
-              {/* 签证类型选择器 */}
-              <div className="space-y-1.5">
-                <label className="font-bold text-black uppercase block">
-                  签证业务类型
-                </label>
-                <div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
-                  {VISA_OPTIONS.map((opt) => {
-                    const isSelected = form.visa_type === opt.value;
-                    return (
-                      <div
-                        key={opt.value}
-                        onClick={() => setForm({ ...form, visa_type: opt.value })}
-                        className={`p-2 border-2 border-black cursor-pointer text-left transition ${
-                          isSelected
-                            ? 'bg-amber-300 shadow-[2px_2px_0px_#000]'
-                            : 'bg-white hover:bg-neutral-100 shadow-[1px_1px_0px_#000]'
-                        }`}
-                      >
-                        <div className="text-xs font-black text-black flex items-center justify-between">
-                          <span>{opt.label}</span>
-                          {isSelected && <Check size={12} />}
-                        </div>
-                        <div className="text-[10px] text-neutral-500 font-sans mt-0.5">{opt.desc}</div>
-                      </div>
-                    );
-                  })}
+                {/* 3. 签证业务类型 */}
+                <div className="space-y-1">
+                  <div className="flex items-center justify-between">
+                    <label className="font-bold text-black uppercase block">
+                      签证业务类型 <span className="text-black">*</span>
+                    </label>
+                    <button
+                      type="button"
+                      onClick={() => setIsCustomVisaType(!isCustomVisaType)}
+                      className="text-[10px] text-neutral-500 hover:text-black underline cursor-pointer"
+                    >
+                      {isCustomVisaType ? '选择预设选项' : '自定义输入'}
+                    </button>
+                  </div>
+                  {isCustomVisaType ? (
+                    <input
+                      type="text"
+                      placeholder="如: Tourist / Business"
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
+                      value={form.visa_type}
+                      onChange={(e) => setForm({ ...form, visa_type: e.target.value })}
+                      onBlur={(e) => setForm({ ...form, visa_type: formatCapitalized(e.target.value) })}
+                    />
+                  ) : (
+                    <select
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-bold text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000] cursor-pointer"
+                      value={form.visa_type}
+                      onChange={(e) => {
+                        if (e.target.value === '__custom__') {
+                          setIsCustomVisaType(true);
+                        } else {
+                          setForm({ ...form, visa_type: e.target.value });
+                        }
+                      }}
+                    >
+                      {VISA_OPTIONS.map((opt) => (
+                        <option key={opt.value} value={opt.value}>
+                          {opt.label} ({opt.value} - {opt.desc})
+                        </option>
+                      ))}
+                      {!VISA_OPTIONS.some((o) => o.value === form.visa_type) && form.visa_type && (
+                        <option value={form.visa_type}>
+                          {form.visa_type} (当前配置)
+                        </option>
+                      )}
+                      <option value="__custom__">⚙️ 其他类型 (手工录入)...</option>
+                    </select>
+                  )}
                 </div>
               </div>
             </div>
@@ -777,13 +1099,123 @@ export default function ProductModal({
               )}
             </div>
 
-            {/* 5. 用户使用教程与操作指引配置 (新特性) */}
+            {/* 5. 履约插件与技术分成归属 */}
+            <div className="bg-emerald-50/60 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-3">
+              <div className="flex items-center justify-between border-b-2 border-black pb-1">
+                <div className="flex items-center gap-1.5">
+                  <Cpu size={14} className="text-black" />
+                  <span className="text-[10px] font-black uppercase text-black">
+                    [ 05 // 履约插件与技术分成归属 (20% 技术版权) ]
+                  </span>
+                </div>
+                <span className="text-[10px] font-bold text-neutral-600 bg-white border border-black px-1.5 py-0.2">
+                  自动核算入账至自然人
+                </span>
+              </div>
+
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                {/* 绑定执行插件 */}
+                <div className="space-y-1.5">
+                  <label className="font-bold text-black uppercase block text-xs">
+                    绑定底层执行插件
+                  </label>
+                  <select
+                    className="w-full border-2 border-black bg-white px-2 py-2 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000] focus:bg-amber-50 disabled:bg-neutral-100"
+                    value={form.plugin_id || 0}
+                    onChange={(e) => handlePluginChange(Number(e.target.value))}
+                    disabled={loadingPlugins}
+                  >
+                    {loadingPlugins ? (
+                      <option value={0}>⏳ 正在加载插件列表...</option>
+                    ) : (
+                      <>
+                        <option value={0}>-- 暂不绑定自动化插件 (未指定) --</option>
+                        {plugins.map((pl) => (
+                          <option key={pl.id} value={pl.id}>
+                            {pl.name} ({pl.display_name || '未命名'}{pl.developer_id ? ` · 维护者: ${pl.developer_id}` : ''})
+                          </option>
+                        ))}
+                      </>
+                    )}
+                  </select>
+                  <p className="text-[10px] text-neutral-500 font-sans">
+                    选择负责处理该服务的自动化抢号或抓取插件,将按其维护者自动计提分成。
+                  </p>
+                </div>
+
+                {/* 技术分成归属人 */}
+                <div className="space-y-1.5">
+                  <div className="flex items-center justify-between">
+                    <label className="font-bold text-black uppercase block text-xs">
+                      技术分成归属人 (USER ID)
+                    </label>
+                    {form.plugin_id > 0 && (
+                      <button
+                        type="button"
+                        onClick={() => {
+                          const pl = plugins.find((p) => p.id === form.plugin_id);
+                          if (pl?.developer_id) {
+                            setForm((prev) => ({ ...prev, developer_id: pl.developer_id || '' }));
+                            toast.success(`已重置为插件默认开发者: ${pl.developer_id}`);
+                          }
+                        }}
+                        className="text-[10px] text-blue-700 hover:underline font-mono"
+                      >
+                        [ 重置为插件默认 ]
+                      </button>
+                    )}
+                  </div>
+                  <input
+                    type="text"
+                    placeholder="输入用户ID,如 usr-c1f46c54"
+                    className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-mono text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
+                    value={form.developer_id}
+                    onChange={(e) => setForm({ ...form, developer_id: e.target.value })}
+                  />
+                  <p className="text-[10px] text-neutral-500 font-sans">
+                    默认继承所选插件的开发管理者,支持特殊情况下手动输入其它自然人用户ID覆盖。
+                  </p>
+                </div>
+              </div>
+
+              {/* 插件关联与分润预览卡片 */}
+              {form.plugin_id > 0 && (() => {
+                const currentPl = plugins.find((p) => p.id === form.plugin_id);
+                return (
+                  <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000] text-xs font-mono space-y-1.5">
+                    <div className="flex flex-wrap items-center justify-between gap-1">
+                      <div className="flex items-center gap-1.5">
+                        <span className="font-bold text-emerald-800">
+                          🔌 已关联插件: {currentPl?.name}
+                        </span>
+                        <span className="text-[10px] bg-neutral-100 border border-neutral-300 px-1 py-0.5">
+                          {currentPl?.display_name}
+                        </span>
+                      </div>
+                      <span className="text-[10px] font-bold text-purple-700 bg-purple-50 border border-purple-200 px-1.5 py-0.5">
+                        分成比例: 20% 净利润技术版权
+                      </span>
+                    </div>
+                    <div className="text-[11px] text-neutral-600 flex items-center gap-2">
+                      <span>插件默认维护者: <strong className="text-black">{currentPl?.developer_id || '未配置'}</strong></span>
+                      {form.developer_id && form.developer_id !== currentPl?.developer_id && (
+                        <span className="text-amber-700 font-bold">
+                          (已特殊覆盖为: {form.developer_id})
+                        </span>
+                      )}
+                    </div>
+                  </div>
+                );
+              })()}
+            </div>
+
+            {/* 6. 用户使用教程与操作指引配置 (新特性) */}
             <div className="bg-sky-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-3.5">
               <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-2">
                 <div className="flex items-center gap-2">
                   <BookOpen size={16} className="text-black" />
                   <span className="font-black text-black text-xs uppercase">
-                    [ 05 // 用户使用教程与操作指引配置 (可选) ]
+                    [ 06 // 用户使用教程与操作指引配置 (可选) ]
                   </span>
                 </div>
                 <label className="flex items-center gap-2 cursor-pointer font-bold text-xs select-none">
@@ -830,22 +1262,22 @@ export default function ProductModal({
                         {
                           type: 'both',
                           label: '⚡️ 弹窗 + 外部超链接 (推荐)',
-                          desc: '既可弹窗看步骤,又可点外链跳文档',
+                          desc: '既可弹窗查阅步骤,又可直接点击跳转外部官方文档',
                         },
                         {
                           type: 'modal',
-                          label: '💬 弹出对话框类型 (Modal)',
-                          desc: '点击按钮弹出详细操作步骤对话框',
+                          label: '💬 弹出对话框模式 (Modal)',
+                          desc: '前台点击按钮弹出居中详细操作步骤与说明对话框',
                         },
                         {
                           type: 'link',
-                          label: '🔗 外部超链接类型 (Link)',
-                          desc: '直接在新标签页跳转飞书/语雀/Wiki',
+                          label: '🔗 外部超链接模式 (Link)',
+                          desc: '前台按钮直接在新标签页打开外部文档,不弹窗',
                         },
                         {
                           type: 'embedded',
                           label: '📑 页面内嵌展开卡片 (Embedded)',
-                          desc: '直接在下单页面上方以卡片形式展开',
+                          desc: '前台商品卡片与下单页直接内嵌展开步骤与FAQ,不弹窗',
                         },
                       ].map((item) => {
                         const isSelected = tutorialConfig.display_type === item.type;
@@ -892,7 +1324,7 @@ export default function ProductModal({
                     </div>
                     <div className="space-y-1">
                       <label className="font-bold text-black uppercase block">
-                        教程弹窗大标题
+                        教程大标题 (弹窗/卡片主标题)
                       </label>
                       <input
                         type="text"
@@ -1061,7 +1493,7 @@ export default function ProductModal({
                 <div className="flex items-center gap-2">
                   <span className="w-2.5 h-2.5 bg-black" />
                   <span className="text-xs font-black uppercase text-black">
-                    [ 06 // 前台展示卡片包装与海报定制 (Showcase Card & Poster) ]
+                    [ 07 // 前台展示卡片包装与海报定制 (Showcase Card & Poster) ]
                   </span>
                 </div>
                 <span className="text-[10px] font-mono text-neutral-500 uppercase">
@@ -1084,19 +1516,18 @@ export default function ProductModal({
                 </div>
 
                 <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
-                  <div className="space-y-1 md:col-span-2">
-                    <label className="text-[11px] font-bold text-black uppercase">
-                      自定义海报大图 URL (可选,填入后将覆盖默认 3D 海报)
-                    </label>
-                    <input
-                      type="text"
-                      placeholder="https://... 或图床外链图片地址"
-                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                  <div className="md:col-span-2">
+                    <ImageUploadField
+                      label="自定义海报大图 (本地上传,将上传至 R2 对象存储并覆盖默认 3D 海报)"
                       value={cardConfig.banner_url || ''}
-                      onChange={(e) => setCardConfig((prev) => ({ ...prev, banner_url: e.target.value }))}
+                      onChange={(url) => setCardConfig((prev) => ({ ...prev, banner_url: url }))}
+                      prefix="posters"
+                      aspectRatio="16:9"
+                      helperText="点击选择本地海报图片,支持 PNG, JPG, WEBP (最大 1MB)"
                     />
                   </div>
 
+
                   <div className="space-y-1">
                     <label className="text-[11px] font-bold text-black uppercase">
                       海报主标题 (大字,如: FRANCE, USA, GPT Plus)
@@ -1196,11 +1627,11 @@ export default function ProductModal({
                 <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
                   <div className="space-y-1">
                     <label className="text-[11px] font-bold text-black uppercase">
-                      活动/通道标贴 (青色微斜标签,如: 官方活动、官方直连、特惠直供)
+                      活动/通道标贴 (如: 官方活动、官方直连、特惠直供)
                     </label>
                     <input
                       type="text"
-                      placeholder="默认: 官方直连"
+                      placeholder="留空则不显示"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.official_tag || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, official_tag: e.target.value }))}
@@ -1209,11 +1640,11 @@ export default function ProductModal({
 
                   <div className="space-y-1">
                     <label className="text-[11px] font-bold text-black uppercase">
-                      状态徽标 (天蓝角标,如: New、Hot、限时可约)
+                      状态徽标 (如: New、Hot、限时可约)
                     </label>
                     <input
                       type="text"
-                      placeholder="默认: New"
+                      placeholder="留空则不显示"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.status_tag || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, status_tag: e.target.value }))}
@@ -1226,7 +1657,7 @@ export default function ProductModal({
                     </label>
                     <input
                       type="text"
-                      placeholder="留空则自动显示教程标题或全额退款保障"
+                      placeholder="留空则不显示"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.pill_text || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, pill_text: e.target.value }))}
@@ -1235,24 +1666,37 @@ export default function ProductModal({
 
                   <div className="space-y-1">
                     <label className="text-[11px] font-bold text-black uppercase">
-                      底部销售/库存描述 (如: 仅剩 5 件 · 已售 77、实时监控中 · 已售 120)
+                      底部销售/库存描述 (如: 仅剩 5 件 · 已售 77、实时监控中)
                     </label>
                     <input
                       type="text"
-                      placeholder="留空则根据商品推荐分自动生成"
+                      placeholder="留空则不显示"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.sales_text || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, sales_text: e.target.value }))}
                     />
                   </div>
 
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      渠道状态文案 (如: 直连就绪、通道正常、全天候巡检)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="留空则不显示"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.status_text || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, status_text: e.target.value }))}
+                    />
+                  </div>
+
                   <div className="space-y-1">
                     <label className="text-[11px] font-bold text-black uppercase">
                       右侧购买按键文案 (如: 立即购买、立即申请、立即抢位)
                     </label>
                     <input
                       type="text"
-                      placeholder="默认: 立即购买"
+                      placeholder="默认: 立即购买 / Order Now"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.buy_button_text || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, buy_button_text: e.target.value }))}
@@ -1265,7 +1709,7 @@ export default function ProductModal({
                     </label>
                     <input
                       type="text"
-                      placeholder="默认: 查阅服务细则 →"
+                      placeholder="留空则不显示"
                       className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       value={cardConfig.sublink_text || ''}
                       onChange={(e) => setCardConfig((prev) => ({ ...prev, sublink_text: e.target.value }))}
@@ -1315,21 +1759,35 @@ export default function ProductModal({
                         )}
                       </div>
 
-                      <p className="text-neutral-600 text-xs line-clamp-2 leading-relaxed">
-                        {form.description || '官方直连极速通道,分布式集群 24 小时毫秒级抢位,预约失败无条件全额退款。'}
-                      </p>
+                      {form.description && (
+                        <p className="text-neutral-600 text-xs line-clamp-2 leading-relaxed">
+                          {form.description}
+                        </p>
+                      )}
 
-                      <div>
-                        <span className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000]">
-                          [ {cardConfig.pill_text || (tutorialConfig.enabled ? (tutorialConfig.modal_title || '查看办理教程与材料指引') : '7×24H 官方代抢 · 失败全额退款')} → ]
-                        </span>
-                      </div>
-
-                      <div className="text-neutral-500 text-[11px] font-mono pt-1 border-t border-neutral-200">
-                        <strong className="text-neutral-800 font-bold">
-                          {cardConfig.sales_text || '实时监控中 · 已售 88'}
-                        </strong>
-                      </div>
+                      {cardConfig.pill_text && (
+                        <div>
+                          <span className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000]">
+                            [ {cardConfig.pill_text} → ]
+                          </span>
+                        </div>
+                      )}
+
+                      {(cardConfig.sales_text || cardConfig.status_text) && (
+                        <div className="text-neutral-500 text-[11px] font-mono pt-1 border-t border-neutral-200 flex items-center gap-2">
+                          {cardConfig.sales_text && (
+                            <strong className="text-neutral-800 font-bold">
+                              {cardConfig.sales_text}
+                            </strong>
+                          )}
+                          {cardConfig.status_text && (
+                            <span className="text-emerald-700 font-bold flex items-center gap-1">
+                              <span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
+                              {cardConfig.status_text}
+                            </span>
+                          )}
+                        </div>
+                      )}
                     </div>
 
                     <div className="md:w-40 shrink-0 flex flex-row md:flex-col items-center md:items-end justify-between md:justify-center gap-2 pt-3 md:pt-0 border-t-2 border-neutral-200 md:border-t-0 md:border-l-2 md:border-neutral-200 md:pl-4">
@@ -1345,9 +1803,11 @@ export default function ProductModal({
                         [ {cardConfig.buy_button_text || '立即购买'} ]
                       </span>
 
-                      <span className="text-[10px] font-mono font-bold text-neutral-600 underline underline-offset-2">
-                        {cardConfig.sublink_text || '查阅服务细则 →'}
-                      </span>
+                      {cardConfig.sublink_text && (
+                        <span className="text-[10px] font-mono font-bold text-neutral-600 underline underline-offset-2">
+                          {cardConfig.sublink_text}
+                        </span>
+                      )}
                     </div>
                   </div>
                 </div>

+ 8 - 8
src/components/admin/settlement/CostRecordsTab.tsx

@@ -23,6 +23,8 @@ import {
 } from '@/types';
 import { toast } from 'react-hot-toast';
 import LocalTime from '@/components/common/LocalTime';
+import { ImageUploadField } from '@/components/common/ImageUploadField';
+
 
 export default function CostRecordsTab() {
   const [costs, setCosts] = useState<VasCostRecord[]>([]);
@@ -428,18 +430,16 @@ export default function CostRecordsTab() {
               </div>
 
               <div>
-                <label className="font-black text-black uppercase block mb-1">
-                  [ 扣款凭证或发票截图 URL ]
-                </label>
-                <input
-                  type="url"
+                <ImageUploadField
+                  label="[ 扣款凭证或发票截图(本地上传至 R2) ]"
                   value={voucherUrl}
-                  onChange={(e) => setVoucherUrl(e.target.value)}
-                  placeholder="https://..."
-                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  onChange={setVoucherUrl}
+                  prefix="vouchers"
+                  helperText="点击本地上传发票或扣款凭证截图,支持 PNG, JPG, WEBP (最大 1MB)"
                 />
               </div>
 
+
               {/* Footer */}
               <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
                 <button

+ 77 - 15
src/components/admin/settlement/SettlementEngineTab.tsx

@@ -42,9 +42,9 @@ export default function SettlementEngineTab() {
   const [startDate, setStartDate] = useState('');
   const [endDate, setEndDate] = useState('');
 
-  // Partner Accounts (Persisted in localStorage with sensible defaults)
-  const [partnerAId, setPartnerAId] = useState('partner_a');
-  const [partnerBId, setPartnerBId] = useState('partner_b');
+  // Partner Accounts (Persisted in localStorage without any hardcoded presets)
+  const [partnerAId, setPartnerAId] = useState('');
+  const [partnerBId, setPartnerBId] = useState('');
   const [showAccountConfig, setShowAccountConfig] = useState(false);
 
   // Preview State
@@ -67,11 +67,11 @@ export default function SettlementEngineTab() {
 
   // Initialize dates and saved partner accounts
   useEffect(() => {
-    // 1. 读取保存的合伙人账户绑定,若未配置则使用默认值
-    const savedA = localStorage.getItem('settlement_partner_a');
-    const savedB = localStorage.getItem('settlement_partner_b');
-    if (savedA) setPartnerAId(savedA);
-    if (savedB) setPartnerBId(savedB);
+    // 1. 读取保存的合伙人账户绑定(不使用任何默认预设)
+    const savedA = localStorage.getItem('settlement_partner_a') || '';
+    const savedB = localStorage.getItem('settlement_partner_b') || '';
+    if (savedA && !savedA.includes('partner_')) setPartnerAId(savedA);
+    if (savedB && !savedB.includes('partner_')) setPartnerBId(savedB);
 
     // 2. 默认选择当月月结
     handlePresetCurrentMonth();
@@ -105,7 +105,10 @@ export default function SettlementEngineTab() {
   const handleSaveAccountConfig = (e: React.FormEvent) => {
     e.preventDefault();
     if (!partnerAId.trim() || !partnerBId.trim()) {
-      return toast.error('合伙人甲方与乙方标识不能为空');
+      return toast.error('合伙人甲方与乙方账户ID均不能为空,必须明确指定真实用户!');
+    }
+    if (partnerAId.trim() === partnerBId.trim()) {
+      return toast.error('合伙人甲方与乙方不能为同一用户!');
     }
     localStorage.setItem('settlement_partner_a', partnerAId.trim());
     localStorage.setItem('settlement_partner_b', partnerBId.trim());
@@ -129,14 +132,18 @@ export default function SettlementEngineTab() {
   const handleCalculatePreview = async (e: React.FormEvent) => {
     e.preventDefault();
     if (!startDate || !endDate) return toast.error('请选择账期起止时间');
+    if (!partnerAId.trim() || !partnerBId.trim()) {
+      setShowAccountConfig(true);
+      return toast.error('未指定合伙人账户!请先在下方「配置合伙账户」中明确选择甲方与乙方。');
+    }
 
     setPreviewLoading(true);
     try {
       const payload: SettlementPreviewRequest = {
         start_date: new Date(startDate).toISOString(),
         end_date: new Date(endDate).toISOString(),
-        partner_a_id: partnerAId.trim() || 'partner_a',
-        partner_b_id: partnerBId.trim() || 'partner_b',
+        partner_a_id: partnerAId.trim(),
+        partner_b_id: partnerBId.trim(),
       };
       const res = await settlementService.previewSettlement(payload);
       const data = res?.data || res;
@@ -155,6 +162,10 @@ export default function SettlementEngineTab() {
 
   const handleOpenConfirmModal = () => {
     if (!previewResult) return;
+    if (!partnerAId.trim() || !partnerBId.trim()) {
+      setShowAccountConfig(true);
+      return toast.error('未指定合伙人账户,请先配置合伙人甲方与乙方!');
+    }
     setIsConfirmModalOpen(true);
   };
 
@@ -303,10 +314,30 @@ export default function SettlementEngineTab() {
               结算分成归属规则:
             </span>
             <span>
-              甲方合伙分红(20%): <strong className="text-black font-mono">{partnerAId}</strong>
+              甲方合伙分红(20%):{' '}
+              {partnerAId ? (
+                <strong className="text-black font-mono">{partnerAId}</strong>
+              ) : (
+                <span
+                  onClick={() => setShowAccountConfig(true)}
+                  className="text-rose-600 font-bold underline cursor-pointer hover:text-rose-700"
+                >
+                  [ 待指定甲方 ⚠️ ]
+                </span>
+              )}
             </span>
             <span>
-              乙方合伙分红(20%): <strong className="text-black font-mono">{partnerBId}</strong>
+              乙方合伙分红(20%):{' '}
+              {partnerBId ? (
+                <strong className="text-black font-mono">{partnerBId}</strong>
+              ) : (
+                <span
+                  onClick={() => setShowAccountConfig(true)}
+                  className="text-rose-600 font-bold underline cursor-pointer hover:text-rose-700"
+                >
+                  [ 待指定乙方 ⚠️ ]
+                </span>
+              )}
             </span>
             <span>
               技术版权(20%): <strong className="text-emerald-700 font-bold">按订单商品插件开发管理者自动归属</strong>
@@ -470,7 +501,14 @@ export default function SettlementEngineTab() {
                       <tr key={idx} className="hover:bg-amber-50/50">
                         <td className="px-4 py-3 font-mono">
                           <div className="flex flex-col sm:flex-row sm:items-center gap-1.5">
-                            <span className="font-black text-black">{p.user_id}</span>
+                            <span className="font-black text-black">
+                              {p.user_name || p.user_id}
+                            </span>
+                            {p.user_name && p.user_name !== p.user_id && (
+                              <span className="text-[10px] text-neutral-500 font-mono">
+                                ({p.user_id})
+                              </span>
+                            )}
                             <span className={`px-1.5 py-0.5 text-[10px] font-bold border rounded w-fit ${roleBadgeClass}`}>
                               {roleBadge}
                             </span>
@@ -536,6 +574,7 @@ export default function SettlementEngineTab() {
                       <th className="px-3 py-2 font-bold">[ 订单流水号 ]</th>
                       <th className="px-3 py-2 font-bold">[ 渠道 ]</th>
                       <th className="px-3 py-2 font-bold">[ 对接人 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 技术归属人 ]</th>
                       <th className="px-3 py-2 font-bold">[ 实收金额 ]</th>
                       <th className="px-3 py-2 font-bold">[ 单均耗材 ]</th>
                       <th className="px-3 py-2 font-bold">[ 单笔净利 ]</th>
@@ -554,7 +593,30 @@ export default function SettlementEngineTab() {
                             {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
                           </span>
                         </td>
-                        <td className="px-3 py-2 text-neutral-600">{d.handler_id || '-'}</td>
+                        <td className="px-3 py-2 text-neutral-700">
+                          {d.handler_name ? (
+                            <span>
+                              <strong className="text-black">{d.handler_name}</strong>
+                              <span className="text-[10px] text-neutral-400 block font-mono">
+                                {d.handler_id}
+                              </span>
+                            </span>
+                          ) : (
+                            d.handler_id || '-'
+                          )}
+                        </td>
+                        <td className="px-3 py-2 text-neutral-700">
+                          {d.developer_name ? (
+                            <span>
+                              <strong className="text-emerald-800">{d.developer_name}</strong>
+                              <span className="text-[10px] text-neutral-400 block font-mono">
+                                {d.developer_id}
+                              </span>
+                            </span>
+                          ) : (
+                            d.developer_id || '-'
+                          )}
+                        </td>
                         <td className="px-3 py-2 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
                         <td className="px-3 py-2 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
                         <td className="px-3 py-2 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>

+ 15 - 2
src/components/admin/settlement/SettlementPeriodDetailModal.tsx

@@ -120,7 +120,14 @@ export default function SettlementPeriodDetailModal({ isOpen, onClose, period }:
                       return (
                         <tr key={idx} className="hover:bg-neutral-50">
                           <td className="px-3 py-2 font-mono">
-                            <span className="font-black text-black mr-1.5">{p.user_id}</span>
+                            <span className="font-black text-black mr-1.5">
+                              {p.user_name || p.user_id}
+                            </span>
+                            {p.user_name && p.user_name !== p.user_id && (
+                              <span className="text-[10px] text-neutral-400 font-mono mr-1.5">
+                                ({p.user_id})
+                              </span>
+                            )}
                             <span className={`px-1.5 py-0.5 text-[9px] font-bold border rounded ${roleBadgeClass}`}>
                               {p.role_description?.split(' ')[0] || '分润方'}
                             </span>
@@ -155,6 +162,7 @@ export default function SettlementPeriodDetailModal({ isOpen, onClose, period }:
                     <th className="px-3 py-2 font-bold">[ 订单号 ]</th>
                     <th className="px-3 py-2 font-bold">[ 渠道 ]</th>
                     <th className="px-3 py-2 font-bold">[ 对接人 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 技术归属人 ]</th>
                     <th className="px-3 py-2 font-bold">[ 实收金额 ]</th>
                     <th className="px-3 py-2 font-bold">[ 单均耗材 ]</th>
                     <th className="px-3 py-2 font-bold">[ 单笔净利 ]</th>
@@ -173,7 +181,12 @@ export default function SettlementPeriodDetailModal({ isOpen, onClose, period }:
                           {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
                         </span>
                       </td>
-                      <td className="px-3 py-1.5 text-neutral-600">{d.handler_id || '-'}</td>
+                      <td className="px-3 py-1.5 text-neutral-700">
+                        {d.handler_name ? `${d.handler_name} (${d.handler_id})` : (d.handler_id || '-')}
+                      </td>
+                      <td className="px-3 py-1.5 text-neutral-700">
+                        {d.developer_name ? `${d.developer_name} (${d.developer_id})` : (d.developer_id || '-')}
+                      </td>
                       <td className="px-3 py-1.5 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
                       <td className="px-3 py-1.5 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
                       <td className="px-3 py-1.5 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>

+ 207 - 51
src/components/admin/tasks/TaskTable.tsx

@@ -264,6 +264,56 @@ export default function TaskTable({
     }
   };
 
+// 路由语义解析映射表
+const ROUTING_COUNTRY_MAP: Record<string, string> = {
+  fr: '🇫🇷 法国',
+  dk: '🇩🇰 丹麦',
+  gr: '🇬🇷 希腊',
+  nl: '🇳🇱 荷兰',
+  at: '🇦🇹 奥地利',
+  de: '🇩🇪 德国',
+  es: '🇪🇸 西班牙',
+  it: '🇮🇹 意大利',
+  ch: '🇨🇭 瑞士',
+  us: '🇺🇸 美国',
+  uk: '🇬🇧 英国',
+  ie: '🇮🇪 爱尔兰',
+};
+
+const ROUTING_CITY_MAP: Record<string, string> = {
+  dub: '都柏林',
+  lon: '伦敦',
+  sha: '上海',
+  bjs: '北京',
+  can: '广州',
+  szx: '深圳',
+  hgh: '杭州',
+  xiy: '西安',
+};
+
+function parseRoutingKey(routingKey: string) {
+  if (!routingKey) return null;
+  const parts = routingKey.split('.');
+  let city = '';
+  let country = '';
+  let visaType = '';
+
+  for (const part of parts) {
+    const p = part.toLowerCase();
+    if (ROUTING_CITY_MAP[p]) {
+      city = ROUTING_CITY_MAP[p];
+    } else if (ROUTING_COUNTRY_MAP[p]) {
+      country = ROUTING_COUNTRY_MAP[p];
+    } else if (p === 'tourist') {
+      visaType = '旅游签';
+    } else if (p === 'business') {
+      visaType = '商务签';
+    }
+  }
+
+  return { city, country, visaType };
+}
+
   if (loading) {
     return (
       <div className="border-2 border-black bg-white p-12 text-center text-xs font-mono shadow-[4px_4px_0px_#000]">
@@ -290,46 +340,64 @@ export default function TaskTable({
           <table className="w-full text-xs text-left border-collapse table-fixed">
             <thead className="bg-neutral-200 border-b-2 border-black text-black uppercase font-black">
               <tr>
-                <th className="w-10 px-2 py-3 text-center"></th>
+                <th className="w-9 px-2 py-3 text-center"></th>
 
-                {/* ID & Route */}
+                {/* 任务ID & 状态 */}
                 <th
                   onClick={() => handleHeaderSort('id')}
-                  className="w-[170px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
+                  className="w-[125px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
                 >
                   <div className="flex items-center">
-                    <span>任务ID // 路由</span>
+                    <span>任务ID // 状态</span>
                     {renderSortIcon('id')}
                   </div>
                 </th>
 
-                {/* 关联订单 & 客户 */}
-                <th className="w-[230px] px-3 py-3">关联订单 & 客户信息</th>
+                {/* 所属商品 (Product) */}
+                <th className="w-[190px] px-3 py-3">
+                  <span>所属商品 (PRODUCT)</span>
+                </th>
 
-                {/* 优先级 & 状态 */}
+                {/* 关联主订单 & 客户 */}
+                <th
+                  onClick={() => handleHeaderSort('order_id')}
+                  className="w-[220px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
+                >
+                  <div className="flex items-center">
+                    <span>关联主订单 // 客户</span>
+                    {renderSortIcon('order_id')}
+                  </div>
+                </th>
+
+                {/* 命中商品路由分流 */}
+                <th className="w-[200px] px-3 py-3">
+                  <span>命中路由规则 (ROUTING)</span>
+                </th>
+
+                {/* 优先级 */}
                 <th
                   onClick={() => handleHeaderSort('priority')}
-                  className="w-[150px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
+                  className="w-[110px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
                 >
                   <div className="flex items-center">
-                    <span>优先级 & 状态</span>
+                    <span>调度优先级</span>
                     {renderSortIcon('priority')}
                   </div>
                 </th>
 
-                {/* 时间流 */}
+                {/* 入队时间 */}
                 <th
-                  onClick={() => handleHeaderSort('updated_at')}
-                  className="w-[190px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
+                  onClick={() => handleHeaderSort('created_at')}
+                  className="w-[170px] px-3 py-3 cursor-pointer hover:bg-neutral-300 transition select-none"
                 >
                   <div className="flex items-center">
-                    <span>活跃更新 / 创建时间</span>
-                    {renderSortIcon('updated_at')}
+                    <span>入队 / 活跃时间</span>
+                    {renderSortIcon('created_at')}
                   </div>
                 </th>
 
                 {/* 操作列 */}
-                <th className="w-[170px] px-3 py-3 text-right">调度操作</th>
+                <th className="w-[160px] px-3 py-3 text-right">调度操作</th>
               </tr>
             </thead>
 
@@ -338,6 +406,7 @@ export default function TaskTable({
               const customerName = getRecipientName(task);
               const phone = getRecipientPhone(task);
               const email = getRecipientEmail(task);
+              const routeMeta = parseRoutingKey(task.routing_key);
 
               return (
                 <tbody
@@ -355,10 +424,10 @@ export default function TaskTable({
                       </div>
                     </td>
 
-                    {/* Task ID & Route */}
+                    {/* Task ID & Status */}
                     <td className="px-3 py-3 align-top">
-                      <div className="flex items-center gap-1.5 mb-1">
-                        <span className="font-bold text-black bg-neutral-100 px-1 py-0.2 border border-black">
+                      <div className="flex items-center gap-1.5 mb-1.5">
+                        <span className="font-mono font-black text-black bg-neutral-100 px-1.5 py-0.5 border border-black text-xs">
                           #{task.id}
                         </span>
                         {task.script_version && (
@@ -367,55 +436,142 @@ export default function TaskTable({
                           </span>
                         )}
                       </div>
-                      <div className="text-[10px] bg-amber-100 border border-black px-1.5 py-0.5 truncate inline-block max-w-full font-bold text-black">
-                        {task.routing_key}
+                      <div>
+                        {renderStatusBadge(task.status)}
                       </div>
+                      {task.attempt_count > 0 && (
+                        <div className="mt-1 text-[10px] text-rose-700 font-bold bg-rose-50 border border-rose-300 px-1 py-0.2 inline-block">
+                          重试: {task.attempt_count}次
+                        </div>
+                      )}
                     </td>
 
-                    {/* Order & Customer */}
+                    {/* 所属商品 (Product) */}
                     <td className="px-3 py-3 align-top">
-                      <div className="flex items-center gap-1 mb-0.5">
-                        <span className="font-bold text-black truncate max-w-[150px]">
-                          {task.order_id}
-                        </span>
-                        <button
-                          onClick={(e) => {
-                            e.stopPropagation();
-                            handleCopy(task.order_id, `order-${task.id}`);
-                          }}
-                          className="p-0.5 hover:bg-neutral-200 border border-transparent hover:border-black"
-                          title="复制订单号"
-                        >
-                          {copiedOrderId === `order-${task.id}` ? (
-                            <Check size={10} className="text-emerald-700 font-bold" />
-                          ) : (
-                            <Copy size={10} />
+                      {task.product_name ? (
+                        <div className="space-y-1">
+                          <div className="flex items-center gap-1">
+                            <span className="bg-amber-300 border border-black px-1 text-[10px] font-black text-black shrink-0">
+                              #{task.product_id}
+                            </span>
+                            <span className="font-black text-black text-xs leading-snug line-clamp-2" title={task.product_name}>
+                              {task.product_name}
+                            </span>
+                          </div>
+                          <div className="text-[10px] text-neutral-500 font-sans flex items-center gap-1">
+                            <span>🛒 商品路由任务</span>
+                          </div>
+                        </div>
+                      ) : (
+                        <div className="text-neutral-400 text-xs italic">
+                          <span>[ 独立直连任务 ]</span>
+                        </div>
+                      )}
+                    </td>
+
+                    {/* 关联主订单 & 客户 */}
+                    <td className="px-3 py-3 align-top">
+                      <div className="space-y-1">
+                        <div className="flex items-center gap-1">
+                          <span className="font-mono font-bold text-black text-xs truncate max-w-[140px]" title={task.order_id}>
+                            {task.order_id}
+                          </span>
+                          <button
+                            onClick={(e) => {
+                              e.stopPropagation();
+                              handleCopy(task.order_id, `order-${task.id}`);
+                            }}
+                            className="p-0.5 hover:bg-neutral-200 border border-transparent hover:border-black shrink-0"
+                            title="复制订单号"
+                          >
+                            {copiedOrderId === `order-${task.id}` ? (
+                              <Check size={11} className="text-emerald-700 font-bold" />
+                            ) : (
+                              <Copy size={11} />
+                            )}
+                          </button>
+                        </div>
+                        <div className="flex flex-wrap items-center gap-1 text-[10px]">
+                          {task.order_status && (
+                            <span className={`px-1 border border-black font-bold uppercase ${
+                              task.order_status === 'paid' ? 'bg-emerald-100 text-emerald-900' :
+                              task.order_status === 'completed' ? 'bg-amber-100 text-black' : 'bg-neutral-100 text-neutral-700'
+                            }`}>
+                              {task.order_status === 'paid' ? '已支付' : task.order_status === 'completed' ? '已完成' : task.order_status}
+                            </span>
                           )}
-                        </button>
+                          {task.order_final_amount !== undefined && task.order_final_amount !== null && (
+                            <span className="text-black font-mono font-bold">
+                              ¥{(task.order_final_amount / 100).toFixed(2)}
+                            </span>
+                          )}
+                        </div>
+                        <div className="text-[10px] text-neutral-600 font-sans truncate max-w-[180px]">
+                          <span className="font-bold text-black">{customerName}</span>
+                          {phone !== '-' && <span className="text-neutral-500"> • {phone}</span>}
+                        </div>
                       </div>
-                      <div className="text-[10px] text-neutral-600 font-sans">
-                        <span>{customerName}</span>
-                        {phone !== '-' && <span> • {phone}</span>}
+                    </td>
+
+                    {/* 命中路由规则 */}
+                    <td className="px-3 py-3 align-top">
+                      <div className="space-y-1">
+                        <div className="text-[10px] bg-amber-50 border border-black px-1.5 py-0.5 truncate block max-w-full font-mono font-bold text-black" title={task.routing_key}>
+                          {task.routing_key}
+                        </div>
+                        {routeMeta && (routeMeta.country || routeMeta.city || routeMeta.visaType) ? (
+                          <div className="flex flex-wrap gap-1 text-[10px]">
+                            {routeMeta.country && (
+                              <span className="bg-white border border-neutral-300 px-1 font-bold text-neutral-800">
+                                {routeMeta.country}
+                              </span>
+                            )}
+                            {routeMeta.city && (
+                              <span className="bg-white border border-neutral-300 px-1 font-bold text-neutral-800">
+                                {routeMeta.city}
+                              </span>
+                            )}
+                            {routeMeta.visaType && (
+                              <span className="bg-neutral-100 border border-neutral-300 px-1 font-mono text-neutral-600">
+                                {routeMeta.visaType}
+                              </span>
+                            )}
+                          </div>
+                        ) : null}
                       </div>
                     </td>
 
-                    {/* Priority & Status */}
+                    {/* 优先级 */}
                     <td className="px-3 py-3 align-top">
                       <div className="flex flex-col gap-1 items-start">
-                        {renderStatusBadge(task.status)}
+                        <span className={`px-2 py-0.5 border border-black text-xs font-mono font-black ${
+                          task.priority >= 20 ? 'bg-rose-200 text-rose-950 shadow-[1px_1px_0px_#000]' :
+                          task.priority > 10 ? 'bg-amber-300 text-black shadow-[1px_1px_0px_#000]' :
+                          'bg-neutral-100 text-black'
+                        }`}>
+                          P-{task.priority}
+                        </span>
                         <span className="text-[10px] text-neutral-500 font-mono">
-                          PRIORITY: {task.priority}
+                          {task.priority >= 20 ? '加急调度' : task.priority > 10 ? '高优处理' : '普通队列'}
                         </span>
                       </div>
                     </td>
 
                     {/* Timestamps */}
                     <td className="px-3 py-3 align-top text-[10px]">
-                      <div className="font-bold text-black">
-                        <LocalTime date={task.updated_at} />
-                      </div>
-                      <div className="text-neutral-500">
-                        建单: <LocalTime date={task.created_at} />
+                      <div className="space-y-1">
+                        <div>
+                          <span className="text-neutral-500">入队: </span>
+                          <span className="font-bold text-black">
+                            <LocalTime date={task.created_at} />
+                          </span>
+                        </div>
+                        <div>
+                          <span className="text-neutral-500">更新: </span>
+                          <span className="text-neutral-700">
+                            <LocalTime date={task.updated_at} />
+                          </span>
+                        </div>
                       </div>
                     </td>
 
@@ -424,7 +580,7 @@ export default function TaskTable({
                       className="px-3 py-3 align-top text-right"
                       onClick={(e) => e.stopPropagation()}
                     >
-                      <div className="flex items-center justify-end gap-1">
+                      <div className="flex items-center justify-end gap-1 flex-wrap">
                         {task.status === 'RUNNING' && (
                           <button
                             onClick={() => onPause(task.id)}
@@ -465,7 +621,7 @@ export default function TaskTable({
                   {/* Expanded Detail Panel */}
                   {isExpanded && (
                     <tr className="bg-neutral-50 border-t border-black">
-                      <td colSpan={6} className="p-4">
+                      <td colSpan={8} className="p-4">
                         <TaskDetailTabs
                           task={task}
                           onOpenMessage={openMessageModal}

+ 227 - 77
src/components/admin/tickets/TicketDetailModal.tsx

@@ -1,12 +1,13 @@
 'use client';
 
 import { useState, useEffect, useRef } from 'react';
-import { X, Send, User, Shield, Check, Ban, RefreshCw, Loader2, MessageSquare, Info, MessageCircle } from 'lucide-react';
+import { X, Send, User, Shield, Check, Ban, RefreshCw, Loader2, MessageSquare, Info, MessageCircle, Image as ImageIcon, ExternalLink } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
 import { toast } from 'react-hot-toast';
 import TicketActionModal from '@/components/admin/TicketActionModal';
 import { AdminTicket, TicketMessage, ActionType } from '@/types';
 import { ticketService } from '@/lib/services';
+import { storageService } from '@/lib/services/storageService';
 
 interface TicketDetailModalProps {
   isOpen: boolean;
@@ -20,52 +21,110 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
   const [reply, setReply] = useState('');
   const [loadingMsg, setLoadingMsg] = useState(false);
   const [sending, setSending] = useState(false);
+
+  // 图片附件状态
+  const [attachedImages, setAttachedImages] = useState<string[]>([]);
+  const [uploadingImage, setUploadingImage] = useState(false);
+  const fileInputRef = useRef<HTMLInputElement>(null);
+
   const [actionType, setActionType] = useState<ActionType | null>(null);
   const [isActionModalOpen, setIsActionModalOpen] = useState(false);
   const messagesEndRef = useRef<HTMLDivElement>(null);
 
   const [activeTab, setActiveTab] = useState<'detail' | 'chat'>('chat');
 
-  const fetchMessages = async () => {
+  const fetchMessages = async (silent = false) => {
     if (!ticket) return;
-    setLoadingMsg(true);
+    if (!silent) setLoadingMsg(true);
     try {
-      const res = await ticketService.fetchMessages(ticket.id, { page: 1, size: 50 });
+      const res = await ticketService.fetchMessages(ticket.id, { page: 1, size: 100 });
       if (res?.data?.items) {
         const sorted = res.data.items.sort((a: any, b: any) => 
           new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
         );
         setMessages(sorted);
-        setTimeout(() => messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }), 100);
+        setTimeout(() => messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }), 50);
       }
     } catch {
       // ignore
     } finally {
-      setLoadingMsg(false);
+      if (!silent) setLoadingMsg(false);
     }
   };
 
   useEffect(() => {
     if (isOpen && ticket) {
-      fetchMessages();
+      setMessages([]);
+      setAttachedImages([]);
+      setReply('');
+      fetchMessages(false);
       setActiveTab('chat');
     }
-  }, [isOpen, ticket]);
+  }, [isOpen, ticket?.id]);
+
+  const handleImageUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
+    const file = e.target.files?.[0];
+    if (!file) return;
+    if (fileInputRef.current) fileInputRef.current.value = '';
+
+    if (file.size > 1 * 1024 * 1024) {
+      toast.error('图片大小不能超过 1MB');
+      return;
+    }
+
+    setUploadingImage(true);
+    try {
+      const res = await storageService.upload(file, 'ticket_attachments');
+      setAttachedImages(prev => [...prev, res.url]);
+      toast.success('图片已上传');
+    } catch (err: any) {
+      console.error('[Ticket Upload Error]', err);
+      const errMsg = err.response?.data?.message || err.message || '图片上传失败';
+      toast.error(errMsg);
+    } finally {
+      setUploadingImage(false);
+    }
+  };
+
+  const handleRemoveImage = (index: number) => {
+    setAttachedImages(prev => prev.filter((_, i) => i !== index));
+  };
 
   const handleSend = async (e: React.FormEvent) => {
     e.preventDefault();
-    if (!reply.trim() || !ticket) return;
+    if ((!reply.trim() && attachedImages.length === 0) || !ticket) return;
 
+    const contentToSend = reply.trim() || (attachedImages.length > 0 ? '[图片附件]' : '');
+    const imagesToSend = [...attachedImages];
+
+    // 1. 乐观更新(即刻上屏,消除闪烁)
+    const tempId = Date.now();
+    const optimisticMsg: TicketMessage = {
+      id: tempId,
+      ticket_id: ticket.id,
+      sender_type: 'admin',
+      content: contentToSend,
+      attachments: imagesToSend.length > 0 ? { images: imagesToSend } : null,
+      created_at: new Date().toISOString(),
+    };
+
+    setMessages(prev => [...prev, optimisticMsg]);
+    setReply('');
+    setAttachedImages([]);
     setSending(true);
+
+    setTimeout(() => messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }), 50);
+
     try {
       await ticketService.sendMessage(ticket.id, {
-        content: reply,
-        attachments: null
+        content: contentToSend,
+        attachments: imagesToSend.length > 0 ? { images: imagesToSend } : null
       });
-      setReply('');
-      fetchMessages(); 
+      // 静默拉取后端更新
+      await fetchMessages(true);
     } catch {
       toast.error("发送失败");
+      fetchMessages(true);
     } finally {
       setSending(false);
     }
@@ -89,6 +148,18 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
     onClose();
   };
 
+  const extractImages = (msg: TicketMessage): string[] => {
+    const imgs: string[] = [];
+    if (msg.attachments) {
+      if (Array.isArray(msg.attachments.images)) {
+        imgs.push(...msg.attachments.images);
+      } else if (typeof msg.attachments.url === 'string') {
+        imgs.push(msg.attachments.url);
+      }
+    }
+    return imgs;
+  };
+
   if (!isOpen || !ticket) return null;
 
   return (
@@ -138,73 +209,81 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
         </div>
 
         {/* 核心双栏内容区 */}
-        <div className="flex-1 flex overflow-hidden relative">
+        <div className="flex-1 flex overflow-hidden">
           
-          {/* 左侧:详情与操作 (Desktop 35%) */}
+          {/* 左侧:工单档案与审核操作 (Desktop 35%) */}
           <div className={`
-            flex-col bg-neutral-50 overflow-y-auto border-r-2 border-black
-            ${activeTab === 'detail' ? 'flex w-full' : 'hidden'} 
-            md:flex md:w-80
+            border-r-2 border-black flex-col bg-white overflow-y-auto
+            ${activeTab === 'detail' ? 'flex w-full' : 'hidden'}
+            md:flex md:w-[380px] shrink-0
           `}>
-            <div className="p-4 space-y-4 text-xs">
-              
-              <div className="md:hidden bg-white p-3 border-2 border-black space-y-1 text-[11px]">
-                <p>用户: {ticket.user_id}</p>
-                <p>订单: #{ticket.order_id}</p>
-                <p>创建: <LocalTime date={ticket.created_at} /></p>
-              </div>
+            <div className="p-4 border-b border-black/10 bg-neutral-100">
+              <span className="text-[11px] font-black uppercase text-black">[ 诉求与争议说明 ]</span>
+              <p className="text-xs text-black font-sans mt-2 whitespace-pre-wrap leading-relaxed">
+                {ticket.reason}
+              </p>
+            </div>
 
-              {/* 状态卡片 */}
-              <div className="bg-white p-3 border-2 border-black shadow-[2px_2px_0px_#000] space-y-1">
-                <label className="text-[10px] font-black text-neutral-500 uppercase block">[ 当前工单状态 ]</label>
-                <div className="font-black text-black text-sm uppercase">
-                  {ticket.status.replace('_', ' ')}
+            <div className="p-4 space-y-3 flex-1 text-xs">
+              <div className="space-y-1">
+                <span className="text-[10px] text-neutral-400 font-bold uppercase">当前处理状态</span>
+                <div>
+                  <span className={`inline-block px-2 py-0.5 text-xs font-black uppercase border border-black ${
+                    ticket.status === 'resolved' ? 'bg-emerald-300 text-black' :
+                    ticket.status === 'rejected' ? 'bg-rose-300 text-black' :
+                    ticket.status === 'info_required' ? 'bg-sky-300 text-black' :
+                    'bg-amber-300 text-black'
+                  }`}>
+                    {ticket.status}
+                  </span>
                 </div>
               </div>
 
-              {/* 描述 */}
-              <div className="space-y-1">
-                <label className="text-[10px] font-black text-neutral-500 uppercase block">[ 用户诉求与申请理由 ]</label>
-                <div className="bg-white p-3 border-2 border-black shadow-[2px_2px_0px_#000] text-xs font-sans text-neutral-800 whitespace-pre-wrap">
-                  {ticket.reason}
+              {ticket.admin_comment && (
+                <div className="space-y-1 bg-amber-50 border border-black p-2.5 text-[11px]">
+                  <span className="font-bold text-black uppercase">[ 客服最终判定结论 ]</span>
+                  <p className="text-neutral-700 mt-1">{ticket.admin_comment}</p>
                 </div>
-              </div>
+              )}
 
-              {/* 操作区 */}
-              <div className="pt-3 border-t-2 border-dashed border-neutral-300 space-y-2">
-                <label className="text-[10px] font-black text-neutral-500 uppercase block">[ 审批流转操作 ]</label>
-                <div className="space-y-2">
-                  <button 
-                    onClick={() => {
-                      setActionType('approve');
-                      setIsActionModalOpen(true);
-                    }}
-                    disabled={ticket.status === 'resolved'}
-                    className="w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-amber-300 hover:bg-amber-400 disabled:opacity-50 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
-                  >
-                    <Check size={14} /> <span>[ 批准 / 结案通过 ]</span>
-                  </button>
-                  <button 
-                    onClick={() => {
-                      setActionType('need-info');
-                      setIsActionModalOpen(true);
-                    }}
-                    disabled={ticket.status === 'info_required'}
-                    className="w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-white hover:bg-neutral-100 disabled:opacity-50 text-black border-2 border-black font-bold text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
-                  >
-                    <RefreshCw size={13} /> <span>[ 要求补充资料 ]</span>
-                  </button>
-                  <button 
-                    onClick={() => {
-                      setActionType('reject');
-                      setIsActionModalOpen(true);
-                    }}
-                    disabled={ticket.status === 'rejected'}
-                    className="w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-rose-100 hover:bg-rose-200 disabled:opacity-50 text-rose-800 border-2 border-black font-bold text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
-                  >
-                    <Ban size={13} /> <span>[ 驳回申请 ]</span>
-                  </button>
+              {ticket.updated_at && (
+                <div className="space-y-1 text-[11px] text-neutral-500 pt-2 border-t border-dashed border-neutral-200">
+                  <span>最后更新时间: </span>
+                  <LocalTime date={ticket.updated_at} />
                 </div>
+              )}
+            </div>
+
+            {/* 审核判定动作栏 */}
+            <div className="p-4 border-t-2 border-black bg-neutral-100 space-y-2 shrink-0">
+              <span className="text-[10px] font-black text-black uppercase block tracking-wider">
+                [ 快速处置决策 ]
+              </span>
+              <div className="grid grid-cols-3 gap-1.5">
+                <button
+                  type="button"
+                  onClick={() => { setActionType('approve'); setIsActionModalOpen(true); }}
+                  className="py-2 bg-emerald-300 hover:bg-emerald-400 text-black border-2 border-black font-bold text-[10px] shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex flex-col items-center justify-center gap-0.5"
+                >
+                  <Check size={12} />
+                  <span>支持诉求</span>
+                </button>
+                <button
+                  type="button"
+                  onClick={() => { setActionType('need-info'); setIsActionModalOpen(true); }}
+                  className="py-2 bg-sky-200 hover:bg-sky-300 text-black border-2 border-black font-bold text-[10px] shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex flex-col items-center justify-center gap-0.5"
+                >
+                  <Info size={12} />
+                  <span>补充凭证</span>
+                </button>
+                <button
+                  type="button"
+                  onClick={() => { setActionType('reject'); setIsActionModalOpen(true); }}
+                  className="py-2 bg-rose-200 hover:bg-rose-300 text-black border-2 border-black font-bold text-[10px] shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex flex-col items-center justify-center gap-0.5"
+                >
+                  <Ban size={12} />
+                  <span>驳回结单</span>
+                </button>
               </div>
             </div>
           </div>
@@ -216,7 +295,8 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
             md:flex md:flex-1
           `}>
             <div className="flex-1 overflow-y-auto p-4 md:p-6 space-y-3 bg-neutral-50">
-              {loadingMsg ? (
+              {/* 仅在首轮加载且无消息时展示 Loader */}
+              {loadingMsg && messages.length === 0 ? (
                 <div className="h-full flex flex-col items-center justify-center text-neutral-500 text-xs">
                   <Loader2 className="animate-spin w-6 h-6 mb-2 text-black" />
                   <span>[ 正在拉取对话流... ]</span>
@@ -228,6 +308,8 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
               ) : (
                 messages.map((msg) => {
                   const isAdmin = msg.sender_type === 'admin' || msg.sender_type === 'system';
+                  const imgs = extractImages(msg);
+
                   return (
                     <div key={msg.id} className={`flex ${isAdmin ? 'justify-end' : 'justify-start'}`}>
                       <div className={`flex max-w-[85%] md:max-w-[80%] ${isAdmin ? 'flex-row-reverse' : 'flex-row'} items-start gap-2`}>
@@ -237,10 +319,37 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
                           {isAdmin ? 'AD' : 'U'}
                         </div>
                         <div>
-                          <div className={`p-3 border-2 border-black text-xs font-sans shadow-[2px_2px_0px_#000] whitespace-pre-wrap ${
+                          <div className={`p-3 border-2 border-black text-xs font-sans shadow-[2px_2px_0px_#000] ${
                             isAdmin ? 'bg-amber-100 text-black' : 'bg-white text-black'
                           }`}>
-                            {msg.content}
+                            {msg.content && msg.content !== '[图片附件]' && (
+                              <p className="whitespace-pre-wrap break-words leading-relaxed">{msg.content}</p>
+                            )}
+
+                            {/* 附件图片渲染 */}
+                            {imgs.length > 0 && (
+                              <div className={`flex flex-wrap gap-2 ${msg.content && msg.content !== '[图片附件]' ? 'mt-2 pt-2 border-t border-black/20' : ''}`}>
+                                {imgs.map((imgUrl, idx) => (
+                                  <a
+                                    key={idx}
+                                    href={imgUrl}
+                                    target="_blank"
+                                    rel="noreferrer"
+                                    className="relative group border border-black bg-white p-1 shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 transition block max-w-[180px]"
+                                  >
+                                    <img
+                                      src={imgUrl}
+                                      alt="Attachment"
+                                      className="max-h-32 max-w-full object-contain"
+                                    />
+                                    <div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition text-white text-[10px] font-bold">
+                                      <ExternalLink size={12} className="mr-1" />
+                                      <span>原图</span>
+                                    </div>
+                                  </a>
+                                ))}
+                              </div>
+                            )}
                           </div>
                           <div className={`text-[10px] text-neutral-500 font-mono mt-1 flex gap-1 items-center ${isAdmin ? 'justify-end' : 'justify-start'}`}>
                             <span>{msg.sender_type === 'system' ? '[系统]' : (isAdmin ? '[客服]' : '[用户]')}</span>
@@ -257,8 +366,48 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
             </div>
 
             {/* Input Area */}
-            <div className="p-3 border-t-2 border-black bg-white shrink-0">
-              <form onSubmit={handleSend} className="flex gap-2">
+            <div className="p-3 border-t-2 border-black bg-white shrink-0 space-y-2">
+              {/* 待发送图片微缩展示 */}
+              {attachedImages.length > 0 && (
+                <div className="flex flex-wrap gap-2 p-1.5 bg-neutral-50 border border-neutral-300">
+                  {attachedImages.map((imgUrl, idx) => (
+                    <div key={idx} className="relative group border border-black bg-white p-1">
+                      <img src={imgUrl} alt="Preview" className="w-12 h-12 object-cover" />
+                      <button
+                        type="button"
+                        onClick={() => handleRemoveImage(idx)}
+                        className="absolute -top-1.5 -right-1.5 w-4 h-4 bg-rose-500 hover:bg-rose-600 text-white rounded-full flex items-center justify-center text-[9px] font-bold"
+                      >
+                        ✕
+                      </button>
+                    </div>
+                  ))}
+                </div>
+              )}
+
+              <form onSubmit={handleSend} className="flex gap-2 items-center">
+                <input
+                  type="file"
+                  ref={fileInputRef}
+                  onChange={handleImageUpload}
+                  accept="image/*"
+                  className="hidden"
+                />
+
+                <button
+                  type="button"
+                  disabled={uploadingImage || sending}
+                  onClick={() => fileInputRef.current?.click()}
+                  className="p-2 border-2 border-black bg-neutral-100 hover:bg-amber-100 text-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition disabled:opacity-50 shrink-0"
+                  title="上传图片附件 (最大 1MB)"
+                >
+                  {uploadingImage ? (
+                    <Loader2 size={15} className="animate-spin text-amber-600" />
+                  ) : (
+                    <ImageIcon size={15} />
+                  )}
+                </button>
+
                 <input
                   type="text"
                   value={reply}
@@ -266,10 +415,11 @@ export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }:
                   placeholder="输入客服答复意见..."
                   className="flex-1 border-2 border-black bg-neutral-50 px-3 py-2 text-xs font-sans focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
                 />
+                
                 <button 
                   type="submit" 
-                  disabled={sending || !reply.trim()}
-                  className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50 flex items-center gap-1"
+                  disabled={sending || (!reply.trim() && attachedImages.length === 0)}
+                  className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50 flex items-center gap-1 shrink-0"
                 >
                   {sending ? <Loader2 className="animate-spin w-4 h-4" /> : <Send size={13} />}
                   <span>[ 发送 ]</span>

+ 169 - 0
src/components/common/ImageUploadField.tsx

@@ -0,0 +1,169 @@
+'use client';
+
+import React, { useRef, useState } from 'react';
+import { Upload, X, Loader2, Image as ImageIcon, ExternalLink } from 'lucide-react';
+import { toast } from 'react-hot-toast';
+import { storageService } from '@/lib/services/storageService';
+
+interface ImageUploadFieldProps {
+  label?: string;
+  value: string;
+  onChange: (url: string) => void;
+  prefix?: string;
+  maxSizeMB?: number;
+  helperText?: string;
+  aspectRatio?: '16:9' | '1:1' | 'auto';
+  className?: string;
+  compact?: boolean;
+}
+
+export const ImageUploadField: React.FC<ImageUploadFieldProps> = ({
+  label,
+  value,
+  onChange,
+  prefix = 'uploads',
+  maxSizeMB = 1,
+  helperText,
+  aspectRatio = 'auto',
+  className = '',
+  compact = false,
+}) => {
+  const fileInputRef = useRef<HTMLInputElement>(null);
+  const [uploading, setUploading] = useState(false);
+
+  const handleFileSelect = async (e: React.ChangeEvent<HTMLInputElement>) => {
+    const file = e.target.files?.[0];
+    if (!file) return;
+
+    // 清理 input,以便能重复选同一文件
+    if (fileInputRef.current) {
+      fileInputRef.current.value = '';
+    }
+
+    if (file.size > maxSizeMB * 1024 * 1024) {
+      toast.error(`File size exceeds the allowed limit (max ${maxSizeMB}MB)`);
+      return;
+    }
+
+    setUploading(true);
+    try {
+      const res = await storageService.upload(file, prefix);
+      onChange(res.url);
+      toast.success('图片已成功上传至 R2 对象存储');
+    } catch (err: any) {
+      console.error('[R2 Upload Error]', err);
+      const msg = err.response?.data?.message || err.message || 'Upload failed';
+      toast.error(`上传失败: ${msg}`);
+    } finally {
+      setUploading(false);
+    }
+  };
+
+  const handleRemove = (e: React.MouseEvent) => {
+    e.stopPropagation();
+    onChange('');
+  };
+
+  const getAspectClass = () => {
+    if (aspectRatio === '16:9') return 'aspect-video';
+    if (aspectRatio === '1:1') return 'aspect-square';
+    return '';
+  };
+
+  return (
+    <div className={`space-y-1.5 ${className}`}>
+      {label ? (
+        <label className="text-xs font-bold text-black uppercase block">
+          {label}
+        </label>
+      ) : null}
+
+      <input
+        type="file"
+        ref={fileInputRef}
+        onChange={handleFileSelect}
+        accept="image/png,image/jpeg,image/webp,image/gif,image/svg+xml,image/bmp,image/x-icon"
+        className="hidden"
+      />
+
+      {value ? (
+        /* 已有图片展示与更换 */
+        <div className="border-2 border-black bg-neutral-50 p-2.5 shadow-[2px_2px_0px_#000] space-y-2">
+          <div className={`relative bg-neutral-200 border border-neutral-300 overflow-hidden flex items-center justify-center ${getAspectClass()} ${compact ? 'max-h-24' : 'max-h-48'}`}>
+            <img
+              src={value}
+              alt="Uploaded Preview"
+              className="max-h-full max-w-full object-contain"
+            />
+            {uploading ? (
+              <div className="absolute inset-0 bg-black/50 flex flex-col items-center justify-center text-white text-xs font-mono">
+                <Loader2 size={18} className="animate-spin mb-1 text-amber-300" />
+                <span>UPLOADING TO R2...</span>
+              </div>
+            ) : null}
+          </div>
+
+          <div className="flex items-center justify-between gap-2 pt-1 border-t border-neutral-200 text-xs font-mono">
+            <span className="truncate text-neutral-600 text-[11px] max-w-[200px] md:max-w-xs" title={value}>
+              {value}
+            </span>
+            <div className="flex items-center gap-1.5 shrink-0">
+              <a
+                href={value}
+                target="_blank"
+                rel="noreferrer"
+                className="px-2 py-1 bg-white hover:bg-neutral-100 border border-black text-black text-[11px] font-bold flex items-center gap-1"
+                title="查看原图"
+              >
+                <ExternalLink size={11} />
+                <span>预览</span>
+              </a>
+              <button
+                type="button"
+                disabled={uploading}
+                onClick={() => fileInputRef.current?.click()}
+                className="px-2 py-1 bg-amber-300 hover:bg-amber-400 border border-black text-black text-[11px] font-bold uppercase transition disabled:opacity-50"
+              >
+                [ 更换 ]
+              </button>
+              <button
+                type="button"
+                disabled={uploading}
+                onClick={handleRemove}
+                className="px-2 py-1 bg-rose-100 hover:bg-rose-200 border border-black text-rose-800 text-[11px] font-bold uppercase transition disabled:opacity-50"
+              >
+                [ 移除 ]
+              </button>
+            </div>
+          </div>
+        </div>
+      ) : (
+        /* 未上传:拖拽/点击上传槽位 */
+        <div
+          onClick={() => !uploading && fileInputRef.current?.click()}
+          className={`border-2 border-dashed border-black bg-neutral-50 hover:bg-amber-50/60 p-4 transition cursor-pointer flex flex-col items-center justify-center shadow-[2px_2px_0px_#000] ${compact ? 'py-3' : 'py-5'}`}
+        >
+          {uploading ? (
+            <div className="flex flex-col items-center gap-1.5 text-black font-mono">
+              <Loader2 size={18} className="animate-spin text-amber-500" />
+              <span className="text-xs font-bold uppercase">正在上传至 R2 对象存储...</span>
+              <span className="text-[10px] text-neutral-500">Processing file stream...</span>
+            </div>
+          ) : (
+            <div className="flex flex-col items-center gap-1 text-center">
+              <div className="w-8 h-8 rounded-none border border-black bg-white flex items-center justify-center mb-0.5 shadow-[1px_1px_0px_#000]">
+                <Upload size={14} className="text-black" />
+              </div>
+              <span className="text-xs font-black text-black uppercase">
+                [ 点击本地上传图片 ]
+              </span>
+              <span className="text-[10px] text-neutral-500 font-mono">
+                {helperText || `支持 PNG, JPG, WEBP, SVG (最大 ${maxSizeMB}MB)`}
+              </span>
+            </div>
+          )}
+        </div>
+      )}
+    </div>
+  );
+};

+ 192 - 83
src/components/common/ProductTutorialBanner.tsx

@@ -5,13 +5,10 @@ import React, { useState } from 'react';
 import {
   BookOpen,
   ExternalLink,
-  HelpCircle,
   X,
   ChevronDown,
   ChevronUp,
-  Sparkles,
   Info,
-  CheckCircle2,
   AlertTriangle,
   FileText,
   Compass,
@@ -64,100 +61,212 @@ export default function ProductTutorialBanner({
       {/* 1. 页面常驻横幅 / 引导卡片 */}
       {!hideBanner && (
         <div className="bg-sky-50 border-2 border-black p-4 sm:p-5 shadow-[4px_4px_0px_#000] space-y-3">
-        {/* 顶部标题与形态切换区 */}
-        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-2.5">
-          <div className="flex items-center gap-2">
-            <div className="w-6 h-6 bg-sky-300 border border-black flex items-center justify-center font-black shadow-[1px_1px_0px_#000]">
-              <Compass size={14} className="text-black" />
+          {/* 顶部标题与形态切换区 */}
+          <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-2.5">
+            <div className="flex items-center gap-2">
+              <div className="w-6 h-6 bg-sky-300 border border-black flex items-center justify-center font-black shadow-[1px_1px_0px_#000]">
+                <Compass size={14} className="text-black" />
+              </div>
+              <span className="font-black text-black text-xs sm:text-sm uppercase tracking-wide">
+                [ {modalTitle} ]
+              </span>
+              <span className="px-1.5 py-0.2 bg-amber-300 border border-black text-[10px] font-black uppercase text-black">
+                ★ {badgeText}
+              </span>
+            </div>
+
+            {/* 右侧动作按钮区 (严格根据 display_type 展示对应按键) */}
+            <div className="flex items-center gap-2">
+              {/* 模式 A: 纯弹窗模式 (modal) */}
+              {displayType === 'modal' && (
+                <button
+                  type="button"
+                  onClick={() => setIsModalOpen(true)}
+                  className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5 cursor-pointer"
+                >
+                  <BookOpen size={12} />
+                  <span>{buttonText}</span>
+                </button>
+              )}
+
+              {/* 模式 B: 纯外部超链接模式 (link) */}
+              {displayType === 'link' && (
+                linkUrl ? (
+                  <a
+                    href={linkUrl}
+                    target="_blank"
+                    rel="noopener noreferrer"
+                    className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5 cursor-pointer"
+                    title="在新窗口打开外部详细图文教程"
+                  >
+                    <ExternalLink size={12} />
+                    <span>{buttonText || linkText}</span>
+                  </a>
+                ) : (
+                  <span className="px-2 py-0.5 bg-neutral-200 border border-neutral-400 text-neutral-500 text-[10px] font-bold">
+                    [ 外部链接未配置 ]
+                  </span>
+                )
+              )}
+
+              {/* 模式 C: 组合模式 (both - 弹窗 + 外部超链接) */}
+              {displayType === 'both' && (
+                <>
+                  <button
+                    type="button"
+                    onClick={() => setIsModalOpen(true)}
+                    className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5 cursor-pointer"
+                  >
+                    <BookOpen size={12} />
+                    <span>{buttonText}</span>
+                  </button>
+
+                  {linkUrl && (
+                    <a
+                      href={linkUrl}
+                      target="_blank"
+                      rel="noopener noreferrer"
+                      className="px-3 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5 cursor-pointer"
+                      title="在新窗口打开外部详细图文教程"
+                    >
+                      <ExternalLink size={12} />
+                      <span>{linkText}</span>
+                    </a>
+                  )}
+                </>
+              )}
+
+              {/* 模式 D: 内嵌模式 (embedded - 页面直接展开,提供折叠按键与外链) */}
+              {displayType === 'embedded' && (
+                <>
+                  {linkUrl && (
+                    <a
+                      href={linkUrl}
+                      target="_blank"
+                      rel="noopener noreferrer"
+                      className="px-3 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5 cursor-pointer"
+                      title="在新窗口打开外部详细图文教程"
+                    >
+                      <ExternalLink size={12} />
+                      <span>{linkText}</span>
+                    </a>
+                  )}
+                  <button
+                    type="button"
+                    onClick={() => setIsEmbeddedExpanded(!isEmbeddedExpanded)}
+                    className="px-2 py-1 bg-amber-300 hover:bg-amber-400 border border-black text-xs font-bold shadow-[1px_1px_0px_#000] flex items-center gap-1 cursor-pointer"
+                    title={isEmbeddedExpanded ? '收起内嵌步骤与内容' : '展开内嵌步骤与内容'}
+                  >
+                    <span>{isEmbeddedExpanded ? '收起指引' : '展开指引'}</span>
+                    {isEmbeddedExpanded ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
+                  </button>
+                </>
+              )}
             </div>
-            <span className="font-black text-black text-xs sm:text-sm uppercase tracking-wide">
-              [ {modalTitle} ]
-            </span>
-            <span className="px-1.5 py-0.2 bg-amber-300 border border-black text-[10px] font-black uppercase text-black">
-              ★ {badgeText}
-            </span>
           </div>
 
-          {/* 右侧动作按钮区 (根据 display_type 展示多种形式) */}
-          <div className="flex items-center gap-2">
-            {/* 弹窗按钮 (用于 modal / both / embedded) */}
-            {(displayType === 'modal' || displayType === 'both' || displayType === 'embedded') && (
-              <button
-                type="button"
-                onClick={() => setIsModalOpen(true)}
-                className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5"
-              >
-                <BookOpen size={12} />
-                <span>{buttonText}</span>
-              </button>
-            )}
+          {/* 摘要提示文案 */}
+          {summary && (
+            <div className="flex items-start gap-2 text-xs text-neutral-800 font-sans leading-relaxed">
+              <Info size={14} className="text-sky-700 shrink-0 mt-0.5" />
+              <p className="font-medium">{summary}</p>
+            </div>
+          )}
 
-            {/* 外部超链接按钮 (用于 link / both / embedded) */}
-            {linkUrl && (displayType === 'link' || displayType === 'both' || displayType === 'embedded') && (
+          {/* 模式 B (link) 的专属导向条 */}
+          {displayType === 'link' && linkUrl && (
+            <div className="bg-white border-2 border-black p-3 shadow-[2px_2px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-2.5">
+              <div>
+                <span className="font-black text-black uppercase text-xs block font-mono">
+                  [ 官方在线图文知识库与账号指引 ]
+                </span>
+                <p className="text-[11px] text-neutral-600 font-sans mt-0.5">
+                  本服务详细教程由官方在外部文档库持续更新维护,支持直接跳转查阅
+                </p>
+              </div>
               <a
                 href={linkUrl}
                 target="_blank"
                 rel="noopener noreferrer"
-                className="px-3 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5"
-                title="在新窗口打开外部详细图文教程"
+                className="px-4 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center justify-center gap-1.5 shrink-0"
               >
-                <ExternalLink size={12} />
-                <span>{linkText}</span>
+                <span>{buttonText || linkText}</span>
+                <ExternalLink size={13} />
               </a>
-            )}
+            </div>
+          )}
 
-            {/* 内嵌模式下的折叠展开按键 */}
-            {displayType === 'embedded' && (
-              <button
-                type="button"
-                onClick={() => setIsEmbeddedExpanded(!isEmbeddedExpanded)}
-                className="p-1 bg-white hover:bg-neutral-100 border border-black text-xs font-bold shadow-[1px_1px_0px_#000]"
-                title={isEmbeddedExpanded ? '折叠步骤' : '展开步骤'}
-              >
-                {isEmbeddedExpanded ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
-              </button>
-            )}
-          </div>
-        </div>
+          {/* 模式 D (embedded) 的内嵌展示区 (展开时显示步骤、长文本 FAQ 与外链) */}
+          {displayType === 'embedded' && isEmbeddedExpanded && (
+            <div className="space-y-3 pt-2 border-t-2 border-dashed border-sky-300">
+              {/* 内嵌步骤卡片 */}
+              {steps.length > 0 && (
+                <div className="space-y-2">
+                  <span className="text-[10px] font-bold text-neutral-500 uppercase block font-mono">
+                    [ 准备与操作步骤 // STEPS ({steps.length}) ]:
+                  </span>
+                  <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5">
+                    {steps.map((step, idx) => (
+                      <div
+                        key={idx}
+                        className="bg-white border-2 border-black p-3 shadow-[2px_2px_0px_#000] space-y-1.5"
+                      >
+                        <div className="flex items-center gap-1.5 font-mono">
+                          <span className="w-5 h-5 bg-black text-white text-[10px] font-black flex items-center justify-center shrink-0">
+                            {step.step_no || idx + 1}
+                          </span>
+                          <span className="text-xs font-black text-black">{step.title}</span>
+                        </div>
+                        <p className="text-[11px] text-neutral-700 font-sans leading-relaxed whitespace-pre-wrap">
+                          {step.desc}
+                        </p>
+                      </div>
+                    ))}
+                  </div>
+                </div>
+              )}
 
-        {/* 摘要提示文案 */}
-        {summary && (
-          <div className="flex items-start gap-2 text-xs text-neutral-800 font-sans leading-relaxed">
-            <Info size={14} className="text-sky-700 shrink-0 mt-0.5" />
-            <p className="font-medium">{summary}</p>
-          </div>
-        )}
+              {/* 内嵌详细长文本 / FAQ */}
+              {content && (
+                <div className="bg-white border-2 border-black p-3.5 shadow-[2px_2px_0px_#000] space-y-2">
+                  <span className="font-black text-black uppercase text-xs block border-b border-neutral-200 pb-1 flex items-center gap-1.5">
+                    <FileText size={13} />
+                    <span>[ 详细说明与常见疑问 FAQ ]</span>
+                  </span>
+                  <div className="text-neutral-800 font-sans text-xs leading-relaxed whitespace-pre-wrap">
+                    {content}
+                  </div>
+                </div>
+              )}
 
-        {/* 2. 内嵌步骤卡片 (仅当 display_type 为 embedded 且展开时显示) */}
-        {displayType === 'embedded' && isEmbeddedExpanded && steps.length > 0 && (
-          <div className="pt-2 border-t border-dashed border-sky-300 space-y-2">
-            <span className="text-[10px] font-bold text-neutral-500 uppercase block font-mono">
-              [ 核心准备三步法 / QUICK STEPS ]:
-            </span>
-            <div className="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
-              {steps.map((step, idx) => (
-                <div
-                  key={idx}
-                  className="bg-white border border-black p-2.5 shadow-[1px_1px_0px_#000] space-y-1"
-                >
-                  <div className="flex items-center gap-1.5 font-mono">
-                    <span className="w-4 h-4 bg-black text-white text-[10px] font-black flex items-center justify-center">
-                      {step.step_no || idx + 1}
+              {/* 内嵌外部文档导向卡片 */}
+              {linkUrl && (
+                <div className="bg-sky-100 border-2 border-black p-3 shadow-[2px_2px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-2.5">
+                  <div>
+                    <span className="font-black text-black uppercase text-xs block">
+                      官方在线图文知识库 / 外部文档
                     </span>
-                    <span className="text-xs font-black text-black truncate">{step.title}</span>
+                    <p className="text-[11px] text-neutral-600 font-sans mt-0.5">
+                      支持在浏览器中查阅带图截屏与更详细的官方说明
+                    </p>
                   </div>
-                  <p className="text-[11px] text-neutral-600 font-sans leading-snug line-clamp-3">
-                    {step.desc}
-                  </p>
+                  <a
+                    href={linkUrl}
+                    target="_blank"
+                    rel="noopener noreferrer"
+                    className="px-3.5 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center justify-center gap-1.5 shrink-0"
+                  >
+                    <span>{linkText}</span>
+                    <ExternalLink size={13} />
+                  </a>
                 </div>
-              ))}
+              )}
             </div>
-          </div>
-        )}
-      </div>
+          )}
+        </div>
       )}
 
-      {/* 3. 弹出对话框模式 (Tutorial Modal Dialog) */}
+      {/* 2. 弹出对话框模式 (Tutorial Modal Dialog) */}
       {isModalOpen && (
         <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-mono animate-in fade-in duration-150">
           <div className="bg-neutral-50 border-4 border-black w-full max-w-2xl max-h-[88vh] flex flex-col shadow-[8px_8px_0px_#000] overflow-hidden">
@@ -182,7 +291,7 @@ export default function ProductTutorialBanner({
               <button
                 type="button"
                 onClick={handleCloseModal}
-                className="w-7 h-7 bg-white hover:bg-neutral-100 border border-black flex items-center justify-center font-bold text-xs shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+                className="w-7 h-7 bg-white hover:bg-neutral-100 border border-black flex items-center justify-center font-bold text-xs shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
               >
                 <X size={14} />
               </button>
@@ -224,7 +333,7 @@ export default function ProductTutorialBanner({
                           <h4 className="font-black text-black text-xs font-sans uppercase">
                             {step.title}
                           </h4>
-                          <p className="text-neutral-700 font-sans text-xs leading-relaxed">
+                          <p className="text-neutral-700 font-sans text-xs leading-relaxed whitespace-pre-wrap">
                             {step.desc}
                           </p>
                         </div>
@@ -247,12 +356,12 @@ export default function ProductTutorialBanner({
                 </div>
               )}
 
-              {/* 外部文档推荐 */}
+              {/* 外部文档推荐 (在 modal, both, link 下皆可展现) */}
               {linkUrl && (
                 <div className="bg-sky-50 border-2 border-black p-3.5 shadow-[2px_2px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-3">
                   <div>
                     <span className="font-black text-black uppercase text-xs block">
-                      官方在线图文知识库 / 视频文档
+                      官方在线图文知识库 / 外部文档
                     </span>
                     <p className="text-[11px] text-neutral-600 font-sans mt-0.5">
                       支持在电脑或手机浏览器中完整查阅带图截屏与更详细的说明
@@ -279,7 +388,7 @@ export default function ProductTutorialBanner({
               <button
                 type="button"
                 onClick={handleCloseModal}
-                className="px-4 py-1.5 bg-black hover:bg-neutral-800 text-white font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+                className="px-4 py-1.5 bg-black hover:bg-neutral-800 text-white font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
               >
                 [ 我已阅读并了解 ]
               </button>

+ 25 - 9
src/components/dashboard/OrderList.tsx

@@ -6,15 +6,17 @@ import { CreditCard, Loader2, AlertCircle, Package, Clock, Hash, Eye, Search, Sp
 import Pagination from '@/components/common/Pagination';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
-import { Order } from '@/types';
+import { Order, UserTicket } from '@/types';
 import { orderService } from '@/lib/services';
 
 interface OrderListProps {
   onRequestTicket: (orderId: string) => void;
   onViewDetail: (order: Order) => void;
+  openTicketsMap?: Record<string, UserTicket>;
+  onViewTicket?: (ticket: UserTicket) => void;
 }
 
-export default function OrderList({ onRequestTicket, onViewDetail }: OrderListProps) {
+export default function OrderList({ onRequestTicket, onViewDetail, openTicketsMap, onViewTicket }: OrderListProps) {
   const router = useRouter();
   const { t } = useLanguage();
   
@@ -223,13 +225,27 @@ export default function OrderList({ onRequestTicket, onViewDetail }: OrderListPr
 
                 {/* 底部操作按键栏 */}
                 <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex flex-wrap items-center justify-between gap-2">
-                  <button
-                    onClick={() => onRequestTicket(String(order.id))}
-                    className="px-3 py-1.5 bg-neutral-100 hover:bg-neutral-200 text-black border border-black font-bold text-xs shadow-[1px_1px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1.5 uppercase"
-                  >
-                    <MessageSquare size={13} />
-                    <span>{t('common.apply_support')}</span>
-                  </button>
+                  {openTicketsMap && openTicketsMap[String(order.id)] ? (
+                    <button
+                      onClick={() => onViewTicket && onViewTicket(openTicketsMap[String(order.id)])}
+                      className="px-3 py-1.5 bg-amber-100 hover:bg-amber-200 text-black border-2 border-black font-bold text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1.5 uppercase"
+                      title={t('ticket.already_has_open_ticket')}
+                    >
+                      <MessageSquare size={13} className="text-amber-800" />
+                      <span>{t('ticket.ticket_in_progress') || '工单处理中'}</span>
+                      <span className="px-1.5 py-0.2 bg-black text-white text-[10px] font-mono">
+                        #{openTicketsMap[String(order.id)].id}
+                      </span>
+                    </button>
+                  ) : (
+                    <button
+                      onClick={() => onRequestTicket(String(order.id))}
+                      className="px-3 py-1.5 bg-neutral-100 hover:bg-neutral-200 text-black border border-black font-bold text-xs shadow-[1px_1px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1.5 uppercase"
+                    >
+                      <MessageSquare size={13} />
+                      <span>{t('common.apply_support')}</span>
+                    </button>
+                  )}
 
                   <div className="flex items-center gap-2">
                     {isPending && (

+ 1 - 1
src/components/dashboard/Sidebar.tsx

@@ -29,7 +29,7 @@ interface MenuItem {
 export default function Sidebar({ activeTab, setActiveTab }: SidebarProps) {
   const { t } = useLanguage();
   
-  const TELEGRAM_USERNAME = "TextSkin Support"; 
+  const TELEGRAM_USERNAME = "STRATA Support"; 
   const TELEGRAM_NUMBER = "+8617386033451"; 
   const WHATSAPP_NUMBER = "8617386033451"; 
 

+ 24 - 4
src/components/dashboard/TicketModal.tsx

@@ -5,15 +5,17 @@ import { Loader2, X, AlertTriangle, Send } from 'lucide-react';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import MessageModal from '@/components/common/MessageModal';
 import { ticketService } from '@/lib/services';
+import { UserTicket } from '@/types';
 
 interface TicketModalProps {
   isOpen: boolean;
   onClose: () => void;
   onSuccess?: () => void;
   defaultOrderId?: string;
+  openTicketsMap?: Record<string, UserTicket>;
 }
 
-export default function TicketModal({ isOpen, onClose, onSuccess, defaultOrderId = '' }: TicketModalProps) {
+export default function TicketModal({ isOpen, onClose, onSuccess, defaultOrderId = '', openTicketsMap }: TicketModalProps) {
   const { t } = useLanguage();
 
   const [loading, setLoading] = useState<boolean>(false);
@@ -60,8 +62,18 @@ export default function TicketModal({ isOpen, onClose, onSuccess, defaultOrderId
     }
   }, [isOpen, defaultOrderId]);
 
+  const trimmedOrderId = form.order_id.trim();
+  const existingActiveTicket = openTicketsMap && trimmedOrderId ? openTicketsMap[trimmedOrderId] : null;
+
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault();
+    if (loading) return;
+
+    if (existingActiveTicket) {
+      setErrorMsg(t('ticket.already_has_open_ticket') || `该订单已存在进行中的工单 (#${existingActiveTicket.id}),无法重复发起`);
+      return;
+    }
+
     setLoading(true);
     setErrorMsg('');
 
@@ -118,11 +130,19 @@ export default function TicketModal({ isOpen, onClose, onSuccess, defaultOrderId
               <input
                 type="text" 
                 required
-                className="w-full border-2 border-black bg-neutral-50 p-2.5 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+                className={`w-full border-2 p-2.5 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black ${
+                  existingActiveTicket ? 'border-rose-600 bg-rose-50' : 'border-black bg-neutral-50'
+                }`}
                 value={form.order_id}
                 onChange={e => setForm({ ...form, order_id: e.target.value })}
                 placeholder={t('ticket.order_id_placeholder') || '例如: 1024'}
               />
+              {existingActiveTicket && (
+                <div className="p-2 bg-rose-50 border border-rose-600 text-[11px] font-bold text-rose-700 flex items-center gap-1 mt-1">
+                  <AlertTriangle size={13} className="shrink-0 text-rose-600" />
+                  <span>{t('ticket.already_has_open_ticket') || '该订单已有处理中的工单'} (#{existingActiveTicket.id})</span>
+                </div>
+              )}
             </div>
 
             <div className="space-y-1">
@@ -164,8 +184,8 @@ export default function TicketModal({ isOpen, onClose, onSuccess, defaultOrderId
               </button>
               <button
                 type="submit"
-                disabled={loading}
-                className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase flex items-center gap-1.5 disabled:opacity-50"
+                disabled={loading || !!existingActiveTicket}
+                className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase flex items-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed"
               >
                 {loading ? <Loader2 className="animate-spin w-4 h-4" /> : <><Send size={13} /> <span>[ {t('ticket.submit_btn') || '确认提交工单'} ]</span></>}
               </button>

+ 159 - 18
src/components/dashboard/UserTicketDetailModal.tsx

@@ -1,12 +1,13 @@
 'use client';
 
 import { useState, useEffect, useRef } from 'react';
-import { X, Send, User, Headset, Paperclip, Loader2, Clock } from 'lucide-react';
+import { X, Send, User, Headset, Paperclip, Loader2, Clock, Image as ImageIcon, ExternalLink } from 'lucide-react';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
 import MessageModal from '@/components/common/MessageModal';
 import { UserTicket, TicketMessage } from '@/types';
 import { ticketService } from '@/lib/services';
+import { storageService } from '@/lib/services/storageService';
 
 interface UserTicketDetailModalProps {
   isOpen: boolean;
@@ -21,6 +22,11 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
   const [loadingMsg, setLoadingMsg] = useState(false);
   const [replyContent, setReplyContent] = useState('');
   const [sending, setSending] = useState(false);
+
+  // 图片附件相关
+  const [attachedImages, setAttachedImages] = useState<string[]>([]);
+  const [uploadingImage, setUploadingImage] = useState(false);
+  const fileInputRef = useRef<HTMLInputElement>(null);
   
   const messagesEndRef = useRef<HTMLDivElement>(null);
 
@@ -46,18 +52,21 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
 
   useEffect(() => {
     if (isOpen && ticket) {
-      fetchMessages();
+      setMessages([]);
+      setAttachedImages([]);
+      setReplyContent('');
+      fetchMessages(false);
     }
-  }, [isOpen, ticket]);
+  }, [isOpen, ticket?.id]);
 
   useEffect(() => {
     scrollToBottom();
   }, [messages]);
 
-  const fetchMessages = async () => {
+  const fetchMessages = async (silent = false) => {
     if (!ticket) return;
+    if (!silent) setLoadingMsg(true);
     try {
-      setLoadingMsg(true);
       const res = await ticketService.fetchMessages(ticket.id, { 
         page: 1,
         size: 100 
@@ -71,26 +80,73 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
     } catch (error) {
       console.error("Fetch messages failed", error);
     } finally {
-      setLoadingMsg(false);
+      if (!silent) setLoadingMsg(false);
     }
   };
 
+  const handleImageUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
+    const file = e.target.files?.[0];
+    if (!file) return;
+    if (fileInputRef.current) fileInputRef.current.value = '';
+
+    if (file.size > 1 * 1024 * 1024) {
+      showMessage('图片大小不能超过 1MB', 'error');
+      return;
+    }
+
+    setUploadingImage(true);
+    try {
+      const res = await storageService.upload(file, 'ticket_attachments');
+      setAttachedImages(prev => [...prev, res.url]);
+    } catch (err: any) {
+      console.error("Image upload failed", err);
+      const errText = err.response?.data?.message || err.message || '图片上传失败,请重试';
+      showMessage(errText, 'error');
+    } finally {
+      setUploadingImage(false);
+    }
+  };
+
+  const handleRemoveImage = (index: number) => {
+    setAttachedImages(prev => prev.filter((_, i) => i !== index));
+  };
+
   const handleSend = async (e: React.FormEvent) => {
     e.preventDefault();
-    if (!replyContent.trim() || !ticket) return;
+    if ((!replyContent.trim() && attachedImages.length === 0) || !ticket) return;
 
+    const contentToSend = replyContent.trim() || (attachedImages.length > 0 ? '[图片附件]' : '');
+    const imagesToSend = [...attachedImages];
+
+    // 1. 乐观更新(立即上屏,解决发送消息时白屏闪烁与顿挫问题)
+    const tempId = Date.now();
+    const optimisticMsg: TicketMessage = {
+      id: tempId,
+      ticket_id: ticket.id,
+      sender_type: 'user',
+      content: contentToSend,
+      attachments: imagesToSend.length > 0 ? { images: imagesToSend } : null,
+      created_at: new Date().toISOString(),
+    };
+
+    setMessages(prev => [...prev, optimisticMsg]);
+    setReplyContent('');
+    setAttachedImages([]);
     setSending(true);
+
     try {
       await ticketService.sendMessage(ticket.id, {
-        content: replyContent,
-        attachments: null
+        content: contentToSend,
+        attachments: imagesToSend.length > 0 ? { images: imagesToSend } : null
       });
 
-      setReplyContent('');
-      fetchMessages();
+      // 静默拉取后端权威数据,无感同步
+      await fetchMessages(true);
     } catch (error) {
       console.error("Send message failed", error);
       showMessage(t('ticket.send_failed') || '发送失败,请重试', 'error');
+      // 发送失败恢复数据并同步
+      fetchMessages(true);
     } finally {
       setSending(false);
     }
@@ -100,6 +156,18 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
     messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
   };
 
+  const extractImages = (msg: TicketMessage): string[] => {
+    const imgs: string[] = [];
+    if (msg.attachments) {
+      if (Array.isArray(msg.attachments.images)) {
+        imgs.push(...msg.attachments.images);
+      } else if (typeof msg.attachments.url === 'string') {
+        imgs.push(msg.attachments.url);
+      }
+    }
+    return imgs;
+  };
+
   if (!isOpen || !ticket) return null;
 
   const serial = `TCK-${String(ticket.id).padStart(4, '0')}`;
@@ -151,7 +219,8 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
             </p>
           </div>
 
-          {loadingMsg ? (
+          {/* 仅在首次拉取且当前无消息时展示 Loader,避免发消息时出现整屏闪烁 */}
+          {loadingMsg && messages.length === 0 ? (
             <div className="flex justify-center py-8">
               <Loader2 className="animate-spin text-black w-6 h-6" />
             </div>
@@ -159,6 +228,7 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
             messages.map((msg) => {
               const isMe = msg.sender_type === 'user';
               const isSystem = msg.sender_type === 'system';
+              const imgs = extractImages(msg);
 
               if (isSystem) {
                 return (
@@ -182,7 +252,34 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
                         ? 'bg-amber-300 text-black shadow-[3px_3px_0px_#000] text-left' 
                         : 'bg-white text-black shadow-[3px_3px_0px_#000] text-left'
                     }`}>
-                      <p className="leading-relaxed whitespace-pre-wrap break-words">{msg.content}</p>
+                      {msg.content && msg.content !== '[图片附件]' && (
+                        <p className="leading-relaxed whitespace-pre-wrap break-words">{msg.content}</p>
+                      )}
+
+                      {/* 图片附件展示 */}
+                      {imgs.length > 0 && (
+                        <div className={`flex flex-wrap gap-2 ${msg.content && msg.content !== '[图片附件]' ? 'mt-2.5 pt-2 border-t border-black/20' : ''}`}>
+                          {imgs.map((imgUrl, idx) => (
+                            <a
+                              key={idx}
+                              href={imgUrl}
+                              target="_blank"
+                              rel="noreferrer"
+                              className="relative group border-2 border-black bg-white p-1 shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 transition block max-w-[200px]"
+                            >
+                              <img
+                                src={imgUrl}
+                                alt="Attachment"
+                                className="max-h-36 max-w-full object-contain"
+                              />
+                              <div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 flex items-center justify-center transition text-white text-[10px] font-bold">
+                                <ExternalLink size={12} className="mr-1" />
+                                <span>原图</span>
+                              </div>
+                            </a>
+                          ))}
+                        </div>
+                      )}
                     </div>
                   </div>
                 </div>
@@ -194,8 +291,51 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
         </div>
 
         {/* Reply Input Bar */}
-        <div className="p-4 bg-white border-t-2 border-black shrink-0">
-          <form onSubmit={handleSend} className="flex gap-2">
+        <div className="p-3.5 bg-white border-t-2 border-black shrink-0 space-y-2">
+          {/* 已选图片预览栏 */}
+          {attachedImages.length > 0 && (
+            <div className="flex flex-wrap gap-2 p-2 bg-neutral-50 border border-neutral-300">
+              {attachedImages.map((imgUrl, idx) => (
+                <div key={idx} className="relative group border border-black bg-white p-1">
+                  <img src={imgUrl} alt="Preview" className="w-14 h-14 object-cover" />
+                  <button
+                    type="button"
+                    onClick={() => handleRemoveImage(idx)}
+                    className="absolute -top-1.5 -right-1.5 w-4 h-4 bg-rose-500 hover:bg-rose-600 text-white rounded-full flex items-center justify-center text-[10px] font-bold shadow"
+                    title="移除图片"
+                  >
+                    ✕
+                  </button>
+                </div>
+              ))}
+            </div>
+          )}
+
+          <form onSubmit={handleSend} className="flex gap-2 items-end">
+            {/* 上传图片隐形 input */}
+            <input
+              type="file"
+              ref={fileInputRef}
+              onChange={handleImageUpload}
+              accept="image/*"
+              className="hidden"
+            />
+
+            {/* 上传按钮 */}
+            <button
+              type="button"
+              disabled={uploadingImage || sending}
+              onClick={() => fileInputRef.current?.click()}
+              className="p-2.5 bg-neutral-100 hover:bg-amber-100 text-black border-2 border-black shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 disabled:opacity-50 shrink-0"
+              title="本地上传图片附件 (最大 1MB)"
+            >
+              {uploadingImage ? (
+                <Loader2 size={16} className="animate-spin text-amber-600" />
+              ) : (
+                <ImageIcon size={16} />
+              )}
+            </button>
+
             <div className="flex-1">
               <textarea
                 value={replyContent}
@@ -208,13 +348,14 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
                 }}
                 placeholder={t('ticket.reply_placeholder') || '输入工单回复信息 (Enter 发送)...'}
                 rows={2}
-                className="w-full border-2 border-black bg-neutral-50 p-2.5 text-xs font-sans focus:bg-white outline-none shadow-[2px_2px_0px_#000] resize-none text-black"
+                className="w-full border-2 border-black bg-neutral-50 p-2 text-xs font-sans focus:bg-white outline-none shadow-[2px_2px_0px_#000] resize-none text-black"
               />
             </div>
+
             <button 
               type="submit" 
-              disabled={sending || !replyContent.trim()}
-              className="px-5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none disabled:opacity-50 flex items-center justify-center gap-1 uppercase shrink-0"
+              disabled={sending || (!replyContent.trim() && attachedImages.length === 0)}
+              className="px-5 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none disabled:opacity-50 flex items-center justify-center gap-1 uppercase shrink-0"
             >
               {sending ? <Loader2 className="animate-spin w-4 h-4" /> : <><Send size={13} /> <span>[ 发送 ]</span></>}
             </button>

+ 38 - 80
src/components/services/ServicePoster.tsx

@@ -37,16 +37,11 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
   const countryLower = (product.country || '').toLowerCase();
   const visaType = product.visa_type || 'Tourist';
 
-  // 国家专属视觉主题
+  // 国家专属视觉主题 (仅提取视觉强调色与图形标识,文本完全来自后端配置)
   const getTheme = () => {
     if (countryLower.includes('france') || countryLower.includes('法国')) {
       return {
-        brand: 'FRANCE VISA',
-        mainTitle: 'FRANCE',
-        highlightTitle: 'Schengen 4M',
-        sub: '申根短期签证官方代抢',
         accentColor: '#2563eb', // blue
-        accentTag: 'VFS 官方通道',
         flagColors: ['#002654', '#ffffff', '#ed2939'],
         watermark: 'france.vfs.vas',
         symbolType: 'schengen',
@@ -54,12 +49,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('united states') || countryLower.includes('usa') || countryLower.includes('us') || countryLower.includes('美国')) {
       return {
-        brand: 'US VISA',
-        mainTitle: 'USA B1/B2',
-        highlightTitle: 'FAST-PASS',
-        sub: '美签免面签 / 加急代刷',
         accentColor: '#dc2626', // red
-        accentTag: 'CGI / AIS 直连',
         flagColors: ['#b22234', '#ffffff', '#3c3b6e'],
         watermark: 'us-visa.vas.ai',
         symbolType: 'us',
@@ -67,12 +57,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('united kingdom') || countryLower.includes('uk') || countryLower.includes('英国')) {
       return {
-        brand: 'UK VISA',
-        mainTitle: 'UK VISITOR',
-        highlightTitle: 'STANDARD',
-        sub: '英签访问 / 留学快速预约',
         accentColor: '#b91c1c',
-        accentTag: 'TLS Contact 通道',
         flagColors: ['#012169', '#ffffff', '#c8102e'],
         watermark: 'ukvi.official.vas',
         symbolType: 'uk',
@@ -80,12 +65,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('germany') || countryLower.includes('德国')) {
       return {
-        brand: 'GERMANY VISA',
-        mainTitle: 'GERMANY',
-        highlightTitle: 'National / Term',
-        sub: '德国大使馆预约加急',
         accentColor: '#d97706', // amber/gold
-        accentTag: 'Termin 直连',
         flagColors: ['#000000', '#dd0000', '#ffcc00'],
         watermark: 'germany.termin.vas',
         symbolType: 'germany',
@@ -93,12 +73,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('italy') || countryLower.includes('意大利')) {
       return {
-        brand: 'ITALY VISA',
-        mainTitle: 'ITALIA',
-        highlightTitle: 'Turismo 90D',
-        sub: '意签快捷办理与刷位',
         accentColor: '#059669', // green
-        accentTag: 'VFS 申根通道',
         flagColors: ['#009246', '#ffffff', '#ce2b37'],
         watermark: 'italy.schengen.vas',
         symbolType: 'italy',
@@ -106,12 +81,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('spain') || countryLower.includes('西班牙')) {
       return {
-        brand: 'SPAIN VISA',
-        mainTitle: 'SPAIN',
-        highlightTitle: 'BLS Priority',
-        sub: '西班牙旅游/商务代抢',
         accentColor: '#ea580c', // orange/crimson
-        accentTag: 'BLS 官方直连',
         flagColors: ['#aa151b', '#f1bf00', '#aa151b'],
         watermark: 'spain.bls.vas',
         symbolType: 'spain',
@@ -119,12 +89,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('denmark') || countryLower.includes('丹麦')) {
       return {
-        brand: 'DENMARK VISA',
-        mainTitle: 'DENMARK',
-        highlightTitle: 'Schengen Plus',
-        sub: '丹麦申根加急代抢',
         accentColor: '#dc2626',
-        accentTag: 'VFS 官方通道',
         flagColors: ['#c8102e', '#ffffff'],
         watermark: 'denmark.vfs.vas',
         symbolType: 'schengen',
@@ -132,12 +97,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('netherlands') || countryLower.includes('荷兰') || countryLower.includes('holland')) {
       return {
-        brand: 'NETHERLANDS VISA',
-        mainTitle: 'HOLLAND',
-        highlightTitle: 'Schengen 90D',
-        sub: '荷兰申根极速代抢',
         accentColor: '#ea580c', // Dutch orange
-        accentTag: 'VFS 官方通道',
         flagColors: ['#ae1c28', '#ffffff', '#21468b'],
         watermark: 'netherlands.vfs.vas',
         symbolType: 'schengen',
@@ -145,12 +105,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('greece') || countryLower.includes('希腊')) {
       return {
-        brand: 'GREECE VISA',
-        mainTitle: 'GREECE',
-        highlightTitle: 'Priority Slot',
-        sub: '希腊官方预约通道',
         accentColor: '#0284c7', // Aegean cyan
-        accentTag: '官方通道直连',
         flagColors: ['#0d5eaf', '#ffffff'],
         watermark: 'greece.schengen.vas',
         symbolType: 'schengen',
@@ -158,12 +113,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     }
     if (countryLower.includes('japan') || countryLower.includes('日本')) {
       return {
-        brand: 'JAPAN VISA',
-        mainTitle: 'JAPAN',
-        highlightTitle: 'e-VISA Fast',
-        sub: '日本单次 / 多次加急',
         accentColor: '#e11d48', // rose
-        accentTag: 'eVisa 官方通道',
         flagColors: ['#ffffff', '#bc002d'],
         watermark: 'japan.evisa.vas',
         symbolType: 'japan',
@@ -172,12 +122,7 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
 
     // Default global
     return {
-      brand: 'GLOBAL VISA',
-      mainTitle: (product.country || 'GLOBAL').toUpperCase(),
-      highlightTitle: `${visaType.toUpperCase()} PASS`,
-      sub: `${product.country} 官方加急预约`,
       accentColor: '#0284c7', // sky
-      accentTag: `${product.provider || 'OFFICIAL'} 直连`,
       flagColors: ['#0284c7', '#38bdf8'],
       watermark: 'vas.global.ai',
       symbolType: 'global',
@@ -187,10 +132,11 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
   const baseTheme = getTheme();
   const theme = {
     ...baseTheme,
-    brand: cardConfig?.poster_tag || baseTheme.brand,
-    mainTitle: cardConfig?.poster_title || baseTheme.mainTitle,
-    highlightTitle: cardConfig?.poster_highlight || baseTheme.highlightTitle,
-    sub: cardConfig?.poster_sub || baseTheme.sub,
+    brand: cardConfig?.poster_tag || product.provider || '',
+    accentTag: cardConfig?.official_tag || product.city || '',
+    mainTitle: cardConfig?.poster_title || (product.country || '').toUpperCase(),
+    highlightTitle: cardConfig?.poster_highlight || (visaType ? visaType.toUpperCase() : ''),
+    sub: cardConfig?.poster_sub || product.title || '',
     accentColor: cardConfig?.poster_accent_color || baseTheme.accentColor,
   };
 
@@ -198,32 +144,44 @@ export default function ServicePoster({ product, className = '' }: ServicePoster
     <div
       className={`relative w-full lg:w-[280px] xl:w-[320px] aspect-[16/9] shrink-0 overflow-hidden bg-gradient-to-br from-[#fafaf9] via-[#ffffff] to-[#f5f5f4] border-2 border-black shadow-[3px_3px_0px_#000] select-none flex flex-col justify-between p-3.5 sm:p-4 ${className}`}
     >
-      {/* 顶部微型品牌标 */}
+      {/* 顶部微型品牌标 (仅在后端有提供对应属性时显示) */}
       <div className="flex items-center justify-between z-10 font-mono">
-        <span className="text-[10px] font-black tracking-widest text-black uppercase bg-neutral-100 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
-          {theme.brand}
-        </span>
-        <span className="text-[10px] font-black px-1.5 py-0.5 border border-black bg-amber-300 text-black shadow-[1px_1px_0px_#000]">
-          {theme.accentTag}
-        </span>
+        {theme.brand ? (
+          <span className="text-[10px] font-black tracking-widest text-black uppercase bg-neutral-100 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
+            {theme.brand}
+          </span>
+        ) : (
+          <span />
+        )}
+        {theme.accentTag ? (
+          <span className="text-[10px] font-black px-1.5 py-0.5 border border-black bg-amber-300 text-black shadow-[1px_1px_0px_#000]">
+            {theme.accentTag}
+          </span>
+        ) : null}
       </div>
 
       {/* 主体文字排版与右侧 3D 拟真徽章 */}
       <div className="flex items-center justify-between gap-2 my-auto z-10">
         {/* 左侧大字 */}
-        <div className="space-y-0.5">
-          <div className="text-xl sm:text-2xl font-black text-black tracking-tighter leading-tight font-sans">
-            {theme.mainTitle}
-          </div>
-          <div
-            className="text-lg sm:text-xl font-black tracking-tight leading-none"
-            style={{ color: theme.accentColor }}
-          >
-            {theme.highlightTitle}
-          </div>
-          <div className="text-[10px] font-bold text-neutral-600 pt-0.5 tracking-tight font-mono">
-            {theme.sub}
-          </div>
+        <div className="space-y-0.5 max-w-[170px] sm:max-w-[190px]">
+          {theme.mainTitle && (
+            <div className="text-xl sm:text-2xl font-black text-black tracking-tighter leading-tight font-sans truncate">
+              {theme.mainTitle}
+            </div>
+          )}
+          {theme.highlightTitle && (
+            <div
+              className="text-lg sm:text-xl font-black tracking-tight leading-none truncate"
+              style={{ color: theme.accentColor }}
+            >
+              {theme.highlightTitle}
+            </div>
+          )}
+          {theme.sub && (
+            <div className="text-[10px] font-bold text-neutral-600 pt-0.5 tracking-tight font-mono line-clamp-1">
+              {theme.sub}
+            </div>
+          )}
         </div>
 
         {/* 右侧 3D 视觉元素 */}

+ 8 - 39
src/components/slots/CitySlotCard.tsx

@@ -1,14 +1,12 @@
 'use client';
 
-import { useRouter } from 'next/navigation';
 import { Calendar, ExternalLink, AlertCircle, CheckCircle, Hourglass, Activity, History } from 'lucide-react';
 import TimeAgo from '@/components/common/TimeAgo';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import { SlotSnapshot } from '@/types';
 
-export default function CitySlotCard({ data, isBlacklisted = false }: { data: SlotSnapshot; isBlacklisted?: boolean }) {
+export default function CitySlotCard({ data }: { data: SlotSnapshot; isBlacklisted?: boolean }) {
   const { t, lang } = useLanguage();
-  const router = useRouter();
   
   // === 1. 时间计算与解析 ===
   const now = new Date().getTime();
@@ -81,21 +79,6 @@ export default function CitySlotCard({ data, isBlacklisted = false }: { data: Sl
   };
 
   const style = getStyleConfig();
-  const slotRoutingKey = data.slot_snapshot?.routing_key || data.routing_key;
-  const slotCity = data.city;
-  const slotCountry = data.country;
-  const slotVisaType = data.visa_type;
-  const canSubscribe = Boolean(slotRoutingKey) && !isBlacklisted;
-
-  const handleSubscribe = () => {
-    if (!slotRoutingKey) return;
-    const params = new URLSearchParams();
-    params.set('slot_routing_key', slotRoutingKey);
-    if (slotCity) params.set('slot_city', slotCity);
-    if (slotCountry) params.set('slot_country', slotCountry);
-    if (slotVisaType) params.set('slot_visa_type', slotVisaType);
-    router.push(`/create-order/16?${params.toString()}`);
-  };
 
   const renderCenterContent = () => {
     if (rawStatus === 'Waitlist') {
@@ -181,34 +164,20 @@ export default function CitySlotCard({ data, isBlacklisted = false }: { data: Sl
           </div>
         </div>
 
-        {data.website && (
+        {data.website ? (
           <a 
             href={data.website} 
             target="_blank" 
             rel="noopener noreferrer"
-            className="w-full flex items-center justify-center gap-1 py-1.5 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-bold transition shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
+            className="w-full flex items-center justify-center gap-1.5 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black transition uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
           >
             <span>{t('common.book_now') || '前往使馆预约'}</span>
-            <ExternalLink size={11} />
+            <ExternalLink size={12} />
           </a>
-        )}
-
-        <button
-          onClick={handleSubscribe}
-          disabled={!canSubscribe}
-          className={`w-full py-2.5 border-2 border-black text-xs font-black transition uppercase ${
-            canSubscribe 
-              ? 'bg-amber-300 hover:bg-amber-400 text-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none' 
-              : 'bg-neutral-100 text-neutral-400 cursor-not-allowed'
-          }`}
-        >
-          {t('slots.subscribe_notification') || '订阅名额自动锁位 →'}
-        </button>
-
-        {!canSubscribe && !isBlacklisted && (
-          <p className="text-[10px] text-neutral-400 text-center font-sans">
-            {t('slots.subscribe_unavailable') || '该节点暂未配置自动分发路由'}
-          </p>
+        ) : (
+          <div className="w-full flex items-center justify-center py-2.5 bg-neutral-100 text-neutral-400 border border-neutral-300 text-xs font-mono select-none">
+            {t('slots.no_direct_link') || '使馆暂无直达链接'}
+          </div>
         )}
       </div>
     </div>

+ 1 - 3
src/components/slots/SlotGrid.tsx

@@ -8,14 +8,12 @@ interface SlotGridProps {
   loading: boolean;
   snapshots: SlotSnapshot[];
   selectedCity: string;
-  isBlacklisted: (slot: SlotSnapshot) => boolean;
 }
 
 export default function SlotGrid({
   loading,
   snapshots,
   selectedCity,
-  isBlacklisted,
 }: SlotGridProps) {
   if (loading && snapshots.length === 0) {
     return (
@@ -41,7 +39,7 @@ export default function SlotGrid({
   return (
     <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5">
       {snapshots.map((slot) => (
-        <CitySlotCard key={slot.id} data={slot} isBlacklisted={isBlacklisted(slot)} />
+        <CitySlotCard key={slot.id} data={slot} />
       ))}
     </div>
   );

+ 29 - 7
src/lib/i18n/locales/en.ts

@@ -131,9 +131,9 @@ export const en = {
   home: {
     hero_title_prefix: 'Visa Application, ',
     hero_title_highlight: 'Never Been Easier',
-    hero_subtitle: 'TextSkin provides global automated visa processing services. Real-time tracking and expert review ensure your trip is worry-free.',
-    cta_start: 'Start Application',
-    cta_check_slots: 'Check Slots',
+    cta_start: 'Place Order',
+    cta_order: 'Place Order',
+    cta_check_slots: 'Query Slot',
     
     process_title: 'How It Works',
     process_subtitle: 'Just 4 steps to fully automate your visa needs',
@@ -262,6 +262,9 @@ export const en = {
     upload_tooltip: 'Upload attachment (Coming soon)',
     urgent_tip: 'For urgent matters, please email support@text.skin',
     create_success: 'Ticket submitted successfully! We will process it shortly',
+    already_has_open_ticket: 'An open ticket already exists for this order. You cannot submit duplicate tickets.',
+    view_existing_ticket: 'View Active Ticket',
+    ticket_in_progress: 'Ticket In Progress',
     types: {
       refund: 'Refund Request',
       dispute: 'Dispute',
@@ -314,7 +317,7 @@ export const en = {
     full_refund_title: 'Full Refund Eligibility',
     full_refund_desc: 'You may apply for a full refund under the following circumstances:',
     full_refund_item_1: 'You have paid for the order, but our system has not yet started any booking operations (Status is Pending).',
-    full_refund_item_2: 'Duplicate charges caused by TextSkin system errors.',
+    full_refund_item_2: 'Duplicate charges caused by STRATA system errors.',
     full_refund_item_3: 'We failed to successfully book a slot for you within the promised timeframe (usually 30 days, depending on the service).',
     standard_refund_title: "Refund Rules & Processing Fees",
     fee_notice_title: "Important: Payment Gateway Fees",
@@ -353,8 +356,27 @@ export const en = {
   services: {
     ascii_only_error: 'Please use English characters only',
     title: 'Visa Service Directory',
-    hero_badge: 'VAS DIRECTORY // SERVICE LEDGER',
-    hero_title: 'Global Visa Service Ledger',
+    hero_badge: '[ VAS-CATALOG // OFFICIAL VISA DIRECT SERVICES ]',
+    hero_title: 'Direct Official Channels & Automated Visa Booking',
+    hero_desc: 'Strict verified product standards, ready for immediate delivery. Each service includes clear operational instructions, automated monitoring strategies, and a 100% money-back guarantee.',
+    sys_node_prefix: 'SYS.NODE: ONLINE // Currently',
+    sys_node_suffix: 'Services Live · Instant Dispatch',
+    benefit_patrol_title: '24/7 Millisecond-Level Official Channel Polling',
+    benefit_patrol_desc: 'High-frequency distributed cluster monitoring, booking appointments automatically the instant slots open.',
+    benefit_escrow_title: 'Official Escrow & 100% Refund Commitment',
+    benefit_escrow_desc: 'Full unconditional refund to the original payment method if appointment fails. Secure and traceable.',
+    default_desc: 'Official direct fast track, 24/7 distributed cluster automated slot booking, full refund guarantee if booking fails.',
+    official_tag_default: 'OFFICIAL LINK',
+    buy_now: 'Order Now',
+    sublink_terms: 'View Service Details →',
+    view_tutorial_guide: 'View Tutorial & Guidelines',
+    card_guarantee_text: '24/7 Automated Slot Snatching · Full Refund Guarantee',
+    sales_prefix: 'Live Monitoring · Delivered',
+    city_prefix: 'Jurisdiction',
+    status_ready: 'Online',
+    no_services_title: 'No Active Services Available',
+    no_services_desc: 'Official services are undergoing channel testing and will be launched soon. Stay tuned.',
+    refresh_services: 'Refresh Catalog',
     stat_monitoring: '24/7 CLOUD MONITOR',
     stat_monitoring_desc: 'Continuous quota polling',
     stat_security: 'Refund Policy',
@@ -496,7 +518,7 @@ export const en = {
   terms: {
     subtitle: 'Visitor Agreement',
     title: 'Terms Of Service',
-    description: 'We strive to operate our platform transparently and securely. By engaging with TextSkin web services, you agree to the policies outlined in this section.',
+    description: 'We strive to operate our platform transparently and securely. By engaging with STRATA web services, you agree to the policies outlined in this section.',
     point_one: 'You are responsible for providing accurate personal and travel information.',
     point_two: 'Payments must be completed through the provided channels; we do not store card data ourselves.',
     point_three: 'Orders are subject to local embassy and provider availability; we reserve the right to refuse or cancel services based on objective constraints.',

+ 29 - 7
src/lib/i18n/locales/zh.ts

@@ -131,9 +131,9 @@ export const zh = {
   home: {
     hero_title_prefix: '签证申请,',
     hero_title_highlight: '从未如此简单',
-    hero_subtitle: 'TextSkin 为您提供全球签证自动化处理服务。实时追踪状态,专家级审核,让您的出行无后顾之忧。',
-    cta_start: '开始申请',
-    cta_check_slots: '查询名额',
+    cta_start: '下单',
+    cta_order: '下单',
+    cta_check_slots: '查询 Slot',
     
     process_title: '工作流程',
     process_subtitle: '只需 4 步,全自动化处理您的签证需求',
@@ -262,6 +262,9 @@ export const zh = {
     upload_tooltip: '上传附件(暂不可用)',
     urgent_tip: '如需紧急处理,请发送邮件至 support@text.skin',
     create_success: '工单提交成功!我们会尽快为您处理',
+    already_has_open_ticket: '该订单已有正在处理中的工单,无法重复发起',
+    view_existing_ticket: '查看处理中工单',
+    ticket_in_progress: '工单处理中',
     types: {
       refund: '退款申请',
       dispute: '交易纠纷',
@@ -347,8 +350,27 @@ export const zh = {
   services: {
     ascii_only_error: '请输入英文字符查询',
     title: '签证服务档案总录',
-    hero_badge: 'VAS DIRECTORY // 签证服务工单库',
-    hero_title: '全球签证服务档案总览',
+    hero_badge: '[ VAS-CATALOG // 官方成熟签证直连服务展厅 ]',
+    hero_title: '全球签证官方通道直连与自动化预约',
+    hero_desc: '严格实行成熟产品准入制,上架即交付。每项服务均配套明确的操作指引、自动化监控策略与失败全额退款保障。',
+    sys_node_prefix: 'SYS.NODE: ONLINE // 当前已上线',
+    sys_node_suffix: '款成熟服务 · 上架即交付',
+    benefit_patrol_title: '7×24H 官方通道毫秒级并发巡检',
+    benefit_patrol_desc: '分布式集群高频巡检,一旦放出即刻精准代抢,全自动提交预约。',
+    benefit_escrow_title: '官方全额资金托管与退款承诺',
+    benefit_escrow_desc: '预约不成功无条件原路全额退费,资金安全透明可追溯。',
+    default_desc: '官方直连极速通道,分布式集群 24 小时毫秒级抢位,预约失败无条件全额退款。',
+    official_tag_default: '官方直连',
+    buy_now: '立即购买',
+    sublink_terms: '查阅服务细则 →',
+    view_tutorial_guide: '查看办理教程与材料指引',
+    card_guarantee_text: '7×24H 官方通道毫秒级代抢 · 失败全额退款保障',
+    sales_prefix: '实时监控中 · 已售',
+    city_prefix: '适用领区',
+    status_ready: '直连就绪',
+    no_services_title: '暂无已上线的成熟服务',
+    no_services_desc: '官方服务正在陆续完成通道测试并准入上架,敬请期待。',
+    refresh_services: '刷新展厅服务',
     stat_monitoring: '24/7 云端监控',
     stat_monitoring_desc: '全天候高频轮询检索',
     stat_security: '退款政策',
@@ -490,10 +512,10 @@ export const zh = {
   terms: {
     subtitle: '访客协议',
     title: '服务条款',
-    description: '我们致力于为每一次服务建立清晰的规则。使用 TextSkin 平台即意味着您同意遵守以下条款。',
+    description: '我们致力于为每一次服务建立清晰的规则。使用 STRATA 平台即意味着您同意遵守以下条款。',
     point_one: '请认真核对并提交您的个人与出行信息,确保其真实有效。',
     point_two: '所有支付行为必须通过授权通道完成,我们不会保存您的银行卡号。',
-    point_three: '订单以当地使馆或合作服务商可用性为准,TextSkin 有权在客观原因下调整或取消服务。',
+    point_three: '订单以当地使馆或合作服务商可用性为准,STRATA 有权在客观原因下调整或取消服务。',
     contact_prompt: '如需进一步说明,请通过以下方式联系',
     article_1_title: '§ 01 // 账户授权与真实性约定',
     article_2_title: '§ 02 // 官方放号与使馆裁量权声明',

+ 37 - 0
src/lib/services/storageService.ts

@@ -0,0 +1,37 @@
+import api from '@/lib/api';
+
+export interface UploadResult {
+  fid: string;
+  url: string;
+  size?: number;
+  filename?: string;
+}
+
+export const storageService = {
+  /**
+   * 上传文件至 Cloudflare R2 对象存储
+   * @param file 待上传的文件
+   * @param prefix 存储前缀目录(如 'posters', 'vouchers', 'icons', 'uploads')
+   */
+  async upload(file: File, prefix: string = 'uploads'): Promise<UploadResult> {
+    if (file.size > 1 * 1024 * 1024) {
+      throw new Error('File size exceeds the allowed limit (max 1MB)');
+    }
+
+    const formData = new FormData();
+    formData.append('file', file);
+
+    const res = await api.post(`/api/r2/upload?prefix=${encodeURIComponent(prefix)}`, formData, {
+      headers: {
+        'Content-Type': 'multipart/form-data',
+      },
+    });
+
+    const data = res.data?.data || res.data;
+    if (!data?.url) {
+      throw new Error('Upload succeeded but no file URL returned');
+    }
+
+    return data;
+  },
+};

+ 4 - 0
src/lib/services/taskService.ts

@@ -7,6 +7,10 @@ export interface TaskListParams {
   size?: number;
   status?: string;
   keyword?: string;
+  routing_key?: string;
+  product_id?: number;
+  sort_by?: string;
+  sort_order?: 'asc' | 'desc';
   [key: string]: any;
 }
 

+ 4 - 0
src/types/product.ts

@@ -107,6 +107,7 @@ export interface ProductCardConfig {
   status_tag?: string;         // 状态徽标 (如 New, Hot, 现成可约)
   pill_text?: string;          // 绿色细线胶囊文本 (如 无法完成绑卡?, 查看办理教程与材料清单)
   sales_text?: string;         // 底部销售/库存描述 (如 仅剩 5 件 · 已售 77, 实时监控中 · 已售 88)
+  status_text?: string;        // 渠道状态 (如 直连就绪、通道正常)
   buy_button_text?: string;    // 购买按钮文案 (如 立即购买, 立即申请)
   sublink_text?: string;       // 底部次级细字链接 (如 查阅服务细则 →, 已购买? 查工单 →)
 }
@@ -128,6 +129,9 @@ export interface Product {
   schema_content?: string | null;
   enabled: boolean | number; // 1 or 0 or boolean
   recommend_score?: number;
+  plugin_id?: number | null;
+  plugin_name?: string | null;
+  developer_id?: string | null;
   extra_fields?: Record<string, any> | null;
   created_at?: string;
   updated_at?: string;

+ 3 - 0
src/types/settlement.ts

@@ -102,6 +102,7 @@ export interface VasFaultCreatePayload {
  */
 export interface SettlementPayoutItem {
   user_id: string;
+  user_name?: string | null;
   role_description: string;
   gross_amount: number; // 分润金额(分)
   fault_penalty: number; // 过错赔偿抵扣(分)
@@ -116,7 +117,9 @@ export interface SettlementOrderDetail {
   channel_type: 'direct' | 'agency' | 'website' | string;
   agency_id?: string | null;
   handler_id?: string | null;
+  handler_name?: string | null;
   developer_id?: string | null;
+  developer_name?: string | null;
   order_amount: number; // 订单实收(分)
   avg_cost: number; // 单均公共耗材(分)
   net_profit: number; // 单笔净利(分)

+ 9 - 0
src/types/task.ts

@@ -19,6 +19,15 @@ export interface VasTask {
   created_at: string;
   updated_at: string;
   expire_at: string;
+
+  // 关联商品与主订单扩展属性
+  product_id?: number;
+  product_name?: string;
+  order_user_name?: string;
+  order_status?: string;
+  order_final_amount?: number;
+  order_base_currency?: string;
+  order_created_at?: string;
 }
 
 /**

+ 2 - 0
src/types/ticket.ts

@@ -8,9 +8,11 @@ export interface TicketMessage {
   ticket_id: number;
   sender_type: 'user' | 'admin' | 'system';
   content: string;
+  attachments?: any;
   created_at: string;
 }
 
+
 /**
  * 基础工单模型
  */

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor