From 103effcfca7fe12ffb9b27cbe36f8f321174a1e0 Mon Sep 17 00:00:00 2001 From: test Date: Mon, 16 Mar 2026 22:42:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20style:=20format=20code=20w?= =?UTF-8?q?ith=20Prettier=20and=20fix=20.gitattributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add *.yaml text eol=lf rule to .gitattributes for consistent line endings - Format cleaner.ts with Prettier (parameter and chain formatting) - Format CleanerPage.tsx (JSX formatting) - Format cleaner.test.ts (array formatting) Co-Authored-By: Claude Sonnet 4.6 --- .gitattributes | 1 + src/main/services/erp/cleaner.ts | 46 +++++++++++++++++++------- src/renderer/src/pages/CleanerPage.tsx | 4 ++- tests/unit/cleaner.test.ts | 6 +--- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2dd1a97..0510b91 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,7 @@ *.js text eol=lf *.json text eol=lf *.yml text eol=lf +*.yaml text eol=lf *.tsx text eol=lf *.jsx text eol=lf *.css text eol=lf diff --git a/src/main/services/erp/cleaner.ts b/src/main/services/erp/cleaner.ts index dad57f0..a1d28b0 100644 --- a/src/main/services/erp/cleaner.ts +++ b/src/main/services/erp/cleaner.ts @@ -62,7 +62,12 @@ export interface ShouldDeleteParams { deleteSet: Set } -function clampNumber(value: number | undefined, fallback: number, min: number, max: number): number { +function clampNumber( + value: number | undefined, + fallback: number, + min: number, + max: number +): number { if (!Number.isFinite(value)) { return fallback } @@ -281,7 +286,9 @@ export class CleanerService { const retryResult = await this.retryFailedOrders({ workFrame, popupPage, - failedDetails: result.details.filter((d) => d.errors.length > 0 && this.isOrderNumber(d.orderNumber)), + failedDetails: result.details.filter( + (d) => d.errors.length > 0 && this.isOrderNumber(d.orderNumber) + ), deleteSet, dryRun, onProgress: input.onProgress @@ -482,7 +489,12 @@ export class CleanerService { onProgress?.( `开始处理订单: ${orderNumber}`, - this.calculateProgress(progressState.completedOrders, 0, detailCount, progressState.totalOrders), + this.calculateProgress( + progressState.completedOrders, + 0, + detailCount, + progressState.totalOrders + ), { currentOrderIndex: progressState.completedOrders + 1, totalOrders: progressState.totalOrders, @@ -530,13 +542,17 @@ export class CleanerService { progressState.totalOrders ) - onProgress?.(`订单 ${orderNumber} - 物料 ${materialIdx}/${detailCount}: ${materialName}`, progress, { - currentOrderIndex: progressState.completedOrders + 1, - totalOrders: progressState.totalOrders, - currentMaterialIndex: materialIdx, - totalMaterialsInOrder: detailCount, - currentOrderNumber: orderNumber - }) + onProgress?.( + `订单 ${orderNumber} - 物料 ${materialIdx}/${detailCount}: ${materialName}`, + progress, + { + currentOrderIndex: progressState.completedOrders + 1, + totalOrders: progressState.totalOrders, + currentMaterialIndex: materialIdx, + totalMaterialsInOrder: detailCount, + currentOrderNumber: orderNumber + } + ) if (deleteSet.has(materialCode)) { const shouldDelete = this.shouldDeleteMaterial({ @@ -610,7 +626,10 @@ export class CleanerService { private async extractSourceOrderNumber(frame: FrameLocator): Promise { try { - const sourceOrder = await frame.locator('.vsourcebillcode .code-detail-link').first().innerText() + const sourceOrder = await frame + .locator('.vsourcebillcode .code-detail-link') + .first() + .innerText() const match = sourceOrder.match(/SC\d{14}/) return match ? match[0] : sourceOrder.trim() } catch { @@ -650,7 +669,10 @@ export class CleanerService { } } - private async getInputValue(container: FrameLocator | Locator, labelRegex: RegExp): Promise { + private async getInputValue( + container: FrameLocator | Locator, + labelRegex: RegExp + ): Promise { try { return await container .locator('div') diff --git a/src/renderer/src/pages/CleanerPage.tsx b/src/renderer/src/pages/CleanerPage.tsx index 65e84c0..670cb94 100644 --- a/src/renderer/src/pages/CleanerPage.tsx +++ b/src/renderer/src/pages/CleanerPage.tsx @@ -465,7 +465,9 @@ const CleanerPage: React.FC = () => {
批量查询数量
-
每批查询订单数,范围 1-100
+
+ 每批查询订单数,范围 1-100 +
{ describe('batch and concurrency helpers', () => { it('should split orders into batches', () => { const batches = createBatches(['A', 'B', 'C', 'D', 'E'], 2) - expect(batches).toEqual([ - ['A', 'B'], - ['C', 'D'], - ['E'] - ]) + expect(batches).toEqual([['A', 'B'], ['C', 'D'], ['E']]) }) it('should identify missing orders', () => {