k5web/assets/index.f19705ec.js
2024-02-15 23:27:43 +08:00

1 line
5.4 KiB
JavaScript

import{e as S,q as I,_ as M}from"./index.71f9a6c9.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as R,r as P,bU as V,bV as H,bB as U,bC as O,C as L,D as K,aI as t,aH as e,aM as l,bw as z,bx as N,G as j,aZ as q,b8 as G,bW as W,b5 as X,bX as Z,bD as J,bM as Q,n as B}from"./arco.beabb834.js";import{m as Y,e as D,a as $,f as tt,g as et}from"./serial.b70f48dc.js";import"./chart.83b8c11b.js";import"./vue.30c84055.js";const ut={class:"container"},at=["innerHTML"],ot={name:"Backup"},nt=R({...ot,setup(ct){const n=S(),o=P({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210 EEPROM \u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:"",showHide:0,startInfo:"0x00"}),y=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 F;await D(n.connectPort);let c=new Uint8Array(a-u);for(let r=u;r<a;r+=128){const b=await $(n.connectPort,r,128,(F=n.configuration)==null?void 0:F.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 p=new Blob([c],{type:"application/octet-stream"}),i=URL.createObjectURL(p),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 p;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,(p=n.configuration)==null?void 0:p.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()},w=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(0,7680,"config.bin")},k=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(7680,8192,"calibration.bin")},A=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)},g=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)},h=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await f(parseInt(o.startInfo))};return(u,a)=>{const d=I,c=q,p=G,i=W,s=X,F=Z,r=V,b=H,_=U,v=O,x=J,T=Q;return L(),K("div",ut,[t(d,{items:["\u5C0F\u5DE5\u5177","\u5907\u4EFD/\u8FD8\u539F"]}),t(T,{gutter:20,align:"stretch"},{default:e(()=>[t(x,{span:24},{default:e(()=>[t(v,{class:"general-card",title:"\u5907\u4EFD/\u8FD8\u539F",onClick:a[2]||(a[2]=()=>{o.showHide+=1})},{default:e(()=>[t(b,{"default-active-key":"1"},{default:e(()=>[t(i,{key:"1",title:"\u5FEB\u6377\u5907\u4EFD"},{default:e(()=>[t(p,null,{default:e(()=>[t(c,{type:"primary",onClick:w},{default:e(()=>[l("\u5907\u4EFD\u914D\u7F6E")]),_:1}),t(c,{onClick:A},{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:C},{default:e(()=>[l("\u6062\u590D\u6821\u51C6")]),_:1})]),_:1})]),_:1}),t(i,{key:"2",title:"\u5B8C\u6574\u5907\u4EFD"},{default:e(()=>[t(p,null,{default:e(()=>[t(c,{type:"primary",onClick:g},{default:e(()=>[l("\u5907\u4EFD")]),_:1}),z(t(s,{modelValue:o.startInfo,"onUpdate:modelValue":a[0]||(a[0]=E=>o.startInfo=E)},null,8,["modelValue"]),[[N,o.showHide>=5]]),t(c,{onClick:h},{default:e(()=>[l("\u6062\u590D")]),_:1}),t(r,{modelValue:o.eepromType,"onUpdate:modelValue":a[1]||(a[1]=E=>o.eepromType=E),style:{width:"320px"},placeholder:"\u9009\u62E9EEPROM\u5927\u5C0F"},{default:e(()=>[t(F,{value:"1"},{default:e(()=>[l("8KB\uFF0864Kbit\uFF09")]),_:1}),t(F,{value:"2"},{default:e(()=>[l("128KB\uFF081Mbit\uFF09")]),_:1}),t(F,{value:"3"},{default:e(()=>[l("256KB\uFF082Mbit\uFF09")]),_:1}),t(F,{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(_),j("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 yt=M(nt,[["__scopeId","data-v-76383a0f"]]);export{yt as default};