更新了一些不重要的代码规范修正

This commit is contained in:
Xu Chang 2025-10-07 16:50:36 +08:00
parent b817fbd384
commit 4c5ea92f29
10 changed files with 20 additions and 35 deletions

View File

@ -25,7 +25,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict> extends Featu
private cacheStore;
private syncEventsCallbacks;
private contextBuilder;
private refreshing;
private executing;
private savedEntities;
private keepFreshPeriod;
private localStorage;

View File

@ -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;

View File

@ -266,7 +266,6 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
entity: keyof ED;
operation: ED[keyof ED]['Operation'];
}> | undefined;
setExecuting(executing: boolean): void;
clean(lsn?: number, dontPublish?: true): void;
checkIfClean(node: Node<ED>): boolean;
}

View File

@ -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);

View File

@ -25,7 +25,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict> extends Featu
private cacheStore;
private syncEventsCallbacks;
private contextBuilder;
private refreshing;
private executing;
private savedEntities;
private keepFreshPeriod;
private localStorage;

View File

@ -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;

View File

@ -266,7 +266,6 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
entity: keyof ED;
operation: ED[keyof ED]['Operation'];
}> | undefined;
setExecuting(executing: boolean): void;
clean(lsn?: number, dontPublish?: true): void;
checkIfClean(node: Node<ED>): boolean;
}

View File

@ -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);

View File

@ -38,7 +38,7 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
(opRecords: OpRecord<ED>[]) => void
>;
private contextBuilder: () => SyncContext<ED>;
private refreshing = 0;
private executing = 0;
private savedEntities: (keyof ED)[];
private keepFreshPeriod: number;
private localStorage: LocalStorage;
@ -171,13 +171,13 @@ export class Cache<ED extends EntityDict & BaseEntityDict> 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<ED extends EntityDict & BaseEntityDict> 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<ED extends EntityDict & BaseEntityDict> 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<ED extends EntityDict & BaseEntityDict> extends Feature {
{
dontCollect: true,
includedDeleted: true,
warnWhenAttributeMiss: !this.refreshing && process.env.NODE_ENV === 'development',
warnWhenAttributeMiss: !this.executing && process.env.NODE_ENV === 'development',
}
);
rollback && rollback();

View File

@ -2197,11 +2197,6 @@ class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
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);