k5web/assets/index.64c80731.js

2 lines
7.5 KiB
JavaScript
Raw Normal View History

2024-07-20 03:04:32 +00:00
import{m as j,ak as K,_ as G}from"./index.12bdcbda.js";/* empty css *//* empty css *//* empty css */import{d as W,r as q,o as Q,bI as X,C as h,D as E,aI as c,aH as i,aM as m,aN as b,G as d,aK as B,aJ as S,F as N,aE as Y,u as Z,a6 as ee,a$ as te,ba as ae,bJ as oe,bL as ne,be as re,bf as le,n as se}from"./arco.7f845a67.js";import{u as ie}from"./loading.1a4e75f4.js";import{i as ce,e as ue,s as D,h as M,g as de,l as pe,b as me}from"./serial.c6b76da8.js";import{B as fe}from"./index.014c7ae3.js";import{I as _e}from"./index.d1cb55ec.js";import{C as ge}from"./index.c07a5fc8.js";import{S as he}from"./index.bb7e4ef6.js";import"./chart.95d38b48.js";import"./vue.0bef8fc5.js";import"./useConfig.8e3dba5c.js";import"./index.211f6b2b.js";import"./helper.b36c554d.js";import"./useDisabled.5453a5a8.js";import"./useGlobalIcon.1badd75e.js";import"./slot.5ae8b203.js";const x=F=>(re("data-v-7fa0c45f"),F=F(),le(),F),be={class:"container"},Fe=x(()=>d("div",{style:{color:"red","font-weight":"bold"}},"\u26A0\uFF1A\u5B9E\u9A8C\u6027\u529F\u80FD \u4F7F\u7528\u53EF\u80FD\u4F1A\u635F\u574F\u624B\u53F0",-1)),we={style:{display:"flex","justify-content":"space-between","margin-left":"10px","margin-right":"10px","align-items":"flex-end","margin-bottom":"3px"}},ye=x(()=>d("div",null,"EEPROM\uFF1A",-1)),Ae={style:{width:"100%",overflow:"scroll","user-select":"none"}},Ee={style:{height:"328px",display:"flex","flex-direction":"column",margin:"0",padding:"0","flex-wrap":"wrap"}},ve=["onClick","ondragover","ondrop","title"],Ce=x(()=>d("br",null,null,-1)),xe=["innerHTML"],ke={name:"BL"},Be=W({...ke,setup(F){const p=j(),{loading:U,setLoading:w}=ie(!0),t=q({calendar:[],rom:[],bl:void 0,blName:"",nowDrag:-1,showAdd:"",status:""}),_=async(e=0,a,n="")=>{var s;for(let r=e;r<a.length+e;r+=192)await me(p.connectPort,r,a.slice(r-e,r-e+192),a.slice(r-e,r-e+192).length,(s=p.configuration)==null?void 0:s.uart),t.status=t.status+n+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((r-e)/a.length*100).toFixed(1)+"%<br/>",se(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)})},$=async e=>{t.showAdd=(e*64+262144).toString(16).toUpperCase(),setTimeout(()=>{t.showAdd=""},5e3)};Q(()=>{I();const e=[];for(let a=0;a<262144/64;a++)a<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 a=await fetch("https://k5.vicicode.cn/diyapi/"+e);if(a.body){const n=a.body.getReader(),s=[];for(;;){const{done:o,value:f}=await n.read();if(o)break;s.push(...f)}let r=new Uint8Array(12288);r.set(s,0),t.bl=r,w(!1)}},P=async()=>{var r;if(p.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}const e=await ce(p.connectPort,(r=p.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 ue(p.connectPort),await _(266240,t.bl,"\u5F15\u5BFC\u7A0B\u5E8F");const a=[];for(let o=256;o<4096;o++)t.calendar[o]>=0&&(console.log(o),a.push({...t.rom[t.calendar[o]],start:262144+o*64,end:262144+(o+Math.ceil(t.rom[t.calendar[o]].binaryFile.length/64))*64-1}),o+=Math.ceil(t.rom[t.calendar[o]].binaryFile.length/64)-1);await _(262144,new Uint8Array([a.length]),"\u56FA\u4EF6\u6570\u91CF");const n=new Uint8Array(8);n.set(D(t.blName.split(".")[0])),await _(262152,n,"\u5F15\u5BFC\u7A0B\u5E8F\u7248\u672C");const s=[];a.map(o=>{const f=new Uint8Array(16),y=new Uint8Array(4),A=new Uint8Array(4);f.set(D(o.binaryName.replace(/[^\x00-\xff]/g,""))),y.set(M(o.start.toString(16))),A.set(M(o.end.toString(16))),s.push(...f,...y,...A,...new Uint8Array(8))}),await _(262176,s,"\u56FA\u4EF6\u5143\u6570\u636E");for(let o=0;o<a.length;o++)await _(a[o].start,a[o].binaryFile,a[o].binaryName+" \u56FA\u4EF6\u6587\u4EF6");await de(p.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 a=0;a<e.files.len