k5web/assets/index.1fbfb7cc.js

2 lines
7.1 KiB
JavaScript
Raw Normal View History

2024-06-16 07:06:52 +00:00
import{k as O,ak as z,_ as L}from"./index.7f62c4d1.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as N,r as j,bV as q,bW as G,bH as W,C as X,D as Y,aI as o,aH as n,G as C,aN as p,aM as d,bn as J,bo as Q,n as _,a$ as Z,ba as x,bX as tt,b7 as et,bY as ot,bF as at,bI as nt,bK as it}from"./arco.949c921a.js";import{i as E,b as F,g as h,e as $,a as rt}from"./serial.c741fbda.js";import{D as st}from"./index.266b5100.js";import"./chart.b6f2f6d9.js";import"./vue.d12e9c08.js";import"./dialog.a4f6c0d8.js";import"./useConfig.63982862.js";import"./index.7d5cd06e.js";import"./helper.2a1c5ca7.js";import"./index.3cdc4583.js";import"./useDisabled.9f58644b.js";const lt={class:"container"},ct=["innerHTML"],ut={name:"Backup"},pt=N({...ut,setup(dt){const i=O(),e=j({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210 EEPROM \u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:"",showHide:0,startInfo:"0x00",showDialog:!1,dialogTitle:1}),S=()=>{if(e.dialogTitle>=3){e.showDialog=!1,A();return}e.dialogTitle+=1},T=()=>{e.dialogTitle=1,e.showDialog=!0},D=async()=>{var a;if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}switch(await E(i.connectPort,(a=i.configuration)==null?void 0:a.uart)){case 8192:e.eepromType="1";break;case 131072:e.eepromType="2";break;case 262144:e.eepromType="3";break;case 524288:e.eepromType="4";break}},A=async()=>{var m,s;if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}const t=await E(i.connectPort,(m=i.configuration)==null?void 0:m.uart);let a=new Uint8Array(128).fill(255);for(let l=0;l<t;l+=128)await F(i.connectPort,l,a,128,(s=i.configuration)==null?void 0:s.uart),e.status=e.status+"\u6E05\u7A7A\u8FDB\u5EA6\uFF1A"+((l-0)/t*100).toFixed(1)+"%<br/>",_(()=>{const r=document==null?void 0:document.getElementById("statusArea");r&&(r.scrollTop=r==null?void 0:r.scrollHeight)});await h(i.connectPort)},y=async(t,a,m=new Date+"_backup.bin")=>{var f;await $(i.connectPort);let s=new Uint8Array(a-t);for(let u=t;u<a;u+=128){const w=await rt(i.connectPort,u,128,(f=i.configuration)==null?void 0:f.uart);s.set(w,u-t),e.status=e.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+((u-t)/s.length*100).toFixed(1)+"%<br/>",_(()=>{const b=document==null?void 0:document.getElementById("statusArea");b&&(b.scrollTop=b==null?void 0:b.scrollHeight)})}e.status=e.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A100.0%<br/>",_(()=>{const u=document==null?void 0:document.getElementById("statusArea");u&&(u.scrollTop=u==null?void 0:u.scrollHeight)}),console.log(s);const l=new Blob([s],{type:"application/octet-stream"}),r=URL.createObjectURL(l),c=document.createElement("a");c.href=r,c.download=m,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(r)},k=async(t=0)=>{await $(i.connectPort);const a=document.createElement("input");a.type="file",a.onchange=async()=>{var l;const m=new Blob([a.files[0]],{type:"application/octet-stream"}),s=new Uint8Array(await m.arrayBuffer());for(let r=t;r<a.files[0].size+t;r+=128)await F(i.connectPort,r,s.slice(r-t,r-t+128),128,(l=i.configuration)==null?void 0:l.uart),e.status=e.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+((r-t)/a.files[0].size*100).toFixed(1)+"%<br/>",_(()=>{const c=document==null?void 0:document.getElementById("statusArea");c&&(c.scrollTop=c==null?void 0:c.scrollHeight)});e.status=e.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A100.0%<br/>",await h(i.connectPort)},a.click()},B=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await y(0,7680,"config.bin")},v=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await y(7680,8192,"calibration.bin")},I=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await k()},P=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await k(7680)},R=async()=>{var a;if(i.connectS