k5web/assets/index.f39e46ea.js
2024-01-29 16:49:58 +08:00

1 line
4.9 KiB
JavaScript

import{e as T,_ as R}from"./index.132300a0.js";/* 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 e,aH as t,aM as l,G as U,aX as K,bb as L,bJ as V,bG as I,bH as z,bK as N,bD as j,bE as G,bC as J,bF as X,n as f}from"./arco.d15c1506.js";import{i as $,e as E,a as q,f as Q,g as W}from"./serial.03b19244.js";import"./chart.4422206f.js";import"./vue.295dbc7d.js";const Y={class:"container"},Z=["innerHTML"],ee={name:"Backup"},te=S({...ee,setup(ue){const n=T(),c=M({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210 EEPROM \u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:""}),B=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await $()},d=async(u,s,_=new Date+"_backup.bin")=>{await E(n.connectPort);let a=new Uint8Array(s-u);for(let o=u;o<s;o+=128){const b=await q(n.connectPort,o);a.set(b,o-u),c.status=c.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+((o-u)/a.length*100).toFixed(1)+"%<br/>",f(()=>{const F=document==null?void 0:document.getElementById("statusArea");F&&(F.scrollTop=F==null?void 0:F.scrollHeight)})}c.status=c.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A100.0%<br/>",f(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)}),console.log(a);const r=new Blob([a],{type:"application/octet-stream"}),i=URL.createObjectURL(r),p=document.createElement("a");p.href=i,p.download=_,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(i)},m=async(u=0)=>{await E(n.connectPort);const s=document.createElement("input");s.type="file",s.onchange=async()=>{const _=new Blob([s.files[0]],{type:"application/octet-stream"}),a=new Uint8Array(await _.arrayBuffer());for(let r=u;r<s.files[0].size+u;r+=128)await Q(n.connectPort,r,a.slice(r-u,r-u+128)),c.status=c.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+((r-u)/s.files[0].size*100).toFixed(1)+"%<br/>",f(()=>{const i=document==null?void 0:document.getElementById("statusArea");i&&(i.scrollTop=i==null?void 0:i.scrollHeight)});c.status=c.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A100.0%<br/>",await W(n.connectPort)},s.click()},y=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await d(0,7680,"config.bin")},D=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await d(7680,8192,"calibration.bin")},k=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m()},w=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m(7680)},C=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}let u=8192;switch(c.eepromType){case"1":u=8192;break;case"2":u=131072;break;case"3":u=262144;break;case"4":u=524288;break;default:u=8192}await d(0,u)},A=async()=>{if(n.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}await m()};return(u,s)=>{const _=P("Breadcrumb"),a=K,r=L,i=V,p=I,o=z,b=N,F=j,g=G,h=J,v=X;return H(),O("div",Y,[e(_,{items:["\u5C0F\u5DE5\u5177","\u5907\u4EFD/\u8FD8\u539F"]}),e(v,{gutter:20,align:"stretch"},{default:t(()=>[e(h,{span:24},{default:t(()=>[e(g,{class:"general-card",title:"\u5907\u4EFD/\u8FD8\u539F"},{default:t(()=>[e(b,{"default-active-key":"1"},{default:t(()=>[e(i,{key:"1",title:"\u5FEB\u6377\u5907\u4EFD"},{default:t(()=>[e(r,null,{default:t(()=>[e(a,{type:"primary",onClick:y},{default:t(()=>[l("\u5907\u4EFD\u914D\u7F6E")]),_:1}),e(a,{onClick:k},{default:t(()=>[l("\u6062\u590D\u914D\u7F6E")]),_:1}),e(a,{type:"primary",onClick:D},{default:t(()=>[l("\u5907\u4EFD\u6821\u51C6")]),_:1}),e(a,{onClick:w},{default:t(()=>[l("\u6062\u590D\u6821\u51C6")]),_:1})]),_:1})]),_:1}),e(i,{key:"2",title:"\u5B8C\u6574\u5907\u4EFD"},{default:t(()=>[e(r,null,{default:t(()=>[e(a,{type:"primary",onClick:C},{default:t(()=>[l("\u5907\u4EFD")]),_:1}),e(a,{onClick:A},{default:t(()=>[l("\u6062\u590D")]),_:1}),e(o,{modelValue:c.eepromType,"onUpdate:modelValue":s[0]||(s[0]=x=>c.eepromType=x),style:{width:"320px"},placeholder:"\u9009\u62E9EEPROM\u5927\u5C0F"},{default:t(()=>[e(p,{value:"1"},{default:t(()=>[l("8KB\uFF0864Kbit\uFF09")]),_:1}),e(p,{value:"2"},{default:t(()=>[l("128KB\uFF081Mbit\uFF09")]),_:1}),e(p,{value:"3"},{default:t(()=>[l("256KB\uFF082Mbit\uFF09")]),_:1}),e(p,{value:"4"},{default:t(()=>[l("512KB\uFF084Mbit\uFF09")]),_:1})]),_:1},8,["modelValue"]),e(a,{type:"text",onClick:B},{default:t(()=>[l("\u81EA\u52A8\u68C0\u6D4B")]),_:1})]),_:1})]),_:1})]),_:1}),e(F),U("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:c.status},null,8,Z)]),_:1})]),_:1})]),_:1})])}}});const be=R(te,[["__scopeId","data-v-de906e10"]]);export{be as default};