k5web/assets/index.da5c768e.js
2024-01-27 01:25:20 +08:00

2 lines
3.4 KiB
JavaScript

import{e as D,_ as w}from"./index.c754acd3.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{a as k,b as x,f as A,g as h}from"./serial.dacf7476.js";import{d as v,r as C,b0 as g,C as T,D as M,aI as o,aH as u,aM as l,G as R,n as _,aX as H,bF as O,bG as P,bb as U,bD as L,bE as V,bC as $,bH as I}from"./arco.d6577a9c.js";import"./chart.4acde4c9.js";import"./vue.4f3ae527.js";const K={class:"container"},S=["innerHTML"],z={name:"Card"},N=v({...z,setup(j){const d=D(),n=C({status:"\u70B9\u51FB\u5907\u4EFD\u6309\u94AE\u5C06\u751F\u6210EEPROM\u5907\u4EFD\u6587\u4EF6<br/><br/>",eepromType:""}),m=async()=>{await k()},F=async()=>{let e=8192;switch(n.eepromType){case"1":e=8192;break;case"2":e=131072;break;case"3":e=262144;break;case"4":e=524288;break;default:e=8192}let c=new Uint8Array(e);for(let s=0;s<e;s+=128){const p=await x(d.connectPort,s);c.set(p,s),n.status=n.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A"+(s/e*100).toFixed(1)+"%<br/>",_(()=>{const r=document==null?void 0:document.getElementById("statusArea");r&&(r.scrollTop=r==null?void 0:r.scrollHeight)})}n.status=n.status+"\u5907\u4EFD\u8FDB\u5EA6\uFF1A100%<br/>",_(()=>{const s=document==null?void 0:document.getElementById("statusArea");s&&(s.scrollTop=s==null?void 0:s.scrollHeight)}),console.log(c);const i=new Blob([c],{type:"application/octet-stream"}),a=URL.createObjectURL(i),t=document.createElement("a");t.href=a,t.download=new Date+"_backup.bin",document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(a)},b=async()=>{const e=document.createElement("input");e.type="file",e.onchange=async()=>{const c=new Blob([e.files[0]],{type:"application/octet-stream"}),i=new Uint8Array(await c.arrayBuffer());for(let a=0;a<e.files[0].size;a+=128)await A(d.connectPort,a,i.slice(a,a+128)),n.status=n.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A"+(a/e.files[0].size*100).toFixed(1)+"%<br/>",_(()=>{const t=document==null?void 0:document.getElementById("statusArea");t&&(t.scrollTop=t==null?void 0:t.scrollHeight)});n.status=n.status+"\u6062\u590D\u8FDB\u5EA6\uFF1A100%<br/>",h(d.connectPort)},e.click()};return(e,c)=>{const i=g("Breadcrumb"),a=H,t=O,s=P,p=U,r=L,f=V,E=$,y=I;return T(),M("div",K,[o(i,{items:["\u5C0F\u5DE5\u5177","\u5907\u4EFD/\u8FD8\u539F"]}),o(y,{gutter:20,align:"stretch"},{default:u(()=>[o(E,{span:24},{default:u(()=>[o(f,{class:"general-card",title:"\u5907\u4EFD/\u8FD8\u539F"},{default:u(()=>[o(p,null,{default:u(()=>[o(a,{type:"primary",onClick:F},{default:u(()=>[l("\u5907\u4EFD")]),_:1}),o(a,{onClick:b},{default:u(()=>[l("\u6062\u590D")]),_:1}),o(s,{modelValue:n.eepromType,"onUpdate:modelValue":c[0]||(c[0]=B=>n.eepromType=B),style:{width:"320px"},placeholder:"\u9009\u62E9EEPROM\u5927\u5C0F"},{default:u(()=>[o(t,{value:"1"},{default:u(()=>[l("8KB\uFF0864Kbit\uFF09")]),_:1}),o(t,{value:"2"},{default:u(()=>[l("128KB\uFF081Mbit\uFF09")]),_:1}),o(t,{value:"3"},{default:u(()=>[l("256KB\uFF082Mbit\uFF09")]),_:1}),o(t,{value:"4"},{default:u(()=>[l("512KB\uFF084Mbit\uFF09")]),_:1})]),_:1},8,["modelValue"]),o(a,{type:"text",onClick:m},{default:u(()=>[l("\u81EA\u52A8\u68C0\u6D4B")]),_:1})]),_:1}),o(r),R("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:n.status},null,8,S)]),_:1})]),_:1})]),_:1})])}}});const oe=w(N,[["__scopeId","data-v-5a428d72"]]);export{oe as default};