diff --git a/.commentlint/frontend-baseline.json b/.commentlint/frontend-baseline.json index 2bc43a7..9ae7ba2 100644 --- a/.commentlint/frontend-baseline.json +++ b/.commentlint/frontend-baseline.json @@ -9425,2160 +9425,6 @@ "kind": "variable", "name": "body" }, - { - "file": "services/api.ts", - "line": 1004, - "kind": "variable", - "name": "setMessageNotification" - }, - { - "file": "services/api.ts", - "line": 1008, - "kind": "variable", - "name": "deleteMessageNotification" - }, - { - "file": "services/api.ts", - "line": 1012, - "kind": "variable", - "name": "deleteAccountNotifications" - }, - { - "file": "services/api.ts", - "line": 1018, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 1022, - "kind": "variable", - "name": "setAccountBindings" - }, - { - "file": "services/api.ts", - "line": 103, - "kind": "variable", - "name": "getAccountTaskSettings" - }, - { - "file": "services/api.ts", - "line": 1032, - "kind": "variable", - "name": "getDefaultReplies" - }, - { - "file": "services/api.ts", - "line": 1036, - "kind": "variable", - "name": "getDefaultReply" - }, - { - "file": "services/api.ts", - "line": 1037, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 1047, - "kind": "variable", - "name": "updateDefaultReply" - }, - { - "file": "services/api.ts", - "line": 1056, - "kind": "variable", - "name": "deleteDefaultReply" - }, - { - "file": "services/api.ts", - "line": 106, - "kind": "variable", - "name": "updateAccountTaskSettings" - }, - { - "file": "services/api.ts", - "line": 1060, - "kind": "variable", - "name": "clearDefaultReplyRecords" - }, - { - "file": "services/api.ts", - "line": 109, - "kind": "variable", - "name": "runAccountTask" - }, - { - "file": "services/api.ts", - "line": 11, - "kind": "variable", - "name": "normalizeSettings" - }, - { - "file": "services/api.ts", - "line": 112, - "kind": "member", - "name": "has_more" - }, - { - "file": "services/api.ts", - "line": 112, - "kind": "member", - "name": "next_cursor" - }, - { - "file": "services/api.ts", - "line": 112, - "kind": "member", - "name": "sessions" - }, - { - "file": "services/api.ts", - "line": 114, - "kind": "variable", - "name": "getChatSessionPage" - }, - { - "file": "services/api.ts", - "line": 115, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 12, - "kind": "variable", - "name": "out" - }, - { - "file": "services/api.ts", - "line": 120, - "kind": "variable", - "name": "getChatSessions" - }, - { - "file": "services/api.ts", - "line": 124, - "kind": "member", - "name": "messages" - }, - { - "file": "services/api.ts", - "line": 125, - "kind": "member", - "name": "has_more" - }, - { - "file": "services/api.ts", - "line": 126, - "kind": "member", - "name": "next_cursor" - }, - { - "file": "services/api.ts", - "line": 127, - "kind": "member", - "name": "session" - }, - { - "file": "services/api.ts", - "line": 130, - "kind": "variable", - "name": "getChatMessagePage" - }, - { - "file": "services/api.ts", - "line": 131, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 137, - "kind": "variable", - "name": "getChatMessages" - }, - { - "file": "services/api.ts", - "line": 14, - "kind": "variable", - "name": "parsed" - }, - { - "file": "services/api.ts", - "line": 140, - "kind": "variable", - "name": "sendChatMessage" - }, - { - "file": "services/api.ts", - "line": 141, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 141, - "kind": "member", - "name": "buyer_id" - }, - { - "file": "services/api.ts", - "line": 141, - "kind": "member", - "name": "buyer_name" - }, - { - "file": "services/api.ts", - "line": 141, - "kind": "member", - "name": "chat_id" - }, - { - "file": "services/api.ts", - "line": 142, - "kind": "member", - "name": "item_id" - }, - { - "file": "services/api.ts", - "line": 142, - "kind": "member", - "name": "item_title" - }, - { - "file": "services/api.ts", - "line": 142, - "kind": "member", - "name": "text" - }, - { - "file": "services/api.ts", - "line": 143, - "kind": "member", - "name": "message" - }, - { - "file": "services/api.ts", - "line": 145, - "kind": "variable", - "name": "sendChatImage" - }, - { - "file": "services/api.ts", - "line": 146, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 146, - "kind": "member", - "name": "buyer_id" - }, - { - "file": "services/api.ts", - "line": 146, - "kind": "member", - "name": "buyer_name" - }, - { - "file": "services/api.ts", - "line": 146, - "kind": "member", - "name": "chat_id" - }, - { - "file": "services/api.ts", - "line": 147, - "kind": "member", - "name": "buyer_avatar_url" - }, - { - "file": "services/api.ts", - "line": 147, - "kind": "member", - "name": "image" - }, - { - "file": "services/api.ts", - "line": 147, - "kind": "member", - "name": "item_id" - }, - { - "file": "services/api.ts", - "line": 147, - "kind": "member", - "name": "item_title" - }, - { - "file": "services/api.ts", - "line": 148, - "kind": "member", - "name": "message" - }, - { - "file": "services/api.ts", - "line": 149, - "kind": "variable", - "name": "form" - }, - { - "file": "services/api.ts", - "line": 150, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 154, - "kind": "variable", - "name": "markChatRead" - }, - { - "file": "services/api.ts", - "line": 158, - "kind": "member", - "name": "state" - }, - { - "file": "services/api.ts", - "line": 159, - "kind": "member", - "name": "message" - }, - { - "file": "services/api.ts", - "line": 160, - "kind": "member", - "name": "connected" - }, - { - "file": "services/api.ts", - "line": 161, - "kind": "member", - "name": "failures" - }, - { - "file": "services/api.ts", - "line": 162, - "kind": "member", - "name": "updated_at" - }, - { - "file": "services/api.ts", - "line": 165, - "kind": "variable", - "name": "getAccountRuntimeStatuses" - }, - { - "file": "services/api.ts", - "line": 169, - "kind": "variable", - "name": "generateQRLogin" - }, - { - "file": "services/api.ts", - "line": 174, - "kind": "variable", - "name": "checkQRLoginStatus" - }, - { - "file": "services/api.ts", - "line": 178, - "kind": "variable", - "name": "completeQRVerification" - }, - { - "file": "services/api.ts", - "line": 192, - "kind": "variable", - "name": "updateAccountStatus" - }, - { - "file": "services/api.ts", - "line": 196, - "kind": "variable", - "name": "deleteAccount" - }, - { - "file": "services/api.ts", - "line": 200, - "kind": "variable", - "name": "updateAccountRemark" - }, - { - "file": "services/api.ts", - "line": 204, - "kind": "variable", - "name": "updateAccountAutoConfirm" - }, - { - "file": "services/api.ts", - "line": 208, - "kind": "variable", - "name": "updateAccountPauseDuration" - }, - { - "file": "services/api.ts", - "line": 21, - "kind": "member", - "name": "email" - }, - { - "file": "services/api.ts", - "line": 21, - "kind": "member", - "name": "password" - }, - { - "file": "services/api.ts", - "line": 21, - "kind": "member", - "name": "username" - }, - { - "file": "services/api.ts", - "line": 21, - "kind": "member", - "name": "verification_code" - }, - { - "file": "services/api.ts", - "line": 21, - "kind": "variable", - "name": "login" - }, - { - "file": "services/api.ts", - "line": 212, - "kind": "variable", - "name": "updateAccountCookie" - }, - { - "file": "services/api.ts", - "line": 217, - "kind": "member", - "name": "cookie" - }, - { - "file": "services/api.ts", - "line": 218, - "kind": "member", - "name": "remark" - }, - { - "file": "services/api.ts", - "line": 219, - "kind": "member", - "name": "auto_confirm" - }, - { - "file": "services/api.ts", - "line": 220, - "kind": "member", - "name": "pause_duration" - }, - { - "file": "services/api.ts", - "line": 221, - "kind": "member", - "name": "username" - }, - { - "file": "services/api.ts", - "line": 222, - "kind": "member", - "name": "login_password" - }, - { - "file": "services/api.ts", - "line": 223, - "kind": "member", - "name": "clear_password" - }, - { - "file": "services/api.ts", - "line": 224, - "kind": "member", - "name": "show_browser" - }, - { - "file": "services/api.ts", - "line": 225, - "kind": "member", - "name": "channel_ids" - }, - { - "file": "services/api.ts", - "line": 228, - "kind": "variable", - "name": "updateAccountSettings" - }, - { - "file": "services/api.ts", - "line": 233, - "kind": "member", - "name": "can_open_long_login" - }, - { - "file": "services/api.ts", - "line": 234, - "kind": "member", - "name": "enabled" - }, - { - "file": "services/api.ts", - "line": 237, - "kind": "variable", - "name": "getLongLoginSettings" - }, - { - "file": "services/api.ts", - "line": 241, - "kind": "variable", - "name": "setLongLoginSettings" - }, - { - "file": "services/api.ts", - "line": 246, - "kind": "member", - "name": "success" - }, - { - "file": "services/api.ts", - "line": 247, - "kind": "member", - "name": "session_id" - }, - { - "file": "services/api.ts", - "line": 248, - "kind": "member", - "name": "status" - }, - { - "file": "services/api.ts", - "line": 249, - "kind": "member", - "name": "message" - }, - { - "file": "services/api.ts", - "line": 25, - "kind": "variable", - "name": "initializeAdmin" - }, - { - "file": "services/api.ts", - "line": 253, - "kind": "member", - "name": "status" - }, - { - "file": "services/api.ts", - "line": 254, - "kind": "member", - "name": "message" - }, - { - "file": "services/api.ts", - "line": 255, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 256, - "kind": "member", - "name": "is_new_account" - }, - { - "file": "services/api.ts", - "line": 257, - "kind": "member", - "name": "cookie_count" - }, - { - "file": "services/api.ts", - "line": 258, - "kind": "member", - "name": "verification_url" - }, - { - "file": "services/api.ts", - "line": 259, - "kind": "member", - "name": "screenshot_path" - }, - { - "file": "services/api.ts", - "line": 260, - "kind": "member", - "name": "qr_code_url" - }, - { - "file": "services/api.ts", - "line": 261, - "kind": "member", - "name": "error" - }, - { - "file": "services/api.ts", - "line": 262, - "kind": "member", - "name": "reason" - }, - { - "file": "services/api.ts", - "line": 265, - "kind": "variable", - "name": "passwordLogin" - }, - { - "file": "services/api.ts", - "line": 266, - "kind": "member", - "name": "account_id" - }, - { - "file": "services/api.ts", - "line": 267, - "kind": "member", - "name": "account" - }, - { - "file": "services/api.ts", - "line": 268, - "kind": "member", - "name": "password" - }, - { - "file": "services/api.ts", - "line": 269, - "kind": "member", - "name": "show_browser" - }, - { - "file": "services/api.ts", - "line": 274, - "kind": "variable", - "name": "checkPasswordLoginStatus" - }, - { - "file": "services/api.ts", - "line": 278, - "kind": "variable", - "name": "cancelPasswordLogin" - }, - { - "file": "services/api.ts", - "line": 282, - "kind": "variable", - "name": "refreshAccountProfile" - }, - { - "file": "services/api.ts", - "line": 286, - "kind": "variable", - "name": "updateAccountLoginInfo" - }, - { - "file": "services/api.ts", - "line": 287, - "kind": "member", - "name": "username" - }, - { - "file": "services/api.ts", - "line": 288, - "kind": "member", - "name": "login_password" - }, - { - "file": "services/api.ts", - "line": 289, - "kind": "member", - "name": "clear_password" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "member", - "name": "authenticated" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "member", - "name": "initialized" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "member", - "name": "is_admin" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "member", - "name": "user_id" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "member", - "name": "username" - }, - { - "file": "services/api.ts", - "line": 29, - "kind": "variable", - "name": "verifySession" - }, - { - "file": "services/api.ts", - "line": 290, - "kind": "member", - "name": "show_browser" - }, - { - "file": "services/api.ts", - "line": 295, - "kind": "variable", - "name": "getAllAISettings" - }, - { - "file": "services/api.ts", - "line": 300, - "kind": "variable", - "name": "normalizeOrderStatus" - }, - { - "file": "services/api.ts", - "line": 301, - "kind": "variable", - "name": "status" - }, - { - "file": "services/api.ts", - "line": 308, - "kind": "variable", - "name": "getOrders" - }, - { - "file": "services/api.ts", - "line": 316, - "kind": "variable", - "name": "params" - }, - { - "file": "services/api.ts", - "line": 321, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 324, - "kind": "variable", - "name": "rawOrders" - }, - { - "file": "services/api.ts", - "line": 325, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 325, - "kind": "variable", - "name": "orders" - }, - { - "file": "services/api.ts", - "line": 34, - "kind": "member", - "name": "commit" - }, - { - "file": "services/api.ts", - "line": 34, - "kind": "member", - "name": "version" - }, - { - "file": "services/api.ts", - "line": 341, - "kind": "member", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 341, - "kind": "member", - "name": "success" - }, - { - "file": "services/api.ts", - "line": 341, - "kind": "variable", - "name": "getOrderDetail" - }, - { - "file": "services/api.ts", - "line": 342, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 349, - "kind": "variable", - "name": "updateOrder" - }, - { - "file": "services/api.ts", - "line": 353, - "kind": "variable", - "name": "deleteOrder" - }, - { - "file": "services/api.ts", - "line": 357, - "kind": "variable", - "name": "syncOrders" - }, - { - "file": "services/api.ts", - "line": 358, - "kind": "variable", - "name": "formData" - }, - { - "file": "services/api.ts", - "line": 365, - "kind": "variable", - "name": "syncSingleOrder" - }, - { - "file": "services/api.ts", - "line": 369, - "kind": "variable", - "name": "manualShipOrder" - }, - { - "file": "services/api.ts", - "line": 376, - "kind": "variable", - "name": "importOrders" - }, - { - "file": "services/api.ts", - "line": 377, - "kind": "variable", - "name": "isFormData" - }, - { - "file": "services/api.ts", - "line": 38, - "kind": "variable", - "name": "logout" - }, - { - "file": "services/api.ts", - "line": 382, - "kind": "variable", - "name": "getAdminStats" - }, - { - "file": "services/api.ts", - "line": 386, - "kind": "variable", - "name": "getDashboardStats" - }, - { - "file": "services/api.ts", - "line": 390, - "kind": "member", - "name": "end_date" - }, - { - "file": "services/api.ts", - "line": 390, - "kind": "member", - "name": "start_date" - }, - { - "file": "services/api.ts", - "line": 390, - "kind": "variable", - "name": "getOrderAnalytics" - }, - { - "file": "services/api.ts", - "line": 391, - "kind": "member", - "name": "end_date" - }, - { - "file": "services/api.ts", - "line": 391, - "kind": "member", - "name": "start_date" - }, - { - "file": "services/api.ts", - "line": 391, - "kind": "variable", - "name": "params" - }, - { - "file": "services/api.ts", - "line": 394, - "kind": "variable", - "name": "endDate" - }, - { - "file": "services/api.ts", - "line": 395, - "kind": "variable", - "name": "startDate" - }, - { - "file": "services/api.ts", - "line": 412, - "kind": "member", - "name": "orders" - }, - { - "file": "services/api.ts", - "line": 413, - "kind": "member", - "name": "total" - }, - { - "file": "services/api.ts", - "line": 414, - "kind": "member", - "name": "truncated" - }, - { - "file": "services/api.ts", - "line": 417, - "kind": "member", - "name": "end_date" - }, - { - "file": "services/api.ts", - "line": 417, - "kind": "member", - "name": "start_date" - }, - { - "file": "services/api.ts", - "line": 417, - "kind": "variable", - "name": "getValidOrders" - }, - { - "file": "services/api.ts", - "line": 418, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 42, - "kind": "variable", - "name": "changePassword" - }, - { - "file": "services/api.ts", - "line": 423, - "kind": "variable", - "name": "orders" - }, - { - "file": "services/api.ts", - "line": 424, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 424, - "kind": "variable", - "name": "normalized" - }, - { - "file": "services/api.ts", - "line": 438, - "kind": "variable", - "name": "normalizeCard" - }, - { - "file": "services/api.ts", - "line": 439, - "kind": "variable", - "name": "apiConfig" - }, - { - "file": "services/api.ts", - "line": 450, - "kind": "variable", - "name": "cardPayload" - }, - { - "file": "services/api.ts", - "line": 455, - "kind": "variable", - "name": "getCards" - }, - { - "file": "services/api.ts", - "line": 456, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 457, - "kind": "variable", - "name": "cards" - }, - { - "file": "services/api.ts", - "line": 46, - "kind": "variable", - "name": "updateLoginCredentials" - }, - { - "file": "services/api.ts", - "line": 461, - "kind": "variable", - "name": "createCard" - }, - { - "file": "services/api.ts", - "line": 465, - "kind": "variable", - "name": "updateCard" - }, - { - "file": "services/api.ts", - "line": 469, - "kind": "variable", - "name": "deleteCard" - }, - { - "file": "services/api.ts", - "line": 47, - "kind": "member", - "name": "current_password" - }, - { - "file": "services/api.ts", - "line": 473, - "kind": "variable", - "name": "getCardDetails" - }, - { - "file": "services/api.ts", - "line": 474, - "kind": "variable", - "name": "card" - }, - { - "file": "services/api.ts", - "line": 48, - "kind": "member", - "name": "new_username" - }, - { - "file": "services/api.ts", - "line": 49, - "kind": "member", - "name": "new_password" - }, - { - "file": "services/api.ts", - "line": 497, - "kind": "variable", - "name": "normalizeBooleanFlag" - }, - { - "file": "services/api.ts", - "line": 500, - "kind": "variable", - "name": "getItems" - }, - { - "file": "services/api.ts", - "line": 501, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 502, - "kind": "variable", - "name": "items" - }, - { - "file": "services/api.ts", - "line": 503, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 512, - "kind": "variable", - "name": "syncItemsFromAccount" - }, - { - "file": "services/api.ts", - "line": 516, - "kind": "variable", - "name": "deleteItem" - }, - { - "file": "services/api.ts", - "line": 520, - "kind": "variable", - "name": "createItem" - }, - { - "file": "services/api.ts", - "line": 524, - "kind": "variable", - "name": "publishItem" - }, - { - "file": "services/api.ts", - "line": 525, - "kind": "member", - "name": "cookie_id" - }, - { - "file": "services/api.ts", - "line": 526, - "kind": "member", - "name": "title" - }, - { - "file": "services/api.ts", - "line": 527, - "kind": "member", - "name": "description" - }, - { - "file": "services/api.ts", - "line": 528, - "kind": "member", - "name": "price" - }, - { - "file": "services/api.ts", - "line": 529, - "kind": "member", - "name": "original_price" - }, - { - "file": "services/api.ts", - "line": 530, - "kind": "member", - "name": "quantity" - }, - { - "file": "services/api.ts", - "line": 531, - "kind": "member", - "name": "postage_mode" - }, - { - "file": "services/api.ts", - "line": 532, - "kind": "member", - "name": "postage" - }, - { - "file": "services/api.ts", - "line": 533, - "kind": "member", - "name": "images" - }, - { - "file": "services/api.ts", - "line": 534, - "kind": "member", - "name": "location" - }, - { - "file": "services/api.ts", - "line": 536, - "kind": "variable", - "name": "body" - }, - { - "file": "services/api.ts", - "line": 546, - "kind": "variable", - "name": "file" - }, - { - "file": "services/api.ts", - "line": 55, - "kind": "variable", - "name": "addAccount" - }, - { - "file": "services/api.ts", - "line": 553, - "kind": "member", - "name": "area" - }, - { - "file": "services/api.ts", - "line": 554, - "kind": "member", - "name": "city" - }, - { - "file": "services/api.ts", - "line": 555, - "kind": "member", - "name": "division_id" - }, - { - "file": "services/api.ts", - "line": 556, - "kind": "member", - "name": "longitude" - }, - { - "file": "services/api.ts", - "line": 557, - "kind": "member", - "name": "latitude" - }, - { - "file": "services/api.ts", - "line": 558, - "kind": "member", - "name": "poi_id" - }, - { - "file": "services/api.ts", - "line": 559, - "kind": "member", - "name": "poi_name" - }, - { - "file": "services/api.ts", - "line": 560, - "kind": "member", - "name": "province" - }, - { - "file": "services/api.ts", - "line": 563, - "kind": "variable", - "name": "recommendPublishCategory" - }, - { - "file": "services/api.ts", - "line": 575, - "kind": "variable", - "name": "previewItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 576, - "kind": "member", - "name": "file" - }, - { - "file": "services/api.ts", - "line": 577, - "kind": "member", - "name": "imagesZip" - }, - { - "file": "services/api.ts", - "line": 578, - "kind": "member", - "name": "defaultCookieId" - }, - { - "file": "services/api.ts", - "line": 579, - "kind": "member", - "name": "fallbackCategory" - }, - { - "file": "services/api.ts", - "line": 580, - "kind": "member", - "name": "catId" - }, - { - "file": "services/api.ts", - "line": 581, - "kind": "member", - "name": "catName" - }, - { - "file": "services/api.ts", - "line": 582, - "kind": "member", - "name": "channelCatId" - }, - { - "file": "services/api.ts", - "line": 583, - "kind": "member", - "name": "tbCatId" - }, - { - "file": "services/api.ts", - "line": 585, - "kind": "member", - "name": "location" - }, - { - "file": "services/api.ts", - "line": 587, - "kind": "variable", - "name": "body" - }, - { - "file": "services/api.ts", - "line": 59, - "kind": "variable", - "name": "accountAvatarURL" - }, - { - "file": "services/api.ts", - "line": 599, - "kind": "variable", - "name": "startItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 60, - "kind": "variable", - "name": "raw" - }, - { - "file": "services/api.ts", - "line": 603, - "kind": "variable", - "name": "getItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 607, - "kind": "variable", - "name": "getItemPublishBatches" - }, - { - "file": "services/api.ts", - "line": 608, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 612, - "kind": "variable", - "name": "deleteItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 616, - "kind": "variable", - "name": "cancelItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 620, - "kind": "variable", - "name": "retryFailedItemPublishBatch" - }, - { - "file": "services/api.ts", - "line": 624, - "kind": "variable", - "name": "updateItem" - }, - { - "file": "services/api.ts", - "line": 629, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 637, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 638, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 64, - "kind": "variable", - "name": "url" - }, - { - "file": "services/api.ts", - "line": 642, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 655, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 656, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 657, - "kind": "variable", - "name": "cfg" - }, - { - "file": "services/api.ts", - "line": 674, - "kind": "variable", - "name": "getShippingRules" - }, - { - "file": "services/api.ts", - "line": 675, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 676, - "kind": "variable", - "name": "rules" - }, - { - "file": "services/api.ts", - "line": 681, - "kind": "member", - "name": "cookieId" - }, - { - "file": "services/api.ts", - "line": 682, - "kind": "member", - "name": "triggerType" - }, - { - "file": "services/api.ts", - "line": 683, - "kind": "member", - "name": "enabled" - }, - { - "file": "services/api.ts", - "line": 684, - "kind": "member", - "name": "search" - }, - { - "file": "services/api.ts", - "line": 685, - "kind": "member", - "name": "page" - }, - { - "file": "services/api.ts", - "line": 686, - "kind": "member", - "name": "pageSize" - }, - { - "file": "services/api.ts", - "line": 689, - "kind": "variable", - "name": "getShippingRulesPage" - }, - { - "file": "services/api.ts", - "line": 697, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 705, - "kind": "variable", - "name": "rules" - }, - { - "file": "services/api.ts", - "line": 714, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 719, - "kind": "variable", - "name": "orderAutomationActions" - }, - { - "file": "services/api.ts", - "line": 721, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 723, - "kind": "variable", - "name": "sendCards" - }, - { - "file": "services/api.ts", - "line": 724, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 725, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 726, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 726, - "kind": "variable", - "name": "others" - }, - { - "file": "services/api.ts", - "line": 729, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 734, - "kind": "variable", - "name": "updateShippingRule" - }, - { - "file": "services/api.ts", - "line": 735, - "kind": "variable", - "name": "triggerType" - }, - { - "file": "services/api.ts", - "line": 736, - "kind": "variable", - "name": "triggerName" - }, - { - "file": "services/api.ts", - "line": 74, - "kind": "variable", - "name": "getAccountDetails" - }, - { - "file": "services/api.ts", - "line": 741, - "kind": "variable", - "name": "generatedName" - }, - { - "file": "services/api.ts", - "line": 745, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 745, - "kind": "variable", - "name": "preservedNonCardActions" - }, - { - "file": "services/api.ts", - "line": 746, - "kind": "variable", - "name": "baseActions" - }, - { - "file": "services/api.ts", - "line": 747, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 75, - "kind": "variable", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 76, - "kind": "variable", - "name": "avatarVersion" - }, - { - "file": "services/api.ts", - "line": 767, - "kind": "variable", - "name": "actions" - }, - { - "file": "services/api.ts", - "line": 768, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 77, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 776, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 790, - "kind": "variable", - "name": "deleteShippingRule" - }, - { - "file": "services/api.ts", - "line": 793, - "kind": "member", - "name": "id" - }, - { - "file": "services/api.ts", - "line": 794, - "kind": "member", - "name": "cookie_id" - }, - { - "file": "services/api.ts", - "line": 795, - "kind": "member", - "name": "order_id" - }, - { - "file": "services/api.ts", - "line": 796, - "kind": "member", - "name": "trigger_type" - }, - { - "file": "services/api.ts", - "line": 797, - "kind": "member", - "name": "error_message" - }, - { - "file": "services/api.ts", - "line": 798, - "kind": "member", - "name": "issue_kind" - }, - { - "file": "services/api.ts", - "line": 799, - "kind": "member", - "name": "allowed_resolutions" - }, - { - "file": "services/api.ts", - "line": 800, - "kind": "member", - "name": "action_cursor" - }, - { - "file": "services/api.ts", - "line": 801, - "kind": "member", - "name": "sent_count" - }, - { - "file": "services/api.ts", - "line": 802, - "kind": "member", - "name": "updated_at" - }, - { - "file": "services/api.ts", - "line": 806, - "kind": "member", - "name": "id" - }, - { - "file": "services/api.ts", - "line": 807, - "kind": "member", - "name": "cookie_id" - }, - { - "file": "services/api.ts", - "line": 808, - "kind": "member", - "name": "trigger_type" - }, - { - "file": "services/api.ts", - "line": 809, - "kind": "member", - "name": "error_message" - }, - { - "file": "services/api.ts", - "line": 810, - "kind": "member", - "name": "attempt_count" - }, - { - "file": "services/api.ts", - "line": 811, - "kind": "member", - "name": "updated_at" - }, - { - "file": "services/api.ts", - "line": 814, - "kind": "member", - "name": "pending_tasks" - }, - { - "file": "services/api.ts", - "line": 814, - "kind": "member", - "name": "runs" - }, - { - "file": "services/api.ts", - "line": 814, - "kind": "variable", - "name": "getAutomationIssues" - }, - { - "file": "services/api.ts", - "line": 815, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 822, - "kind": "variable", - "name": "resolveAutomationRun" - }, - { - "file": "services/api.ts", - "line": 825, - "kind": "variable", - "name": "resolveDeferredAutomationTask" - }, - { - "file": "services/api.ts", - "line": 830, - "kind": "member", - "name": "id" - }, - { - "file": "services/api.ts", - "line": 831, - "kind": "member", - "name": "keyword" - }, - { - "file": "services/api.ts", - "line": 832, - "kind": "member", - "name": "reply" - }, - { - "file": "services/api.ts", - "line": 833, - "kind": "member", - "name": "item_id" - }, - { - "file": "services/api.ts", - "line": 834, - "kind": "member", - "name": "type" - }, - { - "file": "services/api.ts", - "line": 835, - "kind": "member", - "name": "image_url" - }, - { - "file": "services/api.ts", - "line": 838, - "kind": "variable", - "name": "normalizeKeywordRow" - }, - { - "file": "services/api.ts", - "line": 847, - "kind": "variable", - "name": "getKeywordRowsWithType" - }, - { - "file": "services/api.ts", - "line": 848, - "kind": "variable", - "name": "existing" - }, - { - "file": "services/api.ts", - "line": 852, - "kind": "variable", - "name": "getReplyRules" - }, - { - "file": "services/api.ts", - "line": 854, - "kind": "variable", - "name": "keywords" - }, - { - "file": "services/api.ts", - "line": 855, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 867, - "kind": "variable", - "name": "updateReplyRule" - }, - { - "file": "services/api.ts", - "line": 868, - "kind": "variable", - "name": "type" - }, - { - "file": "services/api.ts", - "line": 869, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 881, - "kind": "variable", - "name": "deleteReplyRule" - }, - { - "file": "services/api.ts", - "line": 886, - "kind": "variable", - "name": "getSystemSettings" - }, - { - "file": "services/api.ts", - "line": 887, - "kind": "member", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 887, - "kind": "variable", - "name": "res" - }, - { - "file": "services/api.ts", - "line": 891, - "kind": "variable", - "name": "updateSystemSettings" - }, - { - "file": "services/api.ts", - "line": 892, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 893, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 898, - "kind": "variable", - "name": "getAccountAISettings" - }, - { - "file": "services/api.ts", - "line": 902, - "kind": "variable", - "name": "updateAccountAISettings" - }, - { - "file": "services/api.ts", - "line": 903, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 913, - "kind": "variable", - "name": "fetchAIModels" - }, - { - "file": "services/api.ts", - "line": 914, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 922, - "kind": "variable", - "name": "parseNotificationEventTypes" - }, - { - "file": "services/api.ts", - "line": 926, - "kind": "variable", - "name": "parsed" - }, - { - "file": "services/api.ts", - "line": 931, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 934, - "kind": "variable", - "name": "stringifyNotificationEventTypes" - }, - { - "file": "services/api.ts", - "line": 935, - "kind": "variable", - "name": "clean" - }, - { - "file": "services/api.ts", - "line": 939, - "kind": "member", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 939, - "kind": "member", - "name": "success" - }, - { - "file": "services/api.ts", - "line": 939, - "kind": "variable", - "name": "getNotificationChannels" - }, - { - "file": "services/api.ts", - "line": 940, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 941, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "services/api.ts", - "line": 941, - "kind": "variable", - "name": "channels" - }, - { - "file": "services/api.ts", - "line": 942, - "kind": "variable", - "name": "parsedConfig" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "member", - "name": "config" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "member", - "name": "enabled" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "member", - "name": "event_types" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "member", - "name": "name" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "member", - "name": "type" - }, - { - "file": "services/api.ts", - "line": 962, - "kind": "variable", - "name": "createNotificationChannel" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "member", - "name": "config" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "member", - "name": "enabled" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "member", - "name": "event_types" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "member", - "name": "name" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "member", - "name": "type" - }, - { - "file": "services/api.ts", - "line": 970, - "kind": "variable", - "name": "updateNotificationChannel" - }, - { - "file": "services/api.ts", - "line": 971, - "kind": "variable", - "name": "payload" - }, - { - "file": "services/api.ts", - "line": 981, - "kind": "variable", - "name": "deleteNotificationChannel" - }, - { - "file": "services/api.ts", - "line": 986, - "kind": "member", - "name": "data" - }, - { - "file": "services/api.ts", - "line": 986, - "kind": "member", - "name": "success" - }, - { - "file": "services/api.ts", - "line": 986, - "kind": "variable", - "name": "getMessageNotifications" - }, - { - "file": "services/api.ts", - "line": 987, - "kind": "variable", - "name": "result" - }, - { - "file": "services/api.ts", - "line": 988, - "kind": "variable", - "name": "notifications" - }, - { - "file": "services/api.ts", - "line": 989, - "kind": "variable", - "name": "[cookieId, channelList]" - }, - { - "file": "services/api.ts", - "line": 991, - "kind": "variable", - "name": "item" - }, { "file": "smtpSettings.test.ts", "line": 12, diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index 77c9adb..15bd3a6 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -625,3 +625,4 @@ npm --prefix frontend run build | 2026-08-15 | 完成阶段 9 第三个 PR 切片“账号 cookie/note 兼容字段调用方清理” | `AccountDetail` 移除历史 `cookie`/`note` 别名,账号详情归一化、搜索/展示、编辑回填和运行状态测试统一使用 `value`/`remark`;编辑表单的 `cookie` 保留为真实用户输入字段;前端类型检查、184 个测试、注释检查、仓库 `make check` 和生产构建通过,嵌入式 bundle 已同步并合并为一个可回滚提交 | 阶段 9:旧路由与剩余兼容字段最终审计 | | 2026-08-15 | 完成阶段 9 第四个 PR 切片“旧路由与剩余兼容字段最终审计” | 新增 API 兼容边界清单,明确旧服务端入口的保留条件、复用 handler 约束和删除证据要求;新增 React 架构测试,禁止生产 API 适配层重新调用未版本化 `/api/...` 路径;服务端新旧入口契约测试继续覆盖兼容行为,前端 185 个测试、类型检查和注释门禁通过并合并为一个可回滚提交 | 阶段 10:注释基线清零与严格门禁 | | 2026-08-15 | 完成阶段 10 第一个 PR 切片“前端共享 types.ts 注释基线清零” | 为分页、会话、账号、聊天、订单、卡券、商品、自动化规则、统计、设置、AI、默认回复和通知 DTO 的全部字段补齐准确中文注释,解释字段职责、敏感性、状态和时间/数量单位;`frontend/types.ts` 历史注释基线清零,前端注释门禁、类型检查、185 个测试和生产构建通过并合并为一个可回滚提交 | 阶段 10:前端 services/api.ts 注释基线清零 | +| 2026-08-15 | 完成阶段 10 第二个 PR 切片“前端 services/api.ts 注释基线清零” | 为 API 适配层全部导出函数、局部变量、请求参数和内联响应字段补齐中文注释,明确认证、账号、聊天、订单、商品、卡密、自动化、设置和通知接口的数据职责;增强注释检查器对调用参数、类型字面量和循环变量内联注释的识别能力,`services/api.ts` 注释基线清零;前端注释门禁、类型检查和 185 个测试通过并合并为一个可回滚提交 | 阶段 10:前端 components/hooks 注释基线按领域清零 | diff --git a/frontend/scripts/check-comments.mjs b/frontend/scripts/check-comments.mjs index ddcc480..24cadaa 100644 --- a/frontend/scripts/check-comments.mjs +++ b/frontend/scripts/check-comments.mjs @@ -92,11 +92,23 @@ function hasChineseComment(sourceFile, node) { } // trailingRanges 允许同一行的行尾注释为短小声明提供说明。 const trailingRanges = ts.getTrailingCommentRanges(sourceText, anchor.end) ?? []; - return trailingRanges.some((range) => { + if (trailingRanges.some((range) => { // commentStartLine 是行尾注释起始所在的零基行号。 const commentStartLine = sourceFile.getLineAndCharacterOfPosition(range.pos).line; return commentStartLine === startLine && HAN_PATTERN.test(sourceText.slice(range.pos, range.end)); - }); + })) { + return true; + } + // inlinePrefix 是节点前方紧邻的内联注释,用于支持调用参数和类型字面量中的字段注释。 + const inlinePrefix = sourceText.slice(Math.max(0, node.getStart(sourceFile) - 200), node.getStart(sourceFile)); + const prefixMatch = inlinePrefix.match(/(?:\/\*[\s\S]*?\*\/|\/\/[^\n]*)\s*$/); + if (prefixMatch && HAN_PATTERN.test(prefixMatch[0])) { + return true; + } + // inlineSuffix 是节点结束位置紧邻的内联注释,用于支持循环变量和行尾字段注释。 + const inlineSuffix = sourceText.slice(node.end, Math.min(sourceText.length, node.end + 200)); + const suffixMatch = inlineSuffix.match(/^\s*(?:\/\*[\s\S]*?\*\/|\/\/[^\n]*)/); + return Boolean(suffixMatch && HAN_PATTERN.test(suffixMatch[0])); } // getNodeName 返回 AST 节点的可读名称。 diff --git a/frontend/services/api.ts b/frontend/services/api.ts index 79d5a9d..ed7fd0f 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -8,9 +8,12 @@ import { } from '../types'; import { formatLocalDate } from '../dateRange'; +// normalizeSettings 归一化系统配置。 const normalizeSettings = (settings: Record): SystemSettings => { + // out 配置副本,用于当前 API 处理流程。 const out: Record = { ...settings }; if ('renewal_log_retention_days' in out) { + // parsed 转换后的数值,用于当前 API 处理流程。 const parsed = Number(out.renewal_log_retention_days); out.renewal_log_retention_days = Number.isFinite(parsed) ? parsed : 10; } @@ -18,49 +21,59 @@ const normalizeSettings = (settings: Record): SystemSettings => { }; // Auth -export const login = async (data: { username?: string; password?: string; email?: string; verification_code?: string }): Promise => { +// login 登录,用于当前 API 处理流程。 +export const login = async (data: { /** username 表示用户名。 */ username?: string; /** password 表示密码。 */ password?: string; /** email 表示邮箱。 */ email?: string; /** verification_code 表示登录验证码。 */ verification_code?: string }): Promise => { return post('/api/v1/session/login', data, { skipAuthLogout: true }); }; +// initializeAdmin 初始化管理员并建立会话。 export const initializeAdmin = async (password: string): Promise => { return post('/api/v1/session/initialize', { password }, { skipAuthLogout: true }); }; -export const verifySession = async (options?: RequestControlOptions): Promise<{ authenticated: boolean; initialized?: boolean; user_id?: number; username?: string; is_admin?: boolean }> => { +// verifySession 验证会话。 +export const verifySession = async (options?: RequestControlOptions): Promise<{ /** authenticated 表示当前会话是否已认证。 */ authenticated: boolean; /** initialized 表示系统是否已完成初始化。 */ initialized?: boolean; /** user_id 表示当前用户标识。 */ user_id?: number; /** username 表示用户名。 */ username?: string; /** is_admin 表示当前用户是否为管理员。 */ is_admin?: boolean }> => { return get('/api/v1/session', undefined, options); }; // getHealth 读取服务健康检查和构建版本信息。 -export const getHealth = async (options?: RequestControlOptions): Promise<{ version?: string; commit?: string }> => { +export const getHealth = async (options?: RequestControlOptions): Promise<{ /** version 表示版本。 */ version?: string; /** commit 表示提交版本。 */ commit?: string }> => { return get('/health', undefined, options); }; +// logout 注销当前会话。 export const logout = async (): Promise => { return post('/api/v1/session/logout', {}); }; +// changePassword 修改当前用户密码。 export const changePassword = async (currentPassword: string, newPassword: string): Promise => { return post('/api/v1/session/password', { current_password: currentPassword, new_password: newPassword }); }; +// updateLoginCredentials 更新当前用户登录凭据。 export const updateLoginCredentials = async (data: { - current_password: string; - new_username: string; - new_password?: string; + /** current_password 表示当前密码。 */ current_password: string; + /** new_username 表示新用户名。 */ new_username: string; + /** new_password 表示新密码。 */ new_password?: string; }, options?: RequestControlOptions): Promise => { return put('/api/v1/session/credentials', data, options); }; // Accounts +// addAccount 新增账号。 export const addAccount = async (id: string, value: string, loginMethod?: string): Promise => { return post('/api/v1/accounts', { id, value, login_method: loginMethod }); }; +// accountAvatarURL 生成账号头像地址。 const accountAvatarURL = (item: AccountSummaryResponse, version: string): string => { + // raw 原始值,用于当前 API 处理流程。 const raw = item.avatar_url || ''; if (!raw) return ''; try { + // url 解析后的地址,用于当前 API 处理流程。 const url = new URL(raw, window.location.origin); if (url.hostname.endsWith('alicdn.com')) { url.searchParams.set('_v', version); @@ -71,10 +84,13 @@ const accountAvatarURL = (item: AccountSummaryResponse, version: string): string } }; +// getAccountDetails 读取账号详情。 export const getAccountDetails = async (options?: RequestControlOptions): Promise => { + // data 数据,用于当前 API 处理流程。 const data = await get('/api/v1/accounts/details', undefined, options); + // avatarVersion 头像缓存版本,用于当前 API 处理流程。 const avatarVersion = Date.now().toString(); - return data.map(item => ({ + return data.map(/* 当前回调用于处理集合元素或接口响应。 */ item => ({ id: item.id, value: '', enabled: item.enabled, @@ -100,81 +116,98 @@ export const getAccountDetails = async (options?: RequestControlOptions): Promis })); }; +// getAccountTaskSettings 读取账号计划任务设置。 export const getAccountTaskSettings = async (id: string, options?: RequestControlOptions): Promise => get(`/api/v1/account-tasks/${id}`, undefined, options); +// updateAccountTaskSettings 更新账号计划任务设置。 export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings, options?: RequestControlOptions): Promise => put(`/api/v1/account-tasks/${id}`, settings, options); +// runAccountTask 立即执行账号计划任务。 export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish', options?: RequestControlOptions): Promise => post(`/api/v1/account-tasks/${id}/run`, { task_type: taskType }, { timeoutMs: 120_000, ...options }); -export interface ChatSessionPage { sessions: ChatSession[]; has_more: boolean; next_cursor?: number } +export interface ChatSessionPage { /** sessions 表示聊天会话列表。 */ sessions: ChatSession[]; /** has_more 表示是否存在更多数据。 */ has_more: boolean; /** next_cursor 表示下一页游标。 */ next_cursor?: number } +// getChatSessionPage 分页读取聊天会话。 export const getChatSessionPage = async (accountId: string, cursor?: number, options?: RequestControlOptions, refresh = false): Promise => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get('/api/v1/chat/sessions', { account_id: accountId, cursor, refresh: refresh ? 1 : undefined }, refresh ? { timeoutMs: 60_000, ...options } : options); return { sessions: result.sessions || [], has_more: result.has_more === true, next_cursor: result.next_cursor }; }; +// getChatSessions 读取聊天会话列表。 export const getChatSessions = async (accountId: string, options?: RequestControlOptions): Promise => (await getChatSessionPage(accountId, undefined, options)).sessions; export interface ChatMessagePage { - messages: ChatMessage[]; - has_more: boolean; - next_cursor?: number; - session?: ChatSession; + /** messages 表示聊天消息列表。 */ messages: ChatMessage[]; + /** has_more 表示是否存在更多数据。 */ has_more: boolean; + /** next_cursor 表示下一页游标。 */ next_cursor?: number; + /** session 表示会话。 */ session?: ChatSession; } +// getChatMessagePage 分页读取聊天消息。 export const getChatMessagePage = async (accountId: string, chatId: string, cursor?: number, beforeId?: number, options?: RequestControlOptions): Promise => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get('/api/v1/chat/messages', { account_id: accountId, chat_id: chatId, cursor, before_id: beforeId, }, options); return { messages: result.messages || [], has_more: result.has_more === true, next_cursor: result.next_cursor, session: result.session }; }; +// getChatMessages 读取聊天消息列表。 export const getChatMessages = async (accountId: string, chatId: string, beforeId?: number, options?: RequestControlOptions): Promise => (await getChatMessagePage(accountId, chatId, undefined, beforeId, options)).messages; +// sendChatMessage 发送聊天文本消息。 export const sendChatMessage = async (input: { - account_id: string; chat_id: string; buyer_id: string; buyer_name?: string; - item_id?: string; item_title?: string; text: string; -}, options?: RequestControlOptions): Promise<{message: ChatMessage}> => post('/api/v1/chat/messages', input, options); + /** account_id 表示账号标识。 */ account_id: string; /** chat_id 表示聊天标识。 */ chat_id: string; /** buyer_id 表示买家标识。 */ buyer_id: string; /** buyer_name 表示买家名称。 */ buyer_name?: string; + /** item_id 表示商品标识。 */ item_id?: string; /** item_title 表示商品标题。 */ item_title?: string; /** text 表示文本。 */ text: string; +}, options?: RequestControlOptions): Promise<{/** message 表示消息数据。 */ message: ChatMessage}> => post('/api/v1/chat/messages', input, options); +// sendChatImage 发送聊天图片消息。 export const sendChatImage = async (input: { - account_id: string; chat_id: string; buyer_id: string; buyer_name?: string; - buyer_avatar_url?: string; item_id?: string; item_title?: string; image: File; -}, options?: RequestControlOptions): Promise<{message: ChatMessage}> => { + /** account_id 表示账号标识。 */ account_id: string; /** chat_id 表示聊天标识。 */ chat_id: string; /** buyer_id 表示买家标识。 */ buyer_id: string; /** buyer_name 表示买家名称。 */ buyer_name?: string; + /** buyer_avatar_url 表示买家头像地址。 */ buyer_avatar_url?: string; /** item_id 表示商品标识。 */ item_id?: string; /** item_title 表示商品标题。 */ item_title?: string; /** image 表示图片数据。 */ image: File; +}, options?: RequestControlOptions): Promise<{/** message 表示消息数据。 */ message: ChatMessage}> => { + // form 消息表单,用于当前 API 处理流程。 const form = new FormData(); - Object.entries(input).forEach(([key, value]) => form.append(key, value)); + Object.entries(input).forEach(/* 当前回调用于处理集合元素或接口响应。 */ ([key, value]) => form.append(key, value)); return postForm('/api/v1/chat/images', form, { timeoutMs: 120_000, ...options }); }; +// markChatRead 标记聊天消息已读。 export const markChatRead = async (accountId: string, chatId: string, options?: RequestControlOptions): Promise => post('/api/v1/chat/read', { account_id: accountId, chat_id: chatId }, options); export interface AccountRuntimeStatus { - state: NonNullable; - message?: string; - connected: boolean; - failures: number; - updated_at: string; + /** state 表示状态。 */ state: NonNullable; + /** message 表示消息数据。 */ message?: string; + /** connected 表示连接状态。 */ connected: boolean; + /** failures 表示失败次数。 */ failures: number; + /** updated_at 表示最后更新时间。 */ updated_at: string; } +// getAccountRuntimeStatuses 读取账号运行状态。 export const getAccountRuntimeStatuses = async (options?: RequestControlOptions): Promise> => { return get('/api/v1/accounts/runtime-status', undefined, options); }; +// generateQRLogin 生成二维码登录会话。 export const generateQRLogin = async (options?: RequestControlOptions): Promise => { // 风控后匿名 token 接口可能超过通用的 30 秒请求窗口;后端总生成窗口为 2 分钟。 return post('/api/v1/qr-login/generate', undefined, { ...options, timeoutMs: options?.timeoutMs ?? 130_000 }); }; +// checkQRLoginStatus 查询二维码登录状态。 export const checkQRLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise => { return get(`/api/v1/qr-login/check/${sessionId}`, undefined, { signal, timeoutMs: 10_000 }); }; +// completeQRVerification 完成二维码登录验证。 export const completeQRVerification = async ( sessionId: string, targetAccountId?: string, @@ -189,115 +222,132 @@ export const completeQRVerification = async ( +// updateAccountStatus 更新账号状态。 export const updateAccountStatus = async (id: string, enabled: boolean): Promise => { return put(`/api/v1/accounts/${id}/status`, { enabled }); }; +// deleteAccount 删除账号。 export const deleteAccount = async (id: string): Promise => { return del(`/api/v1/accounts/${id}`); }; +// updateAccountRemark 更新账号备注。 export const updateAccountRemark = async (id: string, remark: string): Promise => { return put(`/api/v1/accounts/${id}/remark`, { remark }); }; +// updateAccountAutoConfirm 更新账号自动确认设置。 export const updateAccountAutoConfirm = async (id: string, autoConfirm: boolean): Promise => { return put(`/api/v1/accounts/${id}/auto-confirm`, { auto_confirm: autoConfirm }); }; +// updateAccountPauseDuration 更新账号暂停时长。 export const updateAccountPauseDuration = async (id: string, pauseDuration: number, options?: RequestControlOptions): Promise => { return put(`/api/v1/accounts/${id}/pause-duration`, { pause_duration: pauseDuration }, options); }; +// updateAccountCookie 更新账号登录凭证。 export const updateAccountCookie = async (id: string, value: string, loginMethod?: string): Promise => { return put(`/api/v1/accounts/${id}`, { id, value, login_method: loginMethod }); }; export interface AccountSettingsUpdate { - cookie?: string; - remark?: string; - auto_confirm?: boolean; - pause_duration?: number; - username?: string; - login_password?: string; - clear_password?: boolean; - show_browser?: boolean; - channel_ids?: number[]; + /** cookie 表示登录凭证。 */ cookie?: string; + /** remark 表示备注。 */ remark?: string; + /** auto_confirm 表示自动确认状态。 */ auto_confirm?: boolean; + /** pause_duration 表示暂停时长。 */ pause_duration?: number; + /** username 表示用户名。 */ username?: string; + /** login_password 表示登录密码。 */ login_password?: string; + /** clear_password 表示是否清理登录密码。 */ clear_password?: boolean; + /** show_browser 表示是否显示浏览器。 */ show_browser?: boolean; + /** channel_ids 表示通知渠道标识列表。 */ channel_ids?: number[]; } +// updateAccountSettings 更新账号设置。 export const updateAccountSettings = async (id: string, data: AccountSettingsUpdate, options?: RequestControlOptions): Promise => { return put(`/api/v1/accounts/${id}/settings`, data, options); }; export interface LongLoginSettings { - can_open_long_login: boolean; - enabled: boolean; + /** can_open_long_login 表示是否允许开启长期登录。 */ can_open_long_login: boolean; + /** enabled 表示启用状态。 */ enabled: boolean; } +// getLongLoginSettings 读取长期登录设置。 export const getLongLoginSettings = async (id: string, options?: RequestControlOptions): Promise => { return get(`/api/v1/accounts/${id}/long-login`, undefined, options); }; +// setLongLoginSettings 设置长期登录开关。 export const setLongLoginSettings = async (id: string, enabled: boolean, options?: RequestControlOptions): Promise => { return put(`/api/v1/accounts/${id}/long-login`, { enabled }, options); }; export interface PasswordLoginStartResponse { - success: boolean; - session_id?: string; - status?: 'processing' | 'failed'; - message?: string; + /** success 表示是否成功。 */ success: boolean; + /** session_id 表示会话标识。 */ session_id?: string; + /** status 表示状态值。 */ status?: 'processing' | 'failed'; + /** message 表示消息数据。 */ message?: string; } export interface PasswordLoginStatusResponse { - status: 'processing' | 'success' | 'failed' | 'verification_required' | 'not_found' | 'error'; - message?: string; - account_id?: string; - is_new_account?: boolean; - cookie_count?: number; - verification_url?: string; - screenshot_path?: string; - qr_code_url?: string; - error?: string; - reason?: string; + /** status 表示状态值。 */ status: 'processing' | 'success' | 'failed' | 'verification_required' | 'not_found' | 'error'; + /** message 表示消息数据。 */ message?: string; + /** account_id 表示账号标识。 */ account_id?: string; + /** is_new_account 表示是否为新账号。 */ is_new_account?: boolean; + /** cookie_count 表示登录凭证数量。 */ cookie_count?: number; + /** verification_url 表示验证地址。 */ verification_url?: string; + /** screenshot_path 表示验证截图路径。 */ screenshot_path?: string; + /** qr_code_url 表示二维码地址。 */ qr_code_url?: string; + /** error 表示错误信息。 */ error?: string; + /** reason 表示失败原因。 */ reason?: string; } +// passwordLogin 执行密码登录。 export const passwordLogin = async (data: { - account_id: string; - account: string; - password: string; - show_browser?: boolean; + /** account_id 表示账号标识。 */ account_id: string; + /** account 表示账号。 */ account: string; + /** password 表示密码。 */ password: string; + /** show_browser 表示是否显示浏览器。 */ show_browser?: boolean; }, options?: RequestControlOptions): Promise => { return post('/api/v1/password-login', data, options); }; +// checkPasswordLoginStatus 查询密码登录状态。 export const checkPasswordLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise => { return get(`/api/v1/password-login/check/${sessionId}`, undefined, { signal, timeoutMs: 10_000 }); }; +// cancelPasswordLogin 取消密码登录。 export const cancelPasswordLogin = async (sessionId: string, options?: RequestControlOptions): Promise => { return del(`/api/v1/password-login/cancel/${sessionId}`, undefined, options); }; +// refreshAccountProfile 刷新账号资料。 export const refreshAccountProfile = async (id: string): Promise => { return post(`/api/v1/accounts/${id}/refresh-profile`, {}); }; +// updateAccountLoginInfo 更新账号登录信息。 export const updateAccountLoginInfo = async (id: string, data: { - username?: string; - login_password?: string; - clear_password?: boolean; - show_browser?: boolean; + /** username 表示用户名。 */ username?: string; + /** login_password 表示登录密码。 */ login_password?: string; + /** clear_password 表示是否清理登录密码。 */ clear_password?: boolean; + /** show_browser 表示是否显示浏览器。 */ show_browser?: boolean; }): Promise => { return put(`/api/v1/accounts/${id}/login-info`, data); }; +// getAllAISettings 读取全部人工智能设置。 export const getAllAISettings = async (options?: RequestControlOptions): Promise> => { return get('/api/v1/settings/ai-reply', undefined, options); }; // Orders +// normalizeOrderStatus 归一化订单状态。 const normalizeOrderStatus = (value: unknown): Order['status'] => { + // status 状态值,用于当前 API 处理流程。 const status = String(value || ''); if (status === 'paid') return 'pending_ship'; return ['processing', 'pending_ship', 'shipped', 'completed', 'cancelled', 'refunding'].includes(status) @@ -305,6 +355,7 @@ const normalizeOrderStatus = (value: unknown): Order['status'] => { : 'unknown'; }; +// getOrders 读取订单列表。 export const getOrders = async ( cookieId?: string, status?: string, @@ -313,16 +364,20 @@ export const getOrders = async ( search?: string, options?: RequestControlOptions, ): Promise> => { + // params 请求参数,用于当前 API 处理流程。 const params: any = { page, page_size: pageSize }; if (cookieId) params.cookie_id = cookieId; if (status && status !== 'all') params.status = status; if (search?.trim()) params.search = search.trim(); + // res 接口响应结果,用于当前 API 处理流程。 const res = await get & { orders?: Order[] /* 后端兼容的订单列表字段。 */ }>('/api/v1/orders', params, options); // Handle backend response variations + // rawOrders 原始订单列表,用于当前 API 处理流程。 const rawOrders = res.orders || res.data || []; - const orders = rawOrders.map((item: any) => ({ + // orders 订单列表,用于当前 API 处理流程。 + const orders = rawOrders.map(/* 当前回调用于处理集合元素或接口响应。 */ (item: any) => ({ ...item, id: item.id || item.order_id, status: normalizeOrderStatus(item.status || item.order_status), @@ -338,7 +393,9 @@ export const getOrders = async ( }; }; -export const getOrderDetail = async (orderId: string): Promise<{ success: boolean; data?: OrderDTOResponse }> => { +// getOrderDetail 读取订单详情。 +export const getOrderDetail = async (orderId: string): Promise<{ /** success 表示是否成功。 */ success: boolean; /** data 表示数据。 */ data?: OrderDTOResponse }> => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get(`/api/v1/orders/${orderId}`); return { success: true, @@ -346,15 +403,19 @@ export const getOrderDetail = async (orderId: string): Promise<{ success: boolea }; }; +// updateOrder 更新订单。 export const updateOrder = async (orderId: string, data: Partial): Promise => { return put(`/api/v1/orders/${orderId}`, data); }; +// deleteOrder 删除订单。 export const deleteOrder = async (orderId: string): Promise => { return del(`/api/v1/orders/${orderId}`); }; +// syncOrders 同步订单。 export const syncOrders = async (cookieId?: string, status?: string): Promise => { + // formData 表单数据,用于当前 API 处理流程。 const formData = new FormData(); if (cookieId) formData.append('cookie_id', cookieId); if (status) formData.append('status', status); @@ -362,10 +423,12 @@ export const syncOrders = async (cookieId?: string, status?: string): Promise => { return post(`/api/v1/orders/${orderId}/refresh`); }; +// manualShipOrder 手动发货订单。 export const manualShipOrder = async (orderIds: string[], shipMode: 'status_only' | 'full_delivery'): Promise => { return post('/api/v1/orders/manual-ship', { order_ids: orderIds, @@ -373,25 +436,33 @@ export const manualShipOrder = async (orderIds: string[], shipMode: 'status_only }); } +// importOrders 导入订单。 export const importOrders = async (data: Partial[] | FormData, options?: RequestControlOptions): Promise => { + // isFormData 是否为表单请求,用于当前 API 处理流程。 const isFormData = data instanceof FormData; return isFormData ? postForm('/api/v1/orders/import', data, options) : post('/api/v1/orders/import', data, options); } // Stats +// getAdminStats 读取管理员统计数据。 export const getAdminStats = async (): Promise => { return get('/api/v1/admin/stats'); }; +// getDashboardStats 读取仪表盘统计数据。 export const getDashboardStats = async (options?: RequestControlOptions): Promise => { return get('/api/v1/analytics/dashboard', undefined, options); }; -export const getOrderAnalytics = async (daysOrParams: number | {start_date: string; end_date: string} = 7, options?: RequestControlOptions): Promise => { - let params: {start_date: string; end_date: string}; +// getOrderAnalytics 读取订单分析数据。 +export const getOrderAnalytics = async (daysOrParams: number | {/** start_date 表示开始日期。 */ start_date: string; /** end_date 表示结束日期。 */ end_date: string} = 7, options?: RequestControlOptions): Promise => { + // params 请求参数,用于当前 API 处理流程。 + let params: {/** start_date 表示开始日期。 */ start_date: string; /** end_date 表示结束日期。 */ end_date: string}; if (typeof daysOrParams === 'number') { + // endDate 结束日期,用于当前 API 处理流程。 const endDate = new Date(); + // startDate 启动日期。 const startDate = new Date(); startDate.setDate(startDate.getDate() - daysOrParams); params = { @@ -409,19 +480,23 @@ export const getOrderAnalytics = async (daysOrParams: number | {start_date: stri } export interface ValidOrdersResult { - orders: Order[]; - total: number; - truncated: boolean; + /** orders 表示订单列表。 */ orders: Order[]; + /** total 表示总数。 */ total: number; + /** truncated 表示是否截断。 */ truncated: boolean; } -export const getValidOrders = async (dateRange: {start_date: string; end_date: string}, options?: RequestControlOptions): Promise => { +// getValidOrders 读取有效订单列表。 +export const getValidOrders = async (dateRange: {/** start_date 表示开始日期。 */ start_date: string; /** end_date 表示结束日期。 */ end_date: string}, options?: RequestControlOptions): Promise => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/analytics/orders/valid', { start_date: dateRange.start_date, end_date: dateRange.end_date, timezone_offset_minutes: -new Date().getTimezoneOffset(), }, options); + // orders 订单列表,用于当前 API 处理流程。 const orders = Array.isArray(res) ? res : (res.orders || []); - const normalized = orders.map((order: any) => ({ + // normalized 归一化结果,用于当前 API 处理流程。 + const normalized = orders.map(/* 当前回调用于处理集合元素或接口响应。 */ (order: any) => ({ ...order, id: order.id || order.order_id, status: normalizeOrderStatus(order.status || order.order_status), @@ -435,7 +510,9 @@ export const getValidOrders = async (dateRange: {start_date: string; end_date: s } // Cards +// normalizeCard 归一化卡密数据。 const normalizeCard = (item: any): Card => { + // apiConfig 卡密接口配置,用于当前 API 处理流程。 let apiConfig = item.api_config; if (typeof apiConfig === 'string' && apiConfig.trim()) { try { @@ -447,30 +524,39 @@ const normalizeCard = (item: any): Card => { return {...item, api_config: apiConfig || undefined} as Card; }; +// cardPayload 卡密请求载荷,用于当前 API 处理流程。 const cardPayload = (data: Partial): Record => ({ ...data, api_config: data.api_config ? JSON.stringify(data.api_config) : '', }); +// getCards 读取卡密列表。 export const getCards = async (options?: RequestControlOptions): Promise => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/cards', undefined, options); + // cards 卡密列表,用于当前 API 处理流程。 const cards = Array.isArray(res) ? res : (res.cards || []); return cards.map(normalizeCard); }; +// createCard 创建卡密组。 export const createCard = async (data: Partial): Promise => { return post('/api/v1/cards', cardPayload(data)); }; +// updateCard 更新卡密组。 export const updateCard = async (cardId: string | number, data: Partial): Promise => { return put(`/api/v1/cards/${cardId}`, cardPayload(data)); }; +// deleteCard 删除卡密组。 export const deleteCard = async (cardId: string | number): Promise => { return del(`/api/v1/cards/${cardId}`); }; +// getCardDetails 读取卡密组详情。 export const getCardDetails = async (cardId: string | number): Promise => { + // card 卡密详情,用于当前 API 处理流程。 const card = await get(`/api/v1/cards/${cardId}/details`); return normalizeCard(card); }; @@ -494,13 +580,17 @@ export const appendCardData = async (cardId: string | number, content: string, o }; // Items +// normalizeBooleanFlag 归一化布尔标记。 const normalizeBooleanFlag = (value: unknown): boolean => value === true || value === 1 || value === '1'; +// getItems 读取商品列表。 export const getItems = async (cookieId?: string, options?: RequestControlOptions): Promise => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/items', cookieId ? { cookie_id: cookieId } : undefined, options); + // items 商品列表,用于当前 API 处理流程。 const items = Array.isArray(res) ? res : (res.items || []); - return items.map((item: any) => ({ + return items.map(/* 当前回调用于处理集合元素或接口响应。 */ (item: any) => ({ ...item, id: item.id || `${item.cookie_id}-${item.item_id}`, is_multi_spec: normalizeBooleanFlag(item.is_multi_spec), @@ -509,30 +599,35 @@ export const getItems = async (cookieId?: string, options?: RequestControlOption })); } +// syncItemsFromAccount 从账号同步商品。 export const syncItemsFromAccount = async (cookieId: string): Promise => { return post('/api/v1/items/get-all-from-account', { cookie_id: cookieId }); } +// deleteItem 删除商品。 export const deleteItem = async (cookieId: string, itemId: string): Promise => { return del(`/api/v1/items/${cookieId}/${itemId}`); } +// createItem 创建商品。 export const createItem = async (cookieId: string, data: Partial): Promise => { return post(`/api/v1/items/${cookieId}`, data); } +// publishItem 发布商品。 export const publishItem = async (form: { - cookie_id: string; - title: string; - description: string; - price: string; - original_price?: string; - quantity: string | number; - postage_mode: string; - postage?: string; - images: File[]; - location?: PublishLocation; + /** cookie_id 表示登录凭证标识。 */ cookie_id: string; + /** title 表示标题。 */ title: string; + /** description 表示描述。 */ description: string; + /** price 表示售价。 */ price: string; + /** original_price 表示原始售价。 */ original_price?: string; + /** quantity 表示数量。 */ quantity: string | number; + /** postage_mode 表示运费模式。 */ postage_mode: string; + /** postage 表示运费。 */ postage?: string; + /** images 表示图片列表。 */ images: File[]; + /** location 表示地址。 */ location?: PublishLocation; }): Promise => { + // body 请求体,用于当前 API 处理流程。 const body = new FormData(); body.set('cookie_id', form.cookie_id); body.set('title', form.title); @@ -543,23 +638,25 @@ export const publishItem = async (form: { body.set('postage_mode', form.postage_mode); body.set('postage', form.postage || ''); if (form.location) body.set('location', JSON.stringify(form.location)); - for (const file of form.images) { + for (const // file 上传文件,用于当前 API 处理流程。 +file of form.images) { body.append('images', file); } return postForm('/api/v1/items/publish', body); } export interface PublishLocation { - area: string; - city: string; - division_id: string; - longitude: number; - latitude: number; - poi_id: string; - poi_name: string; - province: string; + /** area 表示地区。 */ area: string; + /** city 表示城市。 */ city: string; + /** division_id 表示行政区划标识。 */ division_id: string; + /** longitude 表示经度。 */ longitude: number; + /** latitude 表示纬度。 */ latitude: number; + /** poi_id 表示地点标识。 */ poi_id: string; + /** poi_name 表示地点名称。 */ poi_name: string; + /** province 表示省份。 */ province: string; } +// recommendPublishCategory 推荐商品发布分类。 export const recommendPublishCategory = async (cookieId: string, keyword: string): Promise => { // 类目推荐成功响应使用共享 CategoryRecommendationResponse。 // category 字段保留平台类目 ID、名称和频道类目 ID。 @@ -572,18 +669,20 @@ export const recommendPublishCategory = async (cookieId: string, keyword: string return post('/api/v1/items/publish-categories/recommend', { cookie_id: cookieId, keyword }); }; +// previewItemPublishBatch 预览商品批量发布。 export const previewItemPublishBatch = async (form: { - file: File; - imagesZip?: File | null; - defaultCookieId?: string; - fallbackCategory: { - catId: string; - catName: string; - channelCatId?: string; - tbCatId?: string; + /** file 表示上传文件。 */ file: File; + /** imagesZip 表示图片压缩包。 */ imagesZip?: File | null; + /** defaultCookieId 表示默认账号凭证标识。 */ defaultCookieId?: string; + /** fallbackCategory 表示备用分类。 */ fallbackCategory: { + /** catId 表示分类标识。 */ catId: string; + /** catName 表示分类名称。 */ catName: string; + /** channelCatId 表示渠道分类标识。 */ channelCatId?: string; + /** tbCatId 表示淘宝分类标识。 */ tbCatId?: string; }; - location?: PublishLocation; + /** location 表示地址。 */ location?: PublishLocation; }): Promise => { + // body 请求体,用于当前 API 处理流程。 const body = new FormData(); body.set('file', form.file); if (form.imagesZip) body.set('images_zip', form.imagesZip); @@ -596,37 +695,45 @@ export const previewItemPublishBatch = async (form: { return postForm('/api/v1/items/publish-batches/preview', body); } +// startItemPublishBatch 启动商品批量发布。 export const startItemPublishBatch = async (previewId: string): Promise => { return post('/api/v1/items/publish-batches', { preview_id: previewId }); } +// getItemPublishBatch 读取商品发布批次。 export const getItemPublishBatch = async (batchId: string): Promise => { return get(`/api/v1/items/publish-batches/${batchId}`); } +// getItemPublishBatches 读取商品发布批次列表。 export const getItemPublishBatches = async (limit = 20): Promise => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/items/publish-batches', { limit }); return Array.isArray(res) ? res : (res.batches || []); } +// deleteItemPublishBatch 删除商品发布批次。 export const deleteItemPublishBatch = async (batchId: string): Promise => { return del(`/api/v1/items/publish-batches/${batchId}`); } +// cancelItemPublishBatch 取消商品发布批次。 export const cancelItemPublishBatch = async (batchId: string): Promise => { return post(`/api/v1/items/publish-batches/${batchId}/cancel`, {}); } +// retryFailedItemPublishBatch 重试失败的商品发布任务。 export const retryFailedItemPublishBatch = async (batchId: string): Promise => { return post(`/api/v1/items/publish-batches/${batchId}/retry-failed`, {}); } +// updateItem 更新商品。 export const updateItem = async (cookieId: string, itemId: string, data: Partial): Promise => { return put(`/api/v1/items/${cookieId}/${itemId}`, data); } // Rules - 自动化规则 -const normalizeShippingRules = (rules: any[]): ShippingRule[] => rules.map((item: any) => ({ +const normalizeShippingRules = (rules: any[]): ShippingRule[] => rules.map(/* 当前回调用于处理集合元素或接口响应。 */ (item: any) => ({ id: String(item.id), name: item.name || '', trigger_type: item.trigger_type || 'order_paid', @@ -634,12 +741,12 @@ const normalizeShippingRules = (rules: any[]): ShippingRule[] => rules.map((item cookie_id: item.cookie_id || '', item_id: item.item_id || '', item_title: item.item_title || '', - card_group_id: Number((item.actions || []).find((a: any) => a.action_type === 'send_card')?.card_id || 0), - card_group_name: (item.actions || []).find((a: any) => a.action_type === 'send_card')?.card_name || '', + card_group_id: Number((item.actions || []).find(/* 当前回调用于处理集合元素或接口响应。 */ (a: any) => a.action_type === 'send_card')?.card_id || 0), + card_group_name: (item.actions || []).find(/* 当前回调用于处理集合元素或接口响应。 */ (a: any) => a.action_type === 'send_card')?.card_name || '', priority: item.priority || 100, enabled: item.enabled || false, config_json: item.config_json || '{}', - actions: (item.actions || []).map((action: any) => ({ + actions: (item.actions || []).map(/* 当前回调用于处理集合元素或接口响应。 */ (action: any) => ({ id: action.id ? String(action.id) : undefined, action_type: action.action_type, card_id: Number(action.card_id || 0), @@ -652,8 +759,9 @@ const normalizeShippingRules = (rules: any[]): ShippingRule[] => rules.map((item sort_order: Number(action.sort_order || 0), })), variants: (item.actions || []) - .filter((action: any) => action.action_type === 'send_card') - .map((action: any) => { + .filter(/* 当前回调用于处理集合元素或接口响应。 */ (action: any) => action.action_type === 'send_card') + .map(/* 当前回调用于处理集合元素或接口响应。 */ (action: any) => { + // cfg 动作配置,用于当前 API 处理流程。 let cfg: any = {}; try { cfg = JSON.parse(action.config_json || '{}'); } catch {} return { @@ -671,21 +779,25 @@ const normalizeShippingRules = (rules: any[]): ShippingRule[] => rules.map((item }), })); +// getShippingRules 读取发货规则列表。 export const getShippingRules = async (): Promise => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/automation-rules'); + // rules 规则列表,用于当前 API 处理流程。 const rules = Array.isArray(res) ? res : (res.data || []); return normalizeShippingRules(rules); } export interface ShippingRuleListParams { - cookieId?: string; - triggerType?: AutomationTriggerType | ''; - enabled?: boolean; - search?: string; - page?: number; - pageSize?: number; + /** cookieId 表示登录凭证标识。 */ cookieId?: string; + /** triggerType 表示触发类型。 */ triggerType?: AutomationTriggerType | ''; + /** enabled 表示启用状态。 */ enabled?: boolean; + /** search 表示搜索条件。 */ search?: string; + /** page 表示页码。 */ page?: number; + /** pageSize 表示每页数量。 */ pageSize?: number; } +// getShippingRulesPage 分页读取发货规则。 export const getShippingRulesPage = async ({ cookieId, triggerType, @@ -694,6 +806,7 @@ export const getShippingRulesPage = async ({ page = 1, pageSize = 10, }: ShippingRuleListParams = {}): Promise> => { + // res 接口响应结果,用于当前 API 处理流程。 const res = await get('/api/v1/automation-rules', { page, page_size: pageSize, @@ -702,6 +815,7 @@ export const getShippingRulesPage = async ({ enabled, search: search?.trim() || undefined, }); + // rules 规则列表,用于当前 API 处理流程。 const rules = normalizeShippingRules(Array.isArray(res) ? res : (res.data || [])); return { success: true, @@ -711,40 +825,49 @@ export const getShippingRulesPage = async ({ page_size: Number(Array.isArray(res) ? pageSize : (res.page_size ?? pageSize)), total_pages: Number(Array.isArray(res) ? (rules.length ? 1 : 0) : (res.total_pages ?? (rules.length ? 1 : 0))), trigger_counts: Object.fromEntries( - Object.entries(Array.isArray(res) ? {} : res.trigger_counts || {}).map(([key, value]) => [key, Number(value)]), + Object.entries(Array.isArray(res) ? {} : res.trigger_counts || {}).map(/* 当前回调用于处理集合元素或接口响应。 */ ([key, value]) => [key, Number(value)]), ), }; } +// orderAutomationActions 构建订单自动化动作。 const orderAutomationActions = (triggerType: string, actions: AutomationAction[]) => { if (triggerType !== 'order_paid') { - return actions.map((action, index) => ({ ...action, sort_order: action.sort_order || index + 1 })); + return actions.map(/* 当前回调用于处理集合元素或接口响应。 */ (action, index) => ({ ...action, sort_order: action.sort_order || index + 1 })); } + // sendCards 发送Cards。 const sendCards = actions - .filter(action => action.action_type === 'send_card') - .map((action, index) => ({ ...action, sort_order: index + 1 })); - const others = actions.filter(action => action.action_type !== 'send_card' && action.action_type !== 'confirm_shipment'); + .filter(/* 当前回调用于处理集合元素或接口响应。 */ action => action.action_type === 'send_card') + .map(/* 当前回调用于处理集合元素或接口响应。 */ (action, index) => ({ ...action, sort_order: index + 1 })); + // others 其他动作列表,用于当前 API 处理流程。 + const others = actions.filter(/* 当前回调用于处理集合元素或接口响应。 */ action => action.action_type !== 'send_card' && action.action_type !== 'confirm_shipment'); return [ ...sendCards, - ...others.map((action, index) => ({ ...action, sort_order: sendCards.length + index + 1 })), + ...others.map(/* 当前回调用于处理集合元素或接口响应。 */ (action, index) => ({ ...action, sort_order: sendCards.length + index + 1 })), { action_type: 'confirm_shipment' as const, enabled: true, sort_order: sendCards.length + others.length + 1 }, ]; }; +// updateShippingRule 更新发货规则。 export const updateShippingRule = async (rule: Partial): Promise => { + // triggerType 触发类型,用于当前 API 处理流程。 const triggerType = rule.trigger_type || 'order_paid'; + // triggerName 触发名称,用于当前 API 处理流程。 const triggerName: Record = { order_paid: '付款后自动发货', buyer_reviewed: '评价后发送赠品', review_missing_timeout: '超时未评价求评价', }; + // generatedName 生成d名称。 const generatedName = [ triggerName[triggerType] || '自动化规则', rule.item_title || rule.item_id || rule.cookie_id || '', ].filter(Boolean).join(' - '); - const preservedNonCardActions = (rule.actions || []).filter(action => action.action_type !== 'send_card' && action.action_type !== 'confirm_shipment'); + // preservedNonCardActions 保留的非卡密动作,用于当前 API 处理流程。 + const preservedNonCardActions = (rule.actions || []).filter(/* 当前回调用于处理集合元素或接口响应。 */ action => action.action_type !== 'send_card' && action.action_type !== 'confirm_shipment'); + // baseActions 基础动作列表,用于当前 API 处理流程。 const baseActions: AutomationAction[] = rule.variants && rule.variants.length > 0 - ? [...rule.variants.map((variant, index) => ({ + ? [...rule.variants.map(/* 当前回调用于处理集合元素或接口响应。 */ (variant, index) => ({ action_type: 'send_card' as const, card_id: variant.card_id, delivery_count: variant.delivery_count || 1, @@ -764,7 +887,9 @@ export const updateShippingRule = async (rule: Partial): Promise): Promise ({ + actions: actions.map(/* 当前回调用于处理集合元素或接口响应。 */ (action, index) => ({ action_type: action.action_type, card_id: action.card_id || 0, delivery_count: action.delivery_count || 1, @@ -787,31 +912,34 @@ export const updateShippingRule = async (rule: Partial): Promise => del(`/api/v1/automation-rules/${id}`); export interface AutomationRunIssue { - id: number; - cookie_id: string; - order_id: string; - trigger_type: string; - error_message: string; - issue_kind: 'external_result_unknown' | 'invalid_snapshot' | 'rule_unavailable' | 'partial_failure' | 'execution_failed'; - allowed_resolutions: Array<'continue' | 'retry' | 'cancel'>; - action_cursor: number; - sent_count: number; - updated_at: string; + /** id 表示标识。 */ id: number; + /** cookie_id 表示登录凭证标识。 */ cookie_id: string; + /** order_id 表示订单标识。 */ order_id: string; + /** trigger_type 表示触发条件类型。 */ trigger_type: string; + /** error_message 表示错误消息。 */ error_message: string; + /** issue_kind 表示问题类型。 */ issue_kind: 'external_result_unknown' | 'invalid_snapshot' | 'rule_unavailable' | 'partial_failure' | 'execution_failed'; + /** allowed_resolutions 表示允许的解决方式。 */ allowed_resolutions: Array<'continue' | 'retry' | 'cancel'>; + /** action_cursor 表示动作游标。 */ action_cursor: number; + /** sent_count 表示已发送数量。 */ sent_count: number; + /** updated_at 表示最后更新时间。 */ updated_at: string; } export interface DeferredAutomationIssue { - id: number; - cookie_id: string; - trigger_type: string; - error_message: string; - attempt_count: number; - updated_at: string; + /** id 表示标识。 */ id: number; + /** cookie_id 表示登录凭证标识。 */ cookie_id: string; + /** trigger_type 表示触发条件类型。 */ trigger_type: string; + /** error_message 表示错误消息。 */ error_message: string; + /** attempt_count 表示尝试次数。 */ attempt_count: number; + /** updated_at 表示最后更新时间。 */ updated_at: string; } -export const getAutomationIssues = async (): Promise<{ runs: AutomationRunIssue[]; pending_tasks: DeferredAutomationIssue[] }> => { +// getAutomationIssues 读取自动化问题列表。 +export const getAutomationIssues = async (): Promise<{ /** runs 表示运行记录。 */ runs: AutomationRunIssue[]; /** pending_tasks 表示待处理任务列表。 */ pending_tasks: DeferredAutomationIssue[] }> => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get('/api/v1/automation-issues'); return { runs: Array.isArray(result?.runs) ? result.runs : [], @@ -819,22 +947,25 @@ export const getAutomationIssues = async (): Promise<{ runs: AutomationRunIssue[ }; }; +// resolveAutomationRun 处理自动化运行记录。 export const resolveAutomationRun = async (id: number, resolution: 'continue' | 'retry' | 'cancel'): Promise => post(`/api/v1/automation-runs/${id}/resolve`, { resolution }); +// resolveDeferredAutomationTask 处理延迟自动化任务。 export const resolveDeferredAutomationTask = async (id: number, resolution: 'retry' | 'dismiss'): Promise => post(`/api/v1/automation-pending-tasks/${id}/resolve`, { resolution }); // Rules - 关键词回复规则 (使用关键词API) type KeywordRowPayload = { - id: string; - keyword: string; - reply: string; - item_id: string; - type: 'text' | 'image'; - image_url: string; + /** id 表示标识。 */ id: string; + /** keyword 表示关键词。 */ keyword: string; + /** reply 表示回复内容。 */ reply: string; + /** item_id 表示商品标识。 */ item_id: string; + /** type 表示规则类型。 */ type: 'text' | 'image'; + /** image_url 表示图片地址。 */ image_url: string; }; +// normalizeKeywordRow 归一化关键词规则。 const normalizeKeywordRow = (item: any): KeywordRowPayload => ({ id: String(item?.id || ''), keyword: item?.keyword || '', @@ -844,15 +975,19 @@ const normalizeKeywordRow = (item: any): KeywordRowPayload => ({ image_url: item?.image_url || '', }); +// getKeywordRowsWithType 读取带类型的关键词规则。 const getKeywordRowsWithType = async (cookieId: string): Promise => { + // existing 已有规则,用于当前 API 处理流程。 const existing = await get(`/api/v1/reply-rules/${cookieId}/typed`); return Array.isArray(existing) ? existing.map(normalizeKeywordRow) : []; }; +// getReplyRules 读取回复规则。 export const getReplyRules = async (cookieId?: string): Promise => { if (!cookieId) return []; + // keywords keywords,用于当前 API 处理流程。 const keywords = await getKeywordRowsWithType(cookieId); - return keywords.map((item: any) => ({ + return keywords.map(/* 当前回调用于处理集合元素或接口响应。 */ (item: any) => ({ id: item.id, keyword: item.keyword || '', reply_content: item.reply || '', @@ -864,8 +999,11 @@ export const getReplyRules = async (cookieId?: string): Promise => })); } +// updateReplyRule 更新回复规则。 export const updateReplyRule = async (rule: Partial, cookieId: string): Promise => { + // type 规则类型,用于当前 API 处理流程。 const type = rule.type || 'text'; + // payload 请求载荷,用于当前 API 处理流程。 const payload = { keyword: rule.keyword || '', reply: type === 'text' ? (rule.reply_content || '') : '', @@ -878,28 +1016,36 @@ export const updateReplyRule = async (rule: Partial, cookieId: string : post(`/api/v1/reply-rules/${cookieId}/items`, payload); } +// deleteReplyRule 删除回复规则。 export const deleteReplyRule = async (id: string, cookieId: string): Promise => { return del(`/api/v1/reply-rules/${cookieId}/typed/${id}`); } // Settings +// getSystemSettings 读取系统设置。 export const getSystemSettings = async (options?: RequestControlOptions): Promise => { - const res = await get<{data: SystemSettings}>('/api/v1/settings/system', undefined, options); + // res 接口响应结果,用于当前 API 处理流程。 + const res = await get<{/** data 表示数据。 */ data: SystemSettings}>('/api/v1/settings/system', undefined, options); return normalizeSettings(res.data || res); // handle {success:true, data: {...}} wrapper if exists }; +// updateSystemSettings 更新系统设置。 export const updateSystemSettings = async (settings: Partial, options?: RequestControlOptions): Promise => { + // payload 请求载荷,用于当前 API 处理流程。 const payload = Object.fromEntries( - Object.entries(settings).filter(([, value]) => value !== undefined && value !== null), + Object.entries(settings).filter(/* 当前回调用于处理集合元素或接口响应。 */ ([, value]) => value !== undefined && value !== null), ); return put('/api/v1/settings/system', payload, options); }; +// getAccountAISettings 读取账号人工智能设置。 export const getAccountAISettings = async (cookieId: string, options?: RequestControlOptions): Promise => { return get(`/api/v1/settings/ai-reply/${cookieId}`, undefined, options); } +// updateAccountAISettings 更新账号人工智能设置。 export const updateAccountAISettings = async (cookieId: string, settings: Partial, options?: RequestControlOptions): Promise => { + // payload 请求载荷,用于当前 API 处理流程。 const payload = { ai_enabled: settings.ai_enabled ?? false, max_discount_percent: settings.max_discount_percent ?? 10, @@ -910,7 +1056,9 @@ export const updateAccountAISettings = async (cookieId: string, settings: Partia return put(`/api/v1/settings/ai-reply/${cookieId}`, payload, options); } +// fetchAIModels 读取人工智能模型列表。 export const fetchAIModels = async (baseUrl: string, apiKey: string = '', options?: RequestControlOptions): Promise => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await post('/api/v1/settings/ai-models', { base_url: baseUrl, api_key: apiKey, @@ -919,26 +1067,34 @@ export const fetchAIModels = async (baseUrl: string, apiKey: string = '', option }; // Notification Channels +// parseNotificationEventTypes 解析通知事件类型。 const parseNotificationEventTypes = (raw: unknown): NotificationEventType[] => { if (Array.isArray(raw)) return raw.filter(Boolean) as NotificationEventType[]; if (typeof raw !== 'string' || !raw.trim()) return []; try { + // parsed 转换后的数值,用于当前 API 处理流程。 const parsed = JSON.parse(raw); if (Array.isArray(parsed)) return parsed.filter(Boolean) as NotificationEventType[]; } catch { // fall back to legacy comma/semicolon separated values } - return raw.split(/[,\s;]+/).map(v => v.trim()).filter(Boolean) as NotificationEventType[]; + return raw.split(/[,\s;]+/).map(/* 当前回调用于处理集合元素或接口响应。 */ v => v.trim()).filter(Boolean) as NotificationEventType[]; }; +// stringifyNotificationEventTypes 序列化通知事件类型。 const stringifyNotificationEventTypes = (events?: NotificationEventType[]): string => { + // clean 清理后的事件类型列表,用于当前 API 处理流程。 const clean = Array.from(new Set((events || []).filter(Boolean))); return clean.length > 0 ? JSON.stringify(clean) : ''; }; -export const getNotificationChannels = async (options?: RequestControlOptions): Promise<{ success: boolean; data?: NotificationChannel[] }> => { +// getNotificationChannels 读取通知渠道。 +export const getNotificationChannels = async (options?: RequestControlOptions): Promise<{ /** success 表示是否成功。 */ success: boolean; /** data 表示数据。 */ data?: NotificationChannel[] }> => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get('/api/v1/notifications/channels', undefined, options); - const channels = (result || []).map((item: any) => { + // channels 通知渠道列表,用于当前 API 处理流程。 + const channels = (result || []).map(/* 当前回调用于处理集合元素或接口响应。 */ (item: any) => { + // parsedConfig 解析后的通知配置,用于当前 API 处理流程。 let parsedConfig; try { parsedConfig = typeof item.config === 'string' ? JSON.parse(item.config) : item.config; @@ -959,7 +1115,8 @@ export const getNotificationChannels = async (options?: RequestControlOptions): return { success: true, data: channels }; } -export const createNotificationChannel = async (data: { name: string; type: string; config: Record; event_types?: NotificationEventType[]; enabled?: boolean }, options?: RequestControlOptions): Promise => { +// createNotificationChannel 创建通知渠道。 +export const createNotificationChannel = async (data: { /** name 表示名称。 */ name: string; /** type 表示规则类型。 */ type: string; /** config 表示配置对象。 */ config: Record; /** event_types 表示通知事件类型列表。 */ event_types?: NotificationEventType[]; /** enabled 表示启用状态。 */ enabled?: boolean }, options?: RequestControlOptions): Promise => { return post('/api/v1/notifications/channels', { ...data, config: JSON.stringify(data.config), @@ -967,7 +1124,9 @@ export const createNotificationChannel = async (data: { name: string; type: stri }, options); } -export const updateNotificationChannel = async (channelId: string, data: { name?: string; type?: string; config?: Record; event_types?: NotificationEventType[]; enabled?: boolean }, options?: RequestControlOptions): Promise => { +// updateNotificationChannel 更新通知渠道。 +export const updateNotificationChannel = async (channelId: string, data: { /** name 表示名称。 */ name?: string; /** type 表示规则类型。 */ type?: string; /** config 表示配置对象。 */ config?: Record; /** event_types 表示通知事件类型列表。 */ event_types?: NotificationEventType[]; /** enabled 表示启用状态。 */ enabled?: boolean }, options?: RequestControlOptions): Promise => { + // payload 请求载荷,用于当前 API 处理流程。 const payload: Record = { ...data }; if ('config' in data) { payload.config = JSON.stringify(data.config); @@ -978,17 +1137,23 @@ export const updateNotificationChannel = async (channelId: string, data: { name? return put(`/api/v1/notifications/channels/${channelId}`, payload, options); } +// deleteNotificationChannel 删除通知渠道。 export const deleteNotificationChannel = async (channelId: string, options?: RequestControlOptions): Promise => { return del(`/api/v1/notifications/channels/${channelId}`, undefined, options); } // Message Notifications -export const getMessageNotifications = async (): Promise<{ success: boolean; data?: NotificationBinding[] }> => { +// getMessageNotifications 读取消息通知。 +export const getMessageNotifications = async (): Promise<{ /** success 表示是否成功。 */ success: boolean; /** data 表示数据。 */ data?: NotificationBinding[] }> => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get>('/api/v1/notifications/messages'); + // notifications 通知列表,用于当前 API 处理流程。 const notifications: NotificationBinding[] = []; - for (const [cookieId, channelList] of Object.entries(result || {})) { + for (const // [cookieId, channelList] [cookieId,通知渠道List],用于当前 API 处理流程。 +[cookieId, channelList] of Object.entries(result || {})) { if (Array.isArray(channelList)) { - for (const item of channelList) { + for (const // item 当前条目,用于当前 API 处理流程。 +item of channelList) { notifications.push({ cookie_id: cookieId, channel_id: item.channel_id, @@ -1001,24 +1166,29 @@ export const getMessageNotifications = async (): Promise<{ success: boolean; dat return { success: true, data: notifications }; } +// setMessageNotification 设置消息通知。 export const setMessageNotification = async (cookieId: string, channelId: number, enabled: boolean): Promise => { return post(`/api/v1/notifications/accounts/${cookieId}/bindings`, { channel_id: channelId, enabled }); } +// deleteMessageNotification 删除消息通知。 export const deleteMessageNotification = async (notificationId: string): Promise => { return del(`/api/v1/notifications/messages/${notificationId}`); } +// deleteAccountNotifications 删除账号通知。 export const deleteAccountNotifications = async (cookieId: string): Promise => { return del(`/api/v1/notifications/messages/account/${cookieId}`); } // 账号 ↔ 渠道 绑定(覆盖式) export const getAccountBindings = async (cookieId: string, options?: RequestControlOptions): Promise => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get(`/api/v1/notifications/accounts/${cookieId}/bindings`, undefined, options); return result?.channel_ids || []; } +// setAccountBindings 设置账号通知绑定。 export const setAccountBindings = async (cookieId: string, channelIds: number[]): Promise => { return post(`/api/v1/notifications/accounts/${cookieId}/bindings`, { channel_ids: channelIds }); } @@ -1029,11 +1199,14 @@ export const testNotificationChannel = async (channelId: string, options?: Reque } // Default Reply +// getDefaultReplies 读取默认回复列表。 export const getDefaultReplies = async (): Promise> => { return get('/api/v1/default-replies'); }; +// getDefaultReply 读取默认回复。 export const getDefaultReply = async (cookieId: string): Promise => { + // result 接口响应结果,用于当前 API 处理流程。 const result = await get(`/api/v1/default-replies/${cookieId}`); return { cookie_id: cookieId, @@ -1044,6 +1217,7 @@ export const getDefaultReply = async (cookieId: string): Promise = }; }; +// updateDefaultReply 更新默认回复。 export const updateDefaultReply = async (cookieId: string, data: Partial): Promise => { return put(`/api/v1/default-replies/${cookieId}`, { enabled: data.enabled ?? false, @@ -1053,10 +1227,12 @@ export const updateDefaultReply = async (cookieId: string, data: Partial => { return del(`/api/v1/default-replies/${cookieId}`); }; +// clearDefaultReplyRecords 清理默认回复记录。 export const clearDefaultReplyRecords = async (cookieId: string): Promise => { return post(`/api/v1/default-replies/${cookieId}/clear-records`, {}); };