Parcourir la source

refactor: clean up legacy pages and unify domain type system

- Remove Visametric page and sidebar entry
- Remove Worker status page and sidebar entry
- Remove emergency task alert feature from task queue
- Unify domain TypeScript interfaces into src/types modular structure
jerry il y a 2 mois
Parent
commit
63af495b1a
56 fichiers modifiés avec 540 ajouts et 1514 suppressions
  1. 2 3
      src/app/admin/accounts/page.tsx
  2. 1 8
      src/app/admin/configurations/page.tsx
  3. 1 11
      src/app/admin/orders/new/page.tsx
  4. 2 1
      src/app/admin/orders/page.tsx
  5. 2 3
      src/app/admin/proxies/page.tsx
  6. 3 10
      src/app/admin/tasks/page.tsx
  7. 2 1
      src/app/admin/tickets/page.tsx
  8. 2 1
      src/app/admin/users/page.tsx
  9. 0 468
      src/app/admin/visametric/page.tsx
  10. 0 201
      src/app/admin/workers/page.tsx
  11. 3 2
      src/app/dashboard/page.tsx
  12. 2 1
      src/app/slots/page.tsx
  13. 2 32
      src/components/CreateOrderForm.tsx
  14. 2 32
      src/components/PaymentProcessor.tsx
  15. 1 12
      src/components/ServiceList.tsx
  16. 2 4
      src/components/admin/AdminSidebar.tsx
  17. 1 2
      src/components/admin/TicketActionModal.tsx
  18. 1 12
      src/components/admin/accounts/AccountTable.tsx
  19. 1 61
      src/components/admin/orders/OrderDetailModal.tsx
  20. 1 1
      src/components/admin/orders/OrderEditModal.tsx
  21. 1 1
      src/components/admin/orders/OrderPaymentModal.tsx
  22. 2 1
      src/components/admin/orders/OrderPriceAdjustModal.tsx
  23. 1 7
      src/components/admin/orders/OrderTable.tsx
  24. 1 6
      src/components/admin/payments/ExchangeRateModal.tsx
  25. 2 11
      src/components/admin/payments/ProviderList.tsx
  26. 1 10
      src/components/admin/payments/QrManager.tsx
  27. 2 14
      src/components/admin/products/ProductList.tsx
  28. 1 9
      src/components/admin/products/RoutingManager.tsx
  29. 1 7
      src/components/admin/products/SchemaManager.tsx
  30. 1 14
      src/components/admin/proxies/ProxyTable.tsx
  31. 0 395
      src/components/admin/tasks/ExpiringTaskAlert.tsx
  32. 1 1
      src/components/admin/tasks/TaskDetailModal.tsx
  33. 1 1
      src/components/admin/tasks/TaskEditModal.tsx
  34. 1 18
      src/components/admin/tasks/TaskTable.tsx
  35. 1 9
      src/components/admin/tickets/TicketDetailModal.tsx
  36. 1 13
      src/components/admin/tickets/TicketTable.tsx
  37. 1 1
      src/components/admin/users/UserModal.tsx
  38. 1 12
      src/components/admin/users/UserTable.tsx
  39. 1 17
      src/components/dashboard/OrderList.tsx
  40. 1 11
      src/components/dashboard/TicketList.tsx
  41. 1 11
      src/components/dashboard/UserOrderDetailModal.tsx
  42. 3 20
      src/components/dashboard/UserTicketDetailModal.tsx
  43. 1 17
      src/components/slots/CitySlotCard.tsx
  44. 3 9
      src/lib/auth.ts
  45. 18 0
      src/types/account.ts
  46. 14 0
      src/types/config.ts
  47. 13 0
      src/types/index.ts
  48. 101 0
      src/types/order.ts
  49. 91 6
      src/types/payment.ts
  50. 96 0
      src/types/product.ts
  51. 0 27
      src/types/products.ts
  52. 20 0
      src/types/proxy.ts
  53. 21 0
      src/types/slot.ts
  54. 27 0
      src/types/task.ts
  55. 50 0
      src/types/ticket.ts
  56. 28 0
      src/types/user.ts

+ 2 - 3
src/app/admin/accounts/page.tsx

@@ -6,11 +6,10 @@ import api from '@/lib/api';
 import { toast } from 'react-hot-toast';
 
 // 引入拆分后的组件
-import AccountTable, { Account } from '@/components/admin/accounts/AccountTable';
+import AccountTable from '@/components/admin/accounts/AccountTable';
 import Pagination from '@/components/common/Pagination';
 import LocalTime from '@/components/common/LocalTime';
-
-type AccountStatus = 'active' | 'disable';
+import { Account, AccountStatus } from '@/types';
 
 const DEFAULT_EXTRA_DATA = '{}';
 

+ 1 - 8
src/app/admin/configurations/page.tsx

@@ -15,14 +15,7 @@ import {
   X,
   AlertCircle,
 } from 'lucide-react';
-
-interface DynamicConfiguration {
-  id?: number;
-  config_key: string;
-  config_value: string;
-  description: string;
-  type: string;
-}
+import { DynamicConfiguration } from '@/types';
 
 type ConfigurationForm = DynamicConfiguration;
 

+ 1 - 11
src/app/admin/orders/new/page.tsx

@@ -9,17 +9,7 @@ import {
   Sparkles, Bot, Wand2, Check, Info 
 } from 'lucide-react';
 import { useDebounce } from 'use-debounce'; 
-
-interface SchemaProperty {
-  type: string;
-  title?: string;
-  description?: string;
-  default?: any;
-  enum?: string[];
-  'x-order'?: number;
-  order?: number;
-  [key: string]: any;
-}
+import { SchemaProperty } from '@/types';
 
 export default function AdminCreateOrderPage() {
   const router = useRouter();

+ 2 - 1
src/app/admin/orders/page.tsx

@@ -5,11 +5,12 @@ import { useRouter } from 'next/navigation';
 import api from '@/lib/api';
 import { RefreshCw, Search, Plus, DollarSign} from 'lucide-react';
 import OrderTable from '@/components/admin/orders/OrderTable';
-import OrderDetailModal, { OrderDetail } from '@/components/admin/orders/OrderDetailModal';
+import OrderDetailModal from '@/components/admin/orders/OrderDetailModal';
 import OrderEditModal from '@/components/admin/orders/OrderEditModal';
 import OrderPaymentModal from '@/components/admin/orders/OrderPaymentModal'; // 1. 引入支付管理弹窗
 import OrderPriceAdjustModal from '@/components/admin/orders/OrderPriceAdjustModal';
 import Pagination from '@/components/common/Pagination';
+import { OrderDetail } from '@/types';
 
 export default function AdminOrdersPage() {
   const router = useRouter();

+ 2 - 3
src/app/admin/proxies/page.tsx

@@ -6,9 +6,8 @@ import api from '@/lib/api';
 import { toast } from 'react-hot-toast';
 import Pagination from '@/components/common/Pagination';
 import LocalTime from '@/components/common/LocalTime';
-import ProxyTable, { ProxyItem } from '@/components/admin/proxies/ProxyTable';
-
-type ProxyStatus = 'active' | 'disable';
+import ProxyTable from '@/components/admin/proxies/ProxyTable';
+import { ProxyItem, ProxyStatus } from '@/types';
 
 function parseUtcDateTime(value?: string | null) {
   if (!value) return null;

+ 3 - 10
src/app/admin/tasks/page.tsx

@@ -6,11 +6,11 @@ import api from '@/lib/api';
 import { RefreshCw, Search } from 'lucide-react';
 
 // 组件导入
-import TaskTable, { VasTask } from '@/components/admin/tasks/TaskTable';
+import TaskTable from '@/components/admin/tasks/TaskTable';
 import TaskDetailModal from '@/components/admin/tasks/TaskDetailModal';
 import TaskEditModal from '@/components/admin/tasks/TaskEditModal';
 import Pagination from '@/components/common/Pagination';
-import ExpiringTaskAlert from '@/components/admin/tasks/ExpiringTaskAlert'; // [新增] 紧急任务组件
+import { VasTask } from '@/types';
 
 export default function AdminTasksPage() {
   // === 状态定义 ===
@@ -198,14 +198,7 @@ export default function AdminTasksPage() {
         </div>
       </div>
 
-      {/* === [新增] 2. 紧急任务预警区域 === */}
-      {/* 如果有即将过期的任务,这个组件会自动显示;否则不渲染 */}
-      <ExpiringTaskAlert 
-        onViewDetail={handleViewDetail}
-        onEdit={handleEdit}
-      />
-
-      {/* === 3. 主表格区域 === */}
+      {/* === 2. 主表格区域 === */}
       <TaskTable 
         tasks={tasks} 
         loading={loading} 

+ 2 - 1
src/app/admin/tickets/page.tsx

@@ -2,10 +2,11 @@
 
 import { useState, useEffect } from 'react';
 import api from '@/lib/api';
-import TicketTable, { AdminTicket } from '@/components/admin/tickets/TicketTable';
+import TicketTable from '@/components/admin/tickets/TicketTable';
 import TicketDetailModal from '@/components/admin/tickets/TicketDetailModal';
 import Pagination from '@/components/common/Pagination';
 import { RefreshCw, Search } from 'lucide-react';
+import { AdminTicket } from '@/types';
 
 export default function AdminTicketsPage() {
   const [loading, setLoading] = useState<boolean>(true);

+ 2 - 1
src/app/admin/users/page.tsx

@@ -3,9 +3,10 @@
 import { useState, useEffect } from 'react';
 import api from '@/lib/api';
 import { RefreshCw, Search } from 'lucide-react';
-import UserTable, { AdminUser } from '@/components/admin/users/UserTable';
+import UserTable from '@/components/admin/users/UserTable';
 import UserModal from '@/components/admin/users/UserModal';
 import Pagination from '@/components/common/Pagination';
+import { AdminUser } from '@/types';
 
 export default function AdminUsersPage() {
   const [users, setUsers] = useState<AdminUser[]>([]);

+ 0 - 468
src/app/admin/visametric/page.tsx

@@ -1,468 +0,0 @@
-'use client';
-
-import { useState, useEffect } from 'react';
-import { 
-  format, 
-  startOfMonth, 
-  endOfMonth, 
-  startOfWeek, 
-  endOfWeek, 
-  eachDayOfInterval, 
-  isSameMonth, 
-  isSameDay, 
-  addMonths, 
-  subMonths, 
-  parse, 
-  isToday
-} from 'date-fns';
-import { 
-  ChevronLeft, 
-  ChevronRight, 
-  Loader2, 
-  RefreshCw, 
-  Calendar as CalendarIcon,
-  Clock,
-  User,
-  CreditCard,
-  Phone,
-  Mail,
-  XCircle,
-  AlertCircle,
-  MessageCircle
-} from 'lucide-react';
-import api from '@/lib/api';
-import { toast } from 'react-hot-toast';
-
-// --- 类型定义 ---
-interface VisametricTask {
-  id: number;
-  order_id: string;
-  status: string;
-  user_inputs: {
-    first_name: string;
-    last_name: string;
-    passport_no: string;
-    email: string;
-    phone: string;
-    phone_country_code: string;
-    birthday: string;
-    social_media_account?: string;
-  };
-  grabbed_history: {
-    slot_date: string; 
-    slot_time: string; 
-    pnr_number: string;
-  };
-  meta: {
-    cancelled_at?: string;
-  } | null;
-  created_at: string;
-}
-
-export default function VisametricCalendarPage() {
-  const [currentDate, setCurrentDate] = useState(new Date());
-  const [tasks, setTasks] = useState<VisametricTask[]>([]);
-  const [loading, setLoading] = useState(true);
-  
-  const [selectedTask, setSelectedTask] = useState<VisametricTask | null>(null);
-  const [isModalOpen, setIsModalOpen] = useState(false);
-
-  const fetchTasks = async () => {
-    setLoading(true);
-    try {
-      const res = await api.get('/api/vas/task/list', {
-        params: {
-          page: 1,
-          size: 100, 
-          status: 'grabbed',
-          keyword: 'auto.slot.dub.de'
-        }
-      });
-      const items = res.data?.data?.items || [];
-      setTasks(items);
-    } catch (error) {
-      console.error(error);
-      toast.error('获取预约数据失败');
-    } finally {
-      setLoading(false);
-    }
-  };
-
-  useEffect(() => {
-    fetchTasks();
-  }, []);
-
-  const monthStart = startOfMonth(currentDate);
-  const monthEnd = endOfMonth(monthStart);
-  const startDate = startOfWeek(monthStart, { weekStartsOn: 1 });
-  const endDate = endOfWeek(monthEnd, { weekStartsOn: 1 });
-  const calendarDays = eachDayOfInterval({ start: startDate, end: endDate });
-
-  const nextMonth = () => setCurrentDate(addMonths(currentDate, 1));
-  const prevMonth = () => setCurrentDate(subMonths(currentDate, 1));
-  const goToToday = () => setCurrentDate(new Date());
-
-  const getTasksForDay = (day: Date) => {
-    return tasks.filter(task => {
-      try {
-        const taskDate = parse(task.grabbed_history.slot_date, 'dd/MM/yyyy', new Date());
-        return isSameDay(taskDate, day);
-      } catch (e) {
-        return false;
-      }
-    });
-  };
-
-  const handleUpdatePnr = async () => {
-    if (!selectedTask) return;
-    const toastId = toast.loading('正在更新 PNR...');
-    try {
-      await api.post(`/api/visametric/update_pnr?task_id=${selectedTask.id}`, {});
-      toast.success('PNR 更新成功', { id: toastId });
-      setIsModalOpen(false);
-      fetchTasks();
-    } catch (error) {
-      toast.error('PNR 更新失败', { id: toastId });
-    }
-  };
-
-  const handleCancelAppointment = async () => {
-    if (!selectedTask) return;
-    if (!confirm(`确定要取消 ${selectedTask.user_inputs.first_name} 的预约吗?操作不可撤销!`)) return;
-
-    const toastId = toast.loading('正在取消预约...');
-    try {
-      await api.post(`/api/visametric/cancel_appointment?task_id=${selectedTask.id}`, {});
-      toast.success('预约已取消', { id: toastId });
-      setIsModalOpen(false);
-      fetchTasks();
-    } catch (error) {
-      toast.error('取消预约失败', { id: toastId });
-    }
-  };
-
-  return (
-    // 修改 1:使用 dvh 适配移动端浏览器地址栏,同时减小移动端的 padding
-    <div className="flex flex-col h-[calc(100dvh-64px)] md:h-[calc(100vh-64px)] p-2 md:p-6 gap-3 md:gap-4 bg-slate-50/50 overflow-hidden">
-      
-      {/* === 1. 顶部控制栏 === */}
-      <div className="flex flex-col md:flex-row items-start md:items-center justify-between gap-3 md:gap-4 bg-white p-3 md:p-4 rounded-xl border border-slate-200 shadow-sm shrink-0">
-        
-        {/* 标题区:手机端和刷新按钮同行显示 */}
-        <div className="flex items-center justify-between w-full md:w-auto">
-          <div className="flex items-center gap-3">
-            <div className="p-2 md:p-2.5 bg-blue-600 text-white rounded-lg shadow-sm">
-              <CalendarIcon size={20} className="md:w-6 md:h-6" />
-            </div>
-            <div>
-              <h1 className="text-lg md:text-xl font-bold text-slate-800 leading-tight">预约日历视图</h1>
-              <p className="text-[10px] md:text-xs text-slate-500 hidden sm:block">可视化管理 Slot 分布,点击卡片进行操作</p>
-            </div>
-          </div>
-          
-          {/* 手机端的刷新按钮,放在右侧省空间 */}
-          <button 
-            onClick={fetchTasks}
-            disabled={loading}
-            className="md:hidden p-2 bg-slate-100 text-slate-700 rounded-lg active:bg-slate-200 transition"
-          >
-            <RefreshCw size={18} className={loading ? "animate-spin" : ""} />
-          </button>
-        </div>
-
-        {/* 操作区 */}
-        <div className="flex flex-wrap items-center gap-2 w-full md:w-auto">
-          {/* 月份切换器:手机端占满全宽 */}
-          <div className="flex-1 md:flex-none flex items-center justify-between md:justify-start bg-slate-100 p-1 rounded-lg border border-slate-200">
-            <button onClick={prevMonth} className="p-2 md:p-1.5 hover:bg-white rounded-md transition text-slate-600 active:scale-95">
-              <ChevronLeft size={20} />
-            </button>
-            <div className="px-2 md:px-4 py-1.5 font-bold text-slate-800 min-w-[110px] md:w-36 text-center select-none text-sm">
-              {format(currentDate, 'yyyy年 MM月')}
-            </div>
-            <button onClick={nextMonth} className="p-2 md:p-1.5 hover:bg-white rounded-md transition text-slate-600 active:scale-95">
-              <ChevronRight size={20} />
-            </button>
-            <div className="hidden md:block w-px h-6 bg-slate-300 mx-2"></div>
-            <button onClick={goToToday} className="hidden md:block px-3 py-1 text-xs font-bold hover:bg-white rounded-md transition text-slate-600">
-              今天
-            </button>
-          </div>
-          
-          <button onClick={goToToday} className="md:hidden px-4 py-2.5 text-sm font-bold bg-white border border-slate-200 rounded-lg text-slate-600 active:bg-slate-50">
-            今天
-          </button>
-
-          {/* PC端刷新按钮 */}
-          <button 
-            onClick={fetchTasks}
-            disabled={loading}
-            className="hidden md:flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg hover:bg-slate-800 transition shadow-sm text-sm font-medium active:scale-95"
-          >
-            {loading ? <Loader2 size={16} className="animate-spin" /> : <RefreshCw size={16} />}
-            <span>刷新数据</span>
-          </button>
-        </div>
-      </div>
-
-      {/* === 2. 日历主体容器 === */}
-      {/* 修改 2:增加横向滚动 (overflow-x-auto) 适配小屏幕 */}
-      <div className="flex-1 bg-white border border-slate-200 rounded-xl shadow-sm flex flex-col overflow-hidden relative">
-        <div className="flex-1 overflow-x-auto overflow-y-hidden custom-scrollbar">
-          {/* 修改 3:限制最小宽度 min-w-[800px],保证排版不乱。在手机上可左右滑动 */}
-          <div className="flex flex-col h-full min-w-[800px] md:min-w-[1000px]">
-            
-            {/* 星期表头 */}
-            <div 
-              className="grid border-b border-slate-200 bg-slate-50 shrink-0 sticky top-0 z-10"
-              style={{ gridTemplateColumns: 'repeat(7, 1fr)' }}
-            >
-              {['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].map(day => (
-                <div key={day} className="py-2.5 md:py-3 text-center text-xs font-bold text-slate-500 uppercase tracking-wider border-r border-slate-200 last:border-r-0">
-                  {day}
-                </div>
-              ))}
-            </div>
-
-            {/* 日期网格 */}
-            <div 
-              className="grid auto-rows-fr flex-1 overflow-y-auto"
-              style={{ gridTemplateColumns: 'repeat(7, 1fr)' }}
-            >
-              {calendarDays.map((day) => {
-                const dayTasks = getTasksForDay(day);
-                const isCurrentMonth = isSameMonth(day, currentDate);
-                const isDayToday = isToday(day);
-
-                return (
-                  <div 
-                    key={day.toString()} 
-                    className={`
-                      border-b border-r border-slate-100 p-1.5 md:p-2 flex flex-col gap-1 min-h-[100px] md:min-h-[120px]
-                      ${!isCurrentMonth ? 'bg-slate-50/40 text-slate-400' : 'bg-white'}
-                      ${isDayToday ? 'bg-blue-50/30' : ''}
-                      hover:bg-slate-50 transition-colors
-                    `}
-                  >
-                    {/* 日期头 */}
-                    <div className="flex justify-between items-start mb-1">
-                      <span className={`
-                        text-xs md:text-sm font-medium w-6 h-6 md:w-7 md:h-7 flex items-center justify-center rounded-full
-                        ${isDayToday ? 'bg-blue-600 text-white shadow-sm' : ''}
-                      `}>
-                        {format(day, 'd')}
-                      </span>
-                      {dayTasks.length > 0 && (
-                        <span className="text-[10px] font-bold text-slate-500 bg-slate-100 px-1.5 py-0.5 rounded-full">
-                          {dayTasks.length}
-                        </span>
-                      )}
-                    </div>
-
-                    {/* 任务列表 */}
-                    <div className="flex flex-col gap-1 overflow-y-auto max-h-[200px] md:max-h-[220px] pr-1 custom-scrollbar">
-                      {dayTasks
-                        .slice()
-                        .sort((a, b) => {
-                          const parseTime = (time: string) => {
-                            const [hour, minute] = time.split(':').map(Number);
-                            return hour * 60 + minute;
-                          };
-                          return parseTime(a.grabbed_history.slot_time) - parseTime(b.grabbed_history.slot_time);
-                        })
-                        .map(task => {
-                         const isCancelled = !!task.meta?.cancelled_at;
-                         const hasPnr = !!task.grabbed_history.pnr_number;
-                         
-                         return (
-                          <button
-                            key={task.id}
-                            onClick={() => { setSelectedTask(task); setIsModalOpen(true); }}
-                            className={`
-                              text-left p-1.5 md:p-2 rounded border shadow-sm transition-all hover:shadow-md active:scale-95 w-full
-                              ${isCancelled 
-                                ? 'bg-slate-100 border-slate-200 opacity-60' 
-                                : hasPnr 
-                                  ? 'bg-green-50/50 border-green-200' 
-                                  : 'bg-amber-50/50 border-amber-200'
-                              }
-                            `}
-                          >
-                            <div className="flex items-center justify-between text-[10px] md:text-[11px] font-bold leading-none mb-1">
-                               <span className={isCancelled ? 'text-slate-500 line-through' : hasPnr ? 'text-green-700' : 'text-amber-700'}>
-                                 {task.grabbed_history.slot_time}
-                               </span>
-                               {isCancelled && <XCircle size={10} className="text-red-500 shrink-0 ml-1" />}
-                            </div>
-                            <div className={`text-[9px] md:text-[10px] truncate font-medium ${isCancelled ? 'text-slate-400' : 'text-slate-700'}`}>
-                              {task.user_inputs.first_name}
-                            </div>
-                            {!isCancelled && (
-                              <div className={`mt-0.5 md:mt-1 text-[9px] font-mono truncate ${hasPnr ? 'text-green-600' : 'text-amber-600/70'}`}>
-                                {hasPnr ? task.grabbed_history.pnr_number : 'Wait PNR'}
-                              </div>
-                            )}
-                          </button>
-                         );
-                      })}
-                    </div>
-                  </div>
-                );
-              })}
-            </div>
-          </div>
-        </div>
-        
-        {/* 移动端横向滚动提示 */}
-        <div className="md:hidden absolute bottom-2 left-1/2 -translate-x-1/2 bg-slate-800/60 backdrop-blur text-white text-[10px] px-3 py-1 rounded-full pointer-events-none opacity-80 shadow-sm animate-pulse">
-          左右滑动查看更多
-        </div>
-      </div>
-
-      {/* === 3. 详情模态框 (BottomSheet 式适配) === */}
-      {/* 修改 4:移动端时固定在底部弹出,PC端居中弹出 */}
-      {isModalOpen && selectedTask && (
-        <div className="fixed inset-0 z-[100] flex items-end sm:items-center justify-center bg-black/50 backdrop-blur-sm sm:p-4 animate-in fade-in duration-200">
-          
-          {/* 移动端点击背景关闭遮罩 */}
-          <div className="absolute inset-0 sm:hidden" onClick={() => setIsModalOpen(false)}></div>
-          
-          <div className="relative bg-white rounded-t-2xl sm:rounded-2xl shadow-2xl w-full max-w-md overflow-hidden animate-in slide-in-from-bottom-full sm:slide-in-from-bottom-0 sm:zoom-in-95 duration-200 flex flex-col max-h-[85vh] sm:max-h-[90vh]">
-            
-            {/* 顶部小滑块提示 (仅移动端可见) */}
-            <div className="sm:hidden flex justify-center pt-3 pb-1 bg-slate-50 cursor-grab active:cursor-grabbing" onTouchStart={(e) => {
-              // 简易下拉关闭逻辑提示:实际开发中可接入 framer-motion 等库实现真·手势滑动关闭
-            }}>
-              <div className="w-12 h-1.5 bg-slate-300 rounded-full"></div>
-            </div>
-
-            {/* Header */}
-            <div className="px-5 py-3 sm:py-4 border-b border-slate-100 flex justify-between items-center bg-slate-50">
-              <div>
-                <h3 className="font-bold text-slate-800 text-base">预约详情</h3>
-                <p className="text-[10px] sm:text-xs text-slate-400 font-mono mt-0.5">#{selectedTask.id} • {selectedTask.order_id.split('-')[1]}...</p>
-              </div>
-              <button onClick={() => setIsModalOpen(false)} className="p-2 bg-white rounded-full text-slate-400 hover:text-slate-700 shadow-sm border border-slate-200 transition">
-                <XCircle size={20} />
-              </button>
-            </div>
-
-            {/* Body */}
-            <div className="p-4 sm:p-6 space-y-4 sm:space-y-5 overflow-y-auto">
-              {/* Status Banner */}
-              <div className="flex flex-col sm:flex-row sm:items-center justify-between p-4 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl border border-blue-100 shadow-sm gap-3">
-                <div className="flex items-center gap-3">
-                   <div className="p-2 bg-blue-100 text-blue-600 rounded-lg shrink-0">
-                      <Clock size={20} />
-                   </div>
-                   <div>
-                     <p className="text-[10px] text-blue-600 font-bold uppercase tracking-wider">Appointment Time</p>
-                     <p className="font-bold text-lg sm:text-xl text-slate-800 leading-tight">
-                       {selectedTask.grabbed_history.slot_time}
-                     </p>
-                     <p className="text-xs text-slate-500 font-medium">{selectedTask.grabbed_history.slot_date}</p>
-                   </div>
-                </div>
-                
-                <div className="sm:text-right flex sm:flex-col justify-end items-center sm:items-end w-full sm:w-auto pt-2 sm:pt-0 border-t border-blue-100/50 sm:border-t-0 mt-1 sm:mt-0">
-                  {selectedTask.meta?.cancelled_at ? (
-                     <span className="inline-block px-3 py-1 bg-red-100 text-red-700 text-xs font-bold rounded-full border border-red-200">
-                       Cancelled
-                     </span>
-                  ) : selectedTask.grabbed_history.pnr_number ? (
-                     <div className="flex sm:flex-col items-center sm:items-end gap-2 sm:gap-0 w-full sm:w-auto justify-between">
-                       <span className="text-[10px] font-bold text-green-600 sm:mb-0.5">PNR CODE</span>
-                       <span className="font-mono text-base sm:text-lg font-bold text-green-700 bg-green-50 px-2 rounded border border-green-100">
-                         {selectedTask.grabbed_history.pnr_number}
-                       </span>
-                     </div>
-                  ) : (
-                     <span className="inline-block px-3 py-1 bg-amber-100 text-amber-700 text-xs font-bold rounded-full border border-amber-200 animate-pulse w-full sm:w-auto text-center">
-                       Pending PNR
-                     </span>
-                  )}
-                </div>
-              </div>
-
-              {/* Info Grid */}
-              <div className="grid grid-cols-1 gap-4">
-                 <div className="p-3 border border-slate-100 rounded-lg bg-slate-50/50 space-y-3">
-                    <p className="text-xs font-bold text-slate-400 uppercase tracking-wider mb-2">Applicant Details</p>
-                    <div className="flex items-center gap-3">
-                      <User size={16} className="text-slate-400 shrink-0" />
-                      <div className="truncate w-full">
-                        <p className="text-[10px] sm:text-xs text-slate-500">Full Name</p>
-                        <p className="text-xs sm:text-sm font-semibold text-slate-900 truncate">{selectedTask.user_inputs.first_name} {selectedTask.user_inputs.last_name}</p>
-                      </div>
-                    </div>
-                    <div className="flex items-center gap-3">
-                      <CreditCard size={16} className="text-slate-400 shrink-0" />
-                      <div>
-                        <p className="text-[10px] sm:text-xs text-slate-500">Passport No</p>
-                        <p className="text-xs sm:text-sm font-mono font-semibold text-slate-900">{selectedTask.user_inputs.passport_no}</p>
-                      </div>
-                    </div>
-                    <div className="flex items-center gap-3">
-                      <Phone size={16} className="text-slate-400 shrink-0" />
-                      <div>
-                        <p className="text-[10px] sm:text-xs text-slate-500">Phone</p>
-                        <p className="text-xs sm:text-sm font-medium text-slate-800">(+{selectedTask.user_inputs.phone_country_code}) {selectedTask.user_inputs.phone}</p>
-                      </div>
-                    </div>
-                    <div className="flex items-center gap-3">
-                      <Mail size={16} className="text-slate-400 shrink-0" />
-                      <div className="truncate w-full">
-                        <p className="text-[10px] sm:text-xs text-slate-500">Email</p>
-                        <p className="text-xs sm:text-sm font-medium text-slate-800 truncate" title={selectedTask.user_inputs.email}>{selectedTask.user_inputs.email}</p>
-                      </div>
-                    </div>
-
-                    <div className="flex items-center gap-3">
-                      <MessageCircle size={16} className="text-slate-400 shrink-0" />
-                      <div className="truncate w-full">
-                        <p className="text-[10px] sm:text-xs text-slate-500">Social Media</p>
-                        <p className="text-xs sm:text-sm font-medium text-slate-800 truncate">
-                          {selectedTask.user_inputs.social_media_account || '-'}
-                        </p>
-                      </div>
-                    </div>
-                 </div>
-              </div>
-              
-              {selectedTask.meta?.cancelled_at && (
-                <div className="flex gap-3 p-3 sm:p-4 bg-red-50 text-red-800 rounded-xl border border-red-100 items-start sm:items-center">
-                   <AlertCircle size={20} className="shrink-0 mt-0.5 sm:mt-0" />
-                   <div>
-                     <p className="font-bold text-sm">此预约已取消</p>
-                     <p className="text-xs opacity-80 mt-0.5">时间: {new Date(selectedTask.meta.cancelled_at).toLocaleString()}</p>
-                   </div>
-                </div>
-              )}
-            </div>
-
-            {/* Footer Actions */}
-            {/* 修改 5:为了在手机端方便操作,把按钮放到单独一行 */}
-            <div className="px-4 py-4 sm:px-6 sm:py-4 bg-white sm:bg-slate-50 border-t border-slate-100 flex flex-col sm:flex-row justify-end gap-3 shrink-0 pb-6 sm:pb-4">
-              
-              {!selectedTask.meta?.cancelled_at && (
-                <div className="flex flex-row gap-3 w-full sm:w-auto">
-                  <button onClick={handleUpdatePnr} className="flex-1 sm:flex-none flex justify-center items-center gap-2 px-4 py-3 sm:py-2.5 text-sm font-bold bg-white border border-slate-300 text-slate-700 rounded-xl sm:rounded-lg hover:bg-blue-50 active:bg-blue-100 transition shadow-sm">
-                    <RefreshCw size={16} /> <span className="hidden sm:inline">更新</span> PNR
-                  </button>
-                  <button onClick={handleCancelAppointment} className="flex-1 sm:flex-none flex justify-center items-center gap-2 px-4 py-3 sm:py-2.5 text-sm font-bold bg-red-600 text-white rounded-xl sm:rounded-lg hover:bg-red-700 active:bg-red-800 transition shadow-sm">
-                    <XCircle size={16} /> 取消预约
-                  </button>
-                </div>
-              )}
-              
-              <button onClick={() => setIsModalOpen(false)} className="w-full sm:w-auto px-4 py-3 sm:py-2.5 text-sm font-medium text-slate-600 bg-slate-100 sm:bg-transparent sm:hover:bg-slate-200 rounded-xl sm:rounded-lg transition active:bg-slate-200">
-                关闭
-              </button>
-            </div>
-
-          </div>
-        </div>
-      )}
-    </div>
-  );
-}

+ 0 - 201
src/app/admin/workers/page.tsx

@@ -1,201 +0,0 @@
-'use client';
-
-import { useState, useEffect } from 'react';
-import api from '@/lib/api';
-import { 
-  Activity, RefreshCw, Server, AlertTriangle, 
-  Clock, MapPin, Search 
-} from 'lucide-react';
-import LocalTime from '@/components/common/LocalTime';
-// 1. 引入 TimeAgo 组件
-import TimeAgo from '@/components/common/TimeAgo';
-
-interface WorkerStatus {
-  routing_key: string;
-  country: string;
-  city: string;
-  visa_type: string;
-  snapshot_source: string;
-  last_refresh_at: string;
-  last_success_at: string;
-  last_error: string | null;
-  updated_at: string;
-}
-
-export default function WorkerStatusPage() {
-  const [workers, setWorkers] = useState<WorkerStatus[]>([]);
-  const [loading, setLoading] = useState(true);
-  const [keyword, setKeyword] = useState('');
-  const [autoRefresh, setAutoRefresh] = useState(true);
-
-  useEffect(() => {
-    fetchData();
-    let interval: NodeJS.Timeout;
-    if (autoRefresh) {
-      interval = setInterval(fetchData, 30000);
-    }
-    return () => clearInterval(interval);
-  }, [autoRefresh]);
-
-  const fetchData = async () => {
-    if (workers.length === 0) setLoading(true);
-    try {
-      const res = await api.get('/api/slot_refresh/status');
-      const data = res.data.data || [];
-      data.sort((a: WorkerStatus, b: WorkerStatus) => 
-        new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
-      );
-      setWorkers(data);
-    } catch (e) {
-      console.error("Fetch worker status failed", e);
-    } finally {
-      setLoading(false);
-    }
-  };
-
-  const filteredWorkers = workers.filter(w => 
-    w.routing_key.toLowerCase().includes(keyword.toLowerCase()) ||
-    w.country.toLowerCase().includes(keyword.toLowerCase()) ||
-    w.city.toLowerCase().includes(keyword.toLowerCase())
-  );
-
-  const getHealthStatus = (worker: WorkerStatus) => {
-    const now = new Date().getTime();
-    let updateTimeStr = worker.updated_at;
-    if (updateTimeStr && !updateTimeStr.endsWith('Z') && !updateTimeStr.includes('+')) {
-       updateTimeStr += 'Z';
-    }
-    const lastUpdate = new Date(updateTimeStr).getTime();
-    const diffMinutes = (now - lastUpdate) / 1000 / 60;
-    if (worker.last_error) {
-      return { label: '报错', color: 'bg-red-50 text-red-700 border-red-200', icon: AlertTriangle };
-    }
-    if (diffMinutes > 10) { 
-      return { label: '离线/卡死', color: 'bg-gray-100 text-gray-500 border-gray-200', icon: Clock };
-    }
-    if (diffMinutes > 5) { 
-      return { label: '延迟', color: 'bg-yellow-50 text-yellow-700 border-yellow-200', icon: Clock };
-    }
-    return { label: '运行中', color: 'bg-green-50 text-green-700 border-green-200', icon: Activity };
-  };
-
-  return (
-    <div className="p-4 md:p-6">
-      
-      {/* Header */}
-      <div className="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4">
-        <div>
-          <h1 className="text-2xl font-bold text-slate-800 flex items-center gap-2">
-            <Server className="text-blue-600" /> Worker 监控面板
-          </h1>
-          <p className="text-sm text-slate-500 mt-1">
-            监控爬虫节点的刷新状态。
-            <span className={`ml-2 text-xs px-2 py-0.5 rounded ${autoRefresh ? 'bg-green-100 text-green-700' : 'bg-slate-100 text-slate-400'}`}>
-              {autoRefresh ? '自动刷新 ON' : '自动刷新 OFF'}
-            </span>
-          </p>
-        </div>
-
-        <div className="flex flex-wrap gap-3 w-full md:w-auto">
-          <div className="relative flex-1 md:flex-none">
-            <input 
-              type="text" 
-              placeholder="搜索 Route / Country..." 
-              className="w-full pl-9 pr-4 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none transition"
-              value={keyword}
-              onChange={e => setKeyword(e.target.value)}
-            />
-            <Search size={16} className="absolute left-3 top-2.5 text-gray-400" />
-          </div>
-          
-          <button 
-            onClick={() => setAutoRefresh(!autoRefresh)}
-            className={`px-3 py-2 border rounded-lg text-sm font-medium transition whitespace-nowrap
-              ${autoRefresh ? 'bg-blue-50 text-blue-700 border-blue-200' : 'bg-white text-slate-600 border-slate-200'}`}
-          >
-            {autoRefresh ? '暂停' : '开启'}
-          </button>
-
-          <button 
-            onClick={() => fetchData()} 
-            className="p-2 bg-white border border-slate-300 rounded-lg hover:bg-slate-50 text-slate-600 transition"
-          >
-            <RefreshCw size={18} className={loading ? 'animate-spin' : ''} />
-          </button>
-        </div>
-      </div>
-
-      {/* Grid List */}
-      <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
-        {filteredWorkers.map((worker) => {
-          const status = getHealthStatus(worker);
-          const StatusIcon = status.icon;
-
-          return (
-            <div key={worker.routing_key} className={`bg-white border rounded-xl p-5 shadow-sm transition hover:shadow-md ${status.label === '报错' ? 'border-red-200' : 'border-slate-200'}`}>
-              
-              <div className="flex justify-between items-start mb-3">
-                <div className="flex flex-col">
-                  <div className="flex items-center gap-1.5 text-sm font-bold text-slate-800">
-                    <MapPin size={14} className="text-blue-500"/>
-                    {worker.country} - {worker.city}
-                  </div>
-                  <span className="text-xs text-slate-500 mt-0.5">{worker.visa_type}</span>
-                </div>
-                
-                <span className={`flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-bold border ${status.color}`}>
-                  <StatusIcon size={12} /> {status.label}
-                </span>
-              </div>
-
-              <div className="bg-slate-50 px-2 py-1 rounded text-[10px] font-mono text-slate-500 mb-4 break-all">
-                {worker.routing_key}
-              </div>
-
-              <div className="space-y-2 text-xs text-slate-600">
-                <div className="flex justify-between">
-                  <span className="text-slate-400">上次尝试:</span>
-                  <LocalTime date={worker.last_refresh_at} />
-                </div>
-
-                {/* === 修改点:增加“距离上次成功”的时间差 === */}
-                <div className="flex justify-between items-center bg-green-50/50 p-1.5 -mx-1.5 rounded">
-                  <span className="text-slate-500 font-medium">上次成功:</span>
-                  <div className="text-right">
-                    <div className="font-bold text-green-700">
-                       <TimeAgo date={worker.last_success_at} />
-                    </div>
-                    <div className="text-[10px] text-slate-400 scale-90 origin-right">
-                      <LocalTime date={worker.last_success_at} />
-                    </div>
-                  </div>
-                </div>
-
-                <div className="flex justify-between items-center pt-2 border-t border-slate-100 mt-2">
-                   <span className="text-slate-400">Worker 心跳:</span>
-                   <div className="flex items-center gap-1.5">
-                     <LocalTime date={worker.updated_at} className="text-slate-800"/>
-                     <span className="text-[10px] text-slate-400">(<TimeAgo date={worker.updated_at} />)</span>
-                   </div>
-                </div>
-              </div>
-
-              {worker.last_error && (
-                <div className="mt-3 p-2 bg-red-50 border border-red-100 rounded text-[10px] text-red-600 break-all leading-relaxed">
-                  <span className="font-bold block mb-0.5">Error Log:</span>
-                  {worker.last_error}
-                </div>
-              )}
-            </div>
-          );
-        })}
-      </div>
-
-      {!loading && filteredWorkers.length === 0 && (
-        <div className="text-center py-20 text-slate-400 bg-white rounded-xl border border-dashed">
-          暂无 Worker 数据
-        </div>
-      )}
-    </div>
-  );
-}

+ 3 - 2
src/app/dashboard/page.tsx

@@ -9,10 +9,11 @@ import OrderList from '@/components/dashboard/OrderList';
 import TicketList from '@/components/dashboard/TicketList';
 import ProfileSettings from '@/components/dashboard/ProfileSettings';
 import TicketModal from '@/components/dashboard/TicketModal';
-import UserOrderDetailModal, { UserOrder } from '@/components/dashboard/UserOrderDetailModal';
-import UserTicketDetailModal, { UserTicket } from '@/components/dashboard/UserTicketDetailModal';
+import UserOrderDetailModal from '@/components/dashboard/UserOrderDetailModal';
+import UserTicketDetailModal from '@/components/dashboard/UserTicketDetailModal';
 import BindEmailModal from '@/components/BindEmailModal';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
+import { UserOrder, UserTicket } from '@/types';
 
 // 1. 引入通用弹窗组件
 import ConfirmModal from '@/components/common/ConfirmModal';

+ 2 - 1
src/app/slots/page.tsx

@@ -4,7 +4,8 @@ import { useState, useEffect, useMemo } from 'react';
 import api from '@/lib/api';
 import { RefreshCw, MapPin, Info, Globe, Search } from 'lucide-react';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
-import CitySlotCard, { SlotSnapshot } from '@/components/slots/CitySlotCard';
+import CitySlotCard from '@/components/slots/CitySlotCard';
+import { SlotSnapshot } from '@/types';
 
 const LOCATIONS = [
   { code: 'IE', name: 'Ireland', flag: '🇮🇪', cities: ['Dublin'] },

+ 2 - 32
src/components/CreateOrderForm.tsx

@@ -15,9 +15,10 @@ import BindEmailModal from '@/components/BindEmailModal';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import ConfirmModal from '@/components/common/ConfirmModal';
 import MessageModal from '@/components/common/MessageModal';
+import { ProductDetail, SchemaProperty, JsonSchema } from '@/types';
 
 // ==========================================
-// 类型定义
+// 组件入参
 // ==========================================
 
 interface CreateOrderFormProps {
@@ -25,37 +26,6 @@ interface CreateOrderFormProps {
   productName?: string;
 }
 
-interface ProductDetail {
-  id: number;
-  title: string;
-  description: string;
-  price_amount: number;
-  price_currency: string;
-  schema_id?: number; 
-  extra_fields?: any; 
-}
-
-interface SchemaProperty {
-  type: string;
-  title?: string;
-  description?: string;
-  default?: any;
-  enum?: string[] | number[];
-  format?: string;
-  order?: number;
-  'x-order'?: number;
-  [key: string]: any;
-}
-
-interface JsonSchema {
-  title?: string;
-  description?: string;
-  type?: string;
-  properties?: Record<string, SchemaProperty>;
-  required?: string[];
-  'ui:order'?: string[];
-}
-
 // ==========================================
 // 组件逻辑
 // ==========================================

+ 2 - 32
src/components/PaymentProcessor.tsx

@@ -18,44 +18,14 @@ import {
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
 import MessageModal from '@/components/common/MessageModal';
+import { PaymentProvider, PaymentResult } from '@/types';
 
-// === 类型定义 ===
+// === 组件入参 ===
 
 interface PaymentProcessorProps {
   orderId: string;
 }
 
-interface PaymentProvider {
-  id: number | string;
-  name: string;
-  currency?: string;
-  icon?: string;
-  title?: string;
-}
-
-interface PaymentResult {
-  id: number; // payment_id
-  status: string;
-  channel: 'online_link' | 'qr_static' | string;
-  provider: string; 
-  qr_id?: number;   
-  payment_url?: string;
-  expire_at: string;
-  
-  // 金额相关
-  base_amount: number;
-  base_currency: string;
-  amount: number;
-  currency: string;
-  random_offset: number;
-  exchange_rate: number;
-
-  // 新增:人工调价金额 (分)
-  adjustment_delta?: number;
-  
-  [key: string]: any;
-}
-
 // === 组件逻辑 ===
 
 export default function PaymentProcessor({ orderId }: PaymentProcessorProps) {

+ 1 - 12
src/components/ServiceList.tsx

@@ -17,18 +17,7 @@ import {
 } from 'lucide-react';
 import Pagination from '@/components/common/Pagination';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
-
-interface Product {
-  id: number;
-  title: string;
-  price_amount: number;
-  price_currency: string;
-  description: string;
-  country: string;
-  city: string;
-  visa_type: string;
-  provider: string;
-}
+import { Product } from '@/types';
 
 export default function ServiceList() {
   const router = useRouter();

+ 2 - 4
src/components/admin/AdminSidebar.tsx

@@ -6,8 +6,8 @@ import Link from 'next/link';
 import { 
   LayoutDashboard, ShoppingBag, LifeBuoy, Settings, LogOut, 
   Activity, CreditCard, Users, ChevronLeft, ChevronRight, 
-  Plane, LucideIcon, CalendarClock, LayoutGrid, CheckCheck,
-  Menu, X, Server, UserCog, Network, SlidersHorizontal
+  Plane, LucideIcon,
+  Menu, X, UserCog, Network, SlidersHorizontal
 } from 'lucide-react';
 
 interface MenuItem {
@@ -33,8 +33,6 @@ export default function AdminSidebar() {
     { name: '商品配置', href: '/admin/products', icon: Settings },
     { name: '动态配置', href: '/admin/configurations', icon: SlidersHorizontal },
     { name: '系统任务', href: '/admin/tasks', icon: Activity },
-    { name: 'VISAMETRIC', href: '/admin/visametric', icon: CalendarClock },
-    { name: 'Worker 状态', href: '/admin/workers', icon: Server },
     { name: '账号池管理', href: '/admin/accounts', icon: UserCog },
     { name: '代理管理', href: '/admin/proxies', icon: Network },
   ];

+ 1 - 2
src/components/admin/TicketActionModal.tsx

@@ -2,8 +2,7 @@
 
 import { useState } from 'react';
 import { Loader2, X } from 'lucide-react';
-
-export type ActionType = 'approve' | 'reject' | 'need-info';
+import { ActionType } from '@/types';
 
 interface TicketActionModalProps {
   isOpen: boolean;

+ 1 - 12
src/components/admin/accounts/AccountTable.tsx

@@ -1,18 +1,7 @@
 import { useEffect, useState } from 'react';
 import { Lock, Unlock, Timer, Loader2, Ban, Pencil, Trash2, Copy } from 'lucide-react';
 import { toast } from 'react-hot-toast';
-
-export interface Account {
-  id: number;
-  pool_name: string;
-  username: string;
-  password?: string;
-  extra_data?: Record<string, any> | null;
-  status?: string | null;
-  next_use_time?: string | null;
-  created_at?: string;
-  updated_at?: string;
-}
+import { Account } from '@/types';
 
 interface AccountTableProps {
   data: Account[];

+ 1 - 61
src/components/admin/orders/OrderDetailModal.tsx

@@ -4,67 +4,7 @@ import { useState, useEffect, useMemo } from 'react';
 import api from '@/lib/api'; 
 import { X, CreditCard, User, FileText, Package, Loader2, Phone, Mail } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
-
-// ... (接口定义保持不变) ...
-export interface OrderDetail {
-  id: string;
-  user_id: string;
-  created_at: string;
-  status: string;
-  base_amount: number;
-  base_currency: string;
-  product_title?: string;
-  product_name?: string;
-  user?: {
-    email: string;
-    nickname?: string;
-    phone?: string;
-  };
-  user_email?: string;
-  user_name?: string;
-  applicant_name?: string;
-  user_inputs?: Record<string, any>;
-  payments?: PaymentRecord[]; 
-}
-
-export interface PaymentRecord {
-  id: number;
-  provider: string;
-  channel: string;
-  amount: number;
-  currency: string;
-  status: string;
-  created_at: string;
-  external_trade_no?: string;
-  description?: string;
-  qr_id?: number;
-  payment_intent_id?: string;
-}
-
-interface PaymentQrDetail {
-  id: number;
-  description?: string;
-}
-
-interface UserDetail {
-  id: string;
-  email: string;
-  phone?: string;
-  nickname?: string;
-  avatar_url?: string;
-  role?: string;
-  created_at?: string;
-}
-
-interface OrderEvent {
-  id: number;
-  order_no?: string;
-  event_title?: string;
-  event_message?: string;
-  email_uid?: number | null;
-  event_time?: string;
-  created_at?: string;
-}
+import { OrderDetail, PaymentRecord, PaymentQrDetail, UserDetail, OrderEvent } from '@/types';
 
 interface OrderDetailModalProps {
   isOpen: boolean;

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

@@ -3,7 +3,7 @@
 import { useState, useEffect } from 'react';
 import { X, Save, Loader2, AlertTriangle } from 'lucide-react';
 import JsonEditor from '@/components/common/JsonEditor'; // 复用之前封装的组件
-import { OrderDetail } from './OrderDetailModal';
+import { OrderDetail } from '@/types';
 
 interface OrderEditModalProps {
   isOpen: boolean;

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

@@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
 import { X, CreditCard, CheckCircle, AlertCircle, Loader2, Ban } from 'lucide-react';
 import api from '@/lib/api';
 import LocalTime from '@/components/common/LocalTime';
-import { OrderDetail, PaymentRecord } from './OrderDetailModal'; // 复用类型
+import { OrderDetail, PaymentRecord } from '@/types';
 
 interface OrderPaymentModalProps {
   isOpen: boolean;

+ 2 - 1
src/components/admin/orders/OrderPriceAdjustModal.tsx

@@ -3,11 +3,12 @@
 import { useState, useEffect } from 'react';
 import { X, DollarSign, Loader2, Save } from 'lucide-react';
 import api from '@/lib/api';
+import { OrderDetail } from '@/types';
 
 interface OrderPriceAdjustModalProps {
   isOpen: boolean;
   onClose: () => void;
-  order: any;
+  order: OrderDetail | null;
   onSuccess: () => void;
 }
 

+ 1 - 7
src/components/admin/orders/OrderTable.tsx

@@ -1,14 +1,8 @@
 'use client';
 
 import { Eye, XCircle, User, Box, Edit, Clock, FileText, Wallet, DollarSign } from 'lucide-react';
-import { OrderDetail } from './OrderDetailModal'; // 假设类型从这里导入
 import LocalTime from '@/components/common/LocalTime';
-
-// 扩展类型定义以包含调价字段 (如果 OrderDetail 没有包含,请在这里补全)
-interface ExtendedOrderDetail extends OrderDetail {
-  final_amount?: number;
-  adjustment_delta?: number;
-}
+import { OrderDetail, ExtendedOrderDetail } from '@/types';
 
 interface OrderTableProps {
   orders: ExtendedOrderDetail[]; 

+ 1 - 6
src/components/admin/payments/ExchangeRateModal.tsx

@@ -3,18 +3,13 @@
 import { useState, useEffect } from 'react';
 import api from '@/lib/api';
 import { X, Save, RefreshCw, Loader2, ArrowRight, AlertTriangle, Lock } from 'lucide-react';
+import { RateConfig } from '@/types';
 
 interface ExchangeRateModalProps {
   isOpen: boolean;
   onClose: () => void;
 }
 
-interface RateConfig {
-  base: string;
-  precision: number;
-  rates: Record<string, number>;
-}
-
 // 常用货币名称映射,增强可读性
 const CURRENCY_NAMES: Record<string, string> = {
   CNY: '人民币 (Chinese Yuan)',

+ 2 - 11
src/components/admin/payments/ProviderList.tsx

@@ -1,16 +1,7 @@
 'use client';
 
 import { Edit, QrCode, CheckCircle, XCircle, Link as LinkIcon, Trash2, Coins } from 'lucide-react';
-
-interface Provider {
-  id: number;
-  name: string;
-  title: string;
-  icon: string;
-  channel: string;
-  currency: string;
-  enabled: number;
-}
+import { Provider } from '@/types';
 
 interface ProviderListProps {
   providers: Provider[];
@@ -24,7 +15,7 @@ export default function ProviderList({ providers, loading, onEdit, onManageQr, o
   if (loading) return <div className="p-12 text-center text-gray-500">加载中...</div>;
 
   // 提取状态徽章渲染逻辑,供移动端和桌面端复用
-  const renderStatus = (enabled: number) => (
+  const renderStatus = (enabled: number | boolean) => (
     enabled ? (
       <span className="text-green-600 flex items-center text-xs font-medium bg-green-50 px-2 py-0.5 rounded border border-green-100">
         <CheckCircle size={12} className="mr-1"/> Active

+ 1 - 10
src/components/admin/payments/QrManager.tsx

@@ -7,6 +7,7 @@ import {
   Smartphone, ToggleLeft, ToggleRight, Upload 
 } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
+import { PaymentQr } from '@/types';
 
 interface QrManagerProps {
   providerId: number | null; 
@@ -15,16 +16,6 @@ interface QrManagerProps {
   onClose: () => void;
 }
 
-interface PaymentQr {
-  id: number;
-  qr_code: string; 
-  priority?: number;
-  is_active: boolean | number; 
-  description?: string;
-  device?: string;
-  created_at?: string;
-}
-
 export default function QrManager({ providerId, providerName, isOpen, onClose }: QrManagerProps) {
   const [qrs, setQrs] = useState<PaymentQr[]>([]);
   const [loading, setLoading] = useState(false);

+ 2 - 14
src/components/admin/products/ProductList.tsx

@@ -1,19 +1,7 @@
 'use client';
 
 import { Edit, Network, CheckCircle, XCircle } from 'lucide-react';
-
-interface Product {
-  id: number;
-  title: string;
-  country: string;
-  city: string;
-  visa_type: string;
-  price_amount: number;
-  price_currency: string;
-  provider: string;
-  enabled: number;
-  recommend_score?: number;
-}
+import { Product } from '@/types';
 
 interface ProductListProps {
   products: Product[];
@@ -26,7 +14,7 @@ export default function ProductList({ products, loading, onEdit, onManageRouting
   if (loading) return <div className="p-8 text-center text-gray-500">加载商品中...</div>;
 
   // 提取渲染状态的逻辑,供复用
-  const renderStatus = (enabled: number) => (
+  const renderStatus = (enabled: number | boolean) => (
     enabled ? (
       <span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">
         <CheckCircle size={12} className="mr-1"/> 上架中

+ 1 - 9
src/components/admin/products/RoutingManager.tsx

@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
 import api from '@/lib/api';
 import { Loader2, Trash2, Plus, Save, X, Network } from 'lucide-react';
 import JsonEditor from '@/components/common/JsonEditor';
+import { ProductRouting } from '@/types';
 
 interface RoutingManagerProps {
   productId: number | null;
@@ -12,15 +13,6 @@ interface RoutingManagerProps {
   onClose: () => void;
 }
 
-interface ProductRouting {
-  id: number;
-  routing_key: string;
-  script_version: string;
-  priority: number;
-  config?: any; // JSON object or string
-  meta?: any;
-}
-
 export default function RoutingManager({ productId, productTitle, isOpen, onClose }: RoutingManagerProps) {
   const [routings, setRoutings] = useState<ProductRouting[]>([]);
   const [loading, setLoading] = useState(false);

+ 1 - 7
src/components/admin/products/SchemaManager.tsx

@@ -4,19 +4,13 @@ import { useState, useEffect } from 'react';
 import api from '@/lib/api';
 import { Loader2, Plus, Save, X, FileJson, List, Edit3, Trash2 } from 'lucide-react';
 import JsonEditor from '@/components/common/JsonEditor';
+import { SchemaItem } from '@/types';
 
 interface SchemaManagerProps {
   isOpen: boolean;
   onClose: () => void;
 }
 
-interface SchemaItem {
-  id: number;
-  name: string;
-  schema_json: string; 
-  description?: string;
-}
-
 export default function SchemaManager({ isOpen, onClose }: SchemaManagerProps) {
   const [schemas, setSchemas] = useState<SchemaItem[]>([]);
   const [loading, setLoading] = useState(false);

+ 1 - 14
src/components/admin/proxies/ProxyTable.tsx

@@ -2,20 +2,7 @@
 
 import { useEffect, useState } from 'react';
 import { Loader2, Unlock, Lock, Ban, Pencil, Trash2 } from 'lucide-react';
-
-export interface ProxyItem {
-  id: number;
-  pool_name: string;
-  proto: string;
-  ip: string;
-  port: number;
-  username?: string | null;
-  password?: string | null;
-  next_use_time?: string | null;
-  status?: string | null;
-  created_at?: string;
-  updated_at?: string;
-}
+import { ProxyItem } from '@/types';
 
 interface ProxyTableProps {
   data: ProxyItem[];

+ 0 - 395
src/components/admin/tasks/ExpiringTaskAlert.tsx

@@ -1,395 +0,0 @@
-'use client';
-
-import { useEffect, useState } from 'react';
-import api from '@/lib/api';
-import { 
-  AlertTriangle, ChevronDown, ChevronUp, Clock, 
-  Mail, Copy, User, FileText, Zap, Loader2, X, Send, Eye, PenLine, 
-  MessageCircle // [新增] 引入图标
-} from 'lucide-react';
-import { VasTask } from './TaskTable';
-
-// API 返回的数据结构
-interface ExpiringTaskItem {
-  id: number;
-  order_id: string;
-  routing_key: string;
-  status: string;
-  customer_name: string;
-  expected_end_date: string;
-  email: string;
-  days_left: number;
-  social_media_account?: string; // [新增] 社交账号字段
-}
-
-interface ExpiringTaskAlertProps {
-  onViewDetail: (task: VasTask) => void;
-  onEdit: (task: VasTask) => void;
-}
-
-// 邮件草稿状态接口
-interface EmailDraft {
-  taskId: number;
-  customerName: string;
-  from: string;
-  to: string;
-  subject: string;
-  body: string; // 纯文本内容
-}
-
-export default function ExpiringTaskAlert({ onViewDetail, onEdit }: ExpiringTaskAlertProps) {
-  const [tasks, setTasks] = useState<ExpiringTaskItem[]>([]);
-  const [loading, setLoading] = useState(true);
-  const [isExpanded, setIsExpanded] = useState(false);
-
-  // === 邮件模态框状态 ===
-  const [isEmailModalOpen, setIsEmailModalOpen] = useState(false);
-  const [activeTab, setActiveTab] = useState<'write' | 'preview'>('write'); 
-  const [sending, setSending] = useState(false);
-  
-  const [emailDraft, setEmailDraft] = useState<EmailDraft>({
-    taskId: 0,
-    customerName: '',
-    from: 'support@text.skin',
-    to: '',
-    subject: '',
-    body: ''
-  });
-
-  const fetchExpiring = async () => {
-    setLoading(true);
-    try {
-      const res = await api.get('/api/vas/task/expiring?days=3');
-      const data = res.data.data || [];
-      setTasks(data);
-    } catch (error) {
-      console.error("Failed to fetch expiring tasks", error);
-    } finally {
-      setLoading(false);
-    }
-  };
-
-  useEffect(() => {
-    fetchExpiring();
-  }, []);
-
-  // 1. 初始化草稿
-  const openEmailModal = (item: ExpiringTaskItem) => {
-    const textTemplate = `Dear ${item.customer_name},
-
-We noticed that your expected appointment date (${item.expected_end_date}) is approaching or has passed.
-
-Please provide a new expected date range so we can continue the service.`;
-
-    setEmailDraft({
-      taskId: item.id,
-      customerName: item.customer_name,
-      from: 'support@text.skin',
-      to: item.email,
-      subject: `Appointment Reschedule Required - Order ${item.order_id}`,
-      body: textTemplate
-    });
-    
-    setActiveTab('write'); 
-    setIsEmailModalOpen(true);
-  };
-
-  // === 生成 HTML 用于预览和发送 ===
-  const generateFinalHtml = (textBody: string) => {
-    const safeText = textBody
-      .replace(/&/g, "&amp;")
-      .replace(/</g, "&lt;")
-      .replace(/>/g, "&gt;");
-
-    const contentHtml = safeText.replace(/\n/g, '<br/>');
-
-    return `
-      <div style="font-family: Arial, sans-serif; font-size: 14px; line-height: 1.6; color: #333;">
-        ${contentHtml}
-        
-        <br/><br/>
-        <hr style="border: 0; border-top: 1px solid #eee; margin: 20px 0;" />
-        
-        <p style="margin: 0 0 10px 0;">You can visit our official website for more information:</p>
-        <p style="margin: 0;">
-          <a href="https://text.skin" target="_blank" style="color: #2563eb; text-decoration: underline; font-weight: bold;">
-            https://text.skin
-          </a>
-        </p>
-        
-        <br/>
-        <p style="margin: 0 0 5px 0;">Best Regards,</p>
-        <p style="margin: 0; font-weight: bold;">TextSkin Service Team</p>
-      </div>
-    `;
-  };
-
-  // 2. 发送邮件
-  const handleConfirmSend = async () => {
-    setSending(true);
-    try {
-      const finalHtmlBody = generateFinalHtml(emailDraft.body);
-
-      await api.post('/api/email-authorizations/sendmail', 
-        { 
-          body: finalHtmlBody 
-        }, 
-        {
-          params: {
-            emailAccount: emailDraft.from,
-            sendTo: emailDraft.to,
-            subject: emailDraft.subject,
-            contentType: 'html'
-          }
-        }
-      );
-      
-      alert(`邮件已成功发送给 ${emailDraft.customerName}`);
-      setIsEmailModalOpen(false);
-
-    } catch (error: any) {
-      console.error("发送邮件失败", error);
-      alert(`发送失败: ${error.response?.data?.message || error.message || "未知错误"}`);
-    } finally {
-      setSending(false);
-    }
-  };
-
-  // 复制辅助函数
-  const copyText = (text: string) => {
-    if (!text) return;
-    if (navigator.clipboard && navigator.clipboard.writeText) {
-      navigator.clipboard.writeText(text).catch(() => fallbackCopy(text));
-    } else { fallbackCopy(text); }
-  };
-  const fallbackCopy = (text: string) => {
-    const ta = document.createElement("textarea");
-    ta.value = text; ta.style.position="fixed"; ta.style.left="-9999px";
-    document.body.appendChild(ta); ta.select(); document.execCommand('copy');
-    document.body.removeChild(ta);
-  };
-
-  if (loading) return null;
-  if (tasks.length === 0) return null;
-
-  return (
-    <>
-      {/* === 主列表 === */}
-      <div className="mb-4 bg-white border border-orange-200 rounded-lg shadow-sm overflow-hidden transition-all">
-        <div 
-          className={`px-4 py-3 flex justify-between items-center cursor-pointer hover:bg-orange-50 transition-colors ${isExpanded ? 'bg-orange-50 border-b border-orange-100' : 'bg-white'}`}
-          onClick={() => setIsExpanded(!isExpanded)}
-        >
-          <div className="flex items-center gap-2">
-            <AlertTriangle size={18} className="text-orange-500" />
-            <span className="font-bold text-slate-700 text-sm">紧急预警 ({tasks.length})</span>
-            <span className="text-xs text-slate-400 border-l border-slate-200 pl-2 ml-1 hidden sm:inline">
-              {tasks.length} 个任务即将过期或已过期,请及时联系客户改期
-            </span>
-          </div>
-          <button className="text-slate-400 hover:text-slate-600">
-            {isExpanded ? <ChevronUp size={18} /> : <ChevronDown size={18} />}
-          </button>
-        </div>
-
-        {isExpanded && (
-          <div className="bg-white">
-            <div className="max-h-[400px] overflow-y-auto">
-              <table className="w-full text-xs text-left relative">
-                <thead className="bg-slate-50 text-slate-500 font-medium sticky top-0 z-10 shadow-sm">
-                  <tr>
-                    <th className="px-4 py-2 bg-slate-50 w-[140px]">紧迫程度 / 截止</th>
-                    <th className="px-4 py-2 bg-slate-50 w-[200px]">客户信息 (Email)</th>
-                    <th className="px-4 py-2 bg-slate-50">任务详情 (ID / Route)</th>
-                    <th className="px-4 py-2 bg-slate-50 text-right w-[100px]">操作</th>
-                  </tr>
-                </thead>
-                <tbody className="divide-y divide-slate-100">
-                  {tasks.map((task) => (
-                    <tr key={task.id} className="hover:bg-slate-50 transition-colors">
-                      <td className="px-4 py-3 align-top">
-                        <div className="flex flex-col gap-1">
-                          <div className="flex items-center gap-1.5">
-                            <Clock size={12} className={task.days_left < 0 ? "text-red-500" : "text-orange-500"} />
-                            <span className={`font-bold ${task.days_left < 0 ? "text-red-600" : "text-orange-600"}`}>
-                              {task.days_left < 0 ? `逾期 ${Math.abs(task.days_left)} 天` : `${task.days_left} 天后`}
-                            </span>
-                          </div>
-                          <span className="text-slate-400 font-mono pl-4">{task.expected_end_date}</span>
-                        </div>
-                      </td>
-
-                      {/* 2. 客户信息列 (修改点) */}
-                      <td className="px-4 py-3 align-top">
-                        <div className="flex flex-col gap-1">
-                          {/* 姓名 */}
-                          <div className="flex items-center gap-1.5 font-bold text-slate-700">
-                             <User size={12} className="text-slate-400"/> {task.customer_name}
-                          </div>
-
-                          {/* [新增] 社交账号显示 */}
-                          {task.social_media_account && (
-                            <div className="flex items-center gap-1.5 text-slate-500" title="社交媒体账号">
-                                <MessageCircle size={10} className="text-indigo-400 flex-shrink-0" />
-                                <span className="truncate max-w-[160px] font-medium text-[11px] bg-slate-100 px-1 rounded">
-                                  {task.social_media_account}
-                                </span>
-                            </div>
-                          )}
-
-                          {/* 邮箱 */}
-                          <div className="flex items-center gap-1 text-slate-500 cursor-pointer hover:text-blue-600 group/copy w-fit" onClick={() => copyText(task.email)}>
-                            <Mail size={10} />
-                            <span className="truncate max-w-[160px] underline decoration-slate-300 decoration-dotted underline-offset-2">{task.email}</span>
-                            <Copy size={8} className="opacity-0 group-hover/copy:opacity-100 transition-opacity" />
-                          </div>
-                        </div>
-                      </td>
-
-                      <td className="px-4 py-3 align-top">
-                        <div className="flex flex-col gap-1.5">
-                          <div className="flex items-center gap-1.5 cursor-pointer hover:text-blue-600 w-fit" onClick={() => copyText(task.order_id)}>
-                            <FileText size={12} className="text-slate-400 flex-shrink-0" />
-                            <span className="font-mono text-slate-700 font-medium">{task.order_id}</span>
-                          </div>
-                          <div className="flex items-start gap-1.5">
-                            <Zap size={12} className="text-indigo-400 flex-shrink-0 mt-0.5" />
-                            <span className="font-mono text-[10px] text-slate-500 bg-slate-100 px-1 rounded break-all leading-tight">{task.routing_key}</span>
-                          </div>
-                        </div>
-                      </td>
-                      <td className="px-4 py-3 align-middle text-right">
-                        <button 
-                          onClick={(e) => { e.stopPropagation(); openEmailModal(task); }}
-                          className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-orange-50 text-orange-700 hover:bg-orange-100 hover:text-orange-800 rounded-md border border-orange-200 transition-colors shadow-sm"
-                        >
-                          <Mail size={14} />
-                          <span className="font-bold">联系改期</span>
-                        </button>
-                      </td>
-                    </tr>
-                  ))}
-                </tbody>
-              </table>
-            </div>
-          </div>
-        )}
-      </div>
-
-      {/* === 邮件发送模态框 === */}
-      {isEmailModalOpen && (
-        <div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/60 backdrop-blur-sm p-4 animate-in fade-in duration-200">
-          <div className="bg-white rounded-xl shadow-2xl w-full max-w-2xl overflow-hidden flex flex-col max-h-[90vh]">
-            
-            {/* Modal Header */}
-            <div className="px-6 py-4 border-b border-slate-100 flex justify-between items-center bg-slate-50">
-              <h3 className="font-bold text-lg text-slate-800 flex items-center gap-2">
-                <Mail className="text-blue-600" size={20} />
-                发送通知邮件
-              </h3>
-              <button 
-                onClick={() => setIsEmailModalOpen(false)}
-                className="text-slate-400 hover:text-slate-600 hover:bg-slate-200 rounded-full p-1 transition"
-              >
-                <X size={20} />
-              </button>
-            </div>
-
-            {/* Modal Body */}
-            <div className="p-6 overflow-y-auto flex-1 flex flex-col gap-4">
-              
-              {/* Basic Info */}
-              <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
-                <div>
-                  <label className="block text-xs font-semibold text-slate-500 mb-1">发件人</label>
-                  <input type="text" value={emailDraft.from} readOnly className="w-full px-3 py-2 bg-slate-100 border border-slate-200 rounded-lg text-sm text-slate-600 focus:outline-none" />
-                </div>
-                <div>
-                  <label className="block text-xs font-semibold text-slate-500 mb-1">收件人</label>
-                  <input type="text" value={emailDraft.to} readOnly className="w-full px-3 py-2 bg-slate-100 border border-slate-200 rounded-lg text-sm text-slate-800 font-medium focus:outline-none" />
-                </div>
-              </div>
-
-              <div>
-                <label className="block text-xs font-semibold text-slate-500 mb-1">邮件主题</label>
-                <input 
-                  type="text" 
-                  value={emailDraft.subject}
-                  onChange={(e) => setEmailDraft({...emailDraft, subject: e.target.value})}
-                  className="w-full px-3 py-2 border border-slate-300 rounded-lg text-sm text-slate-800 focus:ring-2 focus:ring-blue-500 outline-none transition"
-                />
-              </div>
-
-              {/* 编辑容器 */}
-              <div className="flex flex-col h-[350px]"> 
-                <div className="flex justify-between items-center border-b border-slate-200 mb-0">
-                  <div className="flex gap-1">
-                    <button 
-                      onClick={() => setActiveTab('write')}
-                      className={`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${activeTab === 'write' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500 hover:text-slate-700'}`}
-                    >
-                      <PenLine size={14} /> 编辑文本
-                    </button>
-                    <button 
-                      onClick={() => setActiveTab('preview')}
-                      className={`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${activeTab === 'preview' ? 'border-purple-500 text-purple-600' : 'border-transparent text-slate-500 hover:text-slate-700'}`}
-                    >
-                      <Eye size={14} /> 预览效果
-                    </button>
-                  </div>
-                  <span className="text-[10px] text-slate-400 pr-2">
-                    {activeTab === 'write' ? '支持纯文本,自动换行' : '这是最终发送的 HTML 样式'}
-                  </span>
-                </div>
-
-                <div className="flex-1 border-x border-b border-slate-200 rounded-b-lg bg-slate-50 overflow-hidden relative">
-                  {activeTab === 'write' ? (
-                    <textarea 
-                      value={emailDraft.body}
-                      onChange={(e) => setEmailDraft({...emailDraft, body: e.target.value})}
-                      placeholder="请输入邮件正文..."
-                      className="w-full h-full p-4 text-sm text-slate-800 leading-relaxed bg-white outline-none resize-none focus:bg-slate-50/50 transition"
-                    />
-                  ) : (
-                    <div className="w-full h-full p-4 overflow-y-auto bg-white">
-                      <div 
-                        className="preview-content border border-slate-100 rounded p-4 shadow-sm"
-                        dangerouslySetInnerHTML={{ __html: generateFinalHtml(emailDraft.body) }} 
-                      />
-                    </div>
-                  )}
-                </div>
-              </div>
-
-            </div>
-
-            {/* Modal Footer */}
-            <div className="px-6 py-4 border-t border-slate-100 flex justify-end gap-3 bg-white">
-              <button 
-                onClick={() => setIsEmailModalOpen(false)}
-                className="px-4 py-2 text-slate-600 hover:bg-slate-100 rounded-lg text-sm font-medium transition"
-              >
-                取消
-              </button>
-              <button 
-                onClick={handleConfirmSend}
-                disabled={sending || !emailDraft.subject || !emailDraft.body}
-                className={`flex items-center gap-2 px-6 py-2 rounded-lg text-sm font-bold text-white transition shadow-sm
-                  ${sending || !emailDraft.subject || !emailDraft.body 
-                    ? 'bg-blue-300 cursor-not-allowed' 
-                    : 'bg-blue-600 hover:bg-blue-700 hover:shadow-md'}`}
-              >
-                {sending ? (
-                  <> <Loader2 size={16} className="animate-spin" /> 发送中... </>
-                ) : (
-                  <> <Send size={16} /> 确认发送 </>
-                )}
-              </button>
-            </div>
-
-          </div>
-        </div>
-      )}
-    </>
-  );
-}

+ 1 - 1
src/components/admin/tasks/TaskDetailModal.tsx

@@ -1,7 +1,7 @@
 'use client';
 
 import { X, Activity, Database, Clock, FileJson, AlertTriangle } from 'lucide-react';
-import { VasTask } from './TaskTable'; // 引用 Table 中定义的类型
+import { VasTask } from '@/types';
 
 interface TaskDetailModalProps {
   isOpen: boolean;

+ 1 - 1
src/components/admin/tasks/TaskEditModal.tsx

@@ -3,7 +3,7 @@
 import { useState, useEffect } from 'react';
 import { Loader2, X, Save, AlertTriangle } from 'lucide-react';
 import JsonEditor from '@/components/common/JsonEditor';
-import { VasTask } from './TaskTable';
+import { VasTask } from '@/types';
 
 interface TaskEditModalProps {
   isOpen: boolean;

+ 1 - 18
src/components/admin/tasks/TaskTable.tsx

@@ -7,24 +7,7 @@ import {
 } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
 import api from '@/lib/api';
-
-export interface VasTask {
-  id: number;
-  order_id: string;
-  routing_key: string;
-  status: string;
-  priority: number;
-  script_version?: string;
-  attempt_count: number;
-  notify_count: number;
-  config?: any;
-  user_inputs?: any;
-  grabbed_history?: any; 
-  meta?: any;
-  created_at: string;
-  updated_at: string;
-  expire_at: string;
-}
+import { VasTask } from '@/types';
 
 interface TaskTableProps {
   tasks: VasTask[];

+ 1 - 9
src/components/admin/tickets/TicketDetailModal.tsx

@@ -3,8 +3,8 @@
 import { useState, useEffect, useRef } from 'react';
 import api from '@/lib/api';
 import { X, Send, User, Shield, Check, Ban, RefreshCw, Loader2, MessageSquare, Info, MessageCircle } from 'lucide-react';
-import { AdminTicket } from './TicketTable';
 import LocalTime from '@/components/common/LocalTime';
+import { AdminTicket, TicketMessage } from '@/types';
 
 interface TicketDetailModalProps {
   isOpen: boolean;
@@ -13,14 +13,6 @@ interface TicketDetailModalProps {
   onUpdate?: () => void;
 }
 
-interface TicketMessage {
-  id: number;
-  ticket_id: number;
-  sender_type: 'user' | 'admin' | 'system';
-  content: string;
-  created_at: string;
-}
-
 export default function TicketDetailModal({ isOpen, onClose, ticket, onUpdate }: TicketDetailModalProps) {
   const [messages, setMessages] = useState<TicketMessage[]>([]);
   const [reply, setReply] = useState('');

+ 1 - 13
src/components/admin/tickets/TicketTable.tsx

@@ -3,19 +3,7 @@
 import { Eye, Clock, CheckCircle, XCircle, AlertCircle, HelpCircle, User, FileText } from 'lucide-react';
 // 1. 引入 LocalTime 组件
 import LocalTime from '@/components/common/LocalTime';
-
-// 定义工单数据结构 (对应 API: VasTicketOut)
-export interface AdminTicket {
-  id: number;
-  order_id: string;
-  user_id: string;
-  type: string;     // refund, dispute, change_request
-  status: string;   // pending, info_required, resolved, rejected
-  reason: string;
-  admin_comment?: string;
-  created_at: string;
-  updated_at: string;
-}
+import { AdminTicket } from '@/types';
 
 interface TicketTableProps {
   tickets: AdminTicket[];

+ 1 - 1
src/components/admin/users/UserModal.tsx

@@ -2,7 +2,7 @@
 
 import { useState, useEffect } from 'react';
 import { Loader2, X, Save, UserCog } from 'lucide-react';
-import { AdminUser } from './UserTable';
+import { AdminUser } from '@/types';
 
 interface UserModalProps {
   isOpen: boolean;

+ 1 - 12
src/components/admin/users/UserTable.tsx

@@ -1,18 +1,7 @@
 'use client';
 
 import { Edit, Shield, CheckCircle, XCircle, User, Mail, Phone, Clock } from 'lucide-react';
-
-// 定义用户类型 (参考 VasUserOut)
-export interface AdminUser {
-  id: string;
-  email: string;
-  phone?: string;
-  nickname?: string;
-  role?: string; // 'admin' | 'user'
-  email_verified?: number | boolean; 
-  created_at: string;
-  avatar_url?: string;
-}
+import { AdminUser } from '@/types';
 
 interface UserTableProps {
   users: AdminUser[];

+ 1 - 17
src/components/dashboard/OrderList.tsx

@@ -7,23 +7,7 @@ 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';
-
-export interface Order {
-  id: string;
-  created_at: string; 
-  status: string;
-  base_amount: number;
-  base_currency: string;
-  // 新增调价相关字段
-  final_amount?: number; 
-  adjustment_delta?: number;
-  
-  amount?: number; // 兼容字段
-  currency?: string;
-  product_title?: string;
-  product_name?: string;
-  user_inputs?: Record<string, any>;
-}
+import { Order } from '@/types';
 
 interface OrderListProps {
   onRequestTicket: (orderId: string) => void;

+ 1 - 11
src/components/dashboard/TicketList.tsx

@@ -4,25 +4,15 @@ import { useEffect, useState } from 'react';
 import api from '@/lib/api';
 import { Loader2, MessageSquare, AlertCircle, Clock, CheckCircle, XCircle, ArrowRight, Eye, Search, FileText } from 'lucide-react';
 import Pagination from '@/components/common/Pagination'; 
-import { UserTicket } from './UserTicketDetailModal';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
+import { UserTicket, TicketData } from '@/types';
 
 interface TicketListProps {
   onViewDetail: (ticket: UserTicket) => void;
   refreshTrigger?: number;
 }
 
-interface TicketData extends UserTicket {
-  id: number;
-  order_id: string;
-  type: 'refund' | 'dispute' | 'change_request';
-  reason: string;
-  status: 'pending' | 'info_required' | 'resolved' | 'rejected';
-  admin_comment?: string;
-  created_at: string;
-}
-
 export default function TicketList({ onViewDetail, refreshTrigger }: TicketListProps) {
   const { t } = useLanguage();
 

+ 1 - 11
src/components/dashboard/UserOrderDetailModal.tsx

@@ -5,17 +5,7 @@ import { X, CreditCard, FileText, Package, Check, Clock, Loader2 } from 'lucide-
 import api from '@/lib/api';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
-
-export interface UserOrder {
-  id: string;
-  created_at: string;
-  status: string;
-  base_amount: number;
-  base_currency: string;
-  product_title?: string;
-  product_name?: string;
-  user_inputs?: Record<string, any>;
-}
+import { UserOrder } from '@/types';
 
 interface UserOrderDetailModalProps {
   isOpen: boolean;

+ 3 - 20
src/components/dashboard/UserTicketDetailModal.tsx

@@ -7,24 +7,7 @@ import { useLanguage } from '@/lib/i18n/LanguageContext';
 import LocalTime from '@/components/common/LocalTime';
 // 1. 引入消息弹窗
 import MessageModal from '@/components/common/MessageModal';
-
-export interface UserTicket {
-  id: number;
-  order_id: string;
-  type: string;
-  status: string;
-  reason: string;
-  admin_comment?: string;
-  created_at: string;
-}
-
-interface Message {
-  id: number;
-  ticket_id: number;
-  sender_type: 'user' | 'admin' | 'system';
-  content: string;
-  created_at: string;
-}
+import { UserTicket, TicketMessage } from '@/types';
 
 interface UserTicketDetailModalProps {
   isOpen: boolean;
@@ -35,7 +18,7 @@ interface UserTicketDetailModalProps {
 export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserTicketDetailModalProps) {
   const { t } = useLanguage();
 
-  const [messages, setMessages] = useState<Message[]>([]);
+  const [messages, setMessages] = useState<TicketMessage[]>([]);
   const [loadingMsg, setLoadingMsg] = useState(false);
   const [replyContent, setReplyContent] = useState('');
   const [sending, setSending] = useState(false);
@@ -86,7 +69,7 @@ export default function UserTicketDetailModal({ isOpen, onClose, ticket }: UserT
       });
       
       const items = res.data.data?.items || [];
-      const sorted = items.sort((a: Message, b: Message) => 
+      const sorted = items.sort((a: TicketMessage, b: TicketMessage) => 
         new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
       );
       setMessages(sorted);

+ 1 - 17
src/components/slots/CitySlotCard.tsx

@@ -4,23 +4,7 @@ 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';
-
-export interface SlotSnapshot {
-  id: number;
-  country: string;
-  city: string;
-  visa_type: string;
-  availability_status: 'None' | 'Available' | 'Waitlist';
-  earliest_date: string | null;
-  snapshot_at: string;
-  website?: string;
-  last_check_at?: string | null;
-  routing_key?: string;
-  slot_snapshot?: {
-    routing_key?: string;
-    [key: string]: any;
-  };
-}
+import { SlotSnapshot } from '@/types';
 
 export default function CitySlotCard({ data, isBlacklisted = false }: { data: SlotSnapshot; isBlacklisted?: boolean }) {
   const { t, lang } = useLanguage();

+ 3 - 9
src/lib/auth.ts

@@ -1,12 +1,6 @@
-// 定义用户接口 (参考 OpenAPI VasUserOut)
-export interface User {
-    id: string;
-    email: string;
-    phone?: string; 
-    nickname?: string;
-    role?: string; // 关键字段: 'admin' | 'user'
-    avatar_url?: string;
-  }
+import { User } from '@/types';
+
+export type { User };
   
   // 获取当前用户
   export const getCurrentUser = (): User | null => {

+ 18 - 0
src/types/account.ts

@@ -0,0 +1,18 @@
+// src/types/account.ts
+
+/**
+ * 账号池账号模型
+ */
+export interface Account {
+  id: number;
+  pool_name: string;
+  username: string;
+  password?: string;
+  extra_data?: Record<string, any> | null;
+  status?: string | null;
+  next_use_time?: string | null;
+  created_at?: string;
+  updated_at?: string;
+}
+
+export type AccountStatus = 'active' | 'disable' | string;

+ 14 - 0
src/types/config.ts

@@ -0,0 +1,14 @@
+// src/types/config.ts
+
+/**
+ * 动态系统配置模型
+ */
+export interface DynamicConfiguration {
+  id?: number;
+  config_key: string;
+  config_value: string;
+  description: string;
+  type: string;
+  created_at?: string;
+  updated_at?: string;
+}

+ 13 - 0
src/types/index.ts

@@ -0,0 +1,13 @@
+// src/types/index.ts
+
+export * from './product';
+export * from './order';
+export * from './user';
+export * from './ticket';
+export * from './task';
+export * from './account';
+export * from './proxy';
+export * from './payment';
+export * from './config';
+export * from './slot';
+export * from './card';

+ 101 - 0
src/types/order.ts

@@ -0,0 +1,101 @@
+// src/types/order.ts
+
+/**
+ * 订单关联的支付流水记录
+ */
+export interface PaymentRecord {
+  id: number;
+  provider: string;
+  channel: string;
+  amount: number;
+  currency: string;
+  status: string;
+  created_at: string;
+  external_trade_no?: string;
+  description?: string;
+  qr_id?: number;
+  payment_intent_id?: string;
+}
+
+/**
+ * 订单关联的支付二维码详情
+ */
+export interface PaymentQrDetail {
+  id: number;
+  description?: string;
+}
+
+/**
+ * 订单关联的用户详情
+ */
+export interface OrderUserDetail {
+  id: string;
+  email: string;
+  phone?: string;
+  nickname?: string;
+  avatar_url?: string;
+  role?: string;
+  created_at?: string;
+}
+
+export type UserDetail = OrderUserDetail;
+
+/**
+ * 订单生命周期事件日志
+ */
+export interface OrderEvent {
+  id: number;
+  order_no?: string;
+  event_title?: string;
+  event_message?: string;
+  email_uid?: number | null;
+  event_time?: string;
+  created_at?: string;
+}
+
+/**
+ * 基础订单模型 (面向前台用户及通用展示)
+ */
+export interface Order {
+  id: string;
+  user_id?: string;
+  created_at: string;
+  status: string;
+  base_amount: number;
+  base_currency: string;
+  final_amount?: number;
+  adjustment_delta?: number;
+  amount?: number; // 兼容字段
+  currency?: string;
+  product_title?: string;
+  product_name?: string;
+  user_inputs?: Record<string, any>;
+  applicant_name?: string;
+}
+
+/**
+ * 用户端订单(兼容别名)
+ */
+export type UserOrder = Order;
+
+/**
+ * 管理后台订单详情模型
+ */
+export interface OrderDetail extends Order {
+  user?: {
+    email: string;
+    nickname?: string;
+    phone?: string;
+  };
+  user_email?: string;
+  user_name?: string;
+  payments?: PaymentRecord[];
+}
+
+/**
+ * 管理后台扩展订单信息(带调价信息)
+ */
+export interface ExtendedOrderDetail extends OrderDetail {
+  final_amount?: number;
+  adjustment_delta?: number;
+}

+ 91 - 6
src/types/payment.ts

@@ -7,7 +7,6 @@ export type PaymentStatus = 'pending' | 'approved' | 'rejected' | 'expired' | 'c
 
 /**
  * 支付确认记录 (PaymentConfirmation)
- * 对应数据库中的 payment_confirmations 表
  */
 export interface PaymentConfirmation {
   id: string;              // 唯一标识 ID
@@ -23,17 +22,14 @@ export interface PaymentConfirmation {
   created_at: string;      // 创建/提交时间 (ISO 8601 字符串)
   confirmed_at: string;    // 用户点击"我已支付"的时间 / 确认时间 (ISO 8601 字符串)
   
-  // 以下字段组件中虽未直接显示,但在 "详情 (onViewDetail)" 中可能需要
-  proof_url?: string;      // 支付凭证图片链接 (如果有)
-  transaction_id?: string; // 链上交易哈希或第三方流水号 (如果有)
+  proof_url?: string;      // 支付凭证图片链接
+  transaction_id?: string; // 链上交易哈希或第三方流水号
   remarks?: string;        // 用户或系统备注
   updated_at?: string;     // 更新时间
 }
 
 /**
  * 支付主单 (Payment)
- * 对应数据库中的 payments 表
- * (为了完整性补充在此,ConfirmationTable 主要用的是上面的 Interface)
  */
 export interface Payment {
   id: string;
@@ -47,4 +43,93 @@ export interface Payment {
   expires_at: string;      // 过期时间
   created_at: string;
   updated_at: string;
+}
+
+/**
+ * 支付提供商渠道信息 (前端展示与交互)
+ */
+export interface PaymentProvider {
+  id: number | string;
+  name: string;
+  currency?: string;
+  icon?: string;
+  title?: string;
+  description?: string;
+  enabled?: boolean;
+}
+
+/**
+ * 后台支付渠道配置 (Provider / PaymentProviderConfig)
+ */
+export interface Provider {
+  id: number;
+  name: string;
+  title: string;
+  icon: string;
+  channel: string;
+  currency: string;
+  enabled: number | boolean;
+}
+
+export type PaymentProviderConfig = Provider;
+
+/**
+ * 支付发起返回结果
+ */
+export interface PaymentResult {
+  id?: number | string;
+  payment_id?: string;
+  status?: string;
+  channel?: 'online_link' | 'qr_static' | string;
+  provider?: string;
+  qr_id?: number;
+  qr_code?: string;
+  payment_url?: string;
+  pay_url?: string;
+  expire_at?: string;
+  expires_at?: string;
+  
+  // 金额与汇率相关
+  base_amount?: number;
+  base_currency?: string;
+  amount: number;
+  currency: string;
+  random_offset?: number;
+  exchange_rate?: number;
+  adjustment_delta?: number;
+  
+  [key: string]: any;
+}
+
+/**
+ * 二维码管理项 (PaymentQr)
+ */
+export interface PaymentQr {
+  id: number;
+  qr_code: string;
+  priority?: number;
+  is_active: boolean | number;
+  description?: string;
+  device?: string;
+  provider?: string;
+  amount?: number;
+  currency?: string;
+  qr_url?: string;
+  status?: 'active' | 'inactive' | 'busy' | string;
+  usage_count?: number;
+  created_at?: string;
+  updated_at?: string;
+}
+
+/**
+ * 汇率配置 (RateConfig)
+ */
+export interface RateConfig {
+  base?: string;
+  precision?: number;
+  rates?: Record<string, number>;
+  source_currency?: string;
+  target_currency?: string;
+  rate?: number;
+  updated_at?: string;
 }

+ 96 - 0
src/types/product.ts

@@ -0,0 +1,96 @@
+// src/types/product.ts
+
+/**
+ * 动态表单 JSON Schema 属性定义
+ */
+export interface SchemaProperty {
+  type: string;
+  title?: string;
+  description?: string;
+  default?: any;
+  enum?: (string | number)[];
+  items?: {
+    type: string;
+    enum?: (string | number)[];
+  };
+  properties?: Record<string, SchemaProperty>;
+  required?: string[];
+  format?: string;
+  placeholder?: string;
+  minimum?: number;
+  maximum?: number;
+  order?: number;
+  'x-order'?: number;
+  [key: string]: any;
+}
+
+/**
+ * 动态表单 JSON Schema 整体结构
+ */
+export interface JsonSchema {
+  type?: string;
+  title?: string;
+  description?: string;
+  properties: Record<string, SchemaProperty>;
+  required?: string[];
+  'ui:order'?: string[];
+  [key: string]: any;
+}
+
+/**
+ * 动态表单模板 (SchemaItem)
+ */
+export interface SchemaItem {
+  id: number;
+  name: string;
+  description?: string;
+  content?: string; // JSON schema 字符串
+  schema_json?: string; // 别名兼容
+  created_at?: string;
+  updated_at?: string;
+}
+
+/**
+ * 商品路由规则 (One Product -> Many Routings)
+ */
+export interface ProductRouting {
+  id: number;
+  product_id?: number;
+  routing_key: string;    // e.g. "fr_tls_london_bot" (队列名/标识符)
+  script_version: string; // e.g. "v2.1" (脚本版本)
+  priority: number;       // e.g. 10 (优先级)
+  config?: any;           // JSON string or object
+  meta?: any;             // JSON string or object
+  enabled?: boolean;
+  created_at?: string;
+  updated_at?: string;
+}
+
+/**
+ * 商品主数据模型
+ */
+export interface Product {
+  id: number;
+  title: string;
+  description?: string;
+  country: string;
+  city: string;
+  price_amount: number;
+  price_currency: string;
+  provider: string;       // e.g. 'TROOV', 'TLS', 'VFS'
+  visa_type: string;
+  schema_id?: number | null;
+  schema_content?: string | null;
+  enabled: boolean | number; // 1 or 0 or boolean
+  recommend_score?: number;
+  created_at?: string;
+  updated_at?: string;
+  routings?: ProductRouting[];
+}
+
+/**
+ * 带有表单 Schema 详情的商品数据(用于下单页面)
+ */
+export interface ProductDetail extends Product {
+  schema_content?: string | null;
+}

+ 0 - 27
src/types/products.ts

@@ -1,27 +0,0 @@
-// 商品基本信息
-export interface Product {
-    id: number;
-    title: string;
-    description: string;
-    country: string;
-    city: string;
-    price_amount: number;
-    price_currency: string;
-    provider: string; // e.g., 'TROOV'
-    visa_type: string;
-    schema_id: number;
-    enabled: number; // 1 or 0
-    // ... 其他字段
-  }
-  
-// 商品路由信息 (One Product -> Many Routings)
-export interface ProductRouting {
-  id: number;
-  product_id: number;
-  routing_key: string;    // e.g., "fr_tls_london_bot" (队列名/标识符)
-  script_version: string; // e.g., "v2.1" (脚本版本)
-  priority: number;       // e.g., 10 (优先级)
-  meta?: string;          // JSON string, 额外配置
-  enabled: boolean;
-}
-

+ 20 - 0
src/types/proxy.ts

@@ -0,0 +1,20 @@
+// src/types/proxy.ts
+
+/**
+ * 代理节点模型 (ProxyItem)
+ */
+export interface ProxyItem {
+  id: number;
+  pool_name: string;
+  proto: string;
+  ip: string;
+  port: number;
+  username?: string | null;
+  password?: string | null;
+  next_use_time?: string | null;
+  status?: string | null;
+  created_at?: string;
+  updated_at?: string;
+}
+
+export type ProxyStatus = 'active' | 'disable' | string;

+ 21 - 0
src/types/slot.ts

@@ -0,0 +1,21 @@
+// src/types/slot.ts
+
+/**
+ * 签证预约槽位实时快照数据模型
+ */
+export interface SlotSnapshot {
+  id: number;
+  country: string;
+  city: string;
+  visa_type: string;
+  availability_status: 'None' | 'Available' | 'Waitlist';
+  earliest_date: string | null;
+  snapshot_at: string;
+  website?: string;
+  last_check_at?: string | null;
+  routing_key?: string;
+  slot_snapshot?: {
+    routing_key?: string;
+    [key: string]: any;
+  };
+}

+ 27 - 0
src/types/task.ts

@@ -0,0 +1,27 @@
+// src/types/task.ts
+
+/**
+ * 系统任务基础数据模型 (VasTask)
+ */
+export interface VasTask {
+  id: number;
+  order_id: string;
+  routing_key: string;
+  status: string;
+  priority: number;
+  script_version?: string;
+  attempt_count: number;
+  notify_count: number;
+  config?: any;
+  user_inputs?: any;
+  grabbed_history?: any; 
+  meta?: any;
+  created_at: string;
+  updated_at: string;
+  expire_at: string;
+}
+
+/**
+ * 任务类型通用别名
+ */
+export type Task = VasTask;

+ 50 - 0
src/types/ticket.ts

@@ -0,0 +1,50 @@
+// src/types/ticket.ts
+
+/**
+ * 工单消息结构
+ */
+export interface TicketMessage {
+  id: number;
+  ticket_id: number;
+  sender_type: 'user' | 'admin' | 'system';
+  content: string;
+  created_at: string;
+}
+
+/**
+ * 基础工单模型
+ */
+export interface Ticket {
+  id: number;
+  order_id: string;
+  user_id?: string;
+  type: string;     // refund, dispute, change_request 等
+  status: string;   // pending, info_required, resolved, rejected 等
+  reason: string;
+  admin_comment?: string;
+  created_at: string;
+  updated_at?: string;
+}
+
+/**
+ * 用户端工单类型
+ */
+export type UserTicket = Ticket;
+
+/**
+ * 管理端工单类型 (VasTicketOut)
+ */
+export type AdminTicket = Ticket;
+
+/**
+ * 用户端带有附加状态的工单数据模型
+ */
+export interface TicketData extends UserTicket {
+  unread_count?: number;
+}
+
+/**
+ * 工单处理操作类型
+ */
+export type TicketActionType = 'approve' | 'reject' | 'need-info';
+export type ActionType = TicketActionType;

+ 28 - 0
src/types/user.ts

@@ -0,0 +1,28 @@
+// src/types/user.ts
+
+/**
+ * 基础用户模型
+ */
+export interface User {
+  id: string;
+  email: string;
+  phone?: string;
+  nickname?: string;
+  role?: string; // 'admin' | 'user'
+  avatar_url?: string;
+  email_verified?: number | boolean;
+  created_at?: string;
+  updated_at?: string;
+}
+
+/**
+ * 管理端用户列表/详情模型(别名/扩展)
+ */
+export type AdminUser = User;
+
+/**
+ * 用户详情简要信息
+ */
+export interface UserProfile extends User {
+  status?: string;
+}