k5web/assets/index.08e7fb05.js
2024-07-24 11:01:29 +08:00

2 lines
6.9 KiB
JavaScript

import{s as O,ac as z,_ as L}from"./index.1c489121.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 G,bW as q,bI as J,C as W,D as X,aI as a,aH as n,G as C,aN as p,aM as d,a$ as Y,b0 as Q,n as _,b8 as Z,bi as x,bX as tt,bf as et,bY as ot,bG as at,bJ as nt,bL as it}from"./arco.c29bba08.js";import{i as E,b as h,g as F,e as $,a as st}from"./serial.c6b76da8.js";import{D as lt}from"./index.17f1fd0b.js";import"./chart.34708d29.js";import"./vue.437ba699.js";const rt={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 o;if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}switch(await E(i.connectPort,(o=i.configuration)==null?void 0:o.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,l;if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}const t=await E(i.connectPort,(m=i.configuration)==null?void 0:m.uart);let o=new Uint8Array(128).fill(255);for(let r=0;r<t;r+=128)await h(i.connectPort,r,o,128,(l=i.configuration)==null?void 0:l.uart),e.status=e.status+"\u6E05\u7A7A\u8FDB\u5EA6\uFF1A"+((r-0)/t*100).toFixed(1)+"%<br/>",_(()=>{const s=document==null?void 0:document.getElementById("statusArea");s&&(s.scrollTop=s==null?void 0:s.scrollHeight)});await F(i.connectPort)},y=async(t,o,m=new Date+"_backup.bin")=>{var f;await $(i.connectPort);let l=new Uint8Array(o-t);for(let u=t;u<o;u+=128){const w=await st(i.connectPort,u,128,(f=i.configuration)==null?void 0:f.uart);l.set(w,u-t),e.status=e.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+((u-t)/l.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(l);const r=new Blob([l],{type:"application/octet-stream"}),s=URL.createObjectURL(r),c=document.createElement("a");c.href=s,c.download=m,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(s)},k=async(t=0)=>{await $(i.connectPort);const o=document.createElement("input");o.type="file",o.accept=".bin",o.onchange=async()=>{var r;const m=new Blob([o.files[0]],{type:"application/octet-stream"}),l=new Uint8Array(await m.arrayBuffer());for(let s=t;s<o.files[0].size+t;s+=128)await h(i.connectPort,s,l.slice(s-t,s-t+128),l.slice(s-t,s-t+128).length,(r=i.configuration)==null?void 0:r.uart),e.status=e.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+((s-t)/o.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 F(i.connectPort)},o.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 o;if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}let t=8192;switch(e.eepromType){case"1":t=8192;break;case"2":t=131072;break;case"3":t=262144;break;case"4":t=524288;break;default:t=8192}if(((o=i.configuration)==null?void 0:o.uart)=="official"&&t>=131072){alert("\u8BE5\u56FA\u4EF6\u4E0D\u652F\u6301\u5907\u4EFD\u6269\u5BB9\u7A7A\u95F4");return}await y(0,t)},H=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await k(parseInt(e.startInfo))};return(t,o)=>{const m=z,l=Z,r=x,s=tt,c=et,f=ot,u=G,w=q,b=at,U=J,V=nt,M=it,K=lt;return W(),X("div",rt,[a(m,{items:[t.$t("menu.list"),t.$t("menu.rb")]},null,8,["items"]),a(M,{gutter:20,align:"stretch"},{default:n(()=>[a(V,{span:24},{default:n(()=>[a(U,{class:"general-card"},{title:n(()=>[C("span",{onClick:o[0]||(o[0]=()=>{e.showHide+=1})},p(t.$t("menu.rb")+t.$t("global.onStart")),1)]),default:n(()=>[a(w,{"default-active-key":"1"},{default:n(()=>[a(s,{key:"1",title:t.$t("tool.quickbackup")},{default:n(()=>[a(r,null,{default:n(()=>[a(l,{type:"primary",onClick:B},{default:n(()=>[d(p(t.$t("tool.backupConfig")),1)]),_:1}),a(l,{onClick:I},{default:n(()=>[d(p(t.$t("tool.restoreConfig")),1)]),_:1}),a(l,{type:"primary",onClick:v},{default:n(()=>[d(p(t.$t("tool.backupCalibration")),1)]),_:1}),a(l,{onClick:P},{default:n(()=>[d(p(t.$t("tool.restoreCalibration")),1)]),_:1})]),_:1})]),_:1},8,["title"]),a(s,{key:"2",title:t.$t("tool.fullbackup")},{default:n(()=>[a(r,null,{default:n(()=>[a(l,{type:"primary",onClick:R},{default:n(()=>[d(p(t.$t("tool.backup")),1)]),_:1}),Y(a(c,{modelValue:e.startInfo,"onUpdate:modelValue":o[1]||(o[1]=g=>e.startInfo=g)},null,8,["modelValue"]),[[Q,e.showHide>=5]]),a(l,{onClick:H},{default:n(()=>[d(p(t.$t("tool.restore")),1)]),_:1}),a(u,{modelValue:e.eepromType,"onUpdate:modelValue":o[2]||(o[2]=g=>e.eepromType=g),style:{width:"320px"},placeholder:t.$t("tool.selectSize")},{default:n(()=>[a(f,{value:"1"},{default:n(()=>[d(p(t.$t("global.8kb")),1)]),_:1}),a(f,{value:"2"},{default:n(()=>[d(p(t.$t("global.128kb")),1)]),_:1}),a(f,{value:"3"},{default:n(()=>[d(p(t.$t("global.256kb")),1)]),_:1}),a(f,{value:"4"},{default:n(()=>[d(p(t.$t("global.512kb")),1)]),_:1})]),_:1},8,["modelValue","placeholder"]),a(l,{type:"text",onClick:D},{default:n(()=>[d(p(t.$t("tool.autocheck")),1)]),_:1})]),_:1})]),_:1},8,["title"]),a(s,{key:"3",title:t.$t("tool.cleardata")},{default:n(()=>[a(r,null,{default:n(()=>[a(l,{type:"primary",onClick:T},{default:n(()=>[d(p(t.$t("tool.cleardata")),1)]),_:1})]),_:1})]),_:1},8,["title"])]),_:1}),a(b),C("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:e.status},null,8,ct)]),_:1})]),_:1})]),_:1}),a(K,{visible:e.showDialog,"onUpdate:visible":o[3]||(o[3]=g=>e.showDialog=g),theme:"warning",header:e.dialogTitle>=3?t.$t("tool.first")+e.dialogTitle+t.$t("tool.firstTitle")+t.$t("tool.last"):t.$t("tool.first")+e.dialogTitle+t.$t("tool.firstTitle"),body:t.$t("tool.clearMessage"),onConfirm:S},null,8,["visible","header","body"])])}}});const Tt=L(pt,[["__scopeId","data-v-a5acccab"]]);export{Tt as default};