API版本化:迁移账号设置与资料入口
This commit is contained in:
1 parent
415a3adc5f
commit
eb8a54698c
8 files changed
+202
-14
No files matched your search
@@ -7,7 +7,7 @@
|
||||
| 领域 | 现有路径 | 目标 `/api/v1` 路径 | 迁移状态 |
|
||||
| --- | --- | --- | --- |
|
||||
| 会话 | `/login`、`/initialize`、`/verify`、`/logout` | `/api/v1/session/login`、`/api/v1/session/initialize`、`/api/v1/session`、`/api/v1/session/logout` | React 会话调用方已迁移到版本化入口;旧路径保留并由同一 handler 提供 |
|
||||
| 账号 | `/cookies`、`/cookies/details`、`/cookies/runtime-status`、`/cookies/{cid}/...` | `/api/v1/accounts`、`/api/v1/accounts/details`、`/api/v1/accounts/runtime-status`、`/api/v1/accounts/{cid}` | React 摘要、详情、运行状态和启停状态调用已迁移;旧路径保留并由同一 handler 提供 |
|
||||
| 账号 | `/cookies`、`/cookies/details`、`/cookies/runtime-status`、`/cookies/{cid}/...` | `/api/v1/accounts`、`/api/v1/accounts/details`、`/api/v1/accounts/runtime-status`、`/api/v1/accounts/{cid}/...` | React 摘要、详情、运行状态、启停状态、设置、备注、暂停、自动确认、长登录和资料刷新调用已迁移;旧路径保留并由同一 handler 提供 |
|
||||
| 商品 | `/items...` | `/api/v1/items...` | 旧路径保留,发布/同步/列表/详情 DTO 已落地 |
|
||||
| 商品批量 | `/items/publish-batches...` | `/api/v1/items/publish-batches...` | 旧路径保留,类目推荐/预检/任务 DTO 已落地 |
|
||||
| 自动化 | `/automation-rules...` | `/api/v1/automation-rules...` | 旧路径保留,规则分页/异常 DTO 已落地 |
|
||||
@@ -44,7 +44,7 @@
|
||||
- 管理员和统计分别使用 `adminUserResponse`/`adminCookieResponse`/`adminStatsResponse`、`dashboardStatsResponse`、`orderAnalyticsResponse` 与 `validOrdersResponse`;二维码生成使用 `qrLoginGenerateResponse`。
|
||||
- 动态设置和二维码兼容边界分别使用 `settingsResponse`、`qrLoginStatusResponse` 与 `qrLoginVerificationResponse`;二维码状态契约测试确认 `cookies` 等敏感字段不会回传。
|
||||
- 会话登录、初始化、校验和登出已由 React 请求层迁移到 `/api/v1/session/...`,Go 契约测试确认版本化入口与旧路径共用 handler 且旧路径仍可用。
|
||||
- 账号摘要、非敏感详情、运行状态和启停状态已由 React 请求层迁移到 `/api/v1/accounts...`;Go 契约测试确认账号详情不泄露 Cookie/密码,且旧详情入口仍可用。
|
||||
- 账号摘要、非敏感详情、运行状态、启停状态、设置、备注、暂停、自动确认、长登录和资料刷新已由 React 请求层迁移到 `/api/v1/accounts...`;Go 契约测试确认账号详情不泄露 Cookie/密码,且旧详情与设置入口仍可用。
|
||||
- 聊天会话、消息分页和发送结果使用独立 DTO,不直接暴露数据库模型。
|
||||
- React `frontend/types.ts` 与 `frontend/services/api.ts` 已同步具名成功响应类型,同时保留旧字段归一逻辑。
|
||||
- 会话版本化入口已可用;除会话外的 `/api/v1` 领域入口仍未宣称可用,旧路径继续保留。
|
||||
@@ -140,7 +140,8 @@ app shell / routes
|
||||
- 已完成阶段 3 第十个 PR 切片“分析统计、管理员与剩余公共成功响应收口”:管理员用户/账号/统计、用户仪表盘、订单分析、有效订单分页和二维码生成均改用具名 DTO;React 客户端同步统计和二维码契约类型;新增跨领域契约测试;保留动态设置和二维码状态的兼容边界;全量门禁通过并合并为一个可回滚提交;
|
||||
- 已完成阶段 3 第十二个 PR 切片“HTTP API 版本化兼容入口与会话调用方迁移”:新增 `/api/v1/session/login`、`/api/v1/session/initialize`、`/api/v1/session` 与 `/api/v1/session/logout` 薄适配入口,复用旧 handler;React 登录、初始化、会话校验和登出已迁移,旧路径保留;新增 Go/React 契约测试并保持独立可回滚提交;
|
||||
- 已完成阶段 3 第十三个 PR 切片“账号 API 版本化兼容入口与调用方迁移”:新增 `/api/v1/accounts`、详情、运行状态、单账号详情和启停状态薄适配入口,复用旧 handler;React 账号摘要、详情、运行状态和启停状态调用已迁移,旧路径保留;新增 Go/React 契约测试并保持独立可回滚提交;
|
||||
- 阶段 3 下一 PR 切片为“账号设置与资料 API 版本化兼容入口迁移”:迁移账号设置、备注、暂停和资料刷新的一组调用方,不删除旧路径,不拆分单个 handler 提交;
|
||||
- 已完成阶段 3 第十四个 PR 切片“账号设置与资料 API 版本化兼容入口迁移”:新增账号聚合设置、备注、暂停、自动确认、长登录和资料刷新 `/api/v1/accounts/{cid}/...` 薄适配入口,复用旧 handler;React 相关调用已迁移,旧路径保留;新增 Go/React 契约测试并保持独立可回滚提交;
|
||||
- 阶段 3 下一 PR 切片为“账号凭证与登录信息 API 版本化兼容入口迁移”:迁移 Cookie 更新和登录信息设置的一组调用方,继续保留敏感字段边界与旧路径,不拆分单个 handler 提交;
|
||||
- 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。
|
||||
|
||||
## 6. 阶段 0:治理文档与强约束
|
||||
@@ -530,3 +531,4 @@ npm --prefix frontend run build
|
||||
| 2026-08-14 | 完成阶段 3 第十一个 PR 切片“公共成功响应兼容收尾与版本化迁移入口审计” | 系统、管理员和用户动态设置统一通过具名 map 边界类型;二维码状态保留非敏感扩展字段并过滤 Cookie,验证完成使用具名 DTO;React API 清理剩余 `Promise<any>`/`get<any>` 成功响应并补齐兼容类型;新增动态设置与二维码契约测试,明确旧路径仍保留、尚未宣称 `/api/v1` 可用;所有修改合并为一个可回滚提交 | 阶段 3:HTTP API 版本化兼容入口落地与调用方迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第十二个 PR 切片“HTTP API 版本化兼容入口与会话调用方迁移” | 新增 `/api/v1/session/login`、`/api/v1/session/initialize`、`/api/v1/session` 与 `/api/v1/session/logout` 薄适配入口,全部复用既有认证 handler;React 登录、初始化、会话校验和登出调用已迁移;Go/React 契约测试确认新旧路径兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:账号 API 版本化兼容入口与调用方迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第十三个 PR 切片“账号 API 版本化兼容入口与调用方迁移” | 新增 `/api/v1/accounts`、`/api/v1/accounts/details`、`/api/v1/accounts/runtime-status`、`/api/v1/accounts/{cid}` 与启停状态薄适配入口,全部复用既有账号 handler;React 账号摘要、详情、运行状态和启停状态调用已迁移;Go/React 契约测试确认新旧路径兼容且详情不泄露凭证;全量门禁通过并合并为一个可回滚提交 | 阶段 3:账号设置与资料 API 版本化兼容入口迁移 |
|
||||
| 2026-08-14 | 完成阶段 3 第十四个 PR 切片“账号设置与资料 API 版本化兼容入口迁移” | 新增 `/api/v1/accounts/{cid}/settings`、`remark`、`pause-duration`、`auto-confirm`、`long-login` 和 `refresh-profile` 薄适配入口,全部复用既有账号 handler;React 账号设置、备注、暂停、自动确认、长登录和资料刷新调用已迁移;Go/React 契约测试确认新旧路径兼容;全量门禁通过并合并为一个可回滚提交 | 阶段 3:账号凭证与登录信息 API 版本化兼容入口迁移 |
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
deleteReplyRule,
|
||||
updateAccountCookie,
|
||||
updateAccountLoginInfo,
|
||||
updateAccountSettings,
|
||||
updateAccountSettings, updateAccountRemark, updateAccountAutoConfirm, updateAccountPauseDuration, getLongLoginSettings, setLongLoginSettings, refreshAccountProfile,
|
||||
updateItem,
|
||||
updateNotificationChannel,
|
||||
updateSystemSettings,
|
||||
@@ -345,7 +345,7 @@ test('account editor settings use one aggregate request', async () => {
|
||||
username: 'user', show_browser: true, channel_ids: [1, 2],
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(fetchMock).toHaveBeenCalledWith('/cookies/acc1/settings', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/v1/accounts/acc1/settings', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({
|
||||
remark: 'main', auto_confirm: false, pause_duration: 5,
|
||||
username: 'user', show_browser: true, channel_ids: [1, 2],
|
||||
@@ -783,3 +783,35 @@ const runVersionedAccountAPITest = async () => {
|
||||
};
|
||||
|
||||
test('account summary and status APIs use versioned compatibility routes', runVersionedAccountAPITest);
|
||||
|
||||
// 账号设置、长登录和资料 API 使用版本化兼容入口。
|
||||
const runVersionedAccountSettingsAPITest = async () => {
|
||||
// fetchMock 是账号设置与资料请求的测试替身。
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, paused_until: 0, paused: false }))
|
||||
.mockResolvedValueOnce(jsonResponse({ can_open_long_login: true, enabled: false }))
|
||||
.mockResolvedValueOnce(jsonResponse({ can_open_long_login: true, enabled: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, id: 'acc1', nickname: '主账号', avatar_url: '', profile_error: '' }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true }))
|
||||
.mockResolvedValueOnce(jsonResponse({ success: true, paused_until: 0, paused: false }));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
await updateAccountSettings('acc1', { remark: '主账号' });
|
||||
await getLongLoginSettings('acc1');
|
||||
await setLongLoginSettings('acc1', true);
|
||||
await refreshAccountProfile('acc1');
|
||||
await updateAccountRemark('acc1', '新的备注');
|
||||
await updateAccountAutoConfirm('acc1', true);
|
||||
await updateAccountPauseDuration('acc1', 15);
|
||||
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/v1/accounts/acc1/settings', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/v1/accounts/acc1/long-login', expect.objectContaining({ method: 'GET' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(3, '/api/v1/accounts/acc1/long-login', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(4, '/api/v1/accounts/acc1/refresh-profile', expect.objectContaining({ method: 'POST' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(5, '/api/v1/accounts/acc1/remark', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(6, '/api/v1/accounts/acc1/auto-confirm', expect.objectContaining({ method: 'PUT' }));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(7, '/api/v1/accounts/acc1/pause-duration', expect.objectContaining({ method: 'PUT' }));
|
||||
};
|
||||
|
||||
test('account settings and profile APIs use versioned compatibility routes', runVersionedAccountSettingsAPITest);
|
||||
@@ -195,15 +195,15 @@ export const deleteAccount = async (id: string): Promise<OperationResponse> => {
|
||||
};
|
||||
|
||||
export const updateAccountRemark = async (id: string, remark: string): Promise<OperationResponse> => {
|
||||
return put(`/cookies/${id}/remark`, { remark });
|
||||
return put(`/api/v1/accounts/${id}/remark`, { remark });
|
||||
};
|
||||
|
||||
export const updateAccountAutoConfirm = async (id: string, autoConfirm: boolean): Promise<OperationResponse> => {
|
||||
return put(`/cookies/${id}/auto-confirm`, { auto_confirm: autoConfirm });
|
||||
return put(`/api/v1/accounts/${id}/auto-confirm`, { auto_confirm: autoConfirm });
|
||||
};
|
||||
|
||||
export const updateAccountPauseDuration = async (id: string, pauseDuration: number): Promise<CookieSettingsResponse> => {
|
||||
return put(`/cookies/${id}/pause-duration`, { pause_duration: pauseDuration });
|
||||
return put(`/api/v1/accounts/${id}/pause-duration`, { pause_duration: pauseDuration });
|
||||
};
|
||||
|
||||
export const updateAccountCookie = async (id: string, value: string, loginMethod?: string): Promise<OperationResponse> => {
|
||||
@@ -223,7 +223,7 @@ export interface AccountSettingsUpdate {
|
||||
}
|
||||
|
||||
export const updateAccountSettings = async (id: string, data: AccountSettingsUpdate): Promise<CookieSettingsResponse> => {
|
||||
return put(`/cookies/${id}/settings`, data);
|
||||
return put(`/api/v1/accounts/${id}/settings`, data);
|
||||
};
|
||||
|
||||
export interface LongLoginSettings {
|
||||
@@ -232,11 +232,11 @@ export interface LongLoginSettings {
|
||||
}
|
||||
|
||||
export const getLongLoginSettings = async (id: string): Promise<LongLoginSettings> => {
|
||||
return get(`/cookies/${id}/long-login`);
|
||||
return get(`/api/v1/accounts/${id}/long-login`);
|
||||
};
|
||||
|
||||
export const setLongLoginSettings = async (id: string, enabled: boolean): Promise<LongLoginSettings> => {
|
||||
return put(`/cookies/${id}/long-login`, { enabled });
|
||||
return put(`/api/v1/accounts/${id}/long-login`, { enabled });
|
||||
};
|
||||
|
||||
export interface PasswordLoginStartResponse {
|
||||
@@ -277,7 +277,7 @@ export const cancelPasswordLogin = async (sessionId: string): Promise<ApiRespons
|
||||
};
|
||||
|
||||
export const refreshAccountProfile = async (id: string): Promise<CookieProfileResponse> => {
|
||||
return post(`/cookies/${id}/refresh-profile`, {});
|
||||
return post(`/api/v1/accounts/${id}/refresh-profile`, {});
|
||||
};
|
||||
|
||||
export const updateAccountLoginInfo = async (id: string, data: {
|
||||
|
||||
@@ -138,3 +138,148 @@ func TestVersionedAccountRoutesPreserveLegacyContracts(t *testing.T) {
|
||||
t.Fatalf("restore account status=%d body=%s", restoreRecorder.Code, restoreRecorder.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
// TestVersionedAccountSettingsRoutesPreserveLegacyContracts 验证账号设置、资料和旧路径兼容。
|
||||
func TestVersionedAccountSettingsRoutesPreserveLegacyContracts(t *testing.T) {
|
||||
// srv 是用于验证版本化账号设置路由的 HTTP 测试服务。
|
||||
srv, _, cleanup := newTestServer(t)
|
||||
defer cleanup()
|
||||
// handler 是当前测试使用的完整路由树。
|
||||
handler := srv.Router()
|
||||
// sessionCookie 是管理员登录后得到的认证会话。
|
||||
sessionCookie := loginHelper(t, handler)
|
||||
|
||||
// settingsReq 是提交版本化聚合账号设置的请求。
|
||||
settingsReq := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/settings", strings.NewReader(`{"remark":"版本化备注","pause_duration":10,"auto_confirm":true}`))
|
||||
settingsReq.AddCookie(sessionCookie)
|
||||
// settingsRecorder 是捕获聚合设置响应的记录器。
|
||||
settingsRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(settingsRecorder, settingsReq)
|
||||
if settingsRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned settings status=%d body=%s", settingsRecorder.Code, settingsRecorder.Body.String())
|
||||
}
|
||||
// settingsValue 是聚合账号设置具名响应 DTO。
|
||||
var settingsValue cookieSettingsResponse
|
||||
// settingsDecodeErr 是聚合设置响应反序列化失败的原因。
|
||||
if settingsDecodeErr := json.Unmarshal(settingsRecorder.Body.Bytes(), &settingsValue); settingsDecodeErr != nil {
|
||||
t.Fatalf("decode versioned settings: %v", settingsDecodeErr)
|
||||
}
|
||||
if !settingsValue.Success {
|
||||
t.Fatalf("versioned settings=%+v", settingsValue)
|
||||
}
|
||||
|
||||
// remarkReq 是更新版本化账号备注的请求。
|
||||
remarkReq := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/remark", strings.NewReader(`{"remark":"新备注"}`))
|
||||
remarkReq.AddCookie(sessionCookie)
|
||||
// remarkRecorder 是捕获备注响应的记录器。
|
||||
remarkRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(remarkRecorder, remarkReq)
|
||||
if remarkRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned remark status=%d body=%s", remarkRecorder.Code, remarkRecorder.Body.String())
|
||||
}
|
||||
// remarkValue 是备注变更具名响应 DTO。
|
||||
var remarkValue operationResponse
|
||||
// remarkDecodeErr 是备注响应反序列化失败的原因。
|
||||
if remarkDecodeErr := json.Unmarshal(remarkRecorder.Body.Bytes(), &remarkValue); remarkDecodeErr != nil {
|
||||
t.Fatalf("decode versioned remark: %v", remarkDecodeErr)
|
||||
}
|
||||
if !remarkValue.Success {
|
||||
t.Fatalf("versioned remark=%+v", remarkValue)
|
||||
}
|
||||
|
||||
// autoConfirmReq 是更新版本化自动确认设置的请求。
|
||||
autoConfirmReq := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/auto-confirm", strings.NewReader(`{"auto_confirm":false}`))
|
||||
autoConfirmReq.AddCookie(sessionCookie)
|
||||
// autoConfirmRecorder 是捕获自动确认响应的记录器。
|
||||
autoConfirmRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(autoConfirmRecorder, autoConfirmReq)
|
||||
if autoConfirmRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned auto-confirm status=%d body=%s", autoConfirmRecorder.Code, autoConfirmRecorder.Body.String())
|
||||
}
|
||||
|
||||
// pauseReq 是更新版本化暂停时长的请求。
|
||||
pauseReq := httptest.NewRequest(http.MethodPut, "/api/v1/accounts/acc1/pause-duration", strings.NewReader(`{"pause_duration":15}`))
|
||||
pauseReq.AddCookie(sessionCookie)
|
||||
// pauseRecorder 是捕获暂停时长响应的记录器。
|
||||
pauseRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(pauseRecorder, pauseReq)
|
||||
if pauseRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned pause status=%d body=%s", pauseRecorder.Code, pauseRecorder.Body.String())
|
||||
}
|
||||
// pauseValue 是暂停时长具名响应 DTO。
|
||||
var pauseValue cookieSettingsResponse
|
||||
// pauseDecodeErr 是暂停响应反序列化失败的原因。
|
||||
if pauseDecodeErr := json.Unmarshal(pauseRecorder.Body.Bytes(), &pauseValue); pauseDecodeErr != nil {
|
||||
t.Fatalf("decode versioned pause: %v", pauseDecodeErr)
|
||||
}
|
||||
if !pauseValue.Success {
|
||||
t.Fatalf("versioned pause=%+v", pauseValue)
|
||||
}
|
||||
|
||||
// autoConfirmGetReq 是读取版本化自动确认设置的请求。
|
||||
autoConfirmGetReq := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/acc1/auto-confirm", nil)
|
||||
autoConfirmGetReq.AddCookie(sessionCookie)
|
||||
// autoConfirmGetRecorder 是捕获自动确认查询响应的记录器。
|
||||
autoConfirmGetRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(autoConfirmGetRecorder, autoConfirmGetReq)
|
||||
if autoConfirmGetRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned auto-confirm get status=%d body=%s", autoConfirmGetRecorder.Code, autoConfirmGetRecorder.Body.String())
|
||||
}
|
||||
// autoConfirmValue 是自动确认查询具名响应 DTO。
|
||||
var autoConfirmValue autoConfirmResponse
|
||||
// autoConfirmDecodeErr 是自动确认查询响应反序列化失败的原因。
|
||||
if autoConfirmDecodeErr := json.Unmarshal(autoConfirmGetRecorder.Body.Bytes(), &autoConfirmValue); autoConfirmDecodeErr != nil {
|
||||
t.Fatalf("decode versioned auto-confirm: %v", autoConfirmDecodeErr)
|
||||
}
|
||||
if autoConfirmValue.AutoConfirm {
|
||||
t.Fatalf("versioned auto-confirm=%+v", autoConfirmValue)
|
||||
}
|
||||
|
||||
// pauseGetReq 是读取版本化暂停时长的请求。
|
||||
pauseGetReq := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/acc1/pause-duration", nil)
|
||||
pauseGetReq.AddCookie(sessionCookie)
|
||||
// pauseGetRecorder 是捕获暂停查询响应的记录器。
|
||||
pauseGetRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(pauseGetRecorder, pauseGetReq)
|
||||
if pauseGetRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned pause get status=%d body=%s", pauseGetRecorder.Code, pauseGetRecorder.Body.String())
|
||||
}
|
||||
// pauseGetValue 是暂停查询具名响应 DTO。
|
||||
var pauseGetValue pauseDurationResponse
|
||||
// pauseGetDecodeErr 是暂停查询响应反序列化失败的原因。
|
||||
if pauseGetDecodeErr := json.Unmarshal(pauseGetRecorder.Body.Bytes(), &pauseGetValue); pauseGetDecodeErr != nil {
|
||||
t.Fatalf("decode versioned pause get: %v", pauseGetDecodeErr)
|
||||
}
|
||||
if pauseGetValue.PauseDuration != 15 {
|
||||
t.Fatalf("versioned pause get=%+v", pauseGetValue)
|
||||
}
|
||||
|
||||
// profileReq 是刷新版本化账号资料的请求。
|
||||
profileReq := httptest.NewRequest(http.MethodPost, "/api/v1/accounts/acc1/refresh-profile", nil)
|
||||
profileReq.AddCookie(sessionCookie)
|
||||
// profileRecorder 是捕获资料刷新响应的记录器。
|
||||
profileRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(profileRecorder, profileReq)
|
||||
if profileRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("versioned profile status=%d body=%s", profileRecorder.Code, profileRecorder.Body.String())
|
||||
}
|
||||
// profileValue 是资料刷新具名响应 DTO。
|
||||
var profileValue cookieProfileResponse
|
||||
// profileDecodeErr 是资料刷新响应反序列化失败的原因。
|
||||
if profileDecodeErr := json.Unmarshal(profileRecorder.Body.Bytes(), &profileValue); profileDecodeErr != nil {
|
||||
t.Fatalf("decode versioned profile: %v", profileDecodeErr)
|
||||
}
|
||||
if !profileValue.Success || profileValue.ID != "acc1" {
|
||||
t.Fatalf("versioned profile=%+v", profileValue)
|
||||
}
|
||||
|
||||
// legacySettingsReq 是验证旧账号设置入口仍可用的请求。
|
||||
legacySettingsReq := httptest.NewRequest(http.MethodPut, "/cookies/acc1/settings", strings.NewReader(`{"remark":"旧路径备注"}`))
|
||||
legacySettingsReq.AddCookie(sessionCookie)
|
||||
// legacySettingsRecorder 是捕获旧设置响应的记录器。
|
||||
legacySettingsRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(legacySettingsRecorder, legacySettingsReq)
|
||||
if legacySettingsRecorder.Code != http.StatusOK {
|
||||
t.Fatalf("legacy settings status=%d body=%s", legacySettingsRecorder.Code, legacySettingsRecorder.Body.String())
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,14 @@ func (s *Server) mountVersionedAccounts(r chi.Router) {
|
||||
r.Get("/api/v1/accounts/runtime-status", s.listCookieRuntimeStatus)
|
||||
r.Get("/api/v1/accounts/{cid}", s.getCookieDetails)
|
||||
r.Put("/api/v1/accounts/{cid}/status", s.setCookieStatus)
|
||||
r.Put("/api/v1/accounts/{cid}/settings", s.updateCookieSettings)
|
||||
r.Get("/api/v1/accounts/{cid}/long-login", s.getLongLoginSettings)
|
||||
r.Put("/api/v1/accounts/{cid}/long-login", s.setLongLoginSettings)
|
||||
r.Post("/api/v1/accounts/{cid}/refresh-profile", s.refreshCookieProfile)
|
||||
r.Get("/api/v1/accounts/{cid}/auto-confirm", s.getCookieAutoConfirm)
|
||||
r.Put("/api/v1/accounts/{cid}/auto-confirm", s.setCookieAutoConfirm)
|
||||
r.Put("/api/v1/accounts/{cid}/remark", s.setCookieRemark)
|
||||
r.Get("/api/v1/accounts/{cid}/pause-duration", s.getCookiePauseDuration)
|
||||
r.Put("/api/v1/accounts/{cid}/pause-duration", s.setCookiePauseDuration)
|
||||
})
|
||||
}
|
||||
+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-hmcV3HeZ.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-CQFC3rOm.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