Skip to content

Commit

Permalink
fix: getNodesByValues传入参数必为数组格式,为破坏性变更,请全文搜索getNodesByValues,并修改成只接受数…
Browse files Browse the repository at this point in the history
…组格式。
  • Loading branch information
greper committed Sep 9, 2023
1 parent b3568b4 commit d9583ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/fast-crud/src/use/use-dict-define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface DictOptions<T> {
* 根据values 远程获取字典,prototype=true时有效
* @param values
*/
getNodesByValues?: (values: any, options?: LoadDictOpts) => Promise<T[]>;
getNodesByValues?: (values: any[], options?: LoadDictOpts) => Promise<T[]>;

/**
* dict数据远程加载完后触发
Expand Down Expand Up @@ -228,7 +228,8 @@ export class Dict<T = any> extends UnMergeable implements DictOptions<T> {
if (cached) {
data = cached;
} else {
data = await this.getNodesByValues(context.value, context);
const value = Array.isArray(context.value) ? context.value : [context.value];
data = await this.getNodesByValues(value, context);
if (cacheKey) {
DictGlobalCache.set(cacheKey, data);
}
Expand Down Expand Up @@ -262,11 +263,11 @@ export class Dict<T = any> extends UnMergeable implements DictOptions<T> {
* @param context 当prototype=true时会传入
*/
async loadDict(context?: any) {
return this._loadDict({ ...context });
return await this._loadDict({ ...context });
}

async reloadDict(context?: any) {
return this.loadDict({ ...context, reload: true });
return await this.loadDict({ ...context, reload: true });
}

clear() {
Expand Down

0 comments on commit d9583ef

Please sign in to comment.