mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
2 lines
3.1 KiB
JavaScript
2 lines
3.1 KiB
JavaScript
var V=Object.defineProperty;var N=(c,t,s)=>t in c?V(c,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):c[t]=s;var a=(c,t,s)=>N(c,typeof t!="symbol"?t+"":t,s);import{d as L,a as B,b as T,e as b,w as m,g as h,f as _,k as j,l as D,j as x,t as k,h as w,F}from"./index-DMqaFtX4.js";class y{constructor(t,s=0){a(this,"depth",0);a(this,"key");a(this,"word",!1);a(this,"children",{});a(this,"fail");a(this,"count",0);this.key=t,this.depth=s}}class I{constructor(t,s){a(this,"root",new y("root"));a(this,"customCharacter");const e=t.length;this.customCharacter=(s==null?void 0:s.customCharacter)||"*";for(let r=0;r<e;r++)this.add(t[r],!1);this.build()}build(){const t=[];t.push(this.root);let s=0;for(;t.length>s;){const e=t[s],r=e.children;for(const l in e.children){const o=r[l];let n=e.fail;for(;n&&!n.children[l];)n=n.fail;o.fail=(n==null?void 0:n.children[l])||this.root,t.push(o)}s++}}search(t,s={replace:!0}){let e=this.root;const r=[],l=[],o=[],{replace:n=!0,verify:i=!1}=s,v=t.length;for(let u=0;u<v;u++){const d=t[u],f=d.toLowerCase();for(;e&&!(e!=null&&e.children[f]);)e=e==null?void 0:e.fail;if(e=(e==null?void 0:e.children[f])||this.root,r.push(d),l.push(d),e.word){let p=u+1-e.depth,g="";for(;p<=u;){const C=l[p];g+=C,n&&(r[p]=this.customCharacter),p++}if(o.push(g),i)break}}return{words:o,text:r.join("")}}filter(t,s){return this.search(t,s)}verify(t){const{words:s}=this.search(t,{verify:!0});return!s.length}delete(t){const s=this.pop(t.toLowerCase(),t.length,this.root);return this.build(),s}pop(t,s,e,r="delete",l=0){if(!e)return"delete";if(l===s){e.word=!1,e.count--;let o=!0;for(const n in e.children)if(n){o=!1;break}return o?r:"update"}else{const o=t[l],n=e.children[o],i=this.pop(t,s,n,e.word?"update":r,l+1);return e.count--,i==="delete"&&(n==null?void 0:n.count)===0&&delete e.children[o],i}}add(t,s=!0){const e=t.toLowerCase(),r=e.length;return this.put(e,r),s&&this.build(),!0}put(t,s){let e=this.root;const r=s-1;e.count++;for(let l=0;l<s;l++){const o=t[l],n=e.children[o];if(n)n.count++,e=n;else{const i=new y(o,l+1);i.count=1,e.children[o]=i,e=i}r===l&&e.depth&&(e.word=!0)}}}const K={class:"card-header"},S={class:"flex flex-wrap gap-2 my-2"},q={class:"mt-2!"},U=L({name:"Sensitive",__name:"sensitive",setup(c){const t=["脑残","废物","白痴","三八","智障"],s=B(),e=new I(t);function r(){s.value=e.filter(s.value).text}return(l,o)=>{const n=w("el-link"),i=w("el-tag"),v=w("el-input"),u=w("el-card");return b(),T(u,{shadow:"never"},{header:m(()=>[h("div",K,[o[2]||(o[2]=h("p",{class:"font-medium"},"敏感词过滤",-1)),_(n,{class:"mt-2",href:"https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/able/sensitive.vue",target:"_blank"},{default:m(()=>o[1]||(o[1]=[x(" 代码位置 src/views/able/sensitive.vue ")])),_:1})])]),default:m(()=>[h("div",S,[o[3]||(o[3]=h("span",null,"自定义敏感词",-1)),(b(),j(F,null,D(t,(d,f)=>_(i,{key:f,type:"warning",class:"mx-1",effect:"dark",round:""},{default:m(()=>[x(k(d),1)]),_:2},1024)),64))]),_(v,{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=d=>s.value=d),onInput:r},null,8,["modelValue"]),h("p",q,k(s.value),1)]),_:1})}}});export{U as default};
|