From ec2019418620f92518bc280e168f1c48d6edd2e8 Mon Sep 17 00:00:00 2001 From: chf12mm Date: Wed, 12 Jan 2022 02:43:01 +0000 Subject: [PATCH 1/3] =?UTF-8?q?update=20ruoyi-ui/src/utils/dict/index.js.?= =?UTF-8?q?=20=E9=98=B2=E6=AD=A2=E5=AD=97=E5=85=B8=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=81=9A=E5=AD=97=E5=85=B8=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/dict/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/utils/dict/index.js b/ruoyi-ui/src/utils/dict/index.js index d6fdb802c..c18e45ddc 100644 --- a/ruoyi-ui/src/utils/dict/index.js +++ b/ruoyi-ui/src/utils/dict/index.js @@ -1,6 +1,7 @@ import Dict from './Dict' import { mergeOptions } from './DictOptions' - +var __dictCache = new Map(); +window.__dictCache = __dictCache; export default function(Vue, options) { mergeOptions(options) Vue.mixin({ From a6ef318fbb653fae50b5f008da8d6743a3547387 Mon Sep 17 00:00:00 2001 From: chf12mm Date: Wed, 12 Jan 2022 02:46:35 +0000 Subject: [PATCH 2/3] =?UTF-8?q?update=20ruoyi-ui/src/utils/dict/Dict.js.?= =?UTF-8?q?=20=E9=98=B2=E6=AD=A2=E5=AD=97=E5=85=B8=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/dict/Dict.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/utils/dict/Dict.js b/ruoyi-ui/src/utils/dict/Dict.js index 22db32fe2..422f8ef5c 100644 --- a/ruoyi-ui/src/utils/dict/Dict.js +++ b/ruoyi-ui/src/utils/dict/Dict.js @@ -37,7 +37,7 @@ export default class Dict { if (dictMeta.lazy) { return } - ps.push(loadDict(this, dictMeta)) + ps.push(removal(this, dictMeta)) }) return Promise.all(ps) } @@ -55,6 +55,26 @@ export default class Dict { } } +//过滤重复数据重复请求 +function removal(dict, dictMeta) { + const type = dictMeta.type + let that = dict.owner; + let ld; + if(__dictCache.get(type)){ + ld = __dictCache.get(type) + ld.then(dicts=>{ + dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts) + dicts.forEach(d => { + Vue.set(dict.label[type], d.value, d.label) + }) + }) + }else{ + ld = loadDict(dict, dictMeta); + __dictCache.set(type,ld) + } + return ld +} + /** * 加载字典 * @param {Dict} dict 字典 From 38162b611c2d9fef55e980e83160945d4eaa8b13 Mon Sep 17 00:00:00 2001 From: chf12mm Date: Wed, 12 Jan 2022 03:06:20 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82=EF=BC=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/dict/Dict.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/utils/dict/Dict.js b/ruoyi-ui/src/utils/dict/Dict.js index 422f8ef5c..99ac4baac 100644 --- a/ruoyi-ui/src/utils/dict/Dict.js +++ b/ruoyi-ui/src/utils/dict/Dict.js @@ -51,7 +51,7 @@ export default class Dict { if (dictMeta === undefined) { return Promise.reject(`the dict meta of ${type} was not found`) } - return loadDict(this, dictMeta) + return removal(this, dictMeta) } }