API版本化:迁移设置卡券与通知入口
This commit is contained in:
1 parent
78a256c51e
commit
42e37f7898
9 files changed
+269
-37
No files matched your search
@@ -12,9 +12,9 @@
|
||||
| 商品批量 | `/items/publish-batches...` | `/api/v1/items/publish-batches...` | 旧路径保留,类目推荐/预检/任务 DTO 已落地 |
|
||||
| 自动化 | `/automation-rules...` | `/api/v1/automation-rules...` | 旧路径保留,规则分页/异常 DTO 已落地 |
|
||||
| 订单 | `/api/orders...` | `/api/v1/orders...` | React 列表、详情、更新、刷新、单订单刷新、手动发货和导入调用已迁移;旧路径保留并由同一 handler 提供 |
|
||||
| 设置 | `/system-settings...`、`/user-settings...`、`/ai-reply-settings...` | `/api/v1/settings/...` | 旧路径保留,变更/查询 DTO 已落地;`settingsResponse` 明确动态字符串键值边界,动态键仍由边界适配 |
|
||||
| 卡券 | `/cards...` | `/api/v1/cards...` | 旧路径保留,CRUD/批量 DTO 已落地 |
|
||||
| 通知 | `/notification-channels...`、`/message-notifications...` | `/api/v1/notifications/...` | 旧路径保留,渠道/绑定/变更 DTO 已落地 |
|
||||
| 设置 | `/system-settings...`、`/user-settings...`、`/ai-reply-settings...`、`/ai-models` | `/api/v1/settings/system...`、`/api/v1/settings/user...`、`/api/v1/settings/ai-reply...`、`/api/v1/settings/ai-models` | React 系统设置、AI 设置调用已迁移;版本化入口覆盖公开设置、管理员设置、用户设置和 AI 模型查询;旧路径保留 |
|
||||
| 卡券 | `/cards...` | `/api/v1/cards...` | React 卡券列表、CRUD、批量创建和追加调用已迁移;旧路径保留并由同一 handler 提供 |
|
||||
| 通知 | `/notification-channels...`、`/message-notifications...` | `/api/v1/notifications/channels...`、`/api/v1/notifications/messages...`、`/api/v1/notifications/accounts/{cid}/bindings` | React 通知渠道、消息绑定和账号绑定调用已迁移;旧路径保留并由同一 handler 提供 |
|
||||
| 聊天 | `/api/chat...` | `/api/v1/chat...` | 旧路径保留,会话/消息 DTO 已落地 |
|
||||
| 关键词回复 | `/keywords...`、`/keywords-with-item-id...`、`/keywords-with-type...`、`/item-reply...` | `/api/v1/reply-rules...` | 旧路径保留,基础/商品/类型规则与指定商品回复 DTO 已落地 |
|
||||
| 默认回复 | `/default-replies...`、`/api/default-reply...` | `/api/v1/default-replies...` | 旧路径保留,单账号、列表和映射 DTO 已落地 |
|
||||
@@ -49,6 +49,7 @@
|
||||
- 订单刷新、单订单刷新、手动发货和导入已由 React 请求层迁移到 `/api/v1/orders...`;Go 契约测试确认新旧批量入口保持状态码、具名响应和参数校验语义一致。
|
||||
- 商品列表、详情、发布、更新和删除已由 React 请求层迁移到 `/api/v1/items...`;Go 契约测试确认新旧入口保持商品所有权校验、具名响应和持久化语义一致。
|
||||
- 商品同步、类目推荐、批量发布预检、任务查询、取消、重试和结果下载已由版本化路由提供;React 现有同步/批量发布调用已迁移,Go 契约测试确认新旧入口状态码和参数校验语义一致。
|
||||
- 系统/用户/AI 设置、卡券 CRUD/批量/追加和通知渠道/消息/账号绑定已由版本化路由提供;React 设置、卡券和通知调用已迁移,Go 契约测试确认新旧入口权限、状态码和参数校验语义一致。
|
||||
- 聊天会话、消息分页和发送结果使用独立 DTO,不直接暴露数据库模型。
|
||||
- React `frontend/types.ts` 与 `frontend/services/api.ts` 已同步具名成功响应类型,同时保留旧字段归一逻辑。
|
||||
- 会话版本化入口已可用;除会话外的 `/api/v1` 领域入口仍未宣称可用,旧路径继续保留。
|
||||
- 会话、账号、订单、商品、设置、卡券和通知版本化入口已可用;聊天、关键词、默认回复、账号任务、管理员与统计等领域仍未宣称可用,旧路径继续保留。
|
||||
@@ -146,7 +146,8 @@ app shell / routes
|
||||
- 已完成阶段 3 第十七个 PR 切片“订单刷新与批量操作 API 版本化兼容入口迁移”:新增订单刷新、单订单刷新、手动发货和导入 `/api/v1/orders...` 薄适配入口,复用既有订单 handler;React 对应调用已迁移,旧路径保留;新增刷新/批量契约测试并保持独立可回滚提交;
|
||||
- 已完成阶段 3 第十八个 PR 切片“商品 API 版本化兼容入口与调用方迁移”:新增商品列表、详情、发布、更新和删除 `/api/v1/items...` 薄适配入口,复用既有商品所有权校验与 handler;React 对应调用已迁移,旧路径保留;新增商品契约测试并保持独立可回滚提交;
|
||||
- 已完成阶段 3 第十九个 PR 切片“商品同步与批量发布 API 版本化兼容入口迁移”:新增商品同步、类目推荐、批量发布预检、任务、详情、取消、重试和结果下载 `/api/v1/items...` 薄适配入口,复用既有商品 handler;React 对应同步/批量发布调用已迁移,旧路径保留;新增商品批量契约测试并保持独立可回滚提交;
|
||||
- 阶段 3 下一 PR 切片为“设置、卡券与通知 API 版本化兼容入口迁移”:迁移系统/用户设置、AI 设置、卡券和通知渠道/绑定调用方,继续保留旧路径,不拆分单个 handler 提交;
|
||||
- 已完成阶段 3 第二十个 PR 切片“设置、卡券与通知 API 版本化兼容入口迁移”:新增系统/用户/AI 设置、卡券和通知渠道/消息/账号绑定 `/api/v1/settings`、`/api/v1/cards`、`/api/v1/notifications` 薄适配入口,复用既有权限边界与 handler;React 系统设置、AI 设置、卡券和通知调用已迁移,旧路径保留;新增三领域契约测试并保持独立可回滚提交;
|
||||
- 阶段 3 下一 PR 切片为“聊天与账号任务 API 版本化兼容入口迁移”:迁移聊天会话/消息和账号任务设置/执行调用方,继续保留旧路径,不拆分单个 handler 提交;
|
||||
- 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。
|
||||
|
||||
## 6. 阶段 0:治理文档与强约束
|
||||
@@ -542,3 +543,4 @@ npm --prefix frontend run build
|
||||
| 2026-08-14 | 完成阶段 3 第十七个 PR 切片“订单刷新与批量操作 API 版本化兼容入口迁移” | 新增订单刷新、单订单刷新、手动发货和导入 `/api/v1/orders...` 薄适配入口,复用既有订单 handler;React 刷新、单订单刷新、手动发货和导入调用已迁移;Go/React 契约测试确认新旧入口兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:商品 API 版本化兼容入口与调用方迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第十八个 PR 切片“商品 API 版本化兼容入口与调用方迁移” | 新增商品列表、详情、发布、更新和删除 `/api/v1/items...` 薄适配入口,复用既有商品 handler 与所有权校验;React 列表、详情、发布、更新和删除调用已迁移;Go/React 契约测试确认新旧入口兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:商品同步与批量发布 API 版本化兼容入口迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第十九个 PR 切片“商品同步与批量发布 API 版本化兼容入口迁移” | 新增商品同步、类目推荐、批量发布预检/任务/详情、取消、重试和结果下载 `/api/v1/items...` 薄适配入口,复用既有商品 handler;React 同步和批量发布调用已迁移;Go/React 契约测试确认新旧入口兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:设置、卡券与通知 API 版本化兼容入口迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第二十个 PR 切片“设置、卡券与通知 API 版本化兼容入口迁移” | 新增系统/用户/AI 设置、卡券和通知渠道/消息/账号绑定 `/api/v1/settings`、`/api/v1/cards`、`/api/v1/notifications` 薄适配入口,复用既有权限边界与 handler;React 设置、卡券和通知调用已迁移;Go/React 契约测试确认新旧入口兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:聊天与账号任务 API 版本化兼容入口迁移 |
|
||||
@@ -5,18 +5,18 @@ import {
|
||||
deleteItemPublishBatch, deleteItem, cancelItemPublishBatch, retryFailedItemPublishBatch,
|
||||
checkPasswordLoginStatus,
|
||||
completeQRVerification,
|
||||
createNotificationChannel,
|
||||
createNotificationChannel, getAllAISettings, getAccountAISettings, updateAccountAISettings, fetchAIModels,
|
||||
getAccountDetails, getAccountRuntimeStatuses, updateAccountStatus,
|
||||
getAutomationIssues,
|
||||
getItems, getItemDetail, syncItemsFromAccount,
|
||||
getItemPublishBatches, getItemPublishBatch, startItemPublishBatch,
|
||||
getNotificationChannels,
|
||||
getNotificationChannels, getMessageNotifications, getAccountBindings,
|
||||
getOrders, getOrderDetail, updateOrder,
|
||||
getOrderAnalytics,
|
||||
getReplyRules,
|
||||
getShippingRules,
|
||||
getShippingRulesPage,
|
||||
getSystemSettings,
|
||||
getSystemSettings, getCards, createCard, updateCard, deleteCard, getCardDetails, batchCreateCards, appendCardData,
|
||||
getValidOrders,
|
||||
publishItem, recommendPublishCategory, previewItemPublishBatch,
|
||||
logout,
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
updateAccountLoginInfo,
|
||||
updateAccountSettings, updateAccountRemark, updateAccountAutoConfirm, updateAccountPauseDuration, getLongLoginSettings, setLongLoginSettings, refreshAccountProfile,
|
||||
updateItem,
|
||||
updateNotificationChannel,
|
||||
updateNotificationChannel, deleteNotificationChannel, setMessageNotification, deleteMessageNotification, deleteAccountNotifications, setAccountBindings, testNotificationChannel,
|
||||
updateSystemSettings,
|
||||
updateShippingRule,
|
||||
getChatSessions,
|
||||
@@ -52,7 +52,7 @@ test('updateSystemSettings uses one atomic bulk request', async () => {
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
await updateSystemSettings({ theme_color: 'blue', renewal_log_retention_days: 15 });
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(fetchMock).toHaveBeenCalledWith('/system-settings', expect.objectContaining({ method: 'PUT', credentials: 'include' }));
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/v1/settings/system', expect.objectContaining({ method: 'PUT', credentials: 'include' }));
|
||||
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ theme_color: 'blue', renewal_log_retention_days: 15 });
|
||||
});
|
||||
|
||||
@@ -590,7 +590,7 @@ test('updateNotificationChannel supports partial enabled updates', async () => {
|
||||
|
||||
await updateNotificationChannel('7', { enabled: false });
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith('/notification-channels/7', expect.objectContaining({
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/v1/notifications/channels/7', expect.objectContaining({
|
||||
method: 'PUT',
|
||||
credentials: 'include',
|
||||
}));
|
||||
@@ -922,3 +922,86 @@ const runVersionedItemBatchAPITest = async () => {
|
||||
};
|
||||
|
||||
test('item sync and batch publish APIs use versioned compatibility routes', runVersionedItemBatchAPITest);
|
||||
|
||||
// 设置、卡券和通知 API 使用版本化兼容入口。
|
||||
const runVersionedSettingsCardNotificationAPITest = async () => {
|
||||
// fetchMock 是设置、卡券和通知请求的测试替身。
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(jsonResponse({ data: {} }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({}))
|
||||
.mockResolvedValueOnce(jsonResponse({ ai_enabled: false }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ models: ['qwen-plus'] }))
|
||||
.mockResolvedValueOnce(jsonResponse([]))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, id: 1 }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ id: 1, name: '卡券', type: 'text', text_content: 'CARD' }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, total: 0, created: 0, failed: 0, rows: [] }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, added: 1 }))
|
||||
.mockResolvedValueOnce(jsonResponse([]))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, id: 1 }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({}))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ channel_ids: [] }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
await getSystemSettings();
|
||||
await updateSystemSettings({ theme_color: 'blue' });
|
||||
await getAllAISettings();
|
||||
await getAccountAISettings('acc1');
|
||||
await updateAccountAISettings('acc1', { ai_enabled: true });
|
||||
await fetchAIModels('https://ai.example.com');
|
||||
await getCards();
|
||||
await createCard({ name: '卡券', type: 'text', text_content: 'CARD' });
|
||||
await updateCard(1, { enabled: false });
|
||||
await deleteCard(1);
|
||||
await getCardDetails(1);
|
||||
await batchCreateCards(new File(['name,type,content\n卡券,text,CARD'], 'cards.csv', { type: 'text/csv' }));
|
||||
await appendCardData(1, 'CARD-2');
|
||||
await getNotificationChannels();
|
||||
await createNotificationChannel({ name: '通知', type: 'bark', config: {} });
|
||||
await updateNotificationChannel('1', { enabled: false });
|
||||
await deleteNotificationChannel('1');
|
||||
await getMessageNotifications();
|
||||
await setMessageNotification('acc1', 1, true);
|
||||
await deleteMessageNotification('1');
|
||||
await deleteAccountNotifications('acc1');
|
||||
await getAccountBindings('acc1');
|
||||
await setAccountBindings('acc1', [1]);
|
||||
await testNotificationChannel('1');
|
||||
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/v1/settings/system', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/v1/settings/system', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(3, '/api/v1/settings/ai-reply', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(4, '/api/v1/settings/ai-reply/acc1', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(5, '/api/v1/settings/ai-reply/acc1', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(6, '/api/v1/settings/ai-models', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(7, '/api/v1/cards', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(8, '/api/v1/cards', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(9, '/api/v1/cards/1', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(10, '/api/v1/cards/1', expect.objectContaining({ method: 'DELETE' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(11, '/api/v1/cards/1/details', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(12, '/api/v1/cards/batch', expect.objectContaining({ method: 'POST', body: expect.any(FormData) }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(13, '/api/v1/cards/1/append-data', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(14, '/api/v1/notifications/channels', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(15, '/api/v1/notifications/channels', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(16, '/api/v1/notifications/channels/1', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(17, '/api/v1/notifications/channels/1', expect.objectContaining({ method: 'DELETE' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(18, '/api/v1/notifications/messages', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(19, '/api/v1/notifications/accounts/acc1/bindings', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(20, '/api/v1/notifications/messages/1', expect.objectContaining({ method: 'DELETE' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(21, '/api/v1/notifications/messages/account/acc1', expect.objectContaining({ method: 'DELETE' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(22, '/api/v1/notifications/accounts/acc1/bindings', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(23, '/api/v1/notifications/accounts/acc1/bindings', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(24, '/api/v1/notifications/channels/1/test', expect.objectContaining({ method: 'POST' }));
|
||||
};
|
||||
|
||||
test('settings, card, and notification APIs use versioned compatibility routes', runVersionedSettingsCardNotificationAPITest);
|
||||
+24
-24
@@ -290,7 +290,7 @@ export const updateAccountLoginInfo = async (id: string, data: {
|
||||
};
|
||||
|
||||
export const getAllAISettings = async (options?: RequestControlOptions): Promise<Record<string, AIReplySettings>> => {
|
||||
return get('/ai-reply-settings', undefined, options);
|
||||
return get('/api/v1/settings/ai-reply', undefined, options);
|
||||
};
|
||||
|
||||
// Orders
|
||||
@@ -449,25 +449,25 @@ const cardPayload = (data: Partial<Card>): Record<string, unknown> => ({
|
||||
});
|
||||
|
||||
export const getCards = async (): Promise<Card[]> => {
|
||||
const res = await get<Card[] | CardListResponse>('/cards');
|
||||
const res = await get<Card[] | CardListResponse>('/api/v1/cards');
|
||||
const cards = Array.isArray(res) ? res : (res.cards || []);
|
||||
return cards.map(normalizeCard);
|
||||
};
|
||||
|
||||
export const createCard = async (data: Partial<Card>): Promise<MutationIDResponse> => {
|
||||
return post('/cards', cardPayload(data));
|
||||
return post('/api/v1/cards', cardPayload(data));
|
||||
};
|
||||
|
||||
export const updateCard = async (cardId: string | number, data: Partial<Card>): Promise<OperationResponse> => {
|
||||
return put(`/cards/${cardId}`, cardPayload(data));
|
||||
return put(`/api/v1/cards/${cardId}`, cardPayload(data));
|
||||
};
|
||||
|
||||
export const deleteCard = async (cardId: string | number): Promise<OperationResponse> => {
|
||||
return del(`/cards/${cardId}`);
|
||||
return del(`/api/v1/cards/${cardId}`);
|
||||
};
|
||||
|
||||
export const getCardDetails = async (cardId: string | number): Promise<Card> => {
|
||||
const card = await get<Card>(`/cards/${cardId}/details`);
|
||||
const card = await get<Card>(`/api/v1/cards/${cardId}/details`);
|
||||
return normalizeCard(card);
|
||||
};
|
||||
|
||||
@@ -481,12 +481,12 @@ export const batchCreateCards = async (file: File): Promise<CardBatchResponse> =
|
||||
// 此处只收紧 TypeScript 响应契约。
|
||||
const body = new FormData();
|
||||
body.append('file', file);
|
||||
return postForm('/cards/batch', body);
|
||||
return postForm('/api/v1/cards/batch', body);
|
||||
};
|
||||
|
||||
// 往 data 类型卡密组批量追加卡密号
|
||||
export const appendCardData = async (cardId: string | number, content: string): Promise<CardAppendResponse> => {
|
||||
return post(`/cards/${cardId}/append-data`, { content });
|
||||
return post(`/api/v1/cards/${cardId}/append-data`, { content });
|
||||
};
|
||||
|
||||
// Items
|
||||
@@ -880,7 +880,7 @@ export const deleteReplyRule = async (id: string, cookieId: string): Promise<Ope
|
||||
|
||||
// Settings
|
||||
export const getSystemSettings = async (): Promise<SystemSettings> => {
|
||||
const res = await get<{data: SystemSettings}>('/system-settings');
|
||||
const res = await get<{data: SystemSettings}>('/api/v1/settings/system');
|
||||
return normalizeSettings(res.data || res); // handle {success:true, data: {...}} wrapper if exists
|
||||
};
|
||||
|
||||
@@ -888,11 +888,11 @@ export const updateSystemSettings = async (settings: Partial<SystemSettings>): P
|
||||
const payload = Object.fromEntries(
|
||||
Object.entries(settings).filter(([, value]) => value !== undefined && value !== null),
|
||||
);
|
||||
return put('/system-settings', payload);
|
||||
return put('/api/v1/settings/system', payload);
|
||||
};
|
||||
|
||||
export const getAccountAISettings = async (cookieId: string, options?: RequestControlOptions): Promise<AIReplySettingsResponse> => {
|
||||
return get(`/ai-reply-settings/${cookieId}`, undefined, options);
|
||||
return get(`/api/v1/settings/ai-reply/${cookieId}`, undefined, options);
|
||||
}
|
||||
|
||||
export const updateAccountAISettings = async (cookieId: string, settings: Partial<AIReplySettings>): Promise<OperationResponse> => {
|
||||
@@ -903,11 +903,11 @@ export const updateAccountAISettings = async (cookieId: string, settings: Partia
|
||||
max_bargain_rounds: settings.max_bargain_rounds ?? 3,
|
||||
custom_prompts: settings.custom_prompts ?? ''
|
||||
};
|
||||
return put(`/ai-reply-settings/${cookieId}`, payload);
|
||||
return put(`/api/v1/settings/ai-reply/${cookieId}`, payload);
|
||||
}
|
||||
|
||||
export const fetchAIModels = async (baseUrl: string, apiKey: string = ''): Promise<string[]> => {
|
||||
const result = await post<AIModelsResponse>('/ai-models', {
|
||||
const result = await post<AIModelsResponse>('/api/v1/settings/ai-models', {
|
||||
base_url: baseUrl,
|
||||
api_key: apiKey,
|
||||
});
|
||||
@@ -933,7 +933,7 @@ const stringifyNotificationEventTypes = (events?: NotificationEventType[]): stri
|
||||
};
|
||||
|
||||
export const getNotificationChannels = async (options?: RequestControlOptions): Promise<{ success: boolean; data?: NotificationChannel[] }> => {
|
||||
const result = await get<NotificationChannelResponse[]>('/notification-channels', undefined, options);
|
||||
const result = await get<NotificationChannelResponse[]>('/api/v1/notifications/channels', undefined, options);
|
||||
const channels = (result || []).map((item: any) => {
|
||||
let parsedConfig;
|
||||
try {
|
||||
@@ -956,7 +956,7 @@ export const getNotificationChannels = async (options?: RequestControlOptions):
|
||||
}
|
||||
|
||||
export const createNotificationChannel = async (data: { name: string; type: string; config: Record<string, unknown>; event_types?: NotificationEventType[]; enabled?: boolean }): Promise<MutationIDResponse> => {
|
||||
return post('/notification-channels', {
|
||||
return post('/api/v1/notifications/channels', {
|
||||
...data,
|
||||
config: JSON.stringify(data.config),
|
||||
event_types: stringifyNotificationEventTypes(data.event_types)
|
||||
@@ -971,16 +971,16 @@ export const updateNotificationChannel = async (channelId: string, data: { name?
|
||||
if ('event_types' in data) {
|
||||
payload.event_types = stringifyNotificationEventTypes(data.event_types);
|
||||
}
|
||||
return put(`/notification-channels/${channelId}`, payload);
|
||||
return put(`/api/v1/notifications/channels/${channelId}`, payload);
|
||||
}
|
||||
|
||||
export const deleteNotificationChannel = async (channelId: string): Promise<OperationResponse> => {
|
||||
return del(`/notification-channels/${channelId}`);
|
||||
return del(`/api/v1/notifications/channels/${channelId}`);
|
||||
}
|
||||
|
||||
// Message Notifications
|
||||
export const getMessageNotifications = async (): Promise<{ success: boolean; data?: NotificationBinding[] }> => {
|
||||
const result = await get<Record<string, NotificationBinding[]>>('/message-notifications');
|
||||
const result = await get<Record<string, NotificationBinding[]>>('/api/v1/notifications/messages');
|
||||
const notifications: NotificationBinding[] = [];
|
||||
for (const [cookieId, channelList] of Object.entries(result || {})) {
|
||||
if (Array.isArray(channelList)) {
|
||||
@@ -998,30 +998,30 @@ export const getMessageNotifications = async (): Promise<{ success: boolean; dat
|
||||
}
|
||||
|
||||
export const setMessageNotification = async (cookieId: string, channelId: number, enabled: boolean): Promise<OperationResponse> => {
|
||||
return post(`/message-notifications/${cookieId}`, { channel_id: channelId, enabled });
|
||||
return post(`/api/v1/notifications/accounts/${cookieId}/bindings`, { channel_id: channelId, enabled });
|
||||
}
|
||||
|
||||
export const deleteMessageNotification = async (notificationId: string): Promise<OperationResponse> => {
|
||||
return del(`/message-notifications/${notificationId}`);
|
||||
return del(`/api/v1/notifications/messages/${notificationId}`);
|
||||
}
|
||||
|
||||
export const deleteAccountNotifications = async (cookieId: string): Promise<OperationResponse> => {
|
||||
return del(`/message-notifications/account/${cookieId}`);
|
||||
return del(`/api/v1/notifications/messages/account/${cookieId}`);
|
||||
}
|
||||
|
||||
// 账号 ↔ 渠道 绑定(覆盖式)
|
||||
export const getAccountBindings = async (cookieId: string, options?: RequestControlOptions): Promise<number[]> => {
|
||||
const result = await get<AccountBindingsResponse>(`/message-notifications/${cookieId}`, undefined, options);
|
||||
const result = await get<AccountBindingsResponse>(`/api/v1/notifications/accounts/${cookieId}/bindings`, undefined, options);
|
||||
return result?.channel_ids || [];
|
||||
}
|
||||
|
||||
export const setAccountBindings = async (cookieId: string, channelIds: number[]): Promise<OperationResponse> => {
|
||||
return post(`/message-notifications/${cookieId}`, { channel_ids: channelIds });
|
||||
return post(`/api/v1/notifications/accounts/${cookieId}/bindings`, { channel_ids: channelIds });
|
||||
}
|
||||
|
||||
// 测试发送
|
||||
export const testNotificationChannel = async (channelId: string): Promise<OperationResponse> => {
|
||||
return post(`/notification-channels/${channelId}/test`, {});
|
||||
return post(`/api/v1/notifications/channels/${channelId}/test`, {});
|
||||
}
|
||||
|
||||
// Default Reply
|
||||
|
||||
@@ -10,6 +10,7 @@ func (s *Server) mountHealthAndVersionedRoutes(r chi.Router) {
|
||||
s.mountVersionedOrders(r)
|
||||
s.mountVersionedItems(r)
|
||||
s.mountVersionedItemBatchRoutes(r)
|
||||
s.mountVersionedSettingsCardNotificationRoutes(r)
|
||||
}
|
||||
|
||||
// mountVersionedSession 挂载会话 API 的 `/api/v1` 兼容入口,复用现有 handler。
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// settingsCardNotificationRouteCase 描述一个设置、卡券或通知兼容路由测试样例。
|
||||
type settingsCardNotificationRouteCase struct {
|
||||
// name 是测试样例名称。
|
||||
name string
|
||||
// method 是请求使用的 HTTP 方法。
|
||||
method string
|
||||
// versionedPath 是版本化入口路径。
|
||||
versionedPath string
|
||||
// legacyPath 是旧兼容入口路径。
|
||||
legacyPath string
|
||||
// body 是两条入口共用的请求体。
|
||||
body string
|
||||
// wantStatus 是两条入口应返回的状态码。
|
||||
wantStatus int
|
||||
}
|
||||
|
||||
// requestSettingsCardNotificationRoute 发送带认证会话的兼容请求并返回状态码。
|
||||
func requestSettingsCardNotificationRoute(t *testing.T, handler http.Handler, sessionCookie *http.Cookie, method, path, body string) int {
|
||||
t.Helper()
|
||||
// request 是当前设置、卡券或通知兼容入口请求。
|
||||
request := httptest.NewRequest(method, path, strings.NewReader(body))
|
||||
request.AddCookie(sessionCookie)
|
||||
// recorder 是捕获兼容入口响应的记录器。
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, request)
|
||||
return recorder.Code
|
||||
}
|
||||
|
||||
// TestVersionedSettingsCardNotificationRoutesPreserveLegacyContracts 验证三类领域入口复用旧 handler 和权限边界。
|
||||
func TestVersionedSettingsCardNotificationRoutesPreserveLegacyContracts(t *testing.T) {
|
||||
// srv 是用于验证设置、卡券和通知路由的 HTTP 测试服务。
|
||||
srv, _, cleanup := newTestServer(t)
|
||||
defer cleanup()
|
||||
// handler 是当前测试使用的完整路由树。
|
||||
handler := srv.Router()
|
||||
// sessionCookie 是管理员登录后得到的认证会话。
|
||||
sessionCookie := loginHelper(t, handler)
|
||||
// cases 是覆盖版本化与旧路径状态码兼容性的测试样例集合。
|
||||
cases := []settingsCardNotificationRouteCase{
|
||||
{name: "public-system-settings", method: http.MethodGet, versionedPath: "/api/v1/settings/system/public", legacyPath: "/system-settings/public", wantStatus: http.StatusOK},
|
||||
{name: "system-settings-list", method: http.MethodGet, versionedPath: "/api/v1/settings/system", legacyPath: "/system-settings", wantStatus: http.StatusOK},
|
||||
{name: "system-settings-bulk", method: http.MethodPut, versionedPath: "/api/v1/settings/system", legacyPath: "/system-settings", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "system-settings-key", method: http.MethodPut, versionedPath: "/api/v1/settings/system/theme_color", legacyPath: "/system-settings/theme_color", body: `{"value":"blue"}`, wantStatus: http.StatusOK},
|
||||
{name: "ai-models-invalid", method: http.MethodPost, versionedPath: "/api/v1/settings/ai-models", legacyPath: "/ai-models", body: `not-json`, wantStatus: http.StatusBadRequest},
|
||||
{name: "ai-reply-list", method: http.MethodGet, versionedPath: "/api/v1/settings/ai-reply", legacyPath: "/ai-reply-settings", wantStatus: http.StatusOK},
|
||||
{name: "ai-reply-missing", method: http.MethodGet, versionedPath: "/api/v1/settings/ai-reply/missing", legacyPath: "/ai-reply-settings/missing", wantStatus: http.StatusNotFound},
|
||||
{name: "ai-reply-update-missing", method: http.MethodPut, versionedPath: "/api/v1/settings/ai-reply/missing", legacyPath: "/ai-reply-settings/missing", body: `{}`, wantStatus: http.StatusNotFound},
|
||||
{name: "user-settings-list", method: http.MethodGet, versionedPath: "/api/v1/settings/user", legacyPath: "/user-settings", wantStatus: http.StatusOK},
|
||||
{name: "user-setting-missing", method: http.MethodGet, versionedPath: "/api/v1/settings/user/theme", legacyPath: "/user-settings/theme", wantStatus: http.StatusOK},
|
||||
{name: "user-setting-update", method: http.MethodPut, versionedPath: "/api/v1/settings/user/theme", legacyPath: "/user-settings/theme", body: `{"value":"blue"}`, wantStatus: http.StatusOK},
|
||||
{name: "cards-list", method: http.MethodGet, versionedPath: "/api/v1/cards", legacyPath: "/cards", wantStatus: http.StatusOK},
|
||||
{name: "cards-create-invalid", method: http.MethodPost, versionedPath: "/api/v1/cards", legacyPath: "/cards", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "cards-batch-invalid", method: http.MethodPost, versionedPath: "/api/v1/cards/batch", legacyPath: "/cards/batch", wantStatus: http.StatusBadRequest},
|
||||
{name: "card-details-invalid", method: http.MethodGet, versionedPath: "/api/v1/cards/invalid/details", legacyPath: "/cards/invalid/details", wantStatus: http.StatusBadRequest},
|
||||
{name: "card-get-invalid", method: http.MethodGet, versionedPath: "/api/v1/cards/invalid", legacyPath: "/cards/invalid", wantStatus: http.StatusBadRequest},
|
||||
{name: "card-update-invalid", method: http.MethodPut, versionedPath: "/api/v1/cards/invalid", legacyPath: "/cards/invalid", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "card-delete-invalid", method: http.MethodDelete, versionedPath: "/api/v1/cards/invalid", legacyPath: "/cards/invalid", wantStatus: http.StatusBadRequest},
|
||||
{name: "card-append-invalid", method: http.MethodPost, versionedPath: "/api/v1/cards/invalid/append-data", legacyPath: "/cards/invalid/append-data", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "notification-channels-list", method: http.MethodGet, versionedPath: "/api/v1/notifications/channels", legacyPath: "/notification-channels", wantStatus: http.StatusOK},
|
||||
{name: "notification-channel-create-invalid", method: http.MethodPost, versionedPath: "/api/v1/notifications/channels", legacyPath: "/notification-channels", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "notification-channel-update-invalid", method: http.MethodPut, versionedPath: "/api/v1/notifications/channels/invalid", legacyPath: "/notification-channels/invalid", body: `{}`, wantStatus: http.StatusBadRequest},
|
||||
{name: "notification-channel-delete-invalid", method: http.MethodDelete, versionedPath: "/api/v1/notifications/channels/invalid", legacyPath: "/notification-channels/invalid", wantStatus: http.StatusBadRequest},
|
||||
{name: "notification-channel-test-invalid", method: http.MethodPost, versionedPath: "/api/v1/notifications/channels/invalid/test", legacyPath: "/notification-channels/invalid/test", wantStatus: http.StatusBadRequest},
|
||||
{name: "message-notifications-list", method: http.MethodGet, versionedPath: "/api/v1/notifications/messages", legacyPath: "/message-notifications", wantStatus: http.StatusOK},
|
||||
{name: "message-notification-delete-invalid", method: http.MethodDelete, versionedPath: "/api/v1/notifications/messages/invalid", legacyPath: "/message-notifications/invalid", wantStatus: http.StatusBadRequest},
|
||||
{name: "account-notifications-delete", method: http.MethodDelete, versionedPath: "/api/v1/notifications/messages/account/acc1", legacyPath: "/message-notifications/account/acc1", wantStatus: http.StatusOK},
|
||||
{name: "account-bindings-missing", method: http.MethodGet, versionedPath: "/api/v1/notifications/accounts/missing/bindings", legacyPath: "/message-notifications/missing", wantStatus: http.StatusNotFound},
|
||||
{name: "account-bindings-update-missing", method: http.MethodPost, versionedPath: "/api/v1/notifications/accounts/missing/bindings", legacyPath: "/message-notifications/missing", body: `{}`, wantStatus: http.StatusNotFound},
|
||||
}
|
||||
for _, routeCase := range cases { // routeCase 是当前正在执行的设置、卡券或通知路由样例。
|
||||
// versionedStatus 是版本化入口实际返回的状态码。
|
||||
versionedStatus := requestSettingsCardNotificationRoute(t, handler, sessionCookie, routeCase.method, routeCase.versionedPath, routeCase.body)
|
||||
// legacyStatus 是旧兼容入口实际返回的状态码。
|
||||
legacyStatus := requestSettingsCardNotificationRoute(t, handler, sessionCookie, routeCase.method, routeCase.legacyPath, routeCase.body)
|
||||
if versionedStatus != routeCase.wantStatus || legacyStatus != routeCase.wantStatus {
|
||||
t.Errorf("%s status versioned=%d legacy=%d want=%d", routeCase.name, versionedStatus, legacyStatus, routeCase.wantStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"xianyu-go/internal/auth"
|
||||
)
|
||||
|
||||
// mountVersionedSettingsCardNotificationRoutes 挂载设置、卡券和通知的 `/api/v1` 兼容入口。
|
||||
func (s *Server) mountVersionedSettingsCardNotificationRoutes(r chi.Router) {
|
||||
// 公开系统设置只读取允许匿名访问的主题等配置。
|
||||
r.Get("/api/v1/settings/system/public", s.publicSettings)
|
||||
|
||||
// 管理员设置入口保持旧路径的管理员权限边界。
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(s.Auth.Middleware)
|
||||
r.Use(auth.RequireAuth)
|
||||
r.Use(auth.RequireAdmin)
|
||||
r.Get("/api/v1/settings/system", s.allSettings)
|
||||
r.Put("/api/v1/settings/system", s.setSettings)
|
||||
r.Put("/api/v1/settings/system/{key}", s.setSetting)
|
||||
r.Post("/api/v1/settings/ai-models", s.listAIModels)
|
||||
})
|
||||
|
||||
// 普通登录用户可访问账号 AI 设置、用户设置、卡券和通知资源。
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(s.Auth.Middleware)
|
||||
r.Use(auth.RequireAuth)
|
||||
|
||||
r.Get("/api/v1/settings/ai-reply", s.listAIReply)
|
||||
r.Get("/api/v1/settings/ai-reply/{cookie_id}", s.getAIReply)
|
||||
r.Put("/api/v1/settings/ai-reply/{cookie_id}", s.setAIReply)
|
||||
r.Get("/api/v1/settings/user", s.listUserSettings)
|
||||
r.Put("/api/v1/settings/user/{key}", s.setUserSetting)
|
||||
r.Get("/api/v1/settings/user/{key}", s.getUserSetting)
|
||||
|
||||
r.Get("/api/v1/cards", s.listCards)
|
||||
r.Post("/api/v1/cards", s.createCard)
|
||||
r.Post("/api/v1/cards/batch", s.batchCreateCards)
|
||||
r.Post("/api/v1/cards/{card_id}/append-data", s.appendCardData)
|
||||
r.Get("/api/v1/cards/{card_id}/details", s.getCard)
|
||||
r.Get("/api/v1/cards/{card_id}", s.getCard)
|
||||
r.Put("/api/v1/cards/{card_id}", s.updateCard)
|
||||
r.Delete("/api/v1/cards/{card_id}", s.deleteCard)
|
||||
|
||||
r.Get("/api/v1/notifications/channels", s.listChannels)
|
||||
r.Post("/api/v1/notifications/channels", s.createChannel)
|
||||
r.Put("/api/v1/notifications/channels/{channel_id}", s.updateChannel)
|
||||
r.Delete("/api/v1/notifications/channels/{channel_id}", s.deleteChannel)
|
||||
r.Post("/api/v1/notifications/channels/{channel_id}/test", s.testChannel)
|
||||
r.Get("/api/v1/notifications/messages", s.listMessageNotifications)
|
||||
r.Delete("/api/v1/notifications/messages/account/{cid}", s.deleteAccountNotifications)
|
||||
r.Delete("/api/v1/notifications/messages/{notification_id}", s.deleteMessageNotification)
|
||||
r.Get("/api/v1/notifications/accounts/{cid}/bindings", s.getAccountBindings)
|
||||
r.Post("/api/v1/notifications/accounts/{cid}/bindings", s.setAccountBindings)
|
||||
})
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import{j as e,r,c as ys,b as qe,d as Wa}from"./react-vendor-C_od1ZSF.js";import{L as Ja,U as ha,M as is,C as os,B as ga,S as ba,Z as cs,a as jt,b as js,G as As,c as Ns,d as _s,e as Va,f as rt,A as $s,D as Qa,g as Ps,P as fa,h as qt,E as ya,T as Ga,i as Ka,j as Pe,X as Me,k as Ha,l as Za,m as vs,n as ja,o as He,Q as Xt,p as xt,q as Ke,r as yt,s as Tt,t as Rs,R as ze,u as Na,v as Ya,w as Qe,K as Xa,x as dt,y as lt,z as et,F as Es,H as _t,I as Nt,J as Dt,N as _a,O as el,V as Ds,W as Ts,Y as tl,_ as sl,$ as al,a0 as ll,a1 as es,a2 as Bt,a3 as ds,a4 as rl,a5 as nl,a6 as xs,a7 as Ms,a8 as il,a9 as ol,aa as Mt,ab as qs,ac as Gt,ad as va,ae as cl,af as dl,ag as Zt,ah as wa,ai as xl,aj as ml,ak as pl,al as ul,am as hl,an as gl,ao as Fs}from"./icons-vendor-BpMgNNfy.js";import{R as zt,B as bl,X as Bs,Y as zs,T as Ut,a as fl,C as ts,A as yl,b as jl,c as Nl,P as Us,d as Ws,L as _l}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))i(m);new MutationObserver(m=>{for(const _ of m)if(_.type==="childList")for(const N of _.addedNodes)N.tagName==="LINK"&&N.rel==="modulepreload"&&i(N)}).observe(document,{childList:!0,subtree:!0});function l(m){const _={};return m.integrity&&(_.integrity=m.integrity),m.referrerPolicy&&(_.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?_.credentials="include":m.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function i(m){if(m.ep)return;m.ep=!0;const _=l(m);fetch(m.href,_)}})();const vl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ms=({sizeClass:t="w-12 h-12",logoClassName:a="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23Line truncated
|
||||
import{j as e,r,c as ys,b as qe,d as Wa}from"./react-vendor-C_od1ZSF.js";import{L as Ja,U as ha,M as is,C as os,B as ga,S as ba,Z as cs,a as jt,b as js,G as As,c as Ns,d as _s,e as Va,f as rt,A as $s,D as Qa,g as Ps,P as fa,h as qt,E as ya,T as Ga,i as Ka,j as Pe,X as Me,k as Ha,l as Za,m as vs,n as ja,o as He,Q as Xt,p as xt,q as Ke,r as yt,s as Tt,t as Rs,R as ze,u as Na,v as Ya,w as Qe,K as Xa,x as dt,y as lt,z as et,F as Es,H as _t,I as Nt,J as Dt,N as _a,O as el,V as Ds,W as Ts,Y as tl,_ as sl,$ as al,a0 as ll,a1 as es,a2 as Bt,a3 as ds,a4 as rl,a5 as nl,a6 as xs,a7 as Ms,a8 as il,a9 as ol,aa as Mt,ab as qs,ac as Gt,ad as va,ae as cl,af as dl,ag as Zt,ah as wa,ai as xl,aj as ml,ak as pl,al as ul,am as hl,an as gl,ao as Fs}from"./icons-vendor-BpMgNNfy.js";import{R as zt,B as bl,X as Bs,Y as zs,T as Ut,a as fl,C as ts,A as yl,b as jl,c as Nl,P as Us,d as Ws,L as _l}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))i(m);new MutationObserver(m=>{for(const _ of m)if(_.type==="childList")for(const N of _.addedNodes)N.tagName==="LINK"&&N.rel==="modulepreload"&&i(N)}).observe(document,{childList:!0,subtree:!0});function l(m){const _={};return m.integrity&&(_.integrity=m.integrity),m.referrerPolicy&&(_.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?_.credentials="include":m.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function i(m){if(m.ep)return;m.ep=!0;const _=l(m);fetch(m.href,_)}})();const vl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ms=({sizeClass:t="w-12 h-12",logoClassName:a="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23Line truncated
|
||||
|
||||
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(js,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:n,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:Y,children:"取消"}),e.jsxs("button",{onClick:ut,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:Y,children:[Y?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),Y?"保存中...":"保存"]})]})})]})}),document.body)]})},nn=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(a=>({order_id:String((a==null?void 0:a.order_id)||"unknown"),success:(a==null?void 0:a.success)===!0,message:String((a==null?void 0:a.message)||"")})):[]}),on=t=>(t==null?void 0:t.results.filter(a=>!a.success))||[],sa=({status:t})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${a[t]||a.cancelled}`,children:l[t]||t})},cn=()=>{const[t,a]=r.useState([]),[l,i]=r.useState([]),[m,_]=r.useState([]),[N,R]=r.useState({}),[g,C]=r.useState("all"),[j,F]=r.useState(""),[G,me]=r.useState(""),[oe,v]=r.useState(""),q=r.useRef(0),[ce,Q]=r.useState(1),[ee,B]=r.useState(1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState(!1),[ve,J]=r.useState(!1),[I,E]=r.useState(null),[$,be]=r.useState(null),[Re,ae]=r.useState({}),[T,p]=r.useState(!1),[b,U]=r.useState(""),[M,ne]=r.useState(!1),[he,ye]=r.useState(null),[Ee,ke]=r.useState(null),[x,V]=r.useState(null),[X,c]=r.useState(!1),[d,D]=r.useState(null),[S,Y]=r.useState(null),O=async()=>{const u=++q.current;ue(!0);try{const L=await tr(j||void 0,g,ce,20,oe);if(u!==q.current)return;a(L.data),B(L.total_pages)}catch(L){console.error("加载订单失败:",L)}finally{u===q.current&&ue(!1)}},de=(u,L,le)=>{if(le&&le.trim())return le;if(N[`${u}:${L}`])return N[`${u}:${L}`];const Ne=l.find(Ue=>{if(le&&Ue.item_title){const Fe=le.toLowerCase(),tt=Ue.item_title.toLowerCase();return tt.includes(Fe)||Fe.includes(tt)}return!1});return Ne!=null&&Ne.item_title?Ne.item_title:"未知商品"},Se=u=>{const L={};u.forEach(le=>{le.item_id&&(L[`${le.cookie_id}:${le.item_id}`]=le.item_title||le.item_id)}),R(L)};r.useEffect(()=>{const u=window.setTimeout(()=>{Q(1),v(G.trim())},300);return()=>window.clearTimeout(u)},[G]),r.useEffect(()=>{O()},[j,g,ce,oe]),r.useEffect(()=>{Promise.all([Ft(),vt()]).then(([u,L])=>{_(u),i(L),Se(L)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const fe=r.useMemo(()=>new Map(m.map(u=>[u.id,u])),[m]),Oe=u=>{const L=fe.get(u),le=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return le?`${le} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},re=u=>{const L=fe.get(u);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"},h=async()=>{ue(!0);try{const u=await lr(j||void 0,g);await O(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{ue(!1)}},f=u=>{U(u),ye(null),p(!0)},P=async u=>{var L;ne(!0),ye(null);try{const le=await nr([b],u),Ne=(L=le==null?void 0:le.results)==null?void 0:L[0];Ne!=null&&Ne.success?(ye({success:!0,message:Ne.message}),O()):ye({success:!1,message:(Ne==null?void 0:Ne.message)||"发货失败"})}catch(le){ye({success:!1,message:(le==null?void 0:le.message)||"请求失败"})}finally{ne(!1)}},z=u=>{E(u),Z(!0)},Ie=u=>{be({...u}),K(!0)},Ae=async()=>{if(!(!$||!$.order_id))try{const u={};$.status!==void 0&&(u.order_status=$.status),$.buyer_id!==void 0&&(u.buyer_id=$.buyer_id),$.amount!==void 0&&(u.amount=$.amount),$.receiver_name!==void 0&&(u.receiver_name=$.receiver_name),$.receiver_phone!==
Line truncated
|
||||
VIP-MONTH-002
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Ydisks闲鱼助手 - 自动发货与管家系统</title>
|
||||
<meta name="description" content="Ydisks闲鱼助手 - 自动回复、自动发货、订单管理、AI智能议价一体化解决方案" />
|
||||
<script type="module" crossorigin src="/static/assets/index-BEg6Pows.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-CVnL93T4.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-C_od1ZSF.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-BpMgNNfy.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/vendor-D-Edl3pr.js">
|
||||
|
||||
Reference in new issue
Block a user