mirror of
https://github.com/silenty4ng/k5web
synced 2025-01-15 16:22:44 +00:00
5 lines
7.1 KiB
JavaScript
5 lines
7.1 KiB
JavaScript
import{w as O,h as z,Y as L,_ as N}from"./index.3a834e58.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as j,r as q,bS as G,bT as J,bD as Y,C as Q,D as W,aI as o,aH as n,G as C,aN as p,aM as d,bo as X,bp as Z,n as _,a$ as x,ba as tt,bU as et,b7 as ot,bV as at,bB as nt,bE as it,bJ as rt}from"./arco.b289f6bb.js";import{i as E,b as h,g as F,e as S,a as st}from"./serial.c741fbda.js";import{_ as lt}from"./dialog.3aea52d2.js";import"./chart.7501771f.js";import"./vue.e0867ae8.js";import"./useConfig.1a69b527.js";import"./dep-281dbb92.fa8dfc7c.js";import"./index.9e72de03.js";import"./index.1865e741.js";import"./useDisabled.e7ff81a3.js";/**
|
|
* tdesign v1.9.4
|
|
* (c) 2024 tdesign
|
|
* @license MIT
|
|
*/var ct=O(lt);const ut={class:"container"},pt=["innerHTML"],dt={name:"Backup"},mt=j({...dt,setup(ft){const i=z(),e=q({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}),T=()=>{if(e.dialogTitle>=3){e.showDialog=!1,A();return}e.dialogTitle+=1},$=()=>{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);for(let l=0;l<t;l+=128)await h(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 F(i.connectPort)},y=async(t,a,m=new Date+"_backup.bin")=>{var f;await S(i.connectPort);let s=new Uint8Array(a-t);for(let u=t;u<a;u+=128){const w=await st(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 S(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 h(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 F(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.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(((a=i.configuration)==null?void 0:a.uart)=="official"&&t>=131072){alert("\u8BE5\u56FA\u4EF6\u4E0D\u652F\u6301\u5907\u4EFD\u6269\u5BB9\u7A7A\u95F4");return}await y(0,t)},U=async()=>{if(i.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}await k(parseInt(e.startInfo))};return(t,a)=>{const m=L,s=x,l=tt,r=et,c=ot,f=at,u=G,w=J,b=nt,H=Y,V=it,M=rt,K=ct;return Q(),W("div",ut,[o(m,{items:[t.$t("menu.list"),t.$t("menu.rb")]},null,8,["items"]),o(M,{gutter:20,align:"stretch"},{default:n(()=>[o(V,{span:24},{default:n(()=>[o(H,{class:"general-card"},{title:n(()=>[C("span",{onClick:a[0]||(a[0]=()=>{e.showHide+=1})},p(t.$t("menu.rb")+t.$t("global.onStart")),1)]),default:n(()=>[o(w,{"default-active-key":"1"},{default:n(()=>[o(r,{key:"1",title:t.$t("tool.quickbackup")},{default:n(()=>[o(l,null,{default:n(()=>[o(s,{type:"primary",onClick:B},{default:n(()=>[d(p(t.$t("tool.backupConfig")),1)]),_:1}),o(s,{onClick:I},{default:n(()=>[d(p(t.$t("tool.restoreConfig")),1)]),_:1}),o(s,{type:"primary",onClick:v},{default:n(()=>[d(p(t.$t("tool.backupCalibration")),1)]),_:1}),o(s,{onClick:P},{default:n(()=>[d(p(t.$t("tool.restoreCalibration")),1)]),_:1})]),_:1})]),_:1},8,["title"]),o(r,{key:"2",title:t.$t("tool.fullbackup")},{default:n(()=>[o(l,null,{default:n(()=>[o(s,{type:"primary",onClick:R},{default:n(()=>[d(p(t.$t("tool.backup")),1)]),_:1}),X(o(c,{modelValue:e.startInfo,"onUpdate:modelValue":a[1]||(a[1]=g=>e.startInfo=g)},null,8,["modelValue"]),[[Z,e.showHide>=5]]),o(s,{onClick:U},{default:n(()=>[d(p(t.$t("tool.restore")),1)]),_:1}),o(u,{modelValue:e.eepromType,"onUpdate:modelValue":a[2]||(a[2]=g=>e.eepromType=g),style:{width:"320px"},placeholder:t.$t("tool.selectSize")},{default:n(()=>[o(f,{value:"1"},{default:n(()=>[d(p(t.$t("global.8kb")),1)]),_:1}),o(f,{value:"2"},{default:n(()=>[d(p(t.$t("global.128kb")),1)]),_:1}),o(f,{value:"3"},{default:n(()=>[d(p(t.$t("global.256kb")),1)]),_:1}),o(f,{value:"4"},{default:n(()=>[d(p(t.$t("global.512kb")),1)]),_:1})]),_:1},8,["modelValue","placeholder"]),o(s,{type:"text",onClick:D},{default:n(()=>[d(p(t.$t("tool.autocheck")),1)]),_:1})]),_:1})]),_:1},8,["title"]),o(r,{key:"3",title:t.$t("tool.cleardata")},{default:n(()=>[o(l,null,{default:n(()=>[o(s,{type:"primary",onClick:$},{default:n(()=>[d(p(t.$t("tool.cleardata")),1)]),_:1})]),_:1})]),_:1},8,["title"])]),_:1}),o(b),C("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:e.status},null,8,pt)]),_:1})]),_:1})]),_:1}),o(K,{visible:e.showDialog,"onUpdate:visible":a[3]||(a[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:T},null,8,["visible","header","body"])])}}});const Rt=N(mt,[["__scopeId","data-v-ad3c59af"]]);export{Rt as default};
|