Skip to content

Commit

Permalink
fix: 修复动态getData缓存的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Aug 4, 2021
1 parent 72fd641 commit 86cd495
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions packages/fast-crud/src/use/use-dict-define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,27 @@ class Dict extends UnMergeable {
async getRemoteDictData(context?) {
let getFromRemote;
let cacheKey;
if (this.getData != null) {
cacheKey = this.getData;
getFromRemote = async () => {
// @ts-ignore
return await this.getData({ dict: this, ...context });
};
} else if (this.url) {
let url = this.url;
let url;
if (this.url) {
url = this.url;
if (url instanceof Function) {
url = url({ ...context, dict: this });
}
if (url == null) {
return;
}
cacheKey = url;
}
if (this.getData != null) {
getFromRemote = async () => {
// @ts-ignore
return await this.getData({ url, dict: this, ...context });
};
} else if (url) {
getFromRemote = async () => {
return await dictRequest({ url, dict });
};
} else {
return [];
}
if (this.cache) {
if (this.cache && cacheKey) {
let cached = DictGlobalCache.get(cacheKey);

if (cached == null) {
Expand Down

0 comments on commit 86cd495

Please sign in to comment.