mirror of
https://github.com/silenty4ng/k5web
synced 2024-11-14 22:35:31 +00:00
2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{e as R,ag as S,_ as M}from"./index.006cd607.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as P,r as H,bO as V,bP as O,bH as U,C as L,D as K,aI as t,aH as e,G as y,aM as l,a_ as z,a$ as N,b7 as j,bi as G,bQ as Q,bf as $,bR as q,bF as J,bI as W,bM as X,n as B}from"./arco.93f0afda.js";import{i as Y,e as D,a as Z,b as tt,g as et}from"./serial.bad97c4e.js";import"./chart.c383733a.js";import"./vue.ded74ca2.js";const ut={class:"container"},at=["innerHTML"],ot={name:"Backup"},nt=P({...ot,setup(ct){const n=R(),o=H({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210 EEPROM \u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:"",showHide:0,startInfo:"0x00"}),w=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await Y()},m=async(u,a,d=new Date+"_backup.bin")=>{var p;await D(n.connectPort);let c=new Uint8Array(a-u);for(let r=u;r<a;r+=128){const b=await Z(n.connectPort,r,128,(p=n.configuration)==null?void 0:p.uart);c.set(b,r-u),o.status=o.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+((r-u)/c.length*100).toFixed(1)+"%<br/>",B(()=>{const _=document==null?void 0:document.getElementById("statusArea");_&&(_.scrollTop=_==null?void 0:_.scrollHeight)})}o.status=o.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A100.0%<br/>",B(()=>{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),s=document.createElement("a");s.href=i,s.download=d,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)},f=async(u=0)=>{await D(n.connectPort);const a=document.createElement("input");a.type="file",a.onchange=async()=>{var F;const d=new Blob([a.files[0]],{type:"application/octet-stream"}),c=new Uint8Array(await d.arrayBuffer());for(let i=u;i<a.files[0].size+u;i+=128)await tt(n.connectPort,i,c.slice(i-u,i-u+128),128,(F=n.configuration)==null?void 0:F.uart),o.status=o.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+((i-u)/a.files[0].size*100).toFixed(1)+"%<br/>",B(()=>{const s=document==null?void 0:document.getElementById("statusArea");s&&(s.scrollTop=s==null?void 0:s.scrollHeight)});o.status=o.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A100.0%<br/>",await et(n.connectPort)},a.click()},k=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(0,7680,"config.bin")},A=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(7680,8192,"calibration.bin")},g=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f()},C=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f(7680)},h=async()=>{var a;if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}let u=8192;switch(o.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(((a=n.configuration)==null?void 0:a.uart)=="official"&&u>=131072){alert("\u8BE5\u56FA\u4EF6\u4E0D\u652F\u6301\u5907\u4EFD\u6269\u5BB9\u7A7A\u95F4");return}await m(0,u)},v=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f(parseInt(o.startInfo))};return(u,a)=>{const d=S,c=j,F=G,i=Q,s=$,p=q,r=V,b=O,_=J,x=U,T=W,I=X;return L(),K("div",ut,[t(d,{items:["\u5C0F\u5DE5\u5177","\u5907\u4EFD/\u8FD8\u539F"]}),t(I,{gutter:20,align:"stretch"},{default:e(()=>[t(T,{span:24},{default:e(()=>[t(x,{class:"general-card"},{title:e(()=>[y("span",{onClick:a[0]||(a[0]=()=>{o.showHide+=1})},"\u5907\u4EFD/\u8FD8\u539F\uFF08\u624B\u53F0\u5E94\u5728\u5F00\u673A\u72B6\u6001\u4E0B\uFF09")]),default:e(()=>[t(b,{"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:k},{default:e(()=>[l("\u5907\u4EFD\u914D\u7F6E")]),_:1}),t(c,{onClick:g},{default:e(()=>[l("\u6062\u590D\u914D\u7F6E")]),_:1}),t(c,{type:"primary",onClick:A},{default:e(()=>[l("\u5907\u4EFD\u6821\u51C6")]),_:1}),t(c,{onClick:C},{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:h},{default:e(()=>[l("\u5907\u4EFD")]),_:1}),z(t(s,{modelValue:o.startInfo,"onUpdate:modelValue":a[1]||(a[1]=E=>o.startInfo=E)},null,8,["modelValue"]),[[N,o.showHide>=5]]),t(c,{onClick:v},{default:e(()=>[l("\u6062\u590D")]),_:1}),t(r,{modelValue:o.eepromType,"onUpdate:modelValue":a[2]||(a[2]=E=>o.eepromType=E),style:{width:"320px"},placeholder:"\u9009\u62E9EEPROM\u5927\u5C0F"},{default:e(()=>[t(p,{value:"1"},{default:e(()=>[l("8KB\uFF0864Kbit\uFF09")]),_:1}),t(p,{value:"2"},{default:e(()=>[l("128KB\uFF081Mbit\uFF09")]),_:1}),t(p,{value:"3"},{default:e(()=>[l("256KB\uFF082Mbit\uFF09")]),_:1}),t(p,{value:"4"},{default:e(()=>[l("512KB\uFF084Mbit\uFF09")]),_:1})]),_:1},8,["modelValue"]),t(c,{type:"text",onClick:w},{default:e(()=>[l("\u81EA\u52A8\u68C0\u6D4B")]),_:1})]),_:1})]),_:1})]),_:1}),t(_),y("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:o.status},null,8,at)]),_:1})]),_:1})]),_:1})])}}});const Dt=M(nt,[["__scopeId","data-v-87a07d1e"]]);export{Dt as default};
|