@ditari/bsui 1.0.53 → 1.0.55
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/dic/DicReplace.cjs.js +1 -1
- package/dist/cjs/components/index.cjs.js +1 -1
- package/dist/cjs/components/select/Select.vue.cjs.js +1 -1
- package/dist/cjs/components/worker-pool.d.ts +11 -0
- package/dist/esm/components/dic/DicReplace.esm.js +11 -21
- package/dist/esm/components/index.esm.js +35 -39
- package/dist/esm/components/select/Select.vue.esm.js +40 -49
- package/dist/esm/components/worker-pool.d.ts +11 -0
- package/package.json +1 -1
- package/src/components/dic/DicReplace.tsx +17 -16
- package/src/components/index.ts +14 -12
- package/src/components/select/Select.vue +38 -37
- package/src/components/worker-pool.js +39 -0
- package/dist/cjs/components/dic/replace.worker.cjs.js +0 -1
- package/dist/cjs/components/select/dic.worker.cjs.js +0 -1
- package/dist/esm/components/dic/replace.worker.esm.js +0 -12
- package/dist/esm/components/select/dic.worker.esm.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("../../store/modules/DataDictionary.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("../../store/modules/DataDictionary.cjs.js"),r=e.defineComponent({name:"DicReplace",props:{name:{type:String,default:""},value:{type:String,default:""}},setup(t){const{getDicTextByValue:u}=l.useDataDicStore(),a=e.ref("");return e.watchEffect(()=>{const n=t.value,c=t.name;a.value=u(c,n)}),()=>e.createVNode(e.Fragment,null,[a.value])}});exports.default=r;
|
|
@@ -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 u=require("pinia"),D=require("pinia-plugin-persistedstate"),d=require("./components.cjs.js"),l=require("../directive/trim.cjs.js"),q=require("./table/index.cjs.js"),m=require("./select/index.cjs.js"),x=require("./desensitize/index.cjs.js"),$=require("./dic/index.cjs.js"),S=require("./modal/index.cjs.js"),b=require("./form/index.cjs.js"),r=require("./grid/index.cjs.js"),i=require("./layout/index.cjs.js"),s=d,o=function(e,c){Object.keys(s).forEach(a=>{const n=s[a];n.install&&e.use(n)});const t=u.createPinia();t.use(D.createPersistedState({storage:sessionStorage})),e.use(t),e.directive("trim",l.default),e.provide("menuIcon",c.menuIcon||{})},f={install:o};exports.DTable=q.DTable;exports.DSelect=m.DSelect;exports.DDesensitize=x.DDesensitize;exports.DicReplace=$.DDicReplace;exports.DModal=S.DModal;exports.DForm=b.default;exports.DGrid=r.DGrid;exports.DGridItem=r.DGridItem;exports.DList=i.DList;exports.DMain=i.DMain;exports.DNavTabs=i.DNavTabs;exports.DShow=i.DShow;exports.default=f;exports.install=o;
|
|
@@ -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"),_=require("../../store/modules/DataDictionary.cjs.js"),L={name:"DSelect"},w=e.defineComponent({...L,props:{value:{default:null},name:{default:""},disabled:{type:Boolean,default:!1},placeholder:{default:"请填写默认占位符啊!老铁"},include:{default:[]}},emits:["update:value","change","select"],setup(u,{emit:o}){const t=u,{getDicByKey:f}=_.useDataDicStore(),{modelValue:r,data:v,onSearch:h,onSelect:p,onChange:S}=g();function g(){const s=[...f(t.name)],n=e.ref([]),l=e.ref(t.value);e.watch(()=>t.include,()=>{i(l.value)}),e.watch(()=>t.value,a=>{l.value=a}),i(l.value);const d=a=>{i(a)};function i(a){a=a.trim(),n.value=s.filter(c=>c.value.toLowerCase().indexOf(a.toLowerCase())!==-1||c.label.toLowerCase().includes(a.toLowerCase())).splice(0,10),n.value.length===0&&(n.value=[...s].splice(0,10))}const m=a=>{o("update:value",a),b()},C=()=>{o("update:value",l.value),o("change",l.value)};function b(){const c=f(t.name).find(D=>D.value===l.value);o("select",c)}return{data:n,modelValue:l,onSearch:d,onSelect:m,onChange:C}}return(s,n)=>{const l=e.resolveComponent("a-select");return e.openBlock(),e.createBlock(l,{value:e.unref(r),"onUpdate:value":n[0]||(n[0]=d=>e.isRef(r)?r.value=d:null),"allow-clear":"","show-search":"","filter-option":!1,options:e.unref(v),placeholder:u.placeholder,disabled:u.disabled,onSelect:e.unref(p),onSearch:e.unref(h),onChange:e.unref(S)},null,8,["value","options","placeholder","disabled","onSelect","onSearch","onChange"])}}});exports.default=w;
|
|
@@ -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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as l,
|
|
2
|
-
import { useDataDicStore as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as l, ref as o, watchEffect as u, createVNode as r, Fragment as i } from "vue";
|
|
2
|
+
import { useDataDicStore as m } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const s = /* @__PURE__ */ l({
|
|
4
4
|
name: "DicReplace",
|
|
5
5
|
props: {
|
|
6
6
|
// 字典名称
|
|
@@ -14,26 +14,16 @@ const v = /* @__PURE__ */ l({
|
|
|
14
14
|
default: ""
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
setup(
|
|
17
|
+
setup(e) {
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
} =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, e.onmessage = (t) => {
|
|
26
|
-
n.value = t.data;
|
|
27
|
-
}, i(() => {
|
|
28
|
-
const t = a.value, c = a.name;
|
|
29
|
-
e.postMessage({
|
|
30
|
-
list: JSON.stringify(r),
|
|
31
|
-
name: c,
|
|
32
|
-
value: t
|
|
33
|
-
});
|
|
34
|
-
}), () => f(m, null, [n.value]);
|
|
19
|
+
getDicTextByValue: a
|
|
20
|
+
} = m(), t = o("");
|
|
21
|
+
return u(() => {
|
|
22
|
+
const n = e.value, c = e.name;
|
|
23
|
+
t.value = a(c, n);
|
|
24
|
+
}), () => r(i, null, [t.value]);
|
|
35
25
|
}
|
|
36
26
|
});
|
|
37
27
|
export {
|
|
38
|
-
|
|
28
|
+
s as default
|
|
39
29
|
};
|
|
@@ -1,46 +1,42 @@
|
|
|
1
1
|
import { createPinia as m } from "pinia";
|
|
2
|
-
import { createPersistedState as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const d = function(e, s) {
|
|
18
|
-
Object.keys(n).forEach((c) => {
|
|
19
|
-
const i = n[c];
|
|
20
|
-
i.install && e.use(i);
|
|
2
|
+
import { createPersistedState as n } from "pinia-plugin-persistedstate";
|
|
3
|
+
import * as c from "./components.esm.js";
|
|
4
|
+
import a from "../directive/trim.esm.js";
|
|
5
|
+
import { DTable as v } from "./table/index.esm.js";
|
|
6
|
+
import { DSelect as b } from "./select/index.esm.js";
|
|
7
|
+
import { DDesensitize as T } from "./desensitize/index.esm.js";
|
|
8
|
+
import { DDicReplace as h } from "./dic/index.esm.js";
|
|
9
|
+
import { DModal as M } from "./modal/index.esm.js";
|
|
10
|
+
import { default as R } from "./form/index.esm.js";
|
|
11
|
+
import { DGrid as k, DGridItem as w } from "./grid/index.esm.js";
|
|
12
|
+
import { DList as z, DMain as E, DNavTabs as F, DShow as L } from "./layout/index.esm.js";
|
|
13
|
+
const r = c, f = function(e, i) {
|
|
14
|
+
Object.keys(r).forEach((s) => {
|
|
15
|
+
const t = r[s];
|
|
16
|
+
t.install && e.use(t);
|
|
21
17
|
});
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const o = m();
|
|
19
|
+
o.use(
|
|
20
|
+
n({
|
|
25
21
|
storage: sessionStorage
|
|
26
22
|
})
|
|
27
|
-
), e.use(
|
|
28
|
-
},
|
|
29
|
-
install:
|
|
23
|
+
), e.use(o), e.directive("trim", a), e.provide("menuIcon", i.menuIcon || {});
|
|
24
|
+
}, x = {
|
|
25
|
+
install: f
|
|
30
26
|
};
|
|
31
27
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
T as DDesensitize,
|
|
29
|
+
R as DForm,
|
|
30
|
+
k as DGrid,
|
|
31
|
+
w as DGridItem,
|
|
32
|
+
z as DList,
|
|
33
|
+
E as DMain,
|
|
34
|
+
M as DModal,
|
|
35
|
+
F as DNavTabs,
|
|
36
|
+
b as DSelect,
|
|
37
|
+
L as DShow,
|
|
38
|
+
v as DTable,
|
|
39
|
+
h as DicReplace,
|
|
40
|
+
x as default,
|
|
41
|
+
f as install
|
|
46
42
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useDataDicStore as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as w, ref as p, watch as v, resolveComponent as B, openBlock as x, createBlock as V, unref as o, isRef as H } from "vue";
|
|
2
|
+
import { useDataDicStore as K } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const O = {
|
|
4
4
|
name: "DSelect"
|
|
5
|
-
},
|
|
6
|
-
...
|
|
5
|
+
}, W = /* @__PURE__ */ w({
|
|
6
|
+
...O,
|
|
7
7
|
props: {
|
|
8
8
|
value: { default: null },
|
|
9
9
|
name: { default: "" },
|
|
@@ -12,71 +12,62 @@ const W = {
|
|
|
12
12
|
include: { default: [] }
|
|
13
13
|
},
|
|
14
14
|
emits: ["update:value", "change", "select"],
|
|
15
|
-
setup(u, { emit:
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
d = !1, n = p(l.name);
|
|
22
|
-
}, i.onmessage = (e) => {
|
|
23
|
-
t.value = [...e.data];
|
|
24
|
-
}, h(
|
|
25
|
-
() => l.include,
|
|
15
|
+
setup(u, { emit: t }) {
|
|
16
|
+
const n = u, { getDicByKey: f } = K(), { modelValue: s, data: h, onSearch: S, onSelect: m, onChange: C } = g();
|
|
17
|
+
function g() {
|
|
18
|
+
const r = [...f(n.name)], l = p([]), a = p(n.value);
|
|
19
|
+
v(
|
|
20
|
+
() => n.include,
|
|
26
21
|
() => {
|
|
27
|
-
|
|
22
|
+
i(a.value);
|
|
28
23
|
}
|
|
29
|
-
),
|
|
30
|
-
() =>
|
|
24
|
+
), v(
|
|
25
|
+
() => n.value,
|
|
31
26
|
(e) => {
|
|
32
27
|
a.value = e;
|
|
33
28
|
}
|
|
34
|
-
),
|
|
35
|
-
const
|
|
36
|
-
|
|
29
|
+
), i(a.value);
|
|
30
|
+
const d = (e) => {
|
|
31
|
+
i(e);
|
|
37
32
|
};
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
list: JSON.stringify(S[l.name]),
|
|
41
|
-
keywords: e,
|
|
42
|
-
include: JSON.stringify(l.include ?? [])
|
|
43
|
-
});
|
|
33
|
+
function i(e) {
|
|
34
|
+
e = e.trim(), l.value = r.filter((c) => c.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || c.label.toLowerCase().includes(e.toLowerCase())).splice(0, 10), l.value.length === 0 && (l.value = [...r].splice(0, 10));
|
|
44
35
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
36
|
+
const L = (e) => {
|
|
37
|
+
t("update:value", e), D();
|
|
38
|
+
}, b = () => {
|
|
39
|
+
t("update:value", a.value), t("change", a.value);
|
|
49
40
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
|
|
41
|
+
function D() {
|
|
42
|
+
const c = f(n.name).find((_) => _.value === a.value);
|
|
43
|
+
t("select", c);
|
|
53
44
|
}
|
|
54
45
|
return {
|
|
55
|
-
data:
|
|
46
|
+
data: l,
|
|
56
47
|
modelValue: a,
|
|
57
|
-
onSearch:
|
|
58
|
-
onSelect:
|
|
59
|
-
onChange:
|
|
48
|
+
onSearch: d,
|
|
49
|
+
onSelect: L,
|
|
50
|
+
onChange: b
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
|
-
return (
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
value: o(
|
|
66
|
-
"onUpdate:value":
|
|
53
|
+
return (r, l) => {
|
|
54
|
+
const a = B("a-select");
|
|
55
|
+
return x(), V(a, {
|
|
56
|
+
value: o(s),
|
|
57
|
+
"onUpdate:value": l[0] || (l[0] = (d) => H(s) ? s.value = d : null),
|
|
67
58
|
"allow-clear": "",
|
|
68
59
|
"show-search": "",
|
|
69
60
|
"filter-option": !1,
|
|
70
|
-
options: o(
|
|
61
|
+
options: o(h),
|
|
71
62
|
placeholder: u.placeholder,
|
|
72
63
|
disabled: u.disabled,
|
|
73
|
-
onSelect: o(
|
|
74
|
-
onSearch: o(
|
|
75
|
-
onChange: o(
|
|
64
|
+
onSelect: o(m),
|
|
65
|
+
onSearch: o(S),
|
|
66
|
+
onChange: o(C)
|
|
76
67
|
}, null, 8, ["value", "options", "placeholder", "disabled", "onSelect", "onSearch", "onChange"]);
|
|
77
68
|
};
|
|
78
69
|
}
|
|
79
70
|
});
|
|
80
71
|
export {
|
|
81
|
-
|
|
72
|
+
W as default
|
|
82
73
|
};
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -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({
|
|
@@ -24,31 +24,32 @@ export default defineComponent({
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
setup(props) {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const workerStatus = ref(true);
|
|
27
|
+
const { getDicTextByValue } = useDataDicStore();
|
|
28
|
+
//TODO 使用webworker存在一定的问题
|
|
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
|
*/
|
|
38
|
-
workerInstance.onerror = () => {
|
|
39
|
-
|
|
40
|
-
};
|
|
37
|
+
// workerInstance.onerror = () => {
|
|
38
|
+
// workerStatus.value = false;
|
|
39
|
+
// };
|
|
41
40
|
/**
|
|
42
41
|
* 监听web worker发送的数据
|
|
43
42
|
* @param e
|
|
44
43
|
*/
|
|
45
|
-
workerInstance.onmessage = (e: any) => {
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
// workerInstance.onmessage = (e: any) => {
|
|
45
|
+
// // 赋值给下拉选择数据变量
|
|
46
|
+
// dicValueTxt.value = e.data;
|
|
47
|
+
// };
|
|
48
48
|
watchEffect(() => {
|
|
49
49
|
const value = props.value;
|
|
50
50
|
const name = props.name;
|
|
51
|
-
|
|
51
|
+
dicValueTxt.value = getDicTextByValue(name, value);
|
|
52
|
+
// workerInstance.postMessage({ list: JSON.stringify(list), name, value });
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
return () => <>{dicValueTxt.value}</>;
|
package/src/components/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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
|
-
import ReplaceWorker from "./dic/replace.worker?worker&inline";
|
|
6
|
-
import DicWorker from "./select/dic.worker?worker&inline";
|
|
6
|
+
// import ReplaceWorker from "./dic/replace.worker?worker&inline";
|
|
7
|
+
// import DicWorker from "./select/dic.worker?worker&inline";
|
|
7
8
|
|
|
8
9
|
import * as components from "./components";
|
|
9
10
|
export * from "./components";
|
|
@@ -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,17 @@ 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);
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
export default {
|
|
@@ -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
|
|
@@ -28,38 +28,38 @@ interface Emits {
|
|
|
28
28
|
}
|
|
29
29
|
const emits = defineEmits<Emits>();
|
|
30
30
|
|
|
31
|
-
const { getDicByKey
|
|
31
|
+
const { getDicByKey } = useDataDicStore();
|
|
32
|
+
|
|
33
|
+
// const workerPool: any = inject("dicWorkerPool");
|
|
34
|
+
// // 获取worker
|
|
35
|
+
// const workerInstance: any = workerPool.getWorker();
|
|
32
36
|
|
|
33
37
|
const { modelValue, data, onSearch, onSelect, onChange } = useSelect();
|
|
38
|
+
|
|
34
39
|
function useSelect() {
|
|
35
40
|
// 保存worker启动状态
|
|
36
|
-
let workerStatus = true;
|
|
37
|
-
|
|
38
|
-
const data = ref(
|
|
41
|
+
// let workerStatus = true;
|
|
42
|
+
const dicData: any[] = [...getDicByKey(props.name)];
|
|
43
|
+
const data = ref<any>([]);
|
|
39
44
|
// 取值
|
|
40
45
|
const modelValue = ref(props.value);
|
|
41
|
-
|
|
42
|
-
const workerInstance: any = inject("dicWorkerInstance");
|
|
43
|
-
// if (!workerInstance) {
|
|
44
|
-
// console.log("一次");
|
|
45
|
-
// workerInstance = new DicWorker();
|
|
46
|
-
// }
|
|
46
|
+
|
|
47
47
|
/**
|
|
48
48
|
* web worker 启动失败
|
|
49
49
|
*/
|
|
50
|
-
workerInstance.onerror = () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
50
|
+
// workerInstance.onerror = () => {
|
|
51
|
+
// workerStatus = false;
|
|
52
|
+
// // 启动失败使用store
|
|
53
|
+
// dicData = getDicByKey(props.name);
|
|
54
|
+
// };
|
|
55
55
|
/**
|
|
56
56
|
* 监听web worker发送的数据
|
|
57
57
|
* @param e
|
|
58
58
|
*/
|
|
59
|
-
workerInstance.onmessage = (e: any) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
59
|
+
// workerInstance.onmessage = (e: any) => {
|
|
60
|
+
// // 赋值给下拉选择数据变量
|
|
61
|
+
// data.value = e.data;
|
|
62
|
+
// };
|
|
63
63
|
|
|
64
64
|
// 当include变化的时候,需要重新发送搜索事件 返回对应的下拉数据
|
|
65
65
|
watch(
|
|
@@ -82,27 +82,28 @@ function useSelect() {
|
|
|
82
82
|
|
|
83
83
|
//监听用户搜索事件
|
|
84
84
|
const onSearch = (keywords: string) => {
|
|
85
|
-
|
|
86
|
-
sendWorkerSearch(keywords);
|
|
87
|
-
} else {
|
|
88
|
-
data.value = dicData
|
|
89
|
-
.filter((item: any) => {
|
|
90
|
-
return (
|
|
91
|
-
item.value.toLowerCase().indexOf(keywords.toLowerCase()) !== -1 ||
|
|
92
|
-
item.label.toLowerCase().includes(keywords.toLowerCase())
|
|
93
|
-
);
|
|
94
|
-
})
|
|
95
|
-
.splice(0, 10);
|
|
96
|
-
}
|
|
85
|
+
sendWorkerSearch(keywords);
|
|
97
86
|
};
|
|
98
87
|
|
|
99
88
|
// 发送搜索到webworker
|
|
100
89
|
function sendWorkerSearch(keywords: string) {
|
|
101
|
-
workerInstance.postMessage({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
90
|
+
// workerInstance.postMessage({
|
|
91
|
+
// list: JSON.stringify(list[props.name]),
|
|
92
|
+
// keywords: keywords,
|
|
93
|
+
// include: JSON.stringify(props.include ?? [])
|
|
94
|
+
// });
|
|
95
|
+
keywords = keywords.trim();
|
|
96
|
+
data.value = dicData
|
|
97
|
+
.filter((item: any) => {
|
|
98
|
+
return (
|
|
99
|
+
item.value.toLowerCase().indexOf(keywords.toLowerCase()) !== -1 ||
|
|
100
|
+
item.label.toLowerCase().includes(keywords.toLowerCase())
|
|
101
|
+
);
|
|
102
|
+
})
|
|
103
|
+
.splice(0, 10);
|
|
104
|
+
if (data.value.length === 0) {
|
|
105
|
+
data.value = [...dicData].splice(0, 10);
|
|
106
|
+
}
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
//监听下拉选择事件
|
|
@@ -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
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3NlbGYuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24oYSl7Y29uc3QgdD1hLmRhdGEubmFtZT8/IiIsZT1hLmRhdGEudmFsdWU/PyIiLG49KChKU09OLnBhcnNlKGEuZGF0YS5saXN0KT8/W10pW3RdfHxbXSkuZmlsdGVyKHM9PnMudmFsdWU9PT1lKS5tYXAocz0+cy5sYWJlbCkuam9pbigiIik7c2VsZi5wb3N0TWVzc2FnZShuKX0sITEpfSkoKTsK",t=typeof window<"u"&&window.Blob&&new Blob([atob(n)],{type:"text/javascript;charset=utf-8"});function o(){const e=t&&(window.URL||window.webkitURL).createObjectURL(t);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+n)}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}exports.default=o;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3NlbGYuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24odCl7dmFyIG87Y29uc3QgbD0odC5kYXRhLmtleXdvcmRzPz8iIikudHJpbSgpO2xldCBlPUpTT04ucGFyc2UoKChvPXQuZGF0YSk9PW51bGw/dm9pZCAwOm8ubGlzdCl8fFtdKT8/W107Y29uc3QgYT1KU09OLnBhcnNlKHQuZGF0YS5pbmNsdWRlKTthLmxlbmd0aD4wJiYoZT1lLmZpbHRlcihzPT5hLnNvbWUocj0+cj09PXMudmFsdWUpKSk7Y29uc3QgaT1lLmZpbHRlcihzPT5zLnZhbHVlLnRvTG93ZXJDYXNlKCkuaW5kZXhPZihsLnRvTG93ZXJDYXNlKCkpIT09LTF8fHMubGFiZWwudG9Mb3dlckNhc2UoKS5pbmNsdWRlcyhsLnRvTG93ZXJDYXNlKCkpKTtpLmxlbmd0aD09PTA/c2VsZi5wb3N0TWVzc2FnZShlLnNwbGljZSgwLDEwKSk6c2VsZi5wb3N0TWVzc2FnZShpLnNwbGljZSgwLDEwKSl9LCExKX0pKCk7Cg==",e=typeof window<"u"&&window.Blob&&new Blob([atob(n)],{type:"text/javascript;charset=utf-8"});function b(){const l=e&&(window.URL||window.webkitURL).createObjectURL(e);try{return l?new Worker(l):new Worker("data:application/javascript;base64,"+n)}finally{l&&(window.URL||window.webkitURL).revokeObjectURL(l)}}exports.default=b;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const o = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3NlbGYuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24oYSl7Y29uc3QgdD1hLmRhdGEubmFtZT8/IiIsZT1hLmRhdGEudmFsdWU/PyIiLG49KChKU09OLnBhcnNlKGEuZGF0YS5saXN0KT8/W10pW3RdfHxbXSkuZmlsdGVyKHM9PnMudmFsdWU9PT1lKS5tYXAocz0+cy5sYWJlbCkuam9pbigiIik7c2VsZi5wb3N0TWVzc2FnZShuKX0sITEpfSkoKTsK", e = typeof window < "u" && window.Blob && new Blob([atob(o)], { type: "text/javascript;charset=utf-8" });
|
|
2
|
-
function t() {
|
|
3
|
-
const n = e && (window.URL || window.webkitURL).createObjectURL(e);
|
|
4
|
-
try {
|
|
5
|
-
return n ? new Worker(n) : new Worker("data:application/javascript;base64," + o);
|
|
6
|
-
} finally {
|
|
7
|
-
n && (window.URL || window.webkitURL).revokeObjectURL(n);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
t as default
|
|
12
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const b = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3NlbGYuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24odCl7dmFyIG87Y29uc3QgbD0odC5kYXRhLmtleXdvcmRzPz8iIikudHJpbSgpO2xldCBlPUpTT04ucGFyc2UoKChvPXQuZGF0YSk9PW51bGw/dm9pZCAwOm8ubGlzdCl8fFtdKT8/W107Y29uc3QgYT1KU09OLnBhcnNlKHQuZGF0YS5pbmNsdWRlKTthLmxlbmd0aD4wJiYoZT1lLmZpbHRlcihzPT5hLnNvbWUocj0+cj09PXMudmFsdWUpKSk7Y29uc3QgaT1lLmZpbHRlcihzPT5zLnZhbHVlLnRvTG93ZXJDYXNlKCkuaW5kZXhPZihsLnRvTG93ZXJDYXNlKCkpIT09LTF8fHMubGFiZWwudG9Mb3dlckNhc2UoKS5pbmNsdWRlcyhsLnRvTG93ZXJDYXNlKCkpKTtpLmxlbmd0aD09PTA/c2VsZi5wb3N0TWVzc2FnZShlLnNwbGljZSgwLDEwKSk6c2VsZi5wb3N0TWVzc2FnZShpLnNwbGljZSgwLDEwKSl9LCExKX0pKCk7Cg==", n = typeof window < "u" && window.Blob && new Blob([atob(b)], { type: "text/javascript;charset=utf-8" });
|
|
2
|
-
function c() {
|
|
3
|
-
const l = n && (window.URL || window.webkitURL).createObjectURL(n);
|
|
4
|
-
try {
|
|
5
|
-
return l ? new Worker(l) : new Worker("data:application/javascript;base64," + b);
|
|
6
|
-
} finally {
|
|
7
|
-
l && (window.URL || window.webkitURL).revokeObjectURL(l);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
c as default
|
|
12
|
-
};
|