small-package/luci-themedog/htdocs/luci-static/themedog/assets/index.js

5 lines
30 KiB
JavaScript
Raw Normal View History

2024-08-31 19:04:54 +08:00
var De=Object.defineProperty,Ie=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var ie=(e,s,n)=>s in e?De(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n,L=(e,s)=>{for(var n in s||(s={}))Le.call(s,n)&&ie(e,n,s[n]);if(ce)for(var n of ce(s))Pe.call(s,n)&&ie(e,n,s[n]);return e},ue=(e,s)=>Ie(e,Me(s));var Ae=(e,s)=>()=>(s||e((s={exports:{}}).exports,s),s.exports);var V=(e,s,n)=>new Promise((a,o)=>{var l=r=>{try{i(n.next(r))}catch(v){o(v)}},d=r=>{try{i(n.throw(r))}catch(v){o(v)}},i=r=>r.done?a(r.value):Promise.resolve(r.value).then(l,d);i((n=n.apply(e,s)).next())});import{c as Ge,d as Ne,a as F,r as w,w as ze,v as Oe,o as p,b as h,e as t,t as m,p as B,f as T,g as O,u as k,F as x,n as X,h as j,i as je,j as qe,k as Q,l as ve,m as He,q as P,s as Ue,x as Z,y as q,z as ee,A,B as Ve}from"./vendor.js?c6e33ea3";var En=Ae(J=>{const We=function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerpolicy&&(l.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?l.credentials="include":o.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}};We();const Re=Ge(),Ye=Ne("theme",{state:()=>({popups:0}),getters:{}}),pe=()=>Re,I=window.L;var de;const he=((de=window==null?void 0:window.ThemeDog)==null?void 0:de.BaseURL)||"";var _e;const me=((_e=window==null?void 0:window.ThemeDog)==null?void 0:_e.HostName)||"",Xe=(window==null?void 0:window.ThemeDog.BG)||"/luci-static/themedog/image/bg.gif",ge=e=>he+"/icons/"+e+".png",fe=()=>me,ye=()=>new Promise((e,s)=>{if(!I){s([]);return}I.require("ui").then(function(n){if(n.menu){window.onbeforeunload=o=>{n.menu.flushCache()};const a=(o,l,d)=>{let i=[],r=(d||0)+1,v=n.menu.getChildren(o);if(v.length==0||r>2)return[];for(let g=0;g<v.length;g++){let f={title:window._(v[g].title),name:v[g].name,href:window.L.url(l,v[g].name),level:r,paths:[],isActive:window.L.env.dispatchpath[r]==v[g].name,children:[]};f.paths!=null&&(f.paths.push(o.name,v[g].name),f.children=a(v[g],l+"/"+v[g].name,r),i.push(f))}return i};n.menu.load().then(function(){let o=n.menu.getChildren();for(let l=0;l<o.length;l++)if(o[l].order&&o[l].order,I.env.requestpath.length?o[l].name==I.env.requestpath[0]:l==0){const i=a(o[l],o[l].name,0);e(i)}})}else e([])})}),we=()=>I.rpc.declare({object:"system",method:"board",expect:{}}),Ke=()=>I.rpc.declare({object:"system",method:"info",expect:{memory:{}}}),Je=()=>new Promise((e,s)=>{I.rpc.declare({object:"system",method:"info",expect:{localtime:0}})().then(a=>{e(a||0)}).catch(a=>{s(a)})}),Qe=()=>{window.L.network.getDevices().then(e=>{for(let s=0;s<e.length;s++)if(e[s].getCarrier())return!0;return!1})},Ze=()=>new Promise((e,s)=>{try{window.L.network.getWANNetworks().then(n=>{for(let a=0;a<n.length;a++){const l=n[a].isUp();if(l){e(l);return}}e(!1)})}catch(n){s(n)}}),$e=()=>window.L.rpc.declare({object:"system",method:"reboot"}),et=()=>window.L.network.getHostHints(),K=()=>new Promise((e,s)=>{try{I.require("network").then(n=>{n&&(n.getNetwork("wan").then(a=>{if(a){const o=a.getDevice();if(o)return e({up:o.getTXBytes(),down:o.getRXBytes()})}}),n.flushCache())})}catch(n){s(n)}});var tt=Object.freeze(Object.defineProperty({__proto__:null,BaseURL:he,HostName:me,BG:Xe,getIconBasePath:ge,getLOGO:fe,getNavMenus:ye,getSystemInfoBoard:we,getSystemInfoMemory:Ke,getSystemInfoLocaltime:Je,getNetworkDevices:Qe,getNetworksIsUp:Ze,reboot:$e,getNetworkHostHints:et,getUpDownData:K},Symbol.toStringTag,{value:"Module"}));const te=()=>new Date().getTime(),ke=(e,s)=>V(J,null,function*(){return new
background: none !important;
color-scheme: none !important;
}`,i.contentWindow.document.head.appendChild(r)}}if(s.task.href=="/cgi-bin/luci/admin/store"&&n.value){const i=n.value;i.contentWindow&&(i.contentWindow.onclick=r=>{l(r)})}},l=d=>{var i,r;if(d.target){const v=d.target;if(v.tagName=="A"&&v.className=="app-btn cbi-button cbi-button-apply"&&v.textContent=="\u6253\u5F00"){const g=d.composedPath();let f="",$="";const C=v.getAttribute("href")||"";if(g.length>2){const D=g[2];$=((i=D.querySelector(".app-title"))==null?void 0:i.getAttribute("title"))||"",f=((r=D.querySelector("span.app-name"))==null?void 0:r.textContent)||""}s.onOpenTask({title:f,name:$,href:C,paths:[],level:0,isActive:!1,children:[]}),d.preventDefault()}}};return(d,i)=>ze((p(),h("div",nt,[(p(),h("div",{class:"themedog-iframe_main",key:a.value},[t("div",ot,[t("span",null,m(e.task.title),1),t("div",at,[t("button",{class:"btn-refresh",onClick:i[0]||(i[0]=r=>a.value++)},ct),t("button",{class:"btn-full",onClick:i[1]||(i[1]=r=>e.onHiddenTask(e.i))},ut),t("button",{class:"btn-close",onClick:i[2]||(i[2]=r=>e.onClearTask(e.i))},dt)])]),t("div",_t,[t("iframe",{class:"themedog-iframe_container",allowfullscreen:"true",mozallowfullscreen:"mozallowfullscreen",msallowfullscreen:"msallowfullscreen",oallowfullscreen:"oallowfullscreen",webkitallowfullscreen:"webkitallowfullscreen",src:e.task.href,task:e.task.href=="/cgi-bin/luci/admin/store",onLoad:o,ref_key:"el",ref:n},null,40,vt)])]))],512)),[[Oe,e.task.href==e.ontask]])}});var ht=S(pt,[["__scopeId","data-v-f620deee"]]);const mt=e=>{if(e)try{var s=new Date(Number(e)*1e3),n=s.getHours(),a=s.getMinutes();let o=s.getSeconds();return n<10&&(n=`0${n}`),a<10&&(a=`0${a}`),o<10&&(o=`0${o}`),`${n}:${a} ${o}`}catch(o){}return""},gt=e=>{if(e)try{var s=new Date(Number(e)*1e3),n=s.getFullYear(),a=s.getMonth()+1,o=s.getDate();return n+"\u5E74"+a+"\u6708"+o+"\u65E5 "}catch(l){}return""},ft=e=>{if(e<1e3)return`${e}/B`;let n=1e3,a=0;for(let d=e/1e3;d>=1e3;d/=1e3)n*=1e3,a++;let o=["/KB","/MB","/GB","/TB","/PB","/EB"];return(e/100/(n/100)).toFixed(1)+o[a]},yt=e=>{if(e<1024)return""+e+"KB";let n=1024,a=0;for(let l=e/1024;l>=1024;l/=1024)n*=1024,a++;let o=["M","G","T","P","E"];return(e/100/(n/100)).toFixed(2)+o[a]};var wt=Object.freeze(Object.defineProperty({__proto__:null,dateForm:mt,dateYearDayForm:gt,byteToSize:ft,numberToSize:yt},Symbol.toStringTag,{value:"Module"})),W=L({},wt);const Te=e=>(B("data-v-38a7653c"),e=e(),T(),e),$t={class:"total"},kt={class:"memory"},bt=Te(()=>t("span",null,"CPU",-1)),Ct={class:"progress"},xt={class:"memory"},Et=Te(()=>t("span",null,"\u5185\u5B58",-1)),Ft={class:"progress"},Bt={class:"up"},Tt={class:"date"},St=F({setup(e){const s=w(""),n=w(""),a=w(),o=w(),l=w(0),d=w(0),i=()=>{r(),v(),setInterval(()=>{v()},5e3)},r=()=>{be.GET().then(c=>{var _;if(((_=c==null?void 0:c.data)==null?void 0:_.success)==!0){const u=c.data.result;if(u!=null){let y=u.locallTime||0;n.value=W.dateForm(`${y}`),s.value=W.dateYearDayForm(`${y}`),setInterval(()=>{n.value=W.dateForm(`${y++}`)},1e3)}}})},v=()=>V(this,null,function*(){Ce.GET().then(c=>{var _;if(((_=c==null?void 0:c.data)==null?void 0:_.success)==!0){const u=c.data.result;u!=null&&(a.value=u)}}),xe.GET().then(c=>{var _;if(((_=c==null?void 0:c.data)==null?void 0:_.success)==!0){const u=c.data.result;u!=null&&(o.value=u)}});try{let c=0,_=0,u=0,y=0;const b=yield K();b&&(c=b.up||0,_=b.down||0);const Y=yield g();Y&&(u=Y.up||0,y=Y.down||0);const ae=u-c,le=y-_;ae>=0&&le>=0?(l.value=ae,d.value=le):(l.value=0,d.value=0)}catch(c){}}),g=()=>new Promise((c,_)=>{setTimeout(()=>{const u=K();c(u)},1e3)});i();const f=O(()=>{if(o.value==null)return null;const c=o.value;return c.available!=null&&c.total!=null?(100-c.available/c.total*100).toFixed(2):0}),$=O(()=>{if(a.value==null)return null;const c=a.value;return c.available!=null&&c.total!=null?(100-c.available/c.total*100).toFixed(2):0}),C=W.byteToSize,D=c=>{let _={height:`${c}%`};return c>=80?_.background="#ff0000":c>=60?_.background="#ff9900":c>=40&&(_.background="#3eff08"),_};return(c,_)=>(p(),h("div",$t,[k($)!=null?(p(),h(x,{key:0},[t("div",kt,[t("span",null,m(k($))+"%",1),bt]),t("div