k5web/assets/index.a89f295f.js

2 lines
7.6 KiB
JavaScript
Raw Normal View History

2024-10-11 09:02:55 +00:00
import{t as J,ad as G,O as W,_ as q}from"./index.50b3dfbe.js";/* empty css *//* empty css *//* empty css */import{d as Q,r as X,o as Y,bI as Z,C as h,D as E,aI as u,aH as l,G as d,aM as c,aN as b,aK as x,aJ as B,F as S,aE as ee,u as te,a6 as oe,b8 as ae,bi as ne,bK as re,bO as se,bm as le,bn as ie,n as ue}from"./arco.9755215d.js";import{u as ce}from"./loading.3855ec1d.js";import{i as de,e as pe,s as N,h as D,g as me,l as _e,b as ge}from"./serial.c6b76da8.js";import{L as fe}from"./index.4aa5e28b.js";import{I as he}from"./index.bf84a00a.js";import{C as be}from"./index.0cc40e57.js";import{S as Fe}from"./index.ece1fd7c.js";import"./chart.e5f26fc3.js";import"./vue.e23f7fca.js";import"./slot.e8853103.js";const M=F=>(le("data-v-24342154"),F=F(),ie(),F),we={class:"container"},ye={style:{color:"red","font-weight":"bold"}},Ae={style:{height:"2rem"}},Ee={style:{display:"flex","justify-content":"space-between","margin-left":"10px","margin-right":"10px","align-items":"flex-end","margin-bottom":"3px"}},ve=M(()=>d("div",null,"EEPROM\uFF1A",-1)),Ce={style:{width:"100%",overflow:"scroll","user-select":"none"}},ke={style:{height:"328px",display:"flex","flex-direction":"column",margin:"0",padding:"0","flex-wrap":"wrap"}},xe=["onClick","ondragover","ondrop","title"],Be=M(()=>d("br",null,null,-1)),Se=["innerHTML"],Ne={name:"BL"},De=Q({...Ne,setup(F){const m=J(),{loading:U,setLoading:w}=ce(!0),t=X({calendar:[],rom:[],bl:void 0,blName:"",nowDrag:-1,showAdd:"",status:""}),g=async(e=0,o,n="")=>{var i;for(let r=e;r<o.length+e;r+=192)await ge(m.connectPort,r,o.slice(r-e,r-e+192),o.slice(r-e,r-e+192).length,(i=m.configuration)==null?void 0:i.uart),t.status=t.status+n+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((r-e)/o.length*100).toFixed(1)+"%<br/>",ue(()=>{const a=document==null?void 0:document.getElementById("statusArea");a&&(a.scrollTop=a==null?void 0:a.scrollHeight)})},$=async e=>{t.showAdd=(e*64+262144).toString(16).toUpperCase(),setTimeout(()=>{t.showAdd=""},5e3)};Y(()=>{I();const e=[];for(let o=0;o<262144/64;o++)o<278528/64/16-16?e.push(-2):e.push(-1);t.calendar=e});const I=async()=>{const e=JSON.parse(await(await fetch("https://k5.vicicode.cn/diyapi/bl.json")).text()).latest;t.blName=e;const o=await fetch("https://k5.vicicode.cn/diyapi/"+e);if(o.body){const n=o.body.getReader(),i=[];for(;;){const{done:a,value:_}=await n.read();if(a)break;i.push(..._)}let r=new Uint8Array(12288);r.set(i,0),t.bl=r,w(!1)}},P=async()=>{var r;if(m.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}const e=await de(m.connectPort,(r=m.configuration)==null?void 0:r.uart);if(w(!0),e<524288){alert("\u53EA\u652F\u6301 4Mbit \u4EE5\u4E0A EEPROM \u5199\u5165"),w(!1);return}await pe(m.connectPort),await g(266240,t.bl,"\u5F15\u5BFC\u7A0B\u5E8F");const o=[];for(let a=256;a<4096;a++)t.calendar[a]>=0&&(console.log(a),o.push({...t.rom[t.calendar[a]],start:262144+a*64,end:262144+(a+Math.ceil(t.rom[t.calendar[a]].binaryFile.length/64))*64-1}),a+=Math.ceil(t.rom[t.calendar[a]].binaryFile.length/64)-1);await g(262144,new Uint8Array([o.length]),"\u56FA\u4EF6\u6570\u91CF");const n=new Uint8Array(8);n.set(N(t.blName.split(".")[0])),await g(262152,n,"\u5F15\u5BFC\u7A0B\u5E8F\u7248\u672C");const i=[];o.map(a=>{const _=new Uint8Array(16),y=new Uint8Array(4),A=new Uint8Array(4);_.set(N(a.binaryName.replace(/[^\x00-\xff]/g,""))),y.set(D(a.start.toString(16))),A.set(D(a.end.toString(16))),i.push(..._,...y,...A,...new Uint8Array(8))}),await g(262176,i,"\u56FA\u4EF6\u5143\u6570\u636E");for(let a=0;a<o.length;a++)await g(o[a].start,o[a].binaryFile,o[a].binaryName+" \u56FA\u4EF6\u6587\u4EF6");await me(m.connectPort),t.status=t.status+"\u5199\u5165\u5B8C\u6210<br/>",w(!1)},L=()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.onchange=async()=>{if(e.files)for(let o=0;o<e.files.length;o++){const n=new Blob([e.files[o]],{type:"application/octet-stream"}),i=new Uint8Array(await n.arrayBuffer()),r={binaryFile:_e(i),binaryName:e.files[o].name.replace(/[^\x00-\xff]/g,""),color:R()};t.rom.push(r)}},e.click()},O=(e,o)=>{if(!(