@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.
@@ -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"),u=e.defineComponent({name:"DicReplace",props:{name:{type:String,default:""},value:{type:String,default:""}},setup(n){const{list:o}=l.useDataDicStore(),t=e.inject("replaceWorkerInstance");console.log(t);const s=e.ref(!0),r=e.ref("");return t.onerror=()=>{s.value=!1},t.onmessage=a=>{r.value=a.data},e.watchEffect(()=>{const a=n.value,c=n.name;t.postMessage({list:JSON.stringify(o),name:c,value:a})}),()=>e.createVNode(e.Fragment,null,[r.value])}});exports.default=u;
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 d=require("pinia"),D=require("pinia-plugin-persistedstate"),q=require("./dic/replace.worker.cjs.js"),f=require("./select/dic.worker.cjs.js"),m=require("./components.cjs.js"),x=require("../directive/trim.cjs.js"),$=require("./table/index.cjs.js"),v=require("./select/index.cjs.js"),I=require("./desensitize/index.cjs.js"),S=require("./dic/index.cjs.js"),b=require("./modal/index.cjs.js"),k=require("./form/index.cjs.js"),c=require("./grid/index.cjs.js"),i=require("./layout/index.cjs.js"),o=m;let r=null,n=null;const a=function(e,l){Object.keys(o).forEach(u=>{const s=o[u];s.install&&e.use(s)});const t=d.createPinia();t.use(D.createPersistedState({storage:sessionStorage})),e.use(t),e.directive("trim",x.default),e.provide("menuIcon",l.menuIcon||{}),r||(r=new q.default,e.provide("replaceWorkerInstance",r)),n||(n=new f.default,e.provide("dicWorkerInstance",n))},w={install:a};exports.DTable=$.DTable;exports.DSelect=v.DSelect;exports.DDesensitize=I.DDesensitize;exports.DicReplace=S.DDicReplace;exports.DModal=b.DModal;exports.DForm=k.default;exports.DGrid=c.DGrid;exports.DGridItem=c.DGridItem;exports.DList=i.DList;exports.DMain=i.DMain;exports.DNavTabs=i.DNavTabs;exports.DShow=i.DShow;exports.default=w;exports.install=a;
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"),y=require("../../store/modules/DataDictionary.cjs.js"),k={name:"DSelect"},B=e.defineComponent({...k,props:{value:{default:null},name:{default:""},disabled:{type:Boolean,default:!1},placeholder:{default:"请填写默认占位符啊!老铁"},include:{default:[]}},emits:["update:value","change","select"],setup(r,{emit:c}){const l=r,{getDicByKey:v,list:h}=y.useDataDicStore(),{modelValue:s,data:p,onSearch:S,onSelect:g,onChange:m}=C();function C(){let d=!0,t=[];const o=e.ref(t),n=e.ref(l.value),i=e.inject("dicWorkerInstance");i.onerror=()=>{d=!1,t=v(l.name)},i.onmessage=a=>{o.value=[...a.data]},e.watch(()=>l.include,()=>{f(n.value)}),e.watch(()=>l.value,a=>{n.value=a}),f(n.value);const w=a=>{d?f(a):o.value=t.filter(u=>u.value.toLowerCase().indexOf(a.toLowerCase())!==-1||u.label.toLowerCase().includes(a.toLowerCase())).splice(0,10)};function f(a){i.postMessage({list:JSON.stringify(h[l.name]),keywords:a,include:JSON.stringify(l.include??[])})}const b=a=>{c("update:value",a),_()},D=()=>{c("update:value",n.value),c("change",n.value)};function _(){const u=v(l.name).find(L=>L.value===n.value);c("select",u)}return{data:o,modelValue:n,onSearch:w,onSelect:b,onChange:D}}return(d,t)=>{const o=e.resolveComponent("a-select");return e.openBlock(),e.createBlock(o,{value:e.unref(s),"onUpdate:value":t[0]||(t[0]=n=>e.isRef(s)?s.value=n:null),"allow-clear":"","show-search":"","filter-option":!1,options:e.unref(p),placeholder:r.placeholder,disabled:r.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;
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, inject as u, ref as o, watchEffect as i, createVNode as f, Fragment as m } from "vue";
2
- import { useDataDicStore as p } from "../../store/modules/DataDictionary.esm.js";
3
- const v = /* @__PURE__ */ l({
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(a) {
17
+ setup(e) {
18
18
  const {
19
- list: r
20
- } = p(), e = u("replaceWorkerInstance");
21
- console.log(e);
22
- const s = o(!0), n = o("");
23
- return e.onerror = () => {
24
- s.value = !1;
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
- v as default
28
+ s as default
39
29
  };
@@ -1,46 +1,42 @@
1
1
  import { createPinia as m } from "pinia";
2
- import { createPersistedState as a } from "pinia-plugin-persistedstate";
3
- import f from "./dic/replace.worker.esm.js";
4
- import l from "./select/dic.worker.esm.js";
5
- import * as p from "./components.esm.js";
6
- import D from "../directive/trim.esm.js";
7
- import { DTable as w } from "./table/index.esm.js";
8
- import { DSelect as g } from "./select/index.esm.js";
9
- import { DDesensitize as G } from "./desensitize/index.esm.js";
10
- import { DDicReplace as P } from "./dic/index.esm.js";
11
- import { DModal as j } from "./modal/index.esm.js";
12
- import { default as z } from "./form/index.esm.js";
13
- import { DGrid as F, DGridItem as L } from "./grid/index.esm.js";
14
- import { DList as O, DMain as $, DNavTabs as q, DShow as A } from "./layout/index.esm.js";
15
- const n = p;
16
- let r = null, o = null;
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 t = m();
23
- t.use(
24
- a({
18
+ const o = m();
19
+ o.use(
20
+ n({
25
21
  storage: sessionStorage
26
22
  })
27
- ), e.use(t), e.directive("trim", D), e.provide("menuIcon", s.menuIcon || {}), r || (r = new f(), e.provide("replaceWorkerInstance", r)), o || (o = new l(), e.provide("dicWorkerInstance", o));
28
- }, v = {
29
- install: d
23
+ ), e.use(o), e.directive("trim", a), e.provide("menuIcon", i.menuIcon || {});
24
+ }, x = {
25
+ install: f
30
26
  };
31
27
  export {
32
- G as DDesensitize,
33
- z as DForm,
34
- F as DGrid,
35
- L as DGridItem,
36
- O as DList,
37
- $ as DMain,
38
- j as DModal,
39
- q as DNavTabs,
40
- g as DSelect,
41
- A as DShow,
42
- w as DTable,
43
- P as DicReplace,
44
- v as default,
45
- d as install
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 x, ref as v, inject as y, watch as h, resolveComponent as O, openBlock as V, createBlock as I, unref as o, isRef as J } from "vue";
2
- import { useDataDicStore as N } from "../../store/modules/DataDictionary.esm.js";
3
- const W = {
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
- }, K = /* @__PURE__ */ x({
6
- ...W,
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: c }) {
16
- const l = u, { getDicByKey: p, list: S } = N(), { modelValue: r, data: m, onSearch: g, onSelect: C, onChange: w } = L();
17
- function L() {
18
- let d = !0, n = [];
19
- const t = v(n), a = v(l.value), i = y("dicWorkerInstance");
20
- i.onerror = () => {
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
- f(a.value);
22
+ i(a.value);
28
23
  }
29
- ), h(
30
- () => l.value,
24
+ ), v(
25
+ () => n.value,
31
26
  (e) => {
32
27
  a.value = e;
33
28
  }
34
- ), f(a.value);
35
- const b = (e) => {
36
- d ? f(e) : t.value = n.filter((s) => s.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || s.label.toLowerCase().includes(e.toLowerCase())).splice(0, 10);
29
+ ), i(a.value);
30
+ const d = (e) => {
31
+ i(e);
37
32
  };
38
- function f(e) {
39
- i.postMessage({
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 D = (e) => {
46
- c("update:value", e), k();
47
- }, _ = () => {
48
- c("update:value", a.value), c("change", a.value);
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 k() {
51
- const s = p(l.name).find((B) => B.value === a.value);
52
- c("select", s);
41
+ function D() {
42
+ const c = f(n.name).find((_) => _.value === a.value);
43
+ t("select", c);
53
44
  }
54
45
  return {
55
- data: t,
46
+ data: l,
56
47
  modelValue: a,
57
- onSearch: b,
58
- onSelect: D,
59
- onChange: _
48
+ onSearch: d,
49
+ onSelect: L,
50
+ onChange: b
60
51
  };
61
52
  }
62
- return (d, n) => {
63
- const t = O("a-select");
64
- return V(), I(t, {
65
- value: o(r),
66
- "onUpdate:value": n[0] || (n[0] = (a) => J(r) ? r.value = a : null),
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(m),
61
+ options: o(h),
71
62
  placeholder: u.placeholder,
72
63
  disabled: u.disabled,
73
- onSelect: o(C),
74
- onSearch: o(g),
75
- onChange: o(w)
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
- K as default
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -3,10 +3,10 @@
3
3
  * 根据字典名字及对应的value替换成中文或者人能看懂的文字
4
4
  * @author 余春林
5
5
  */
6
- import { defineComponent, ref, watchEffect, inject } from "vue";
6
+ import { defineComponent, inject, ref, watchEffect } from "vue";
7
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
  // @ts-ignore
9
- // import DicWorker from "./replace.worker?worker&inline";
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 { list } = useDataDicStore();
28
- const workerInstance: any = inject("replaceWorkerInstance");
29
- console.log(workerInstance);
30
- const workerStatus = ref(true);
27
+ const { getDicTextByValue } = useDataDicStore();
28
+ //TODO 使用webworker存在一定的问题
29
+ //const workerStatus = ref(true);
31
30
  const dicValueTxt = ref<any>("");
32
- // if (!workerInstance) {
33
- // workerInstance = new DicWorker();
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
- workerStatus.value = false;
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
- dicValueTxt.value = e.data;
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
- workerInstance.postMessage({ list: JSON.stringify(list), name, value });
51
+ dicValueTxt.value = getDicTextByValue(name, value);
52
+ // workerInstance.postMessage({ list: JSON.stringify(list), name, value });
52
53
  });
53
54
 
54
55
  return () => <>{dicValueTxt.value}</>;
@@ -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
- if (!replaceWorkerInstance) {
44
- replaceWorkerInstance = new ReplaceWorker();
45
- app.provide("replaceWorkerInstance", replaceWorkerInstance);
46
- }
47
- if (!dicWorkerInstance) {
48
- dicWorkerInstance = new DicWorker();
49
- app.provide("dicWorkerInstance", dicWorkerInstance);
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, list } = useDataDicStore();
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
- let dicData: any[] = [];
38
- const data = ref(dicData);
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
- // 获取worker
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
- workerStatus = false;
52
- // 启动失败使用store
53
- dicData = getDicByKey(props.name);
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
- data.value = [...e.data];
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
- if (workerStatus) {
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
- list: JSON.stringify(list[props.name]),
103
- keywords: keywords,
104
- include: JSON.stringify(props.include ?? [])
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
- };