@qy_better_lib/hooks 0.2.4 → 0.2.5
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/DOCUMENTATION.md +0 -27
- package/LICENSE +24 -0
- package/dist/hooks.min.js +6 -6
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -6
- package/lib/node_modules/@qy_better_lib/core/lib/utils/echarts.js +166 -0
- package/lib/use-chart/config.js +1 -1
- package/lib/{use-chart/index.js → use-chart.js} +3 -2
- package/lib/use-watermark/index.js +2 -2
- package/package.json +16 -4
- /package/lib/{use-layout-flow/index.js → use-layout-flow.js} +0 -0
- /package/lib/{use-mqtt/index.js → use-mqtt.js} +0 -0
package/DOCUMENTATION.md
CHANGED
|
@@ -668,33 +668,6 @@ console.log(status);
|
|
|
668
668
|
close();
|
|
669
669
|
```
|
|
670
670
|
|
|
671
|
-
|
|
672
|
-
## 安装和使用
|
|
673
|
-
|
|
674
|
-
### 安装
|
|
675
|
-
```bash
|
|
676
|
-
npm install @qy_better_lib/hooks
|
|
677
|
-
# 或
|
|
678
|
-
yarn add @qy_better_lib/hooks
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
### 全局引入
|
|
682
|
-
```typescript
|
|
683
|
-
// main.ts
|
|
684
|
-
import { createApp } from 'vue'
|
|
685
|
-
import App from './App.vue'
|
|
686
|
-
import QYHooks from '@qy_better_lib/hooks'
|
|
687
|
-
|
|
688
|
-
const app = createApp(App)
|
|
689
|
-
app.use(QYHooks)
|
|
690
|
-
app.mount('#app')
|
|
691
|
-
```
|
|
692
|
-
|
|
693
|
-
### 按需引入(推荐)
|
|
694
|
-
```typescript
|
|
695
|
-
import { use_print, use_fullscreen, use_water_mark } from '@qy_better_lib/hooks'
|
|
696
|
-
```
|
|
697
|
-
|
|
698
671
|
## 注意事项
|
|
699
672
|
|
|
700
673
|
1. **use-chart** 需要安装 ECharts 依赖:`npm install echarts`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Modified MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Swordsman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software for non-commercial purposes without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. Commercial use of the Software requires explicit written authorization from the copyright holders.
|
|
16
|
+
For commercial licensing inquiries, please contact the project maintainers.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/dist/hooks.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(v,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("mitt"),require("vue")):typeof define=="function"&&define.amd?define(["exports","mitt","vue"],L):(v=typeof globalThis<"u"?globalThis:v||self,L(v.QyBetterLibHooks={},v.mitt,v.Vue))})(this,(function(v,L,O){"use strict";function H(){if(typeof L>"u")return{};const r=L();return r.emitAsync=async function(o,...c){const m=this.all?.get(o);if(!m||m.length===0)return[];const h=m.map(p=>{try{const w=p(...c);return w instanceof Promise?w:Promise.resolve(w)}catch(w){return Promise.reject(w)}});return Promise.all(h)},r.emit,r.emit=function(o,...c){const m=this.all?.get(o);if(!m||m.length===0)return;let h;return m.forEach(p=>{try{h=p(...c)}catch(w){console.error(`Error in event handler for ${o}:`,w)}}),h},r}const I=H();function F(r){return typeof L>"u"?{emitter:{}}:(O.onMounted(()=>{if(r&&r.length>0)for(const o of r)I.on(o.key,o.value)}),O.onUnmounted(()=>{if(r&&r.length>0)for(const o of r)I.off(o.key,o.value)}),{emitter:I})}function J(){let r=null,o=!1;function c(e,t){const n=t?.page_size||"A4",a=t?.page_orientation||"portrait",l=t?.margin||"1cm",d=t?.print_background?"true":"false",s=`#print-container {
|
|
2
2
|
display: none;
|
|
3
3
|
}
|
|
4
4
|
#preview-container {
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
padding: 0;
|
|
60
60
|
width: 100%;
|
|
61
61
|
height: 100%;
|
|
62
|
-
-webkit-print-color-adjust: ${
|
|
63
|
-
print-color-adjust: ${
|
|
62
|
+
-webkit-print-color-adjust: ${d};
|
|
63
|
+
print-color-adjust: ${d};
|
|
64
64
|
}
|
|
65
65
|
#print-container {
|
|
66
66
|
display: block;
|
|
@@ -71,6 +71,6 @@
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
@page {
|
|
74
|
-
size: ${
|
|
75
|
-
margin: ${
|
|
76
|
-
}`,l=document.createElement("style");return l.innerHTML=o||s,l}function a(){const o=document.getElementById("print-container");if(o)try{document.body.removeChild(o)}catch(r){console.error("清理打印容器失败:",r)}}function _(){const o=document.getElementById("preview-container");if(o)try{document.body.removeChild(o),e=null}catch(r){console.error("清理预览容器失败:",r)}}function m(o){a();const r=document.createElement("div");return r.setAttribute("id","print-container"),r.innerHTML=o,r}function x(o){if(!o||typeof o.querySelectorAll!="function")return Promise.resolve();const r=o.querySelectorAll("img"),t=Array.from(r);if(t.length===0)return Promise.resolve();let u=0;return new Promise((d,p)=>{function s(){u++,u===t.length&&d()}t.forEach(l=>{l.complete?s():(l.addEventListener("load",s),l.addEventListener("error",s))}),setTimeout(()=>{p(new Error("图片加载超时"))},1e4)})}async function $(o,r){if(n){console.warn("打印已在进行中");return}try{n=!0;const t=i(r?.custom_style,r),u=m(o);document.body.appendChild(t),document.body.appendChild(u),await x(u),window.print(),setTimeout(()=>{try{t.parentNode&&t.parentNode.removeChild(t),u.parentNode&&u.parentNode.removeChild(u),n=!1,r?.on_complete?.()}catch(d){console.error("清理打印元素失败:",d),r?.on_error?.(d)}},100)}catch(t){console.error("打印失败:",t),n=!1,r?.on_error?.(t)}}async function z(o,r){try{_();const t=i(r?.custom_style,r),u=document.createElement("div");u.innerHTML=o,await x(u);const d=document.createElement("div");d.setAttribute("id","preview-container");const p=document.createElement("div");p.setAttribute("id","preview-content"),p.appendChild(u);const s=document.createElement("button");s.setAttribute("id","preview-close"),s.textContent="×",s.addEventListener("click",()=>{_(),r?.on_cancel?.()});const l=document.createElement("button");l.setAttribute("id","preview-print"),l.textContent="打印",l.addEventListener("click",()=>{_(),$(o,r)}),p.appendChild(s),p.appendChild(l),d.appendChild(p),document.body.appendChild(t),document.body.appendChild(d),e=d}catch(t){console.error("预览失败:",t),r?.on_error?.(t)}}async function C(o,r){try{const t=document.querySelector(o);if(t)r?.preview?await z(t.innerHTML,r):await $(t.innerHTML,r);else throw new Error(`未找到DOM节点: ${o}`)}catch(t){console.error("打印DOM元素失败:",t),r?.on_error?.(t)}}async function q(o,r){try{if(!o||o.length===0)throw new Error("元素数组为空");let t="";for(const u of o)t+=u.outerHTML;if(!t)throw new Error("元素内容为空");r?.preview?await z(t,r):await $(t,r)}catch(t){console.error("打印元素数组失败:",t),r?.on_error?.(t)}}function E(o,r){try{const t=document.querySelector(o);if(t)z(t.innerHTML,r);else throw new Error(`未找到DOM节点: ${o}`)}catch(t){console.error("预览DOM元素失败:",t),r?.on_error?.(t)}}function T(o,r){try{if(!o||o.length===0)throw new Error("元素数组为空");let t="";for(const u of o)t+=u.outerHTML;if(!t)throw new Error("元素内容为空");z(t,r)}catch(t){console.error("预览元素数组失败:",t),r?.on_error?.(t)}}function y(){_()}return{print_html:C,print_html_element:q,preview_html:E,preview_html_element:T,close_preview:y}}function ye(){const e=pe;return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function pe(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function Z(e){return typeof e=="object"&&e!==null&&Object.prototype.toString.call(e)==="[object Object]"}const we=typeof window<"u";function te(e){const n=Object.prototype.toString;if(!e||typeof e!="object")return e;if(e.nodeType&&"cloneNode"in e)return e.cloneNode(!0);if(n.call(e)==="[object Date]")return new Date(e.getTime());if(n.call(e)==="[object RegExp]"){const a=[];return e.global&&a.push("g"),e.multiline&&a.push("m"),e.ignoreCase&&a.push("i"),new RegExp(e.source,a.join(""))}if(n.call(e)==="[object FormData]"){const a=new FormData;for(const[_,m]of e.entries())a.append(_,m);return a}if(n.call(e)==="[object Map]"){const a=new Map;for(const[_,m]of e.entries())a.set(_,te(m));return a}if(n.call(e)==="[object Set]"){const a=new Set;for(const _ of e.values())a.add(te(_));return a}const i=Array.isArray(e)?[]:e.constructor?new e.constructor:{};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=te(e[a]));return i}function re(...e){let n=e.length,i=e[0];Z(i)||(i={});for(let a=1;a<n;a++){let _=e[a];if(Z(_))for(let m in _)m==="__proto__"||i===_[m]||(Z(_[m])?(Z(i[m])||(i[m]=Array.isArray(_[m])?[]:{}),i[m]=re(i[m],_[m])):i[m]=_[m])}return i}function ae(e,n=document){return n.querySelector(e)}function ue(e,n,i,a){e&&e.addEventListener(n,i,a)}function se(e,n,i,a){e&&e.removeEventListener(n,i,a)}function ve(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function be({path:e,name:n}){const i=document.createElement("a");i.href=e,i.target="_blank",n&&i.setAttribute("download",n),document.body.appendChild(i),i.click(),document.body.removeChild(i)}async function xe(e){if(!e)return;const n=new FileReader;return n.readAsDataURL(e),new Promise((i,a)=>{n.onload=_=>i(_.target?.result),n.onerror=_=>a(void 0)})}async function $e(e,n=800,i=800,a=.8){if(e.type.startsWith("image/"))return new Promise(_=>{const m=document.createElement("canvas"),x=m.getContext("2d"),$=new Image;$.onload=()=>{let{width:z,height:C}=$;if(z>n||C>i){const q=Math.min(n/z,i/C);z*=q,C*=q}m.width=z,m.height=C,x?.drawImage($,0,0,z,C),m.toBlob(q=>{if(q){const E=new File([q],e.name,{type:e.type});_(E)}else _(void 0)},e.type,a)},$.src=URL.createObjectURL(e)})}var ne={exports:{}},Se=ne.exports,le;function Ee(){return le||(le=1,(function(e,n){(function(i,a){e.exports=a()})(Se,(function(){var i=1e3,a=6e4,_=36e5,m="millisecond",x="second",$="minute",z="hour",C="day",q="week",E="month",T="quarter",y="year",o="date",r="Invalid Date",t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,u=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(v){var h=["th","st","nd","rd"],f=v%100;return"["+v+(h[(f-20)%10]||h[f]||h[0])+"]"}},p=function(v,h,f){var w=String(v);return!w||w.length>=h?v:""+Array(h+1-w.length).join(f)+v},s={s:p,z:function(v){var h=-v.utcOffset(),f=Math.abs(h),w=Math.floor(f/60),c=f%60;return(h<=0?"+":"-")+p(w,2,"0")+":"+p(c,2,"0")},m:function v(h,f){if(h.date()<f.date())return-v(f,h);var w=12*(f.year()-h.year())+(f.month()-h.month()),c=h.clone().add(w,E),b=f-c<0,D=h.clone().add(w+(b?-1:1),E);return+(-(w+(f-c)/(b?c-D:D-c))||0)},a:function(v){return v<0?Math.ceil(v)||0:Math.floor(v)},p:function(v){return{M:E,y,w:q,d:C,D:o,h:z,m:$,s:x,ms:m,Q:T}[v]||String(v||"").toLowerCase().replace(/s$/,"")},u:function(v){return v===void 0}},l="en",g={};g[l]=d;var S="$isDayjsObject",O=function(v){return v instanceof A||!(!v||!v[S])},L=function v(h,f,w){var c;if(!h)return l;if(typeof h=="string"){var b=h.toLowerCase();g[b]&&(c=b),f&&(g[b]=f,c=b);var D=h.split("-");if(!c&&D.length>1)return v(D[0])}else{var N=h.name;g[N]=h,c=N}return!w&&c&&(l=c),c||!w&&l},k=function(v,h){if(O(v))return v.clone();var f=typeof h=="object"?h:{};return f.date=v,f.args=arguments,new A(f)},M=s;M.l=L,M.i=O,M.w=function(v,h){return k(v,{locale:h.$L,utc:h.$u,x:h.$x,$offset:h.$offset})};var A=(function(){function v(f){this.$L=L(f.locale,null,!0),this.parse(f),this.$x=this.$x||f.x||{},this[S]=!0}var h=v.prototype;return h.parse=function(f){this.$d=(function(w){var c=w.date,b=w.utc;if(c===null)return new Date(NaN);if(M.u(c))return new Date;if(c instanceof Date)return new Date(c);if(typeof c=="string"&&!/Z$/i.test(c)){var D=c.match(t);if(D){var N=D[2]-1||0,B=(D[7]||"0").substring(0,3);return b?new Date(Date.UTC(D[1],N,D[3]||1,D[4]||0,D[5]||0,D[6]||0,B)):new Date(D[1],N,D[3]||1,D[4]||0,D[5]||0,D[6]||0,B)}}return new Date(c)})(f),this.init()},h.init=function(){var f=this.$d;this.$y=f.getFullYear(),this.$M=f.getMonth(),this.$D=f.getDate(),this.$W=f.getDay(),this.$H=f.getHours(),this.$m=f.getMinutes(),this.$s=f.getSeconds(),this.$ms=f.getMilliseconds()},h.$utils=function(){return M},h.isValid=function(){return this.$d.toString()!==r},h.isSame=function(f,w){var c=k(f);return this.startOf(w)<=c&&c<=this.endOf(w)},h.isAfter=function(f,w){return k(f)<this.startOf(w)},h.isBefore=function(f,w){return this.endOf(w)<k(f)},h.$g=function(f,w,c){return M.u(f)?this[w]:this.set(c,f)},h.unix=function(){return Math.floor(this.valueOf()/1e3)},h.valueOf=function(){return this.$d.getTime()},h.startOf=function(f,w){var c=this,b=!!M.u(w)||w,D=M.p(f),N=function(Q,F){var j=M.w(c.$u?Date.UTC(c.$y,F,Q):new Date(c.$y,F,Q),c);return b?j:j.endOf(C)},B=function(Q,F){return M.w(c.toDate()[Q].apply(c.toDate("s"),(b?[0,0,0,0]:[23,59,59,999]).slice(F)),c)},H=this.$W,I=this.$M,U=this.$D,K="set"+(this.$u?"UTC":"");switch(D){case y:return b?N(1,0):N(31,11);case E:return b?N(1,I):N(0,I+1);case q:var V=this.$locale().weekStart||0,X=(H<V?H+7:H)-V;return N(b?U-X:U+(6-X),I);case C:case o:return B(K+"Hours",0);case z:return B(K+"Minutes",1);case $:return B(K+"Seconds",2);case x:return B(K+"Milliseconds",3);default:return this.clone()}},h.endOf=function(f){return this.startOf(f,!1)},h.$set=function(f,w){var c,b=M.p(f),D="set"+(this.$u?"UTC":""),N=(c={},c[C]=D+"Date",c[o]=D+"Date",c[E]=D+"Month",c[y]=D+"FullYear",c[z]=D+"Hours",c[$]=D+"Minutes",c[x]=D+"Seconds",c[m]=D+"Milliseconds",c)[b],B=b===C?this.$D+(w-this.$W):w;if(b===E||b===y){var H=this.clone().set(o,1);H.$d[N](B),H.init(),this.$d=H.set(o,Math.min(this.$D,H.daysInMonth())).$d}else N&&this.$d[N](B);return this.init(),this},h.set=function(f,w){return this.clone().$set(f,w)},h.get=function(f){return this[M.p(f)]()},h.add=function(f,w){var c,b=this;f=Number(f);var D=M.p(w),N=function(I){var U=k(b);return M.w(U.date(U.date()+Math.round(I*f)),b)};if(D===E)return this.set(E,this.$M+f);if(D===y)return this.set(y,this.$y+f);if(D===C)return N(1);if(D===q)return N(7);var B=(c={},c[$]=a,c[z]=_,c[x]=i,c)[D]||1,H=this.$d.getTime()+f*B;return M.w(H,this)},h.subtract=function(f,w){return this.add(-1*f,w)},h.format=function(f){var w=this,c=this.$locale();if(!this.isValid())return c.invalidDate||r;var b=f||"YYYY-MM-DDTHH:mm:ssZ",D=M.z(this),N=this.$H,B=this.$m,H=this.$M,I=c.weekdays,U=c.months,K=c.meridiem,V=function(F,j,ee,ie){return F&&(F[j]||F(w,b))||ee[j].slice(0,ie)},X=function(F){return M.s(N%12||12,F,"0")},Q=K||function(F,j,ee){var ie=F<12?"AM":"PM";return ee?ie.toLowerCase():ie};return b.replace(u,(function(F,j){return j||(function(ee){switch(ee){case"YY":return String(w.$y).slice(-2);case"YYYY":return M.s(w.$y,4,"0");case"M":return H+1;case"MM":return M.s(H+1,2,"0");case"MMM":return V(c.monthsShort,H,U,3);case"MMMM":return V(U,H);case"D":return w.$D;case"DD":return M.s(w.$D,2,"0");case"d":return String(w.$W);case"dd":return V(c.weekdaysMin,w.$W,I,2);case"ddd":return V(c.weekdaysShort,w.$W,I,3);case"dddd":return I[w.$W];case"H":return String(N);case"HH":return M.s(N,2,"0");case"h":return X(1);case"hh":return X(2);case"a":return Q(N,B,!0);case"A":return Q(N,B,!1);case"m":return String(B);case"mm":return M.s(B,2,"0");case"s":return String(w.$s);case"ss":return M.s(w.$s,2,"0");case"SSS":return M.s(w.$ms,3,"0");case"Z":return D}return null})(F)||D.replace(":","")}))},h.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},h.diff=function(f,w,c){var b,D=this,N=M.p(w),B=k(f),H=(B.utcOffset()-this.utcOffset())*a,I=this-B,U=function(){return M.m(D,B)};switch(N){case y:b=U()/12;break;case E:b=U();break;case T:b=U()/3;break;case q:b=(I-H)/6048e5;break;case C:b=(I-H)/864e5;break;case z:b=I/_;break;case $:b=I/a;break;case x:b=I/i;break;default:b=I}return c?b:M.a(b)},h.daysInMonth=function(){return this.endOf(E).$D},h.$locale=function(){return g[this.$L]},h.locale=function(f,w){if(!f)return this.$L;var c=this.clone(),b=L(f,w,!0);return b&&(c.$L=b),c},h.clone=function(){return M.w(this.$d,this)},h.toDate=function(){return new Date(this.valueOf())},h.toJSON=function(){return this.isValid()?this.toISOString():null},h.toISOString=function(){return this.$d.toISOString()},h.toString=function(){return this.$d.toUTCString()},v})(),P=A.prototype;return k.prototype=P,[["$ms",m],["$s",x],["$m",$],["$H",z],["$W",C],["$M",E],["$y",y],["$D",o]].forEach((function(v){P[v[1]]=function(h){return this.$g(h,v[0],v[1])}})),k.extend=function(v,h){return v.$i||(v(h,A,k),v.$i=!0),k},k.locale=L,k.isDayjs=O,k.unix=function(v){return k(1e3*v)},k.en=g[l],k.Ls=g,k.p={},k}))})(ne)),ne.exports}Ee();function W(e,n=1920){let i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;if(!i)return e;let a=i/n;return Number((e*a).toFixed(3))}function Me(e,n,i){return{type:"linear",x:0,y:0,x2:e==="v"?0:1,y2:e==="v"?1:0,colorStops:[{offset:0,color:n},{offset:1,color:i}]}}function ke(e,n,i="canvas",a){return(async()=>{try{let m;if(typeof window<"u"&&window.echarts)m=window.echarts;else{const z=await import("echarts");m=z.default||z}const x=typeof e=="string"?document.getElementById(e):e;if(!x)return console.error("ECharts DOM容器未找到"),null;const $=m.init(x,a,{renderer:i});return n&&$.setOption(n),$}catch(m){return console.error("加载 ECharts 失败:",m),null}})()}function fe(e){e&&typeof e.dispose=="function"&&e.dispose()}function De(e,n){e&&typeof e.setOption=="function"&&e.setOption(n)}function de(e){e&&typeof e.resize=="function"&&e.resize()}function Le(e,n=200){if(!e)return;let i;const a=()=>{clearTimeout(i),i=setTimeout(()=>{de(e)},n)};return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),clearTimeout(i)}}function ze(e,n){const a=n||["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc","#67c23a"],_=[];for(let m=0;m<e;m++)_.push(a[m%a.length]);return _}function Ce(e,n){return{...e,...n,series:n.series||e.series,xAxis:n.xAxis||e.xAxis,yAxis:n.yAxis||e.yAxis,legend:n.legend||e.legend,tooltip:n.tooltip||e.tooltip,title:n.title||e.title}}function Te(e,n,i){e&&typeof e.on=="function"&&e.on(n,i)}function qe(e,n,i){e&&typeof e.off=="function"&&e.off(n,i)}function Ne(e,n={}){if(!e||typeof e.getDataURL!="function")return null;const{type:i="png",pixel_ratio:a=2,background_color:_="#fff",exclude_components:m=[],file_name:x="echarts-image"}=n,$=e.getDataURL({type:i,pixelRatio:a,backgroundColor:_,excludeComponents:m}),z=document.createElement("a");return z.download=`${x}.${i}`,z.href=$,z.click(),$}const Oe=new Map;let oe=null;we&&(document.addEventListener("mousedown",e=>{oe=e}),document.addEventListener("mouseup",e=>{for(const n of Oe.values())for(const{document_handler:i}of n)oe&&i(e,oe);oe=null}));function Ae(){const e=ye();let n=null,i=null;function a(E){return E&&ae(E)||document.body}function _(E){const{text1:T,text2:y,font_size:o=16,font_family:r="Avenir,Helvetica,Arial,sans-serif",rotate:t=-15,text_color:u="#999",opacity:d=.1,size:p={width:250,height:150}}=E;try{const s=document.createElement("canvas");s.width=p.width,s.height=p.height;const l=s.getContext("2d");if(l&&(l.font=`${o}px ${r}`,l.fillStyle=u.replace(/\,\s(1|(0\.\d+)\))/,`, ${d}`),l.textAlign="left",l.textBaseline="middle",l.rotate(t*Math.PI/180),l.fillText(T,0,s.height/2),y)){const g=l.measureText(T).width;l.fillText(y,g+16,s.height/2)}return s}catch(s){console.error("创建水印画布失败:",s);const l=document.createElement("canvas");return l.width=0,l.height=0,l}}function m(E){const{wrapper:T,z_index:y=1e5,position:o="fixed",spacing:r=0,size:t={width:250,height:150}}=E,u=a(T),d=document.getElementById(e);if(d)try{u.removeChild(d)}catch(g){console.error("移除旧水印失败:",g)}const p=_(E),s=document.createElement("div");s.id=e,s.style.pointerEvents="none",s.style.top="0px",s.style.left="0px",s.style.position=o,s.style.zIndex=y.toString();const l=ve();s.style.width=l.width+"px",s.style.height=l.height+"px",s.style.background=`url(${p.toDataURL("image/png")}) left top repeat`,r>0&&(s.style.backgroundSize=`${t.width+r}px ${t.height+r}px`);try{u.appendChild(s)}catch(g){console.error("添加水印失败:",g)}}function x(){n&&m(n)}function $(E){n=E,m(E),E.responsive?i||(i=x,ue(window,"resize",i)):i&&(se(window,"resize",i),i=null)}function z(){const E=document.getElementById(e);if(E)try{const T=E.parentElement;T&&T.removeChild(E)}catch(T){console.error("移除水印失败:",T)}i&&(se(window,"resize",i),i=null),n=null}function C(E){if(n){const T={...n,...E};$(T)}else console.warn("水印未初始化,请先调用 create_water_mark")}function q(){return document.getElementById(e)!==null}return{create_water_mark:$,remove_water_mark:z,update_water_mark:C,has_water_mark:q}}function We(e){const{server:n,receive:i,max_reconnect_attempts:a=5,reconnect_interval:_=5e3,heartbeat_interval:m=3e4,heartbeat_message:x="ping",on_open:$,on_error:z,on_close:C,auto_reconnect:q=!0,auto_connect:E=!0,max_message_queue_size:T=100}=e;let y=0,o=!1,r,t=null,u=null,d=[],p=0;const s=m*1.5;typeof window<"u"&&(window.onbeforeunload=()=>{f()});function l(){try{console.log("正在连接WebSocket:",n),r=new WebSocket(n),g()}catch(c){console.error("WebSocket连接建立异常:",c),z?.(c),q&&S()}}function g(){r&&(r.onopen=()=>{console.log("WebSocket连接成功:",n),y=0,p=Date.now(),L(),h(),$?.()},r.onerror=c=>{console.error("WebSocket连接错误:",c),z?.(c)},r.onclose=c=>{console.log("WebSocket连接关闭:",new Date().toLocaleTimeString(),"原因:",c.code,c.reason),k(),C?.(),q&&!c.wasClean&&S()},r.onmessage=c=>{try{p=Date.now(),i(c)}catch(b){console.error("WebSocket消息处理错误:",b),console.log("原始消息:",c.data)}})}function S(){if(y>=a){console.error("WebSocket重连失败次数过多,停止重连"),f();return}o||(o=!0,console.log(`WebSocket尝试重连 ${y+1}/${a}...`),t=setTimeout(()=>{l(),y++,o=!1,O()},_))}function O(){t&&(clearTimeout(t),t=null)}function L(){k(),u=setInterval(()=>{M(),A()},m)}function k(){u&&(clearInterval(u),u=null)}function M(){if(r?.readyState===WebSocket.OPEN)try{const c=Z(x)?JSON.stringify(x):x;r.send(c)}catch(c){console.error("发送心跳消息失败:",c)}}function A(){Date.now()-p>s&&(console.error("WebSocket心跳超时,尝试重连"),S())}function P(c){if(r?.readyState===WebSocket.OPEN)try{const b=Z(c)?JSON.stringify(c):c;return r.send(b),!0}catch(b){return console.error("发送消息失败:",b),v(c),!1}else return console.warn("WebSocket未连接,消息已加入队列"),v(c),!1}function v(c){if(d.length>=T){const b=d.shift();console.warn("消息队列已满,移除最旧的消息:",b)}d.push(c),console.log(`消息已加入队列,当前队列大小: ${d.length}/${T}`)}function h(){if(r?.readyState===WebSocket.OPEN&&d.length>0)for(console.log(`发送队列中的 ${d.length} 条消息`);d.length>0;){const c=d.shift();P(c)}}function f(){if(k(),O(),r){try{r.close()}catch(c){console.error("关闭WebSocket失败:",c)}r=void 0}d=[]}function w(){if(!r)return"CLOSED";switch(r.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNKNOWN"}}return E&&l(),{ws:r,create:l,close:f,send_message:P,get_status:w,reconnect:S,start_heartbeat:L,stop_heartbeat:k}}var G=(e=>(e.PNG="image/png",e.JPEG="image/jpeg",e.GIF="image/gif",e))(G||{});function Pe(){function e(y){return Object.values(G).includes(y)}async function n(y,o=.92,r=G.JPEG){return e(r)||(r=G.JPEG),y.toDataURL(r,o)}async function i(y,o="image",r=.92,t=G.JPEG){const u=await n(y,r,t);return a(u,t,o)}async function a(y,o=G.JPEG,r="image"){e(o)||(o=G.JPEG);const t=y.split(","),u=t[0].match(/:(.*?);/)?.[1]||o,d=atob(t[1]);let p=d.length;const s=new Uint8Array(p);for(;p--;)s[p]=d.charCodeAt(p);const l=u.split("/")[1],g=`${r}.${l}`;return new File([s],g,{type:u})}async function _(y){return new Promise((o,r)=>{const t=new Image;t.onload=()=>o(t),t.onerror=r,t.src=y})}function m(y,o="download"){const r=URL.createObjectURL(y);be({path:r,name:o}),URL.revokeObjectURL(r)}async function x(y){const o=await xe(y);if(!o)throw new Error("转换文件为DataURL失败");return o}async function $(y,o={}){const r=document.createElement("canvas"),t=r.getContext("2d");if(!t)throw new Error("创建Canvas上下文失败");const u=o.width||y.width,d=o.height||y.height,p=o.scale||1;return r.width=u*p,r.height=d*p,t.scale(p,p),t.drawImage(y,0,0,u,d),r}async function z(y){const o=await fetch(y);if(!o.ok)throw new Error(`获取图片失败: ${o.statusText}`);return o.blob()}async function C(y){return new Promise((o,r)=>{const t=new Image;t.onload=()=>o(t),t.onerror=r,t.src=y})}async function q(y,o={}){if(!(y instanceof Blob))throw new Error("compress(): 第一个参数必须是Blob对象或File对象");const r=Math.max(0,Math.min(1,isNaN(Number(o.quality))?.92:Number(o.quality)));o.quality=r;const t=await x(y),u=t.split(",")[0].match(/:(.*?);/)?.[1];let d=G.JPEG;e(o.type)&&(d=o.type);const p=await _(t),s=await $(p,o),l=await n(s,o.quality,d),g=await a(l,u||d);return g.size>y.size?y:g}async function E(y,o={}){if(!(y instanceof Blob))throw new Error("compressAccurately(): 第一个参数必须是Blob对象或File对象");const r=Math.max(0,isNaN(Number(o.size))?0:Number(o.size));o.size=r;const t=Math.max(.8,Math.min(.99,isNaN(Number(o.accuracy))?.95:Number(o.accuracy)));if(o.accuracy=t,isNaN(o.size)||o.size*1024>y.size)return y;(!o.accuracy||o.accuracy<.8||o.accuracy>.99)&&(o.accuracy=.95);const u={max:o.size*(2-o.accuracy)*1024,accurate:o.size*1024,min:o.size*o.accuracy*1024},d=await x(y),p=d.split(",")[0].match(/:(.*?);/)?.[1];let s=G.JPEG;e(o.type)&&(s=o.type);const l=await _(d),g=await $(l,o),S=.75;let O=1,L="";const k=[];for(let A=1;A<=7;A++){L=await n(g,O,s);const P=L.length*S;if(A===7){(u.max<P||u.min>P)&&(L=[L,...k].filter(Boolean).sort((v,h)=>Math.abs(v.length*S-u.accurate)-Math.abs(h.length*S-u.accurate))[0]);break}if(u.max<P)k[1]=L,O-=.5**(A+1);else if(u.min>P)k[0]=L,O+=.5**(A+1);else break}const M=await a(L,p||s);return M.size>y.size?y:M}async function T(y,o=800,r=800,t=.8){return $e(y,o,r,t)}return{compress:q,compress_accurately:E,compress_image:T,canvas_to_data_url:n,canvas_to_file:i,data_url_to_file:a,data_url_to_image:_,file_to_data_url:x,image_to_canvas:$,url_to_blob:z,url_to_image:C,download_file:m}}function Be(e){const n=J.ref(!1),i=J.shallowRef(null);function a(){n.value=document.fullscreenElement===i.value}J.onMounted(()=>{i.value=ae(e),i.value&&ue(i.value,"fullscreenchange",a)}),J.onUnmounted(()=>{i.value&&se(i.value,"fullscreenchange",a)});function _(){!n.value&&i.value?.requestFullscreen&&i.value.requestFullscreen().catch($=>{console.error("进入全屏失败:",$)})}function m(){document.exitFullscreen&&document.exitFullscreen().catch($=>{console.error("退出全屏失败:",$)})}function x(){n.value?m():_()}return{container:i,full:n,toggle_fullscreen:x,enter_fullscreen:_,exit_fullscreen:m}}const he={textStyle:{fontSize:W(12),fontFamily:"Helvetica Neue, Arial, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif"},color:[],title:{textStyle:{fontSize:W(14)}},legend:{icon:"rect",itemHeight:W(12),itemWidth:W(12),textStyle:{color:"#606266",fontSize:W(12)},itemStyle:{shadowColor:"rgba(161, 163, 170, 0.25)",shadowBlur:W(4),shadowOffsetX:W(4),shadowOffsetY:W(4)}},tooltip:{trigger:"axis",axisPointer:{lineStyle:{color:"#D4D9E2",width:W(1)}},backgroundColor:"rgba(0,0,0,0.6)",textStyle:{color:"#fff",fontWeight:400,width:W(10),height:W(10),fontSize:W(12)},borderWidth:0,padding:[W(8),W(16)],formatter:"{a}<br/>{b}: {c}"},xAxis:{axisLine:{lineStyle:{color:"#D4D9E2",width:W(1)}},axisLabel:{color:"#606266",fontSize:W(12)},nameTextStyle:{color:"#606266",fontSize:W(12)},splitLine:{show:!1,lineStyle:{color:"#EBECEF",type:"dashed",width:W(1)}}},yAxis:{axisLine:{show:!1,lineStyle:{color:"#D4D9E2",width:W(1)}},axisLabel:{color:"#606266",fontSize:W(12)},nameTextStyle:{color:"#606266",fontSize:W(12)},splitLine:{lineStyle:{color:"#EBECEF",type:"dashed",width:W(1)}}}};function He(e){return{backgroundColor:"#1a1a1a",textStyle:{color:"#ccc"},title:{textStyle:{color:"#fff"}},legend:{textStyle:{color:"#ccc"}},xAxis:{axisLine:{lineStyle:{color:"#444"}},axisLabel:{color:"#ccc"},splitLine:{lineStyle:{color:"#333"}}},yAxis:{axisLine:{lineStyle:{color:"#444"}},axisLabel:{color:"#ccc"},splitLine:{lineStyle:{color:"#333"}}}}}function Re(e={}){const{default_theme:n="light",default_renderer:i="canvas",auto_responsive:a=!0,responsive_delay:_=200}=e,m=new Map,x=new Map;J.onUnmounted(()=>{T()});async function $(t,u,d){try{if(q(u),!document.querySelector(u))return console.error(`渲染图表失败:未找到DOM元素 ${u}`),null;const s=re(te(he),t),l=d?.default_theme||n;if(l==="dark"){const O=He("dark");re(s,O)}const g=d?.default_renderer||i,S=await ke(u,s,g,l==="dark"?"dark":void 0);if(S){if(m.set(u,S),d?.auto_responsive??a){const O=Le(S,d?.responsive_delay||_);O&&x.set(u,O)}return S}else return console.warn("渲染图表失败:ECharts 初始化失败。请确保已安装 echarts 依赖:npm install echarts 或 yarn add echarts"),null}catch(p){p.message?.includes("Cannot find module")?console.warn("渲染图表失败:未找到 echarts 模块。请安装 echarts 依赖:npm install echarts 或 yarn add echarts"):console.error("渲染图表失败:",p)}return null}function z(t){return m.get(t)}function C(t,u){try{const d=m.get(t);if(d){const p=Ce(he,u);return De(d,p),!0}}catch(d){console.error("更新图表失败:",d)}return!1}function q(t){try{const u=m.get(t);if(u){fe(u),m.delete(t);const d=x.get(t);return d&&(d(),x.delete(t)),!0}}catch(u){console.error("删除图表失败:",u)}return!1}function E(t){try{const u=m.get(t);if(u)return de(u),!0}catch(u){console.error("调整图表大小失败:",u)}return!1}function T(){m.forEach(t=>{fe(t)}),m.clear(),x.forEach(t=>{t()}),x.clear()}function y(t,u){const d=m.get(t);return d?Ne(d,u):null}function o(t,u,d){const p=m.get(t);p&&Te(p,u,d)}function r(t,u,d){const p=m.get(t);p&&qe(p,u,d)}return{render_chart:$,get_chart:z,update_chart:C,remove_chart:q,resize_chart:E,destroy_all_charts:T,generate_chart_colors:ze,get_chart_gradient_color:Me,export_chart_image:y,add_chart_listener:o,remove_chart_listener:r,auto_size:W}}function Ie(e){let n,i,a;async function _(){try{if(!i||!a){i=(await import("@antv/x6")).Graph;const l=await import("dagre");a=l.default||l}return!0}catch(s){return console.error("加载依赖失败:",s),console.error("请安装必要的依赖: npm install @antv/x6 dagre"),!1}}const m={panning:!0,interacting:!1,mousewheel:{enabled:!0},scaling:{min:.1,max:10}};async function x(s){if(!s)throw new Error("init(): 容器元素不能为空");if(!await _())return!1;const l=re(m,e);try{return n=new i({container:s,...l}),!0}catch(g){return console.error("初始化画布失败:",g),!1}}function $(){return n?!0:(console.error("错误:画布未初始化,请先调用 init() 方法"),!1)}function z(s){if($()){if(!Array.isArray(s)){console.error("错误:elements 参数必须是数组");return}n.resetCells(s)}}function C(s,l,g,S){const{node_w:O,node_h:L,nodesep:k,ranksep:M}=g,A=new a.graphlib.Graph;A.setGraph({rankdir:S,nodesep:k,ranksep:M}),A.setDefaultEdgeLabel(()=>({}));const P=O,v=L;return s.forEach(h=>{A.setNode(h.id,{width:P,height:v})}),l.forEach(h=>{const f=h.getSource(),w=h.getTarget();f&&w&&f.cell&&w.cell&&A.setEdge(f.cell,w.cell)}),A}function q(s){s.nodes().forEach(l=>{const g=n.getCellById(l);if(g){const S=s.node(l);g.position(S.x,S.y)}})}function E(s,l){s.forEach(g=>{try{const S=g.getSourceNode(),O=g.getTargetNode();if(!S||!O)return;const L=S.getBBox(),k=O.getBBox();if((l==="LR"||l==="RL")&&L.y!==k.y){const M=l==="LR"?k.x-L.x-L.width:-L.x+k.x+k.width,A=l==="LR"?L.width:0,P=L.x+A+M/2;g.setVertices([{x:P,y:L.center.y},{x:P,y:k.center.y}])}else if((l==="TB"||l==="BT")&&L.x!==k.x){const M=l==="TB"?k.y-L.y-L.height:-L.y+k.y+k.height,A=l==="TB"?L.height:0,P=L.y+A+M/2;g.setVertices([{x:L.center.x,y:P},{x:k.center.x,y:P}])}else g.setVertices([])}catch(S){console.error("处理边布局时出错:",S)}})}async function T(s,l="LR"){if(!$())return!1;if(!s)return console.error("错误:布局配置不能为空"),!1;if(!await _())return!1;const{node_w:g,node_h:S,nodesep:O,ranksep:L}=s;if(typeof g!="number"||g<=0||typeof S!="number"||S<=0||typeof O!="number"||O<0||typeof L!="number"||L<0)return console.error("错误:布局配置参数必须为正数"),!1;if(!["LR","RL","TB","BT"].includes(l))return console.error("错误:无效的布局方向,支持的方向:LR, RL, TB, BT"),!1;try{const M=n.getNodes(),A=n.getEdges(),P=C(M,A,s,l);return a.layout(P),q(P),E(A,l),!0}catch(M){return console.error("执行布局时出错:",M),!1}}function y(s){if($()){if(typeof s!="number"||s<0){console.error("错误:padding 参数必须为非负数");return}n.zoomToFit({padding:s,maxScale:1.2}),n.centerContent()}}function o(s){if(!$())return[];if(!Array.isArray(s))return console.error("错误:node_options 参数必须是数组"),[];const l=[];return s.forEach(g=>{if(g)try{const S=n.createNode(g);l.push(S)}catch(S){console.error("创建节点时出错:",S)}}),l}function r(s){if(!$())return[];if(!Array.isArray(s))return console.error("错误:edge_options 参数必须是数组"),[];const l=[];return s.forEach(g=>{if(g&&g.source_id&&g.target_id)try{const S=n.createEdge({shape:g.shape,source:{cell:g.source_id},target:{cell:g.target_id}});l.push(S)}catch(S){console.error("创建边时出错:",S)}}),l}function t(s){if(!$())return;if(!s||typeof s!="object"){console.error("错误:event_options 参数必须是对象");return}Object.keys(s).forEach(g=>{const S=s[g];typeof S=="function"?(s[g]=l(S,"g",n),n.on(g,s[g])):console.error(`错误:事件 ${g} 的处理函数必须是函数`)});function l(g,S,O){return function(...L){return L[0][S]=O,g.apply(this,L)}}}async function u(s){return!s||typeof s!="object"?(console.error("错误:el_options 参数必须是对象"),!1):await _()?(s.nodes&&typeof s.nodes=="object"&&Object.keys(s.nodes).forEach(l=>{const g=s.nodes[l];if(g)try{i.registerNode(l,g,!0)}catch(S){console.error(`注册自定义节点 ${l} 时出错:`,S)}}),s.edges&&typeof s.edges=="object"&&Object.keys(s.edges).forEach(l=>{const g=s.edges[l];if(g)try{i.registerEdge(l,g,!0)}catch(S){console.error(`注册自定义边 ${l} 时出错:`,S)}}),!0):!1}function d(){return $()?n.getNodes():[]}function p(){n&&n.clearCells()}return{init:x,add_graph_elements:z,layout:T,center_content:y,create_nodes:o,create_edges:r,register_event:t,register_custom_elements:u,get_nodes:d,clear:p}}function Fe(e,n={}){let i,a,_="disconnected",m;function x(){e||(console.error("mqtt:连接地址不能为空!"),_="error")}async function $(){try{if(!i){const r=await import("mqtt");i=r.default||r}return i}catch(r){console.error("mqtt:加载MQTT库失败,请确保已安装mqtt包:",r);return}}async function z({success:r,error:t,receive:u}){if(!e){console.error("mqtt:连接地址不能为空"),_="error",t(new Error("连接地址不能为空"));return}try{_="connecting";const d=await $();if(!d){_="error",t(new Error("MQTT库加载失败"));return}a=d.connect(e,n),a?(a.on("connect",()=>{console.log("mqtt:连接成功!"),_="connected",r()}),a.on("error",p=>{console.error("mqtt:连接错误-",p),_="error",t(p)}),a.on("close",()=>{console.log("mqtt:连接关闭"),_="disconnected",y()}),a.on("message",u),a.on("reconnect",()=>{console.log("mqtt:正在重连..."),_="connecting"})):(console.error("mqtt:创建客户端失败"),_="error",t(new Error("创建MQTT客户端失败")))}catch(d){console.error("mqtt:连接异常!",d),_="error",t(d)}}function C(r){o(),a?a.end(!1,void 0,()=>{console.log("mqtt:连接关闭"),_="disconnected",a=void 0,r?.()}):(_="disconnected",r?.())}function q(r,t,u){if(!a){console.error("mqtt:客户端未连接"),u?.(new Error("客户端未连接"),[]);return}if(!r){console.error("mqtt:订阅主题不能为空"),u?.(new Error("订阅主题不能为空"),[]);return}a.subscribe(r,t,(d,p)=>{d?console.error(`mqtt:订阅主题失败-${r}`,d):console.log(`mqtt:成功订阅主题-${r}`),u?.(d,p)})}function E(r,t){if(!a){console.error("mqtt:客户端未连接"),t?.(new Error("客户端未连接"));return}if(!r){console.error("mqtt:取消订阅主题不能为空"),t?.(new Error("取消订阅主题不能为空"));return}a.unsubscribe(r,u=>{u?console.error(`mqtt:取消订阅失败-${r}`,u):console.log(`mqtt:成功取消订阅主题-${r}`),t?.(u)})}function T(r,t,u,d){if(!a){console.error("mqtt:客户端未连接"),d?.(new Error("客户端未连接"));return}if(!r){console.error("mqtt:发布主题不能为空"),d?.(new Error("发布主题不能为空"));return}if(!t){console.error("mqtt:发布消息不能为空"),d?.(new Error("发布消息不能为空"));return}a.publish(r,t,u,p=>{p?console.error(`mqtt:发布消息失败-${r}`,p):console.log(`mqtt:成功发布消息到主题-${r}`),d?.(p)})}function y(){o(),n.reconnectPeriod&&n.reconnectPeriod>0&&(m=setTimeout(()=>{console.log("mqtt:尝试重连...")},n.reconnectPeriod))}function o(){m&&(clearTimeout(m),m=void 0)}return x(),{get status(){return _},connect:z,close:C,subscribe:q,unsubscribe:E,publish:T}}R.EImageType=G,R.use_chart=Re,R.use_emit=_e,R.use_fullscreen=Be,R.use_image=Pe,R.use_layout_flow=Ie,R.use_mqtt=Fe,R.use_print=ge,R.use_water_mark=Ae,R.use_web_socket=We,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
74
|
+
size: ${n} ${a};
|
|
75
|
+
margin: ${l};
|
|
76
|
+
}`,u=document.createElement("style");return u.innerHTML=e||s,u}function m(){const e=document.getElementById("print-container");if(e)try{document.body.removeChild(e)}catch(t){console.error("清理打印容器失败:",t)}}function h(){const e=document.getElementById("preview-container");if(e)try{document.body.removeChild(e),r=null}catch(t){console.error("清理预览容器失败:",t)}}function p(e){m();const t=document.createElement("div");return t.setAttribute("id","print-container"),t.innerHTML=e,t}function w(e){if(!e||typeof e.querySelectorAll!="function")return Promise.resolve();const t=e.querySelectorAll("img"),n=Array.from(t);if(n.length===0)return Promise.resolve();let a=0;return new Promise((l,d)=>{function s(){a++,a===n.length&&l()}n.forEach(u=>{u.complete?s():(u.addEventListener("load",s),u.addEventListener("error",s))}),setTimeout(()=>{d(new Error("图片加载超时"))},1e4)})}async function g(e,t){if(o){console.warn("打印已在进行中");return}try{o=!0;const n=c(t?.custom_style,t),a=p(e);document.body.appendChild(n),document.body.appendChild(a),await w(a),window.print(),setTimeout(()=>{try{n.parentNode&&n.parentNode.removeChild(n),a.parentNode&&a.parentNode.removeChild(a),o=!1,t?.on_complete?.()}catch(l){console.error("清理打印元素失败:",l),t?.on_error?.(l)}},100)}catch(n){console.error("打印失败:",n),o=!1,t?.on_error?.(n)}}async function b(e,t){try{h();const n=c(t?.custom_style,t),a=document.createElement("div");a.innerHTML=e,await w(a);const l=document.createElement("div");l.setAttribute("id","preview-container");const d=document.createElement("div");d.setAttribute("id","preview-content"),d.appendChild(a);const s=document.createElement("button");s.setAttribute("id","preview-close"),s.textContent="×",s.addEventListener("click",()=>{h(),t?.on_cancel?.()});const u=document.createElement("button");u.setAttribute("id","preview-print"),u.textContent="打印",u.addEventListener("click",()=>{h(),g(e,t)}),d.appendChild(s),d.appendChild(u),l.appendChild(d),document.body.appendChild(n),document.body.appendChild(l),r=l}catch(n){console.error("预览失败:",n),t?.on_error?.(n)}}async function k(e,t){try{const n=document.querySelector(e);if(n)t?.preview?await b(n.innerHTML,t):await g(n.innerHTML,t);else throw new Error(`未找到DOM节点: ${e}`)}catch(n){console.error("打印DOM元素失败:",n),t?.on_error?.(n)}}async function E(e,t){try{if(!e||e.length===0)throw new Error("元素数组为空");let n="";for(const a of e)n+=a.outerHTML;if(!n)throw new Error("元素内容为空");t?.preview?await b(n,t):await g(n,t)}catch(n){console.error("打印元素数组失败:",n),t?.on_error?.(n)}}function _(e,t){try{const n=document.querySelector(e);if(n)b(n.innerHTML,t);else throw new Error(`未找到DOM节点: ${e}`)}catch(n){console.error("预览DOM元素失败:",n),t?.on_error?.(n)}}function y(e,t){try{if(!e||e.length===0)throw new Error("元素数组为空");let n="";for(const a of e)n+=a.outerHTML;if(!n)throw new Error("元素内容为空");b(n,t)}catch(n){console.error("预览元素数组失败:",n),t?.on_error?.(n)}}function i(){h()}return{print_html:k,print_html_element:E,preview_html:_,preview_html_element:y,close_preview:i}}function K(){const r=Q;return`${r()}${r()}-${r()}-${r()}-${r()}-${r()}${r()}${r()}`}function Q(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function U(r){return typeof r=="object"&&r!==null&&Object.prototype.toString.call(r)==="[object Object]"}const V=typeof window<"u";function B(r,o=document){return o.querySelector(r)}function R(r,o,c,m){r&&r.addEventListener(o,c,m)}function j(r,o,c,m){r&&r.removeEventListener(o,c,m)}function X(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function Y({path:r,name:o}){const c=document.createElement("a");c.href=r,c.target="_blank",o&&c.setAttribute("download",o),document.body.appendChild(c),c.click(),document.body.removeChild(c)}async function Z(r){if(!r)return;const o=new FileReader;return o.readAsDataURL(r),new Promise((c,m)=>{o.onload=h=>c(h.target?.result),o.onerror=h=>m(void 0)})}async function ee(r,o=800,c=800,m=.8){if(r.type.startsWith("image/"))return new Promise(h=>{const p=document.createElement("canvas"),w=p.getContext("2d"),g=new Image;g.onload=()=>{let{width:b,height:k}=g;if(b>o||k>c){const E=Math.min(o/b,c/k);b*=E,k*=E}p.width=b,p.height=k,w?.drawImage(g,0,0,b,k),p.toBlob(E=>{if(E){const _=new File([E],r.name,{type:r.type});h(_)}else h(void 0)},r.type,m)},g.src=URL.createObjectURL(r)})}const te=new Map;let T=null;V&&(document.addEventListener("mousedown",r=>{T=r}),document.addEventListener("mouseup",r=>{for(const o of te.values())for(const{document_handler:c}of o)T&&c(r,T);T=null}));function ne(){const r=K();let o=null,c=null;function m(_){return _&&B(_)||document.body}function h(_){const{text1:y,text2:i,font_size:e=16,font_family:t="Avenir,Helvetica,Arial,sans-serif",rotate:n=-15,text_color:a="#999",opacity:l=.1,size:d={width:250,height:150}}=_;try{const s=document.createElement("canvas");s.width=d.width,s.height=d.height;const u=s.getContext("2d");if(u&&(u.font=`${e}px ${t}`,u.fillStyle=a.replace(/\,\s(1|(0\.\d+)\))/,`, ${l}`),u.textAlign="left",u.textBaseline="middle",u.rotate(n*Math.PI/180),u.fillText(y,0,s.height/2),i)){const x=u.measureText(y).width;u.fillText(i,x+16,s.height/2)}return s}catch(s){console.error("创建水印画布失败:",s);const u=document.createElement("canvas");return u.width=0,u.height=0,u}}function p(_){const{wrapper:y,z_index:i=1e5,position:e="fixed",spacing:t=0,size:n={width:250,height:150}}=_,a=m(y),l=document.getElementById(r);if(l)try{a.removeChild(l)}catch(x){console.error("移除旧水印失败:",x)}const d=h(_),s=document.createElement("div");s.id=r,s.style.pointerEvents="none",s.style.top="0px",s.style.left="0px",s.style.position=e,s.style.zIndex=i.toString();const u=X();s.style.width=u.width+"px",s.style.height=u.height+"px",s.style.background=`url(${d.toDataURL("image/png")}) left top repeat`,t>0&&(s.style.backgroundSize=`${n.width+t}px ${n.height+t}px`);try{a.appendChild(s)}catch(x){console.error("添加水印失败:",x)}}function w(){o&&p(o)}function g(_){o=_,p(_),_.responsive?c||(c=w,R(window,"resize",c)):c&&(j(window,"resize",c),c=null)}function b(){const _=document.getElementById(r);if(_)try{const y=_.parentElement;y&&y.removeChild(_)}catch(y){console.error("移除水印失败:",y)}c&&(j(window,"resize",c),c=null),o=null}function k(_){if(o){const y={...o,..._};g(y)}else console.warn("水印未初始化,请先调用 create_water_mark")}function E(){return document.getElementById(r)!==null}return{create_water_mark:g,remove_water_mark:b,update_water_mark:k,has_water_mark:E}}function re(r){const{server:o,receive:c,max_reconnect_attempts:m=5,reconnect_interval:h=5e3,heartbeat_interval:p=3e4,heartbeat_message:w="ping",on_open:g,on_error:b,on_close:k,auto_reconnect:E=!0,auto_connect:_=!0,max_message_queue_size:y=100}=r;let i=0,e=!1,t,n=null,a=null,l=[],d=0;const s=p*1.5;typeof window<"u"&&(window.onbeforeunload=()=>{G()});function u(){try{console.log("正在连接WebSocket:",o),t=new WebSocket(o),x()}catch(f){console.error("WebSocket连接建立异常:",f),b?.(f),E&&N()}}function x(){t&&(t.onopen=()=>{console.log("WebSocket连接成功:",o),i=0,d=Date.now(),z(),D(),g?.()},t.onerror=f=>{console.error("WebSocket连接错误:",f),b?.(f)},t.onclose=f=>{console.log("WebSocket连接关闭:",new Date().toLocaleTimeString(),"原因:",f.code,f.reason),C(),k?.(),E&&!f.wasClean&&N()},t.onmessage=f=>{try{d=Date.now(),c(f)}catch(P){console.error("WebSocket消息处理错误:",P),console.log("原始消息:",f.data)}})}function N(){if(i>=m){console.error("WebSocket重连失败次数过多,停止重连"),G();return}e||(e=!0,console.log(`WebSocket尝试重连 ${i+1}/${m}...`),n=setTimeout(()=>{u(),i++,e=!1,W()},h))}function W(){n&&(clearTimeout(n),n=null)}function z(){C(),a=setInterval(()=>{q(),$()},p)}function C(){a&&(clearInterval(a),a=null)}function q(){if(t?.readyState===WebSocket.OPEN)try{const f=U(w)?JSON.stringify(w):w;t.send(f)}catch(f){console.error("发送心跳消息失败:",f)}}function $(){Date.now()-d>s&&(console.error("WebSocket心跳超时,尝试重连"),N())}function M(f){if(t?.readyState===WebSocket.OPEN)try{const P=U(f)?JSON.stringify(f):f;return t.send(P),!0}catch(P){return console.error("发送消息失败:",P),A(f),!1}else return console.warn("WebSocket未连接,消息已加入队列"),A(f),!1}function A(f){if(l.length>=y){const P=l.shift();console.warn("消息队列已满,移除最旧的消息:",P)}l.push(f),console.log(`消息已加入队列,当前队列大小: ${l.length}/${y}`)}function D(){if(t?.readyState===WebSocket.OPEN&&l.length>0)for(console.log(`发送队列中的 ${l.length} 条消息`);l.length>0;){const f=l.shift();M(f)}}function G(){if(C(),W(),t){try{t.close()}catch(f){console.error("关闭WebSocket失败:",f)}t=void 0}l=[]}function ie(){if(!t)return"CLOSED";switch(t.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNKNOWN"}}return _&&u(),{ws:t,create:u,close:G,send_message:M,get_status:ie,reconnect:N,start_heartbeat:z,stop_heartbeat:C}}var S=(r=>(r.PNG="image/png",r.JPEG="image/jpeg",r.GIF="image/gif",r))(S||{});function oe(){function r(i){return Object.values(S).includes(i)}async function o(i,e=.92,t=S.JPEG){return r(t)||(t=S.JPEG),i.toDataURL(t,e)}async function c(i,e="image",t=.92,n=S.JPEG){const a=await o(i,t,n);return m(a,n,e)}async function m(i,e=S.JPEG,t="image"){r(e)||(e=S.JPEG);const n=i.split(","),a=n[0].match(/:(.*?);/)?.[1]||e,l=atob(n[1]);let d=l.length;const s=new Uint8Array(d);for(;d--;)s[d]=l.charCodeAt(d);const u=a.split("/")[1],x=`${t}.${u}`;return new File([s],x,{type:a})}async function h(i){return new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=t,n.src=i})}function p(i,e="download"){const t=URL.createObjectURL(i);Y({path:t,name:e}),URL.revokeObjectURL(t)}async function w(i){const e=await Z(i);if(!e)throw new Error("转换文件为DataURL失败");return e}async function g(i,e={}){const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("创建Canvas上下文失败");const a=e.width||i.width,l=e.height||i.height,d=e.scale||1;return t.width=a*d,t.height=l*d,n.scale(d,d),n.drawImage(i,0,0,a,l),t}async function b(i){const e=await fetch(i);if(!e.ok)throw new Error(`获取图片失败: ${e.statusText}`);return e.blob()}async function k(i){return new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=t,n.src=i})}async function E(i,e={}){if(!(i instanceof Blob))throw new Error("compress(): 第一个参数必须是Blob对象或File对象");const t=Math.max(0,Math.min(1,isNaN(Number(e.quality))?.92:Number(e.quality)));e.quality=t;const n=await w(i),a=n.split(",")[0].match(/:(.*?);/)?.[1];let l=S.JPEG;r(e.type)&&(l=e.type);const d=await h(n),s=await g(d,e),u=await o(s,e.quality,l),x=await m(u,a||l);return x.size>i.size?i:x}async function _(i,e={}){if(!(i instanceof Blob))throw new Error("compressAccurately(): 第一个参数必须是Blob对象或File对象");const t=Math.max(0,isNaN(Number(e.size))?0:Number(e.size));e.size=t;const n=Math.max(.8,Math.min(.99,isNaN(Number(e.accuracy))?.95:Number(e.accuracy)));if(e.accuracy=n,isNaN(e.size)||e.size*1024>i.size)return i;(!e.accuracy||e.accuracy<.8||e.accuracy>.99)&&(e.accuracy=.95);const a={max:e.size*(2-e.accuracy)*1024,accurate:e.size*1024,min:e.size*e.accuracy*1024},l=await w(i),d=l.split(",")[0].match(/:(.*?);/)?.[1];let s=S.JPEG;r(e.type)&&(s=e.type);const u=await h(l),x=await g(u,e),N=.75;let W=1,z="";const C=[];for(let $=1;$<=7;$++){z=await o(x,W,s);const M=z.length*N;if($===7){(a.max<M||a.min>M)&&(z=[z,...C].filter(Boolean).sort((A,D)=>Math.abs(A.length*N-a.accurate)-Math.abs(D.length*N-a.accurate))[0]);break}if(a.max<M)C[1]=z,W-=.5**($+1);else if(a.min>M)C[0]=z,W+=.5**($+1);else break}const q=await m(z,d||s);return q.size>i.size?i:q}async function y(i,e=800,t=800,n=.8){return ee(i,e,t,n)}return{compress:E,compress_accurately:_,compress_image:y,canvas_to_data_url:o,canvas_to_file:c,data_url_to_file:m,data_url_to_image:h,file_to_data_url:w,image_to_canvas:g,url_to_blob:b,url_to_image:k,download_file:p}}function ce(r){const o=O.ref(!1),c=O.shallowRef(null);function m(){o.value=document.fullscreenElement===c.value}O.onMounted(()=>{c.value=B(r),c.value&&R(c.value,"fullscreenchange",m)}),O.onUnmounted(()=>{c.value&&j(c.value,"fullscreenchange",m)});function h(){!o.value&&c.value?.requestFullscreen&&c.value.requestFullscreen().catch(g=>{console.error("进入全屏失败:",g)})}function p(){document.exitFullscreen&&document.exitFullscreen().catch(g=>{console.error("退出全屏失败:",g)})}function w(){o.value?p():h()}return{container:c,full:o,toggle_fullscreen:w,enter_fullscreen:h,exit_fullscreen:p}}v.EImageType=S,v.use_emit=F,v.use_fullscreen=ce,v.use_image=oe,v.use_print=J,v.use_water_mark=ne,v.use_web_socket=re,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -4,18 +4,12 @@ import { use_water_mark } from "./use-watermark/index.js";
|
|
|
4
4
|
import { use_web_socket } from "./use-websocket/index.js";
|
|
5
5
|
import { use_image } from "./use-image/index.js";
|
|
6
6
|
import { use_fullscreen } from "./use-fullscreen/index.js";
|
|
7
|
-
import { use_chart } from "./use-chart/index.js";
|
|
8
|
-
import { use_layout_flow } from "./use-layout-flow/index.js";
|
|
9
|
-
import { use_mqtt } from "./use-mqtt/index.js";
|
|
10
7
|
import { EImageType } from "./use-image/type.js";
|
|
11
8
|
export {
|
|
12
9
|
EImageType,
|
|
13
|
-
use_chart,
|
|
14
10
|
use_emit,
|
|
15
11
|
use_fullscreen,
|
|
16
12
|
use_image,
|
|
17
|
-
use_layout_flow,
|
|
18
|
-
use_mqtt,
|
|
19
13
|
use_print,
|
|
20
14
|
use_water_mark,
|
|
21
15
|
use_web_socket
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function auto_size(size, deflate_width = 1920) {
|
|
2
|
+
let client_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
3
|
+
if (!client_width) return size;
|
|
4
|
+
let scale = client_width / deflate_width;
|
|
5
|
+
return Number((size * scale).toFixed(3));
|
|
6
|
+
}
|
|
7
|
+
function get_chart_gradient_color(type, start_color, end_color) {
|
|
8
|
+
return {
|
|
9
|
+
type: "linear",
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
x2: type === "v" ? 0 : 1,
|
|
13
|
+
y2: type === "v" ? 1 : 0,
|
|
14
|
+
colorStops: [
|
|
15
|
+
{
|
|
16
|
+
offset: 0,
|
|
17
|
+
color: start_color
|
|
18
|
+
// 0% 处的颜色
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
offset: 1,
|
|
22
|
+
color: end_color
|
|
23
|
+
// 100% 处的颜色
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function init_chart(container, options, renderer = "canvas", theme) {
|
|
29
|
+
const load_echarts = async () => {
|
|
30
|
+
try {
|
|
31
|
+
let echarts;
|
|
32
|
+
if (typeof window !== "undefined" && window.echarts) {
|
|
33
|
+
echarts = window.echarts;
|
|
34
|
+
} else {
|
|
35
|
+
const imported = await import("echarts");
|
|
36
|
+
echarts = imported.default || imported;
|
|
37
|
+
}
|
|
38
|
+
const chart_dom = typeof container === "string" ? document.getElementById(container) : container;
|
|
39
|
+
if (!chart_dom) {
|
|
40
|
+
console.error("ECharts DOM容器未找到");
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const chart = echarts.init(chart_dom, theme, {
|
|
44
|
+
renderer
|
|
45
|
+
});
|
|
46
|
+
if (options) {
|
|
47
|
+
chart.setOption(options);
|
|
48
|
+
}
|
|
49
|
+
return chart;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("加载 ECharts 失败:", error);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return load_echarts();
|
|
56
|
+
}
|
|
57
|
+
function destroy_chart(chart) {
|
|
58
|
+
if (chart && typeof chart.dispose === "function") {
|
|
59
|
+
chart.dispose();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function update_chart(chart, options) {
|
|
63
|
+
if (chart && typeof chart.setOption === "function") {
|
|
64
|
+
chart.setOption(options);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function resize_chart(chart) {
|
|
68
|
+
if (chart && typeof chart.resize === "function") {
|
|
69
|
+
chart.resize();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function make_chart_responsive(chart, debounce_time = 200) {
|
|
73
|
+
if (!chart) return;
|
|
74
|
+
let resize_timer;
|
|
75
|
+
const resize_handler = () => {
|
|
76
|
+
clearTimeout(resize_timer);
|
|
77
|
+
resize_timer = setTimeout(() => {
|
|
78
|
+
resize_chart(chart);
|
|
79
|
+
}, debounce_time);
|
|
80
|
+
};
|
|
81
|
+
window.addEventListener("resize", resize_handler);
|
|
82
|
+
return () => {
|
|
83
|
+
window.removeEventListener("resize", resize_handler);
|
|
84
|
+
clearTimeout(resize_timer);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function generate_chart_colors(count, base_colors) {
|
|
88
|
+
const default_colors = [
|
|
89
|
+
"#5470c6",
|
|
90
|
+
"#91cc75",
|
|
91
|
+
"#fac858",
|
|
92
|
+
"#ee6666",
|
|
93
|
+
"#73c0de",
|
|
94
|
+
"#3ba272",
|
|
95
|
+
"#fc8452",
|
|
96
|
+
"#9a60b4",
|
|
97
|
+
"#ea7ccc",
|
|
98
|
+
"#67c23a"
|
|
99
|
+
];
|
|
100
|
+
const colors = base_colors || default_colors;
|
|
101
|
+
const result = [];
|
|
102
|
+
for (let i = 0; i < count; i++) {
|
|
103
|
+
result.push(colors[i % colors.length]);
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
function merge_chart_options(defaultOption, customOption) {
|
|
108
|
+
return {
|
|
109
|
+
...defaultOption,
|
|
110
|
+
...customOption,
|
|
111
|
+
// 特殊处理数组类型的配置
|
|
112
|
+
series: customOption.series || defaultOption.series,
|
|
113
|
+
xAxis: customOption.xAxis || defaultOption.xAxis,
|
|
114
|
+
yAxis: customOption.yAxis || defaultOption.yAxis,
|
|
115
|
+
legend: customOption.legend || defaultOption.legend,
|
|
116
|
+
tooltip: customOption.tooltip || defaultOption.tooltip,
|
|
117
|
+
title: customOption.title || defaultOption.title
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function add_chart_listener(chart, eventName, handler) {
|
|
121
|
+
if (chart && typeof chart.on === "function") {
|
|
122
|
+
chart.on(eventName, handler);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function remove_chart_listener(chart, eventName, handler) {
|
|
126
|
+
if (chart && typeof chart.off === "function") {
|
|
127
|
+
chart.off(eventName, handler);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function export_chart_image(chart, options = {}) {
|
|
131
|
+
if (!chart || typeof chart.getDataURL !== "function") {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const {
|
|
135
|
+
type = "png",
|
|
136
|
+
pixel_ratio = 2,
|
|
137
|
+
background_color = "#fff",
|
|
138
|
+
exclude_components = [],
|
|
139
|
+
file_name = "echarts-image"
|
|
140
|
+
} = options;
|
|
141
|
+
const data_url = chart.getDataURL({
|
|
142
|
+
type,
|
|
143
|
+
pixelRatio: pixel_ratio,
|
|
144
|
+
backgroundColor: background_color,
|
|
145
|
+
excludeComponents: exclude_components
|
|
146
|
+
});
|
|
147
|
+
const link = document.createElement("a");
|
|
148
|
+
link.download = `${file_name}.${type}`;
|
|
149
|
+
link.href = data_url;
|
|
150
|
+
link.click();
|
|
151
|
+
return data_url;
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
add_chart_listener,
|
|
155
|
+
auto_size,
|
|
156
|
+
destroy_chart,
|
|
157
|
+
export_chart_image,
|
|
158
|
+
generate_chart_colors,
|
|
159
|
+
get_chart_gradient_color,
|
|
160
|
+
init_chart,
|
|
161
|
+
make_chart_responsive,
|
|
162
|
+
merge_chart_options,
|
|
163
|
+
remove_chart_listener,
|
|
164
|
+
resize_chart,
|
|
165
|
+
update_chart
|
|
166
|
+
};
|
package/lib/use-chart/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onUnmounted } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { deep_assign, deep_clone } from "@qy_better_lib/core";
|
|
3
|
+
import { destroy_chart, auto_size, get_chart_gradient_color, generate_chart_colors, remove_chart_listener, add_chart_listener, export_chart_image, resize_chart, merge_chart_options, update_chart, init_chart, make_chart_responsive } from "./node_modules/@qy_better_lib/core/lib/utils/echarts.js";
|
|
4
|
+
import options from "./use-chart/config.js";
|
|
4
5
|
function get_chart_theme(theme) {
|
|
5
6
|
{
|
|
6
7
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { guid, on, off, get_window_size, get_element } from "@qy_better_lib/core";
|
|
2
2
|
function use_water_mark() {
|
|
3
|
-
const id =
|
|
3
|
+
const id = guid();
|
|
4
4
|
let current_options = null;
|
|
5
5
|
let resize_handler = null;
|
|
6
6
|
function get_wrapper(wrapper) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qy_better_lib/hooks",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.5",
|
|
5
5
|
"description": "qy better lib hooks",
|
|
6
6
|
"author": "luhuiming",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "MIT",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build:lib": "vite build --config vite.lib.config.ts",
|
|
10
10
|
"build:dist-min": "vite build --config vite.dist.min.config.ts",
|
|
@@ -40,11 +40,23 @@
|
|
|
40
40
|
"./*": {
|
|
41
41
|
"import": "./lib/*/index.js",
|
|
42
42
|
"types": "./lib/*/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./use-chart": {
|
|
45
|
+
"import": "./lib/use-chart/index.js",
|
|
46
|
+
"types": "./lib/use-chart/index.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./use-layout-flow": {
|
|
49
|
+
"import": "./lib/use-layout-flow/index.js",
|
|
50
|
+
"types": "./lib/use-layout-flow/index.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./use-mqtt": {
|
|
53
|
+
"import": "./lib/use-mqtt/index.js",
|
|
54
|
+
"types": "./lib/use-mqtt/index.d.ts"
|
|
43
55
|
}
|
|
44
56
|
},
|
|
45
57
|
"devDependencies": {
|
|
46
58
|
"@antv/x6": "^2.18.1",
|
|
47
|
-
"@qy_better_lib/core": "^0.2.
|
|
59
|
+
"@qy_better_lib/core": "^0.2.5",
|
|
48
60
|
"@types/dagre": "^0.7.53",
|
|
49
61
|
"@types/node": "^24.5.2",
|
|
50
62
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
@@ -86,4 +98,4 @@
|
|
|
86
98
|
"optional": false
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
|
-
}
|
|
101
|
+
}
|
|
File without changes
|
|
File without changes
|