mirror of
https://github.com/silenty4ng/k5web
synced 2025-01-29 23:23:50 +00:00
2 lines
4.9 KiB
JavaScript
2 lines
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")]),_
|