k5web/assets/index.f75b4827.js
2024-02-02 21:28:38 +08:00

2 lines
3.3 KiB
JavaScript

import{e as A,_ as P}from"./index.d368c164.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as K,r as L,bi as N,C as F,D as R,aE as r,b0 as _,aZ as x,aV as D,bY as U,b$ as O,bd as T,bs as V,bP as H,bR as M,bN as j,bQ as z,bu as G,bv as Q,G as C}from"./arco.b143604e.js";import{e as Y,f as Z,g as $}from"./serial.3518333f.js";import"./chart.9aa904c5.js";import"./vue.12fb94d8.js";const B=b=>(G("data-v-208cc1d9"),b=b(),Q(),b),q={class:"container"},J=B(()=>C("div",{id:"canvasDiv",style:{zoom:"250%"}},null,-1)),W=B(()=>C("br",null,null,-1)),X={name:"Backup"},tt=K({...X,setup(b){const l=A(),a=L({activeKey:1,binaryFile:void 0,loading:!1}),k=()=>{const o=document.createElement("input");o.type="file",o.onchange=async()=>{const p=new Blob([o.files[0]],{type:"application/octet-stream"}),f=URL.createObjectURL(p),t=document.createElement("canvas");t.width=128,t.height=64;const u=t.cloneNode(),c=document.getElementById("canvasDiv");c.innerHTML="",c==null||c.append(t,u);const n=new Image;n.src=f,n.onload=()=>{const d=t.getContext("2d");d==null||d.drawImage(n,0,0,128,64);const g=d==null?void 0:d.getImageData(0,0,t.width,t.height).data;function y(i,s){const e=(s*128+i)*4;return g[e]+g[e+1]+g[e+2]>128*3?0:1}const h=u.getContext("2d"),m=h.getImageData(0,0,u.width,u.height);for(let i=0;i<64;i++)for(let s=0;s<128;s++){const e=(i*128+s)*4,E=!y(s,i);m.data[e]=E*255,m.data[e+1]=E*255,m.data[e+2]=E*255,m.data[e+3]=255}h.putImageData(m,0,0);const w=new Uint8Array(1024);let S=0;for(let i=0;i<64;i+=8)for(let s=0;s<128;s++){let v=0;for(let e=0;e<8;e++)v|=y(s,i+e)<<e;w[S++]=v}a.binaryFile=w}},o.click()},I=async()=>{var f,t,u,c;if(l.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(((f=l.configuration)==null?void 0:f.uart)=="official"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==2&&((t=l.configuration)==null?void 0:t.charset)!="gb2312"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==1&&((u=l.configuration)==null?void 0:u.charset)!="losehu"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}a.loading=!0;let o=123728;a.activeKey==2&&(o=8320),await Y(l.connectPort);const p=a.binaryFile;for(let n=o;n<p.length+o;n+=128)await Z(l.connectPort,n,p.slice(n-o,n-o+128),128,(c=l.configuration)==null?void 0:c.uart);await $(l.connectPort),a.loading=!1};return(o,p)=>{const f=N("Breadcrumb"),t=U,u=O,c=T,n=V,d=H,g=M,y=j,h=z;return F(),R("div",q,[r(f,{items:["\u5C0F\u5DE5\u5177","\u5F00\u673A\u56FE\u7247"]}),r(h,{gutter:20,align:"stretch"},{default:_(()=>[r(y,{span:24},{default:_(()=>[r(g,{loading:a.loading,tip:"\u5199\u5165\u4E2D...",style:{width:"100%"}},{default:_(()=>[r(d,{class:"general-card",title:"\u5F00\u673A\u56FE\u7247"},{default:_(()=>[r(u,{"active-key":a.activeKey,onChange:p[0]||(p[0]=m=>{a.activeKey=m})},{default:_(()=>[(F(),x(t,{key:1,title:"LOSEHU 117"})),(F(),x(t,{key:2,title:"LOSEHU 118+"}))]),_:1},8,["active-key"]),J,W,r(n,null,{default:_(()=>[r(c,{onClick:k},{default:_(()=>[D("\u9009\u62E9\u56FE\u7247")]),_:1}),r(c,{type:"primary",disabled:!a.binaryFile,onClick:I},{default:_(()=>[D("\u5199\u5165")]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["loading"])]),_:1})]),_:1})])}}});const lt=P(tt,[["__scopeId","data-v-208cc1d9"]]);export{lt as default};