@ditari/bsui 1.0.52 → 1.0.54
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/cjs/components/components.cjs.js +1 -1
- package/dist/cjs/components/components.d.ts +16 -0
- package/dist/cjs/components/dic/DicReplace.cjs.js +1 -1
- package/dist/cjs/components/index.cjs.js +1 -1
- package/dist/cjs/components/select/DemoSelect.vue.cjs.js +1 -0
- package/dist/cjs/components/select/DemoSelect.vue.cjs2.js +1 -0
- package/dist/cjs/components/select/DemoSelect.vue.d.ts +17 -0
- package/dist/cjs/components/select/Select.vue.cjs.js +1 -1
- package/dist/cjs/components/worker-pool.cjs.js +1 -0
- package/dist/cjs/components/worker-pool.d.ts +11 -0
- package/dist/esm/components/components.d.ts +16 -0
- package/dist/esm/components/components.esm.js +24 -19
- package/dist/esm/components/dic/DicReplace.esm.js +11 -13
- package/dist/esm/components/index.esm.js +44 -39
- package/dist/esm/components/select/DemoSelect.vue.d.ts +17 -0
- package/dist/esm/components/select/DemoSelect.vue.esm.js +29 -0
- package/dist/esm/components/select/DemoSelect.vue.esm2.js +4 -0
- package/dist/esm/components/select/Select.vue.esm.js +39 -39
- package/dist/esm/components/worker-pool.d.ts +11 -0
- package/dist/esm/components/worker-pool.esm.js +29 -0
- package/package.json +1 -1
- package/src/components/components.ts +6 -0
- package/src/components/dic/DicReplace.tsx +7 -7
- package/src/components/index.ts +13 -10
- package/src/components/select/DemoSelect.vue +49 -0
- package/src/components/select/Select.vue +10 -10
- package/src/components/worker-pool.js +39 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../utils/install.cjs.js"),D=require("./form/index.cjs.js"),e=require("./layout/index.cjs.js"),n=require("./table/index.cjs.js"),i=require("./grid/index.cjs.js"),s=require("./select/index.cjs.js"),o=require("./desensitize/index.cjs.js"),u=require("./dic/index.cjs.js"),c=require("./modal/index.cjs.js"),l=require("./select/DemoSelect.vue.cjs.js"),t=r.default(l.default);exports.DForm=D.default;exports.DList=e.DList;exports.DMain=e.DMain;exports.DNavTabs=e.DNavTabs;exports.DShow=e.DShow;exports.DTable=n.DTable;exports.DGrid=i.DGrid;exports.DGridItem=i.DGridItem;exports.DSelect=s.DSelect;exports.DDesensitize=o.DDesensitize;exports.DicReplace=u.DDicReplace;exports.DModal=c.DModal;exports.DemoSelect=t;exports.default=t;
|
|
@@ -6,3 +6,19 @@ export { default as DSelect } from "./select";
|
|
|
6
6
|
export { default as DDesensitize } from "./desensitize";
|
|
7
7
|
export { default as DicReplace } from "./dic";
|
|
8
8
|
export { default as DModal } from "./modal";
|
|
9
|
+
export declare const DemoSelect: import("../utils/install").SFCWithInstall<import("vue").DefineComponent<{
|
|
10
|
+
name: {
|
|
11
|
+
type: import("vue").PropType<string>;
|
|
12
|
+
required: true;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
+
name: {
|
|
17
|
+
type: import("vue").PropType<string>;
|
|
18
|
+
required: true;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>>, {
|
|
22
|
+
name: string;
|
|
23
|
+
}>>;
|
|
24
|
+
export default DemoSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("../../store/modules/DataDictionary.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("../../store/modules/DataDictionary.cjs.js"),c=e.defineComponent({name:"DicReplace",props:{name:{type:String,default:""},value:{type:String,default:""}},setup(o){const{list:n}=u.useDataDicStore(),s=e.ref(!0),a=e.ref(""),t=e.inject("repWorkerPool").getWorker();return t.onerror=()=>{s.value=!1},t.onmessage=r=>{a.value=r.data},e.watchEffect(()=>{const r=o.value,l=o.name;t.postMessage({list:JSON.stringify(n),name:l,value:r})}),()=>e.createVNode(e.Fragment,null,[a.value])}});exports.default=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("pinia"),m=require("pinia-plugin-persistedstate"),s=require("./worker-pool.cjs.js"),f=require("./dic/replace.worker.cjs.js"),P=require("./select/dic.worker.cjs.js"),l=require("./components.cjs.js"),S=require("../directive/trim.cjs.js"),$=require("./table/index.cjs.js"),x=require("./select/index.cjs.js"),k=require("./desensitize/index.cjs.js"),v=require("./dic/index.cjs.js"),w=require("./modal/index.cjs.js"),b=require("./form/index.cjs.js"),u=require("./grid/index.cjs.js"),i=require("./layout/index.cjs.js"),c=l,a=function(e,d){Object.keys(c).forEach(D=>{const n=c[D];n.install&&e.use(n)});const r=q.createPinia();r.use(m.createPersistedState({storage:sessionStorage})),e.use(r),e.directive("trim",S.default),e.provide("menuIcon",d.menuIcon||{});const t=new s.default(P.default,2);t.initialize(),e.provide("dicWorkerPool",t);const o=new s.default(f.default,2);o.initialize(),e.provide("repWorkerPool",o)},M={install:a};exports.DemoSelect=l.DemoSelect;exports.DTable=$.DTable;exports.DSelect=x.DSelect;exports.DDesensitize=k.DDesensitize;exports.DicReplace=v.DDicReplace;exports.DModal=w.DModal;exports.DForm=b.default;exports.DGrid=u.DGrid;exports.DGridItem=u.DGridItem;exports.DList=i.DList;exports.DMain=i.DMain;exports.DNavTabs=i.DNavTabs;exports.DShow=i.DShow;exports.default=M;exports.install=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("../../store/modules/DataDictionary.cjs.js"),c={name:"DemoSelect"},u=e.defineComponent({...c,props:{name:{default:""}},setup(s){const n=s,t=e.inject("dicWorkerInstance"),o=e.ref([]);t.onmessage=a=>{o.value=a.data};const{list:r}=i.useDataDicStore();return e.onMounted(()=>{t.postMessage({list:JSON.stringify(r[n.name]),keywords:"",include:JSON.stringify([])})}),e.onUnmounted(()=>{t.terminate()}),(a,l)=>(e.openBlock(),e.createElementBlock("div",null,e.toDisplayString(n.name)+" "+e.toDisplayString(o.value),1))}});exports.default=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./DemoSelect.vue.cjs.js");exports.default=e.default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropType as __PropType } from 'vue';
|
|
2
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
3
|
+
name: {
|
|
4
|
+
type: __PropType<string>;
|
|
5
|
+
required: true;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
name: {
|
|
10
|
+
type: __PropType<string>;
|
|
11
|
+
required: true;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>>, {
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
export default _sfc_main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),L=require("../../store/modules/DataDictionary.cjs.js"),y={name:"DSelect"},B=e.defineComponent({...y,props:{value:{default:null},name:{default:""},disabled:{type:Boolean,default:!1},placeholder:{default:"请填写默认占位符啊!老铁"},include:{default:[]}},emits:["update:value","change","select"],setup(u,{emit:c}){const n=u,{getDicByKey:v,list:h}=L.useDataDicStore(),s=e.inject("dicWorkerPool").getWorker(),{modelValue:i,data:p,onSearch:S,onSelect:g,onChange:m}=C();function C(){let d=!0,t=[];const o=e.ref([]),l=e.ref(n.value);s.onerror=()=>{d=!1,t=v(n.name)},s.onmessage=a=>{o.value=a.data},e.watch(()=>n.include,()=>{f(l.value)}),e.watch(()=>n.value,a=>{l.value=a}),f(l.value);const w=a=>{d?f(a):o.list=t.filter(r=>r.value.toLowerCase().indexOf(a.toLowerCase())!==-1||r.label.toLowerCase().includes(a.toLowerCase())).splice(0,10)};function f(a){s.postMessage({list:JSON.stringify(h[n.name]),keywords:a,include:JSON.stringify(n.include??[])})}const b=a=>{c("update:value",a),D()},k=()=>{c("update:value",l.value),c("change",l.value)};function D(){const r=v(n.name).find(_=>_.value===l.value);c("select",r)}return{data:o,modelValue:l,onSearch:w,onSelect:b,onChange:k}}return(d,t)=>{const o=e.resolveComponent("a-select");return e.openBlock(),e.createBlock(o,{value:e.unref(i),"onUpdate:value":t[0]||(t[0]=l=>e.isRef(i)?i.value=l:null),"allow-clear":"","show-search":"","filter-option":!1,options:e.unref(p),placeholder:u.placeholder,disabled:u.disabled,onSelect:e.unref(g),onSearch:e.unref(S),onChange:e.unref(m)},null,8,["value","options","placeholder","disabled","onSelect","onSearch","onChange"])}}});exports.default=B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class t{constructor(e,o){this.workerClass=e,this.poolSize=o,this.pool=[],this.activeWorkers=new Set}initialize(){for(let e=0;e<this.poolSize;e++){const o=new this.workerClass;this.pool.push(o)}}getWorker(){if(this.pool.length>0){const e=this.pool.pop();return this.activeWorkers.add(e),e}return null}releaseWorker(e){this.pool.push(e),this.activeWorkers.delete(e)}cleanup(){for(const e of this.activeWorkers)e.terminate();this.pool=[],this.activeWorkers.clear()}}exports.default=t;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default class WorkerPool {
|
|
2
|
+
constructor(workerClass: any, poolSize: any);
|
|
3
|
+
workerClass: any;
|
|
4
|
+
poolSize: any;
|
|
5
|
+
pool: any[];
|
|
6
|
+
activeWorkers: Set<any>;
|
|
7
|
+
initialize(): void;
|
|
8
|
+
getWorker(): any;
|
|
9
|
+
releaseWorker(worker: any): void;
|
|
10
|
+
cleanup(): void;
|
|
11
|
+
}
|
|
@@ -6,3 +6,19 @@ export { default as DSelect } from "./select";
|
|
|
6
6
|
export { default as DDesensitize } from "./desensitize";
|
|
7
7
|
export { default as DicReplace } from "./dic";
|
|
8
8
|
export { default as DModal } from "./modal";
|
|
9
|
+
export declare const DemoSelect: import("../utils/install").SFCWithInstall<import("vue").DefineComponent<{
|
|
10
|
+
name: {
|
|
11
|
+
type: import("vue").PropType<string>;
|
|
12
|
+
required: true;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
+
name: {
|
|
17
|
+
type: import("vue").PropType<string>;
|
|
18
|
+
required: true;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>>, {
|
|
22
|
+
name: string;
|
|
23
|
+
}>>;
|
|
24
|
+
export default DemoSelect;
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import o from "../utils/install.esm.js";
|
|
2
|
+
import { default as f } from "./form/index.esm.js";
|
|
3
|
+
import { DList as i, DMain as l, DNavTabs as s, DShow as x } from "./layout/index.esm.js";
|
|
4
|
+
import { DTable as d } from "./table/index.esm.js";
|
|
5
|
+
import { DGrid as S, DGridItem as b } from "./grid/index.esm.js";
|
|
6
|
+
import { DSelect as u } from "./select/index.esm.js";
|
|
7
|
+
import { DDesensitize as G } from "./desensitize/index.esm.js";
|
|
7
8
|
import { DDicReplace as M } from "./dic/index.esm.js";
|
|
8
|
-
import { DModal as
|
|
9
|
+
import { DModal as T } from "./modal/index.esm.js";
|
|
10
|
+
import e from "./select/DemoSelect.vue.esm.js";
|
|
11
|
+
const m = o(e);
|
|
9
12
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
G as DDesensitize,
|
|
14
|
+
f as DForm,
|
|
15
|
+
S as DGrid,
|
|
16
|
+
b as DGridItem,
|
|
17
|
+
i as DList,
|
|
18
|
+
l as DMain,
|
|
19
|
+
T as DModal,
|
|
20
|
+
s as DNavTabs,
|
|
21
|
+
u as DSelect,
|
|
22
|
+
x as DShow,
|
|
23
|
+
d as DTable,
|
|
24
|
+
m as DemoSelect,
|
|
25
|
+
M as DicReplace,
|
|
26
|
+
m as default
|
|
22
27
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useDataDicStore as
|
|
3
|
-
const v = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as c, ref as a, inject as u, watchEffect as i, createVNode as p, Fragment as f } from "vue";
|
|
2
|
+
import { useDataDicStore as m } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const v = /* @__PURE__ */ c({
|
|
4
4
|
name: "DicReplace",
|
|
5
5
|
props: {
|
|
6
6
|
// 字典名称
|
|
@@ -14,24 +14,22 @@ const v = /* @__PURE__ */ l({
|
|
|
14
14
|
default: ""
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
setup(
|
|
17
|
+
setup(o) {
|
|
18
18
|
const {
|
|
19
|
-
list:
|
|
20
|
-
} =
|
|
21
|
-
console.log(e);
|
|
22
|
-
const s = o(!0), n = o("");
|
|
19
|
+
list: n
|
|
20
|
+
} = m(), s = a(!0), r = a(""), e = u("repWorkerPool").getWorker();
|
|
23
21
|
return e.onerror = () => {
|
|
24
22
|
s.value = !1;
|
|
25
23
|
}, e.onmessage = (t) => {
|
|
26
|
-
|
|
24
|
+
r.value = t.data;
|
|
27
25
|
}, i(() => {
|
|
28
|
-
const t =
|
|
26
|
+
const t = o.value, l = o.name;
|
|
29
27
|
e.postMessage({
|
|
30
|
-
list: JSON.stringify(
|
|
31
|
-
name:
|
|
28
|
+
list: JSON.stringify(n),
|
|
29
|
+
name: l,
|
|
32
30
|
value: t
|
|
33
31
|
});
|
|
34
|
-
}), () => f
|
|
32
|
+
}), () => p(f, null, [r.value]);
|
|
35
33
|
}
|
|
36
34
|
});
|
|
37
35
|
export {
|
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import { createPinia as
|
|
2
|
-
import { createPersistedState as
|
|
3
|
-
import
|
|
1
|
+
import { createPinia as a } from "pinia";
|
|
2
|
+
import { createPersistedState as f } from "pinia-plugin-persistedstate";
|
|
3
|
+
import m from "./worker-pool.esm.js";
|
|
4
|
+
import p from "./dic/replace.worker.esm.js";
|
|
4
5
|
import l from "./select/dic.worker.esm.js";
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
i.install && e.use(i);
|
|
6
|
+
import * as D from "./components.esm.js";
|
|
7
|
+
import { DemoSelect as I } from "./components.esm.js";
|
|
8
|
+
import d from "../directive/trim.esm.js";
|
|
9
|
+
import { DTable as g } from "./table/index.esm.js";
|
|
10
|
+
import { DSelect as G } from "./select/index.esm.js";
|
|
11
|
+
import { DDesensitize as R } from "./desensitize/index.esm.js";
|
|
12
|
+
import { DDicReplace as y } from "./dic/index.esm.js";
|
|
13
|
+
import { DModal as F } from "./modal/index.esm.js";
|
|
14
|
+
import { default as N } from "./form/index.esm.js";
|
|
15
|
+
import { DGrid as $, DGridItem as q } from "./grid/index.esm.js";
|
|
16
|
+
import { DList as B, DMain as C, DNavTabs as H, DShow as J } from "./layout/index.esm.js";
|
|
17
|
+
const n = D, x = function(o, s) {
|
|
18
|
+
Object.keys(n).forEach((c) => {
|
|
19
|
+
const i = n[c];
|
|
20
|
+
i.install && o.use(i);
|
|
21
21
|
});
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const r = a();
|
|
23
|
+
r.use(
|
|
24
|
+
f({
|
|
25
25
|
storage: sessionStorage
|
|
26
26
|
})
|
|
27
|
-
),
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
), o.use(r), o.directive("trim", d), o.provide("menuIcon", s.menuIcon || {});
|
|
28
|
+
const e = new m(l, 2);
|
|
29
|
+
e.initialize(), o.provide("dicWorkerPool", e);
|
|
30
|
+
const t = new m(p, 2);
|
|
31
|
+
t.initialize(), o.provide("repWorkerPool", t);
|
|
32
|
+
}, w = {
|
|
33
|
+
install: x
|
|
30
34
|
};
|
|
31
35
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
R as DDesensitize,
|
|
37
|
+
N as DForm,
|
|
38
|
+
$ as DGrid,
|
|
39
|
+
q as DGridItem,
|
|
40
|
+
B as DList,
|
|
41
|
+
C as DMain,
|
|
42
|
+
F as DModal,
|
|
43
|
+
H as DNavTabs,
|
|
44
|
+
G as DSelect,
|
|
45
|
+
J as DShow,
|
|
46
|
+
g as DTable,
|
|
47
|
+
I as DemoSelect,
|
|
48
|
+
y as DicReplace,
|
|
49
|
+
w as default,
|
|
50
|
+
x as install
|
|
46
51
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropType as __PropType } from 'vue';
|
|
2
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
3
|
+
name: {
|
|
4
|
+
type: __PropType<string>;
|
|
5
|
+
required: true;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
name: {
|
|
10
|
+
type: __PropType<string>;
|
|
11
|
+
required: true;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>>, {
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
export default _sfc_main;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineComponent as c, inject as i, ref as l, onMounted as m, onUnmounted as u, openBlock as d, createElementBlock as p, toDisplayString as a } from "vue";
|
|
2
|
+
import { useDataDicStore as f } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const _ = {
|
|
4
|
+
name: "DemoSelect"
|
|
5
|
+
}, y = /* @__PURE__ */ c({
|
|
6
|
+
..._,
|
|
7
|
+
props: {
|
|
8
|
+
name: { default: "" }
|
|
9
|
+
},
|
|
10
|
+
setup(s) {
|
|
11
|
+
const t = s, e = i("dicWorkerInstance"), n = l([]);
|
|
12
|
+
e.onmessage = (o) => {
|
|
13
|
+
n.value = o.data;
|
|
14
|
+
};
|
|
15
|
+
const { list: r } = f();
|
|
16
|
+
return m(() => {
|
|
17
|
+
e.postMessage({
|
|
18
|
+
list: JSON.stringify(r[t.name]),
|
|
19
|
+
keywords: "",
|
|
20
|
+
include: JSON.stringify([])
|
|
21
|
+
});
|
|
22
|
+
}), u(() => {
|
|
23
|
+
e.terminate();
|
|
24
|
+
}), (o, g) => (d(), p("div", null, a(t.name) + " " + a(n.value), 1));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
y as default
|
|
29
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as x,
|
|
2
|
-
import { useDataDicStore as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as x, inject as y, ref as v, watch as h, resolveComponent as O, openBlock as P, createBlock as V, unref as t, isRef as W } from "vue";
|
|
2
|
+
import { useDataDicStore as J } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const N = {
|
|
4
4
|
name: "DSelect"
|
|
5
|
-
},
|
|
6
|
-
...
|
|
5
|
+
}, K = /* @__PURE__ */ x({
|
|
6
|
+
...N,
|
|
7
7
|
props: {
|
|
8
8
|
value: { default: null },
|
|
9
9
|
name: { default: "" },
|
|
@@ -12,15 +12,15 @@ const j = {
|
|
|
12
12
|
include: { default: [] }
|
|
13
13
|
},
|
|
14
14
|
emits: ["update:value", "change", "select"],
|
|
15
|
-
setup(
|
|
16
|
-
const l =
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
15
|
+
setup(s, { emit: c }) {
|
|
16
|
+
const l = s, { getDicByKey: p, list: S } = J(), u = y("dicWorkerPool").getWorker(), { modelValue: d, data: m, onSearch: g, onSelect: C, onChange: w } = k();
|
|
17
|
+
function k() {
|
|
18
|
+
let i = !0, o = [];
|
|
19
|
+
const n = v([]), a = v(l.value);
|
|
20
|
+
u.onerror = () => {
|
|
21
|
+
i = !1, o = p(l.name);
|
|
22
|
+
}, u.onmessage = (e) => {
|
|
23
|
+
n.value = e.data;
|
|
24
24
|
}, h(
|
|
25
25
|
() => l.include,
|
|
26
26
|
() => {
|
|
@@ -32,51 +32,51 @@ const j = {
|
|
|
32
32
|
a.value = e;
|
|
33
33
|
}
|
|
34
34
|
), f(a.value);
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const L = (e) => {
|
|
36
|
+
i ? f(e) : n.list = o.filter((r) => r.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || r.label.toLowerCase().includes(e.toLowerCase())).splice(0, 10);
|
|
37
37
|
};
|
|
38
38
|
function f(e) {
|
|
39
|
-
|
|
39
|
+
u.postMessage({
|
|
40
40
|
list: JSON.stringify(S[l.name]),
|
|
41
41
|
keywords: e,
|
|
42
42
|
include: JSON.stringify(l.include ?? [])
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
c("update:value", e),
|
|
47
|
-
},
|
|
45
|
+
const b = (e) => {
|
|
46
|
+
c("update:value", e), _();
|
|
47
|
+
}, D = () => {
|
|
48
48
|
c("update:value", a.value), c("change", a.value);
|
|
49
49
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
c("select",
|
|
50
|
+
function _() {
|
|
51
|
+
const r = p(l.name).find((B) => B.value === a.value);
|
|
52
|
+
c("select", r);
|
|
53
53
|
}
|
|
54
54
|
return {
|
|
55
|
-
data:
|
|
55
|
+
data: n,
|
|
56
56
|
modelValue: a,
|
|
57
|
-
onSearch:
|
|
58
|
-
onSelect:
|
|
59
|
-
onChange:
|
|
57
|
+
onSearch: L,
|
|
58
|
+
onSelect: b,
|
|
59
|
+
onChange: D
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
return (
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
value:
|
|
66
|
-
"onUpdate:value":
|
|
62
|
+
return (i, o) => {
|
|
63
|
+
const n = O("a-select");
|
|
64
|
+
return P(), V(n, {
|
|
65
|
+
value: t(d),
|
|
66
|
+
"onUpdate:value": o[0] || (o[0] = (a) => W(d) ? d.value = a : null),
|
|
67
67
|
"allow-clear": "",
|
|
68
68
|
"show-search": "",
|
|
69
69
|
"filter-option": !1,
|
|
70
|
-
options:
|
|
71
|
-
placeholder:
|
|
72
|
-
disabled:
|
|
73
|
-
onSelect:
|
|
74
|
-
onSearch:
|
|
75
|
-
onChange:
|
|
70
|
+
options: t(m),
|
|
71
|
+
placeholder: s.placeholder,
|
|
72
|
+
disabled: s.disabled,
|
|
73
|
+
onSelect: t(C),
|
|
74
|
+
onSearch: t(g),
|
|
75
|
+
onChange: t(w)
|
|
76
76
|
}, null, 8, ["value", "options", "placeholder", "disabled", "onSelect", "onSearch", "onChange"]);
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
export {
|
|
81
|
-
|
|
81
|
+
K as default
|
|
82
82
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default class WorkerPool {
|
|
2
|
+
constructor(workerClass: any, poolSize: any);
|
|
3
|
+
workerClass: any;
|
|
4
|
+
poolSize: any;
|
|
5
|
+
pool: any[];
|
|
6
|
+
activeWorkers: Set<any>;
|
|
7
|
+
initialize(): void;
|
|
8
|
+
getWorker(): any;
|
|
9
|
+
releaseWorker(worker: any): void;
|
|
10
|
+
cleanup(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
constructor(e, o) {
|
|
3
|
+
this.workerClass = e, this.poolSize = o, this.pool = [], this.activeWorkers = /* @__PURE__ */ new Set();
|
|
4
|
+
}
|
|
5
|
+
initialize() {
|
|
6
|
+
for (let e = 0; e < this.poolSize; e++) {
|
|
7
|
+
const o = new this.workerClass();
|
|
8
|
+
this.pool.push(o);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
getWorker() {
|
|
12
|
+
if (this.pool.length > 0) {
|
|
13
|
+
const e = this.pool.pop();
|
|
14
|
+
return this.activeWorkers.add(e), e;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
releaseWorker(e) {
|
|
19
|
+
this.pool.push(e), this.activeWorkers.delete(e);
|
|
20
|
+
}
|
|
21
|
+
cleanup() {
|
|
22
|
+
for (const e of this.activeWorkers)
|
|
23
|
+
e.terminate();
|
|
24
|
+
this.pool = [], this.activeWorkers.clear();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
r as default
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withInstall } from "../utils";
|
|
2
|
+
|
|
1
3
|
export { default as DForm } from "./form";
|
|
2
4
|
export * from "./layout";
|
|
3
5
|
export { default as DTable } from "./table";
|
|
@@ -6,3 +8,7 @@ export { default as DSelect } from "./select";
|
|
|
6
8
|
export { default as DDesensitize } from "./desensitize";
|
|
7
9
|
export { default as DicReplace } from "./dic";
|
|
8
10
|
export { default as DModal } from "./modal";
|
|
11
|
+
|
|
12
|
+
import Select from "./select/DemoSelect.vue";
|
|
13
|
+
export const DemoSelect = withInstall(Select);
|
|
14
|
+
export default DemoSelect;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* 根据字典名字及对应的value替换成中文或者人能看懂的文字
|
|
4
4
|
* @author 余春林
|
|
5
5
|
*/
|
|
6
|
-
import { defineComponent, ref, watchEffect
|
|
6
|
+
import { defineComponent, inject, ref, watchEffect } from "vue";
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
8
|
// @ts-ignore
|
|
9
|
-
|
|
9
|
+
import DicWorker from "./replace.worker?worker&inline";
|
|
10
10
|
import { useDataDicStore } from "../../store/modules/DataDictionary";
|
|
11
11
|
|
|
12
12
|
export default defineComponent({
|
|
@@ -25,13 +25,12 @@ export default defineComponent({
|
|
|
25
25
|
},
|
|
26
26
|
setup(props) {
|
|
27
27
|
const { list } = useDataDicStore();
|
|
28
|
-
|
|
29
|
-
console.log(workerInstance);
|
|
28
|
+
|
|
30
29
|
const workerStatus = ref(true);
|
|
31
30
|
const dicValueTxt = ref<any>("");
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
31
|
+
const repWorkerPool: any = inject("repWorkerPool");
|
|
32
|
+
// 获取worker
|
|
33
|
+
const workerInstance: any = repWorkerPool.getWorker();
|
|
35
34
|
/**
|
|
36
35
|
* web worker 启动失败
|
|
37
36
|
*/
|
|
@@ -43,6 +42,7 @@ export default defineComponent({
|
|
|
43
42
|
* @param e
|
|
44
43
|
*/
|
|
45
44
|
workerInstance.onmessage = (e: any) => {
|
|
45
|
+
// 赋值给下拉选择数据变量
|
|
46
46
|
dicValueTxt.value = e.data;
|
|
47
47
|
};
|
|
48
48
|
watchEffect(() => {
|
package/src/components/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { App } from "vue";
|
|
2
2
|
import { createPinia } from "pinia";
|
|
3
3
|
import { createPersistedState } from "pinia-plugin-persistedstate";
|
|
4
|
+
import WorkerPool from "./worker-pool";
|
|
4
5
|
|
|
5
6
|
import ReplaceWorker from "./dic/replace.worker?worker&inline";
|
|
6
7
|
import DicWorker from "./select/dic.worker?worker&inline";
|
|
@@ -19,8 +20,6 @@ export interface Options {
|
|
|
19
20
|
prop?: string;
|
|
20
21
|
}
|
|
21
22
|
const c: any = components;
|
|
22
|
-
let replaceWorkerInstance: any = null;
|
|
23
|
-
let dicWorkerInstance: any = null;
|
|
24
23
|
|
|
25
24
|
export const install = function (app: App, opts: Options) {
|
|
26
25
|
Object.keys(c).forEach((key) => {
|
|
@@ -40,14 +39,18 @@ export const install = function (app: App, opts: Options) {
|
|
|
40
39
|
app.use(pinia);
|
|
41
40
|
app.directive("trim", vTrim);
|
|
42
41
|
app.provide("menuIcon", opts.menuIcon || {});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
|
|
43
|
+
// 创建 Web Worker 连接池实例
|
|
44
|
+
const workerPool = new WorkerPool(DicWorker, 2); // 这里设置连接池的大小为 5
|
|
45
|
+
workerPool.initialize();
|
|
46
|
+
// 注入连接池实例
|
|
47
|
+
app.provide("dicWorkerPool", workerPool);
|
|
48
|
+
// 创建 Web Worker 连接池实例
|
|
49
|
+
const repWorkerPool = new WorkerPool(ReplaceWorker, 2); // 这里设置连接池的大小为 5
|
|
50
|
+
repWorkerPool.initialize();
|
|
51
|
+
// 注入连接池实例
|
|
52
|
+
app.provide("repWorkerPool", repWorkerPool);
|
|
53
|
+
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
export default {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, onMounted, onUnmounted, inject } from "vue";
|
|
3
|
+
import { useDataDicStore } from "../../store/modules/DataDictionary";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
name: string; //字典名字
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
10
|
+
name: ""
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const workerInstance: any = inject("dicWorkerInstance");
|
|
14
|
+
|
|
15
|
+
const data = ref([]);
|
|
16
|
+
|
|
17
|
+
// 监听 Web Worker 的消息
|
|
18
|
+
workerInstance.onmessage = (event: any) => {
|
|
19
|
+
data.value = event.data;
|
|
20
|
+
};
|
|
21
|
+
const { list } = useDataDicStore();
|
|
22
|
+
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
workerInstance.postMessage({
|
|
25
|
+
list: JSON.stringify(list[props.name]),
|
|
26
|
+
keywords: "",
|
|
27
|
+
include: JSON.stringify([])
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
onUnmounted(() => {
|
|
32
|
+
// 组件销毁时终止 Web Worker
|
|
33
|
+
workerInstance.terminate();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// 其他组件逻辑...
|
|
37
|
+
</script>
|
|
38
|
+
<script lang="ts">
|
|
39
|
+
export default {
|
|
40
|
+
name: "DemoSelect"
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
<template>
|
|
44
|
+
<div>
|
|
45
|
+
{{ props.name }}
|
|
46
|
+
{{ data }}
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
<style scoped></style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { inject, ref, watch } from "vue";
|
|
2
|
+
import { inject, reactive, ref, watch } from "vue";
|
|
3
3
|
import { useDataDicStore } from "../../store/modules/DataDictionary";
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
5
|
// @ts-ignore
|
|
@@ -30,20 +30,20 @@ const emits = defineEmits<Emits>();
|
|
|
30
30
|
|
|
31
31
|
const { getDicByKey, list } = useDataDicStore();
|
|
32
32
|
|
|
33
|
+
const workerPool: any = inject("dicWorkerPool");
|
|
34
|
+
// 获取worker
|
|
35
|
+
const workerInstance: any = workerPool.getWorker();
|
|
36
|
+
|
|
33
37
|
const { modelValue, data, onSearch, onSelect, onChange } = useSelect();
|
|
38
|
+
|
|
34
39
|
function useSelect() {
|
|
35
40
|
// 保存worker启动状态
|
|
36
41
|
let workerStatus = true;
|
|
37
42
|
let dicData: any[] = [];
|
|
38
|
-
const data = ref(
|
|
43
|
+
const data = ref<any>([]);
|
|
39
44
|
// 取值
|
|
40
45
|
const modelValue = ref(props.value);
|
|
41
|
-
|
|
42
|
-
const workerInstance: any = inject("workerInstance");
|
|
43
|
-
// if (!workerInstance) {
|
|
44
|
-
// console.log("一次");
|
|
45
|
-
// workerInstance = new DicWorker();
|
|
46
|
-
// }
|
|
46
|
+
|
|
47
47
|
/**
|
|
48
48
|
* web worker 启动失败
|
|
49
49
|
*/
|
|
@@ -58,7 +58,7 @@ function useSelect() {
|
|
|
58
58
|
*/
|
|
59
59
|
workerInstance.onmessage = (e: any) => {
|
|
60
60
|
// 赋值给下拉选择数据变量
|
|
61
|
-
data.value =
|
|
61
|
+
data.value = e.data;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// 当include变化的时候,需要重新发送搜索事件 返回对应的下拉数据
|
|
@@ -85,7 +85,7 @@ function useSelect() {
|
|
|
85
85
|
if (workerStatus) {
|
|
86
86
|
sendWorkerSearch(keywords);
|
|
87
87
|
} else {
|
|
88
|
-
data.
|
|
88
|
+
data.list = dicData
|
|
89
89
|
.filter((item: any) => {
|
|
90
90
|
return (
|
|
91
91
|
item.value.toLowerCase().indexOf(keywords.toLowerCase()) !== -1 ||
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// worker-pool.js
|
|
2
|
+
|
|
3
|
+
export default class WorkerPool {
|
|
4
|
+
constructor(workerClass, poolSize) {
|
|
5
|
+
this.workerClass = workerClass;
|
|
6
|
+
this.poolSize = poolSize;
|
|
7
|
+
this.pool = [];
|
|
8
|
+
this.activeWorkers = new Set();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
initialize() {
|
|
12
|
+
for (let i = 0; i < this.poolSize; i++) {
|
|
13
|
+
const worker = new this.workerClass();
|
|
14
|
+
this.pool.push(worker);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getWorker() {
|
|
19
|
+
if (this.pool.length > 0) {
|
|
20
|
+
const worker = this.pool.pop();
|
|
21
|
+
this.activeWorkers.add(worker);
|
|
22
|
+
return worker;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
releaseWorker(worker) {
|
|
28
|
+
this.pool.push(worker);
|
|
29
|
+
this.activeWorkers.delete(worker);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
cleanup() {
|
|
33
|
+
for (const worker of this.activeWorkers) {
|
|
34
|
+
worker.terminate();
|
|
35
|
+
}
|
|
36
|
+
this.pool = [];
|
|
37
|
+
this.activeWorkers.clear();
|
|
38
|
+
}
|
|
39
|
+
}
|