## Home 模块三栏 VCHSM 重组
- 按渲染归属重新分配文件:ModelSelector/TaskHistory → left/,ModelInputForm/widgets → center/,OutputPreview → right/
- BannerCarousel 移至 shared/views/(全局组件)
- controls/ → widgets/ 重命名,消除与 controllers/ 的命名歧义
- 新增 barrel 文件(left/center/right/shared 各级 index.ts)
## Services 层迁回 src/services/modules/
- 全部 API 类型定义与请求函数从 modules/*/controllers/ 迁回 services/modules/{domain}/
- 恢复原始文件名(model-api.ts → models.ts,task-api.ts → task.ts 等)
- 新增 domain 子文件夹(home/auth/announcement/account)
- 更新全局 ~70 处导入路径
## TaskHistory 提取 Controller + Hook 层
- 新建 left/controllers/task-table-config.ts(常量 + 纯工具函数,零 React 依赖)
- 新建 left/hooks/useTaskTable.tsx(状态管理 + 数据获取 + 列定义 + 滚动同步)
- TaskHistory.tsx 从 915 行精简为 265 行纯视图
## 右键菜单体系完善
- 共享 <ContextMenu> 组件(antd Dropdown 封装,防 Select 冲突)
- 四组菜单定义:任务列表 / 文本输入 / 媒体参考 / 预览区域
- 统一的 ContextMenuItems → AntD MenuProps 转换
## 公告功能修复
- useAnnouncements 增加 isLoggedIn 登录门控,避免未登录时 401 双重请求
- 抽屉打开时触发 refetch(),确保拿到最新数据
Co-Authored-By: Claude <noreply@anthropic.com>
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
import { get, post } from '@/services/request';
|
||
|
||
export const PAYMENT_METHODS = {
|
||
Alipay: 'alipay',
|
||
WeChat: 'wechat',
|
||
Mock: "mock"
|
||
} as const;
|
||
|
||
export type PaymentMethod = typeof PAYMENT_METHODS[keyof typeof PAYMENT_METHODS];
|
||
|
||
export type AvailablePaymentMethod = typeof PAYMENT_METHODS.Alipay;
|
||
|
||
export interface CreateOrderRequestBody {
|
||
amount_cent: number,
|
||
payment_channel: AvailablePaymentMethod
|
||
}
|
||
|
||
export const PAYMENT_STATUS = {
|
||
Pending: 'pending', // 待支付
|
||
Paid: 'paid', // 已支付
|
||
Expired: 'expired', // 已过期
|
||
Failed: 'failed', // 支付失败
|
||
} as const;
|
||
|
||
export type PaymentStatus = typeof PAYMENT_STATUS[keyof typeof PAYMENT_STATUS];
|
||
// 中文映射表
|
||
export const PAYMENT_STATUS_TEXT_MAP: Record<PaymentStatus, string> = {
|
||
[PAYMENT_STATUS.Pending]: '待支付',
|
||
[PAYMENT_STATUS.Paid]: '已支付',
|
||
[PAYMENT_STATUS.Expired]: '已过期',
|
||
[PAYMENT_STATUS.Failed]: '支付失败',
|
||
};
|
||
|
||
// 辅助函数:根据状态获取中文
|
||
export function getPaymentStatusText(status: PaymentStatus): string {
|
||
return PAYMENT_STATUS_TEXT_MAP[status];
|
||
}
|
||
|
||
export interface CreateOrderResponseBody {
|
||
id: string,
|
||
user_id: string,
|
||
amount_cent: number,
|
||
status: PaymentStatus,
|
||
payment_channel: AvailablePaymentMethod,
|
||
out_trade_no: string,
|
||
transaction_id: string,
|
||
pay_url: string,
|
||
expires_at: Date,
|
||
paid_at: Date,
|
||
created_at: Date,
|
||
}
|
||
|
||
export interface OrderListRequestParam {
|
||
status?: PaymentStatus,
|
||
page: number,
|
||
page_size: number,
|
||
}
|
||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||
export interface OrderListResponseBody extends CreateOrderResponseBody {
|
||
|
||
}
|
||
|
||
export interface OrderInfoRequestParam {
|
||
order_id: string,
|
||
}
|
||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||
export interface OrderInfoResponseBody extends CreateOrderResponseBody {
|
||
|
||
}
|
||
|
||
const PaymentUrlObj = {
|
||
createOrder: "/api/v1/payments/orders",
|
||
getOrderList: "/api/v1/payments/orders",
|
||
getOrderInfo: "/api/v1/payments/orders/{order_id}",
|
||
};
|
||
|
||
// ============================================================
|
||
// 调用方式:PaymentAPI.createOrder() / PaymentAPI.getOrdersListInfo() 等
|
||
// ============================================================
|
||
|
||
export class PaymentAPI {
|
||
/** 创建支付订单 */
|
||
static async createOrder(body: CreateOrderRequestBody): Promise<CreateOrderResponseBody> {
|
||
return await post<CreateOrderResponseBody>(PaymentUrlObj.createOrder, body);
|
||
}
|
||
|
||
/** 获取订单列表(支持按状态筛选 + 分页) */
|
||
static async getOrdersListInfo(param: OrderListRequestParam, signal?: AbortSignal): Promise<OrderListResponseBody[]> {
|
||
return await get<OrderListResponseBody[]>(PaymentUrlObj.getOrderList, param as unknown as Record<string, unknown>, { signal });
|
||
}
|
||
|
||
/** 获取单个订单详情 */
|
||
static async getOrderInfo(param: OrderInfoRequestParam): Promise<OrderInfoResponseBody> {
|
||
const url = PaymentUrlObj.getOrderInfo.replace('{order_id}', param.order_id);
|
||
return await get<OrderInfoResponseBody>(url);
|
||
}
|
||
}
|