From 4c5ea92f294333dd6772af428ba8b2280fde9657 Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 7 Oct 2025 16:50:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=B8=8D=E9=87=8D=E8=A6=81=E7=9A=84=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/features/cache.d.ts | 2 +- es/features/cache.js | 12 ++++++------ es/features/runningTree.d.ts | 1 - es/features/runningTree.js | 4 ---- lib/features/cache.d.ts | 2 +- lib/features/cache.js | 12 ++++++------ lib/features/runningTree.d.ts | 1 - lib/features/runningTree.js | 4 ---- src/features/cache.ts | 12 ++++++------ src/features/runningTree.ts | 5 ----- 10 files changed, 20 insertions(+), 35 deletions(-) diff --git a/es/features/cache.d.ts b/es/features/cache.d.ts index 5b194d2d..9954e06c 100644 --- a/es/features/cache.d.ts +++ b/es/features/cache.d.ts @@ -25,7 +25,7 @@ export declare class Cache extends Featu private cacheStore; private syncEventsCallbacks; private contextBuilder; - private refreshing; + private executing; private savedEntities; private keepFreshPeriod; private localStorage; diff --git a/es/features/cache.js b/es/features/cache.js index 2e4c7c21..533416ee 100644 --- a/es/features/cache.js +++ b/es/features/cache.js @@ -12,7 +12,7 @@ export class Cache extends Feature { cacheStore; syncEventsCallbacks; contextBuilder; - refreshing = 0; + executing = 0; savedEntities; keepFreshPeriod; localStorage; @@ -92,13 +92,13 @@ export class Cache extends Feature { } */ async exec(name, params, callback, dontPublish, ignoreContext) { try { - this.refreshing++; + this.executing++; const { result, opRecords, message } = await this.connector.callAspect(name, params, ignoreContext ? undefined : this.context || this.contextBuilder()); callback && callback(result, opRecords); if (opRecords?.length) { this.syncInner(opRecords); } - this.refreshing--; + this.executing--; if (opRecords && opRecords.length > 0 && !dontPublish) { this.publish(); } @@ -109,7 +109,7 @@ export class Cache extends Feature { } catch (e) { // 如果是数据不一致错误,这里可以让用户知道 - this.refreshing--; + this.executing--; if (e instanceof OakException) { const { opRecords } = e; if (opRecords.length) { @@ -440,7 +440,7 @@ export class Cache extends Feature { return; } fetchRows(missedRows) { - if (!this.refreshing) { + if (!this.executing) { if (process.env.NODE_ENV === 'development') { console.warn('缓存被动去获取数据,请查看页面行为并加以优化', missedRows); } @@ -462,7 +462,7 @@ export class Cache extends Feature { const result = this.cacheStore.select(entity, selection, this.context, { dontCollect: true, includedDeleted: true, - warnWhenAttributeMiss: !this.refreshing && process.env.NODE_ENV === 'development', + warnWhenAttributeMiss: !this.executing && process.env.NODE_ENV === 'development', }); rollback && rollback(); return result; diff --git a/es/features/runningTree.d.ts b/es/features/runningTree.d.ts index ee85ca2d..632fac5b 100644 --- a/es/features/runningTree.d.ts +++ b/es/features/runningTree.d.ts @@ -266,7 +266,6 @@ declare class VirtualNode extends Node | undefined; - setExecuting(executing: boolean): void; clean(lsn?: number, dontPublish?: true): void; checkIfClean(node: Node): boolean; } diff --git a/es/features/runningTree.js b/es/features/runningTree.js index b0ee5b38..54942419 100644 --- a/es/features/runningTree.js +++ b/es/features/runningTree.js @@ -1845,10 +1845,6 @@ class VirtualNode extends Node { } return operationss; } - setExecuting(executing) { - this.executing = executing; - this.publish(); - } clean(lsn, dontPublish) { for (const ele in this.children) { this.children[ele].clean(lsn, true); diff --git a/lib/features/cache.d.ts b/lib/features/cache.d.ts index 5b194d2d..9954e06c 100644 --- a/lib/features/cache.d.ts +++ b/lib/features/cache.d.ts @@ -25,7 +25,7 @@ export declare class Cache extends Featu private cacheStore; private syncEventsCallbacks; private contextBuilder; - private refreshing; + private executing; private savedEntities; private keepFreshPeriod; private localStorage; diff --git a/lib/features/cache.js b/lib/features/cache.js index 38f48ec3..d981e8f8 100644 --- a/lib/features/cache.js +++ b/lib/features/cache.js @@ -15,7 +15,7 @@ class Cache extends Feature_1.Feature { cacheStore; syncEventsCallbacks; contextBuilder; - refreshing = 0; + executing = 0; savedEntities; keepFreshPeriod; localStorage; @@ -95,13 +95,13 @@ class Cache extends Feature_1.Feature { } */ async exec(name, params, callback, dontPublish, ignoreContext) { try { - this.refreshing++; + this.executing++; const { result, opRecords, message } = await this.connector.callAspect(name, params, ignoreContext ? undefined : this.context || this.contextBuilder()); callback && callback(result, opRecords); if (opRecords?.length) { this.syncInner(opRecords); } - this.refreshing--; + this.executing--; if (opRecords && opRecords.length > 0 && !dontPublish) { this.publish(); } @@ -112,7 +112,7 @@ class Cache extends Feature_1.Feature { } catch (e) { // 如果是数据不一致错误,这里可以让用户知道 - this.refreshing--; + this.executing--; if (e instanceof Exception_1.OakException) { const { opRecords } = e; if (opRecords.length) { @@ -443,7 +443,7 @@ class Cache extends Feature_1.Feature { return; } fetchRows(missedRows) { - if (!this.refreshing) { + if (!this.executing) { if (process.env.NODE_ENV === 'development') { console.warn('缓存被动去获取数据,请查看页面行为并加以优化', missedRows); } @@ -465,7 +465,7 @@ class Cache extends Feature_1.Feature { const result = this.cacheStore.select(entity, selection, this.context, { dontCollect: true, includedDeleted: true, - warnWhenAttributeMiss: !this.refreshing && process.env.NODE_ENV === 'development', + warnWhenAttributeMiss: !this.executing && process.env.NODE_ENV === 'development', }); rollback && rollback(); return result; diff --git a/lib/features/runningTree.d.ts b/lib/features/runningTree.d.ts index ee85ca2d..632fac5b 100644 --- a/lib/features/runningTree.d.ts +++ b/lib/features/runningTree.d.ts @@ -266,7 +266,6 @@ declare class VirtualNode extends Node | undefined; - setExecuting(executing: boolean): void; clean(lsn?: number, dontPublish?: true): void; checkIfClean(node: Node): boolean; } diff --git a/lib/features/runningTree.js b/lib/features/runningTree.js index 790c4dc0..7c9390ed 100644 --- a/lib/features/runningTree.js +++ b/lib/features/runningTree.js @@ -1848,10 +1848,6 @@ class VirtualNode extends Node { } return operationss; } - setExecuting(executing) { - this.executing = executing; - this.publish(); - } clean(lsn, dontPublish) { for (const ele in this.children) { this.children[ele].clean(lsn, true); diff --git a/src/features/cache.ts b/src/features/cache.ts index 394342b5..ae269f0e 100644 --- a/src/features/cache.ts +++ b/src/features/cache.ts @@ -38,7 +38,7 @@ export class Cache extends Feature { (opRecords: OpRecord[]) => void >; private contextBuilder: () => SyncContext; - private refreshing = 0; + private executing = 0; private savedEntities: (keyof ED)[]; private keepFreshPeriod: number; private localStorage: LocalStorage; @@ -171,13 +171,13 @@ export class Cache extends Feature { ignoreContext?: true, ) { try { - this.refreshing++; + this.executing++; const { result, opRecords, message } = await this.connector.callAspect(name as string, params, ignoreContext ? undefined : this.context || this.contextBuilder()); callback && callback(result, opRecords); if (opRecords?.length) { this.syncInner(opRecords); } - this.refreshing--; + this.executing--; if (opRecords && opRecords.length > 0 && !dontPublish) { this.publish(); } @@ -188,7 +188,7 @@ export class Cache extends Feature { } catch (e) { // 如果是数据不一致错误,这里可以让用户知道 - this.refreshing--; + this.executing--; if (e instanceof OakException) { const { opRecords } = e; if (opRecords.length) { @@ -592,7 +592,7 @@ export class Cache extends Feature { } fetchRows(missedRows: Array<{ entity: keyof ED, selection: ED[keyof ED]['Selection'] }>) { - if (!this.refreshing) { + if (!this.executing) { if (process.env.NODE_ENV === 'development') { console.warn('缓存被动去获取数据,请查看页面行为并加以优化', missedRows); } @@ -621,7 +621,7 @@ export class Cache extends Feature { { dontCollect: true, includedDeleted: true, - warnWhenAttributeMiss: !this.refreshing && process.env.NODE_ENV === 'development', + warnWhenAttributeMiss: !this.executing && process.env.NODE_ENV === 'development', } ); rollback && rollback(); diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index 09857ad7..afabb50b 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -2197,11 +2197,6 @@ class VirtualNode extends Node { return operationss; } - setExecuting(executing: boolean) { - this.executing = executing; - this.publish(); - } - clean(lsn?: number, dontPublish?: true) { for (const ele in this.children) { this.children[ele].clean(lsn, true);