mirror of
https://github.com/silenty4ng/k5web
synced 2024-11-14 14:33:23 +00:00
2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
import{e as x,_ as R}from"./index.20864429.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as S,r as M,b0 as P,C as H,D as O,aI as t,aH as e,aM as l,G as U,aX as L,bb as V,bQ as I,bG as K,bH as z,bR as N,bD as j,bE as G,bC as Q,bF as X,n as E}from"./arco.cd87ac27.js";import{m as q,e as B,a as J,f as W,g as Y}from"./serial.3518333f.js";import"./chart.19f3a5b6.js";import"./vue.a1682e6c.js";const Z={class:"container"},$=["innerHTML"],tt={name:"Backup"},et=S({...tt,setup(ut){const o=x(),s=M({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210 EEPROM \u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:""}),y=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await q()},m=async(u,n,_=new Date+"_backup.bin")=>{var d;await B(o.connectPort);let c=new Uint8Array(n-u);for(let r=u;r<n;r+=128){const b=await J(o.connectPort,r,128,(d=o.configuration)==null?void 0:d.uart);c.set(b,r-u),s.status=s.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+((r-u)/c.length*100).toFixed(1)+"%<br/>",E(()=>{const p=document==null?void 0:document.getElementById("statusArea");p&&(p.scrollTop=p==null?void 0:p.scrollHeight)})}s.status=s.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A100.0%<br/>",E(()=>{const r=document==null?void 0:document.getElementById("statusArea");r&&(r.scrollTop=r==null?void 0:r.scrollHeight)}),console.log(c);const F=new Blob([c],{type:"application/octet-stream"}),i=URL.createObjectURL(F),a=document.createElement("a");a.href=i,a.download=_,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},f=async(u=0)=>{await B(o.connectPort);const n=document.createElement("input");n.type="file",n.onchange=async()=>{var F;const _=new Blob([n.files[0]],{type:"application/octet-stream"}),c=new Uint8Array(await _.arrayBuffer());for(let i=u;i<n.files[0].size+u;i+=128)await W(o.connectPort,i,c.slice(i-u,i-u+128),128,(F=o.configuration)==null?void 0:F.uart),s.status=s.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+((i-u)/n.files[0].size*100).toFixed(1)+"%<br/>",E(()=>{const a=document==null?void 0:document.getElementById("statusArea");a&&(a.scrollTop=a==null?void 0:a.scrollHeight)});s.status=s.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A100.0%<br/>",await Y(o.connectPort)},n.click()},D=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(0,7680,"config.bin")},k=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(7680,8192,"calibration.bin")},w=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f()},A=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f(7680)},C=async()=>{var n;if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}let u=8192;switch(s.eepromType){case"1":u=8192;break;case"2":u=131072;break;case"3":u=262144;break;case"4":u=524288;break;default:u=8192}if(((n=o.configuration)==null?void 0:n.uart)=="official"&&u>=131072){alert("\u8BE5\u56FA\u4EF6\u4E0D\u652F\u6301\u5907\u4EFD\u6269\u5BB9\u7A7A\u95F4");return}await m(0,u)},g=async()=>{if(o.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f()};return(u,n)=>{const _=P("Breadcrumb"),c=L,F=V,i=I,a=K,d=z,r=N,b=j,p=G,h=Q,v=X;return H(),O("div",Z,[t(_,{items:["\u5C0F\u5DE5\u5177","\u5907\u4EFD/\u8FD8\u539F"]}),t(v,{gutter:20,align:"stretch"},{default:e(()=>[t(h,{span:24},{default:e(()=>[t(p,{class:"general-card",title:"\u5907\u4EFD/\u8FD8\u539F"},{default:e(()=>[t(r,{"default-active-key":"1"},{default:e(()=>[t(i,{key:"1",title:"\u5FEB\u6377\u5907\u4EFD"},{default:e(()=>[t(F,null,{default:e(()=>[t(c,{type:"primary",onClick:D},{default:e(()=>[l("\u5907\u4EFD\u914D\u7F6E")]),_:1}),t(c,{onClick:w},{default:e(()=>[l("\u6062\u590D\u914D\u7F6E")]),_:1}),t(c,{type:"primary",onClick:k},{default:e(()=>[l("\u5907\u4EFD\u6821\u51C6")]),_:1}),t(c,{onClick:A},{default:e(()=>[l("\u6062\u590D\u6821\u51C6")]),_:1})]),_:1})]),_:1}),t(i,{key:"2",title:"\u5B8C\u6574\u5907\u4EFD"},{default:e(()=>[t(F,null,{default:e(()=>[t(c,{type:"primary",onClick:C},{default:e(()=>[l("\u5907\u4EFD")]),_:1}),t(c,{onClick:g},{default:e(()=>[l("\u6062\u590D")]),_:1}),t(d,{modelValue:s.eepromType,"onUpdate:modelValue":n[0]||(n[0]=T=>s.eepromType=T),style:{width:"320px"},placeholder:"\u9009\u62E9EEPROM\u5927\u5C0F"},{default:e(()=>[t(a,{value:"1"},{default:e(()=>[l("8KB\uFF0864Kbit\uFF09")]),_:1}),t(a,{value:"2"},{default:e(()=>[l("128KB\uFF081Mbit\uFF09")]),_:1}),t(a,{value:"3"},{default:e(()=>[l("256KB\uFF082Mbit\uFF09")]),_:1}),t(a,{value:"4"},{default:e(()=>[l("512KB\uFF084Mbit\uFF09")]),_:1})]),_:1},8,["modelValue"]),t(c,{type:"text",onClick:y},{default:e(()=>[l("\u81EA\u52A8\u68C0\u6D4B")]),_:1})]),_:1})]),_:1})]),_:1}),t(b),U("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:s.status},null,8,$)]),_:1})]),_:1})]),_:1})])}}});const bt=R(et,[["__scopeId","data-v-bac7f4ab"]]);export{bt as default};
|