adtec-hnyzfc-core-package 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/dict/DictDisplay.vue.js +1 -1
- package/dist/src/hooks/useDictHooks.d.ts +5 -2
- package/dist/src/hooks/useDictHooks.js +1 -1
- package/dist/src/stores/dictStore.d.ts +22 -1
- package/dist/src/stores/dictStore.js +1 -1
- package/dist/styles/element-ui.css +1 -1
- package/package.json +1 -1
- package/dist/src/utils/iconfontRuntime.d.ts +0 -26
- package/dist/src/utils/iconfontRuntime.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as o}from"../../../chunks/DictDisplay.vue_vue_type_script_setup_true_lang-DiFlFWi1.js";import"vue";import"../../hooks/useDictHooks.js";import"
|
|
1
|
+
import{_ as o}from"../../../chunks/DictDisplay.vue_vue_type_script_setup_true_lang-DiFlFWi1.js";import"vue";import"../../hooks/useDictHooks.js";import"../../api/SysDictCacheApi.js";import"../../utils/request.js";import"../../utils/AxiosConfig.js";import"axios";import"uuid";import"../../utils/encrypt.js";import"jsencrypt";import"../../utils/behaviorTrack.js";import"crypto-js/enc-base64";import"crypto-js/enc-utf8";import"../../utils/behaviorContext.js";import"element-plus";import"../../utils/frontendBus.js";import"../../stores/dictStore.js";import"pinia";import"../../stores/userInfoStore.js";import"../../utils/userSessionStorage.js";import"../../utils/FrameworkUtils.js";import"xlsx-js-style";import"../../../chunks/ElTagDisplay.vue_vue_type_script_setup_true_lang-DQXuYsW_.js";export{o as default};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ISysDictDataCacheVo } from '../interface/ISysDictDataCacheVo';
|
|
2
|
+
import { type dictMapType } from '../stores/dictStore';
|
|
2
3
|
export default function useDictHooks(dictTypes?: string[], orgId?: string): {
|
|
3
4
|
getDict: (dictTypes?: string[], orgId?: string) => Promise<void>;
|
|
4
5
|
userReady: globalThis.Ref<boolean, boolean>;
|
|
5
6
|
dictReady: globalThis.Ref<boolean, boolean>;
|
|
6
|
-
|
|
7
|
+
dictLoading: globalThis.Ref<boolean, boolean>;
|
|
8
|
+
dictError: globalThis.ShallowRef<unknown>;
|
|
9
|
+
dictMap: globalThis.Ref<dictMapType, dictMapType>;
|
|
7
10
|
dictDataMap: globalThis.Ref<import("../stores/dictStore").dictDataMapType, import("../stores/dictStore").dictDataMapType>;
|
|
8
|
-
dictDefaultValueMap: globalThis.Ref<
|
|
11
|
+
dictDefaultValueMap: globalThis.Ref<dictMapType, dictMapType>;
|
|
9
12
|
getDictName: (value?: string, dictType?: string, orgId?: string) => string | undefined;
|
|
10
13
|
getDictData: (value: string, dictType: string, orgId?: string) => ISysDictDataCacheVo | {};
|
|
11
14
|
getDictTypeData: (dictType: string, orgId?: string) => ISysDictDataCacheVo[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ref as w,shallowRef as $}from"vue";import j from"../api/SysDictCacheApi.js";import{dictStore as z}from"../stores/dictStore.js";import{storeToRefs as B}from"pinia";import{userInfoStore as G}from"../stores/userInfoStore.js";import N from"../utils/FrameworkUtils.js";import"../utils/request.js";import"../utils/AxiosConfig.js";import"axios";import"uuid";import"../utils/encrypt.js";import"jsencrypt";import"../utils/behaviorTrack.js";import"crypto-js/enc-base64";import"crypto-js/enc-utf8";import"../utils/behaviorContext.js";import"element-plus";import"../utils/frontendBus.js";import"../utils/userSessionStorage.js";import"xlsx-js-style";const P=o=>{if(!o?.length)return o??[];if(o.some(c=>Array.isArray(c.children)&&c.children.length>0))return o;const u=new Map;if(o.forEach(c=>{c?.id&&u.set(c.id,{...c,children:void 0})}),!u.size)return o;const l=[];let n=0;return u.forEach(c=>{const h=c.parentId;if(h&&h!=="0"&&u.has(h)){const d=u.get(h);d.children||(d.children=[]),d.children.push(c),n+=1}else l.push(c)}),n?l:o};function he(o,u){const l=G(),n=z(),{clearDictCache:c}=n,{dictMap:h,dictDefaultValueMap:d,dictDataMap:D}=B(n),p=e=>e||(l.user?.orgId||l.hydrateFromRootSession(),l.user?.orgId),g=(e,r)=>r?`${r}:${e}`:e,F=(e,r)=>n.isDictCacheLoaded(g(e,r)),L=(e,r)=>{const t=g(e,r??p());return n.isDictCacheLoaded(t)?t:void 0},q=(e,r)=>{const t=g(e,r??p());return n.isDictCacheLoaded(t)?t:void 0},E=w(!o?.length),I=w(!o?.length),k=w(!1),C=$();let R=0;const M=async(e,r)=>{R+=1,k.value=!0,C.value=void 0;try{if(!e||!e.length)return;await l.ensureUserHydrated(),E.value=!0;const t=p(r),i=[...new Set(e.filter(Boolean))];n.syncFromSharedCache();const a=new Set,f=[],y=[];if(i.forEach(s=>{if(F(s,t))return;const v=g(s,t),m=n.getPendingDictRequest(v);m?a.add(m):(f.push(s),y.push(v))}),f.length){let s;s=(async()=>{const v=await j.batchGetSysDictDataCacheVo(f,t),m={};f.forEach((O,U)=>{const S=y[U];n.isPendingDictRequest(S,s)&&(m[S]=P(v[S]??v[O]??[]))}),Object.keys(m).length&&n.setDictCacheEntries(m)})(),n.registerPendingDictRequest(y,s),s.then(()=>n.clearPendingDictRequest(y,s),()=>n.clearPendingDictRequest(y,s)),a.add(s)}await Promise.all(a),n.syncFromSharedCache()}catch(t){C.value=t,N.messageError(t)}finally{R-=1,k.value=R>0}},b=(e,r,t)=>{const i=q(r,t);return i&&D.value[i]&&D.value[i][e]?.label||e},A=(e,r,t)=>{const i=q(r,t);return i&&D.value[i]?.[e]?D.value[i][e]:{}},K=(e,r)=>{const t=g(e,r??p());return d.value[t]??[]},V=(e,r)=>{const t=L(e,r);if(!t)return[];const i=h.value[t],a=P(i);return a!==i&&a.some(f=>f.children?.length)&&n.setDictCacheEntries({[t]:a}),a},H=(e,r,t)=>{c(e,p(),r,t)};return o?.length&&(async()=>{try{await M(o,u)}finally{I.value=!0}})(),{getDict:M,userReady:E,dictReady:I,dictLoading:k,dictError:C,dictMap:h,dictDataMap:D,dictDefaultValueMap:d,getDictName:b,getDictData:A,getDictTypeData:V,getDictDefaultValue:K,clearDict:H}}export{he as default};
|
|
@@ -13,9 +13,12 @@ export interface dictDataMapType {
|
|
|
13
13
|
}
|
|
14
14
|
/** 跨应用共享的 plain 缓存(非 Vue ref,避免 wujie 子应用与宿主 ref 响应式隔离) */
|
|
15
15
|
export interface SharedDictCache {
|
|
16
|
+
version: number;
|
|
16
17
|
dictMap: dictMapType;
|
|
17
18
|
dictDataMap: dictDataMapType;
|
|
18
19
|
dictDefaultValueMap: dictMapType;
|
|
20
|
+
loadedKeys: Record<string, true>;
|
|
21
|
+
pendingRequests: Map<string, Promise<void>>;
|
|
19
22
|
}
|
|
20
23
|
declare global {
|
|
21
24
|
interface Window {
|
|
@@ -44,6 +47,12 @@ export declare const dictStore: import("pinia").StoreDefinition<"dictStore", Pic
|
|
|
44
47
|
dictDefaultValueMap: Ref<dictMapType, dictMapType>;
|
|
45
48
|
clearDictCache: (dictType?: string[], userOrgId?: string, orgId?: string, all?: Boolean) => void;
|
|
46
49
|
syncFromSharedCache: () => void;
|
|
50
|
+
setDictCacheEntries: (entries: dictMapType) => void;
|
|
51
|
+
isDictCacheLoaded: (key: string) => boolean;
|
|
52
|
+
getPendingDictRequest: (key: string) => Promise<void> | undefined;
|
|
53
|
+
registerPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
54
|
+
isPendingDictRequest: (key: string, request: Promise<void>) => boolean;
|
|
55
|
+
clearPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
47
56
|
publishToSharedCache: () => void;
|
|
48
57
|
}, "dictMap" | "dictDataMap" | "dictDefaultValueMap">, Pick<{
|
|
49
58
|
dictMap: Ref<dictMapType, dictMapType>;
|
|
@@ -51,6 +60,12 @@ export declare const dictStore: import("pinia").StoreDefinition<"dictStore", Pic
|
|
|
51
60
|
dictDefaultValueMap: Ref<dictMapType, dictMapType>;
|
|
52
61
|
clearDictCache: (dictType?: string[], userOrgId?: string, orgId?: string, all?: Boolean) => void;
|
|
53
62
|
syncFromSharedCache: () => void;
|
|
63
|
+
setDictCacheEntries: (entries: dictMapType) => void;
|
|
64
|
+
isDictCacheLoaded: (key: string) => boolean;
|
|
65
|
+
getPendingDictRequest: (key: string) => Promise<void> | undefined;
|
|
66
|
+
registerPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
67
|
+
isPendingDictRequest: (key: string, request: Promise<void>) => boolean;
|
|
68
|
+
clearPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
54
69
|
publishToSharedCache: () => void;
|
|
55
70
|
}, never>, Pick<{
|
|
56
71
|
dictMap: Ref<dictMapType, dictMapType>;
|
|
@@ -58,5 +73,11 @@ export declare const dictStore: import("pinia").StoreDefinition<"dictStore", Pic
|
|
|
58
73
|
dictDefaultValueMap: Ref<dictMapType, dictMapType>;
|
|
59
74
|
clearDictCache: (dictType?: string[], userOrgId?: string, orgId?: string, all?: Boolean) => void;
|
|
60
75
|
syncFromSharedCache: () => void;
|
|
76
|
+
setDictCacheEntries: (entries: dictMapType) => void;
|
|
77
|
+
isDictCacheLoaded: (key: string) => boolean;
|
|
78
|
+
getPendingDictRequest: (key: string) => Promise<void> | undefined;
|
|
79
|
+
registerPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
80
|
+
isPendingDictRequest: (key: string, request: Promise<void>) => boolean;
|
|
81
|
+
clearPendingDictRequest: (keys: string[], request: Promise<void>) => void;
|
|
61
82
|
publishToSharedCache: () => void;
|
|
62
|
-
}, "clearDictCache" | "syncFromSharedCache" | "publishToSharedCache">>;
|
|
83
|
+
}, "clearDictCache" | "syncFromSharedCache" | "setDictCacheEntries" | "isDictCacheLoaded" | "getPendingDictRequest" | "registerPendingDictRequest" | "isPendingDictRequest" | "clearPendingDictRequest" | "publishToSharedCache">>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineStore as
|
|
1
|
+
import{defineStore as K}from"pinia";import{ref as E}from"vue";import M from"crypto-js/enc-base64";import w from"crypto-js/enc-utf8";const D=2,v="dictStore:v2",h="adtec-dict-cache-update";function p(){return typeof window>"u"?window:window.__POWERED_BY_WUJIE__?window.parent:window}function S(e){const t=p().sessionStorage.getItem(v);if(t)try{const n=JSON.parse(M.parse(t).toString(w));if(n.version!==D||!n.dictMap)return;Object.entries(n.dictMap).forEach(([c,i])=>{e.dictMap[c]=i;const{dataMap:r,defaultList:f}=R(i);e.dictDataMap[c]=r,e.dictDefaultValueMap[c]=f}),n.loadedKeys?.forEach(c=>{e.loadedKeys[c]=!0})}catch{}}function V(e){if(typeof window>"u")return;const t=p().sessionStorage;try{const n=JSON.stringify({version:D,dictMap:e.dictMap,loadedKeys:Object.keys(e.loadedKeys)});t.setItem(v,M.stringify(w.parse(n)))}catch{}}function I(e,t){Object.keys(t).forEach(n=>{e[n]={...e[n],...t[n]}})}function g(e){const t={};return I(t,e),t}function R(e){const t={},n=[],c=[...e].reverse();for(;c.length;){const i=c.pop();t[i.value]={...i,children:void 0},i.isDefault==="1"&&n.push({...i,children:void 0}),i.children?.length&&c.push(...[...i.children].reverse())}return{dataMap:t,defaultList:n}}function l(e){Object.keys(e).forEach(t=>delete e[t])}function C(){const e=p();e.__ADTEC_SHARED_DICT_CACHE__?.version!==D&&(e.__ADTEC_SHARED_DICT_CACHE__={version:D,dictMap:{},dictDataMap:{},dictDefaultValueMap:{},loadedKeys:{},pendingRequests:new Map},S(e.__ADTEC_SHARED_DICT_CACHE__));const t=e.__ADTEC_SHARED_DICT_CACHE__;return(!t.pendingRequests||typeof t.pendingRequests.get!="function")&&(t.pendingRequests=new Map),t}function O(){if(typeof window>"u")return;const e=new CustomEvent(h);window.dispatchEvent(e);const t=p();if(t!==window)try{t.dispatchEvent(new CustomEvent(h))}catch{}}function $(){return C()}function F(e){S(C())}const J=K("dictStore",()=>{const e=C(),t=E({...e.dictMap}),n=E(g(e.dictDataMap)),c=E({...e.dictDefaultValueMap}),i=()=>{t.value={...e.dictMap},n.value=g(e.dictDataMap),c.value={...e.dictDefaultValueMap}},r=()=>{V(e),O(),i()},f=a=>{Object.entries(a).forEach(([o,s])=>{e.dictMap[o]=s;const{dataMap:_,defaultList:u}=R(s);e.dictDataMap[o]=_,e.dictDefaultValueMap[o]=u,e.loadedKeys[o]=!0}),r()},A=a=>e.loadedKeys[a]===!0,m=a=>e.pendingRequests.get(a),q=(a,o)=>{a.forEach(s=>e.pendingRequests.set(s,o))},T=(a,o)=>e.pendingRequests.get(a)===o,y=(a,o)=>{a.forEach(s=>{e.pendingRequests.get(s)===o&&e.pendingRequests.delete(s)})},H=()=>{f(t.value)};if(typeof window<"u"){window.addEventListener(h,i);const a=p();if(a!==window)try{a.addEventListener(h,i)}catch{}}return i(),{dictMap:t,dictDataMap:n,dictDefaultValueMap:c,clearDictCache:(a,o,s,_)=>{a&&a.length>0?(a.forEach(u=>{(s?[`${s}:${u}`]:[u,...o?[`${o}:${u}`]:[]]).forEach(d=>{delete t.value[d],delete n.value[d],delete c.value[d],delete e.dictMap[d],delete e.dictDataMap[d],delete e.dictDefaultValueMap[d],delete e.loadedKeys[d],e.pendingRequests.delete(d)})}),r()):_&&(t.value={},n.value={},c.value={},l(e.dictMap),l(e.dictDataMap),l(e.dictDefaultValueMap),l(e.loadedKeys),e.pendingRequests.clear(),r())},syncFromSharedCache:i,setDictCacheEntries:f,isDictCacheLoaded:A,getPendingDictRequest:m,registerPendingDictRequest:q,isPendingDictRequest:T,clearPendingDictRequest:y,publishToSharedCache:H}});export{J as dictStore,C as getSharedDictCache,$ as getSharedDictRefs,F as syncDictFromSessionStorage};
|