This commit is contained in:
Silent YANG 2024-04-21 11:38:33 +08:00
parent 49e4b07a38
commit d796a96085
48 changed files with 417 additions and 29 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1 +1 @@
import{e as g,q as B,_ as E}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as w,r as A,bC as k,C as v,D as C,aI as s,aH as c,aM as p,aN as x,G as D,n as m,aZ as N,b8 as P,bA as S,bD as T,bM as H}from"./arco.a5c2f283.js";import{d as F,c as I,r as _,j as M,k as b,l as V,m as j}from"./serial.ceb8d64a.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const L={class:"container"},R=["innerHTML"],U={name:"Flash"},q=w({...U,setup(z){const u=g(),t=A({status:"\u70B9\u51FB\u66F4\u65B0\u6309\u94AE\u66F4\u65B0\u56FA\u4EF6\u5230\u8BBE\u5907<br/><br/>",binaryFile:void 0,binaryName:""}),f=()=>{const a=document.createElement("input");a.type="file",a.onchange=async()=>{const r=new Blob([a.files[0]],{type:"application/octet-stream"}),i=new Uint8Array(await r.arrayBuffer());t.binaryFile=i,t.binaryName=a.files[0].name},a.click()},y=async()=>{if(!t.binaryFile){alert("\u8BF7\u9009\u62E9\u6587\u4EF6");return}u.connectPort&&await F(u.connectPort);let a=await I();await _(a,24,1e3);const r=M(t.binaryFile),i=new Uint8Array([48,5,r.length,0,...r]);await b(a,i),await _(a,24);const o=V(t.binaryFile);if(o.length>61439)throw new Error("Last resort boundary check failed. Whoever touched the code is an idiot.");for(let e=0;e<o.length;e+=256){const l=o.slice(e,e+256),d=j(l,e,o.length);try{await b(a,d),await _(a,26)}catch(n){return console.log("Flash command rejected. Aborting."),Promise.reject(n)}t.status=t.status+`\u66F4\u65B0\u8FDB\u5EA6 ${(e/o.length*100).toFixed(1)}%<br/>`,m(()=>{const n=document==null?void 0:document.getElementById("statusArea");n&&(n.scrollTop=n==null?void 0:n.scrollHeight)})}t.status=t.status+"\u66F4\u65B0\u8FDB\u5EA6 100.0%<br/>",t.status=t.status+"\u56FA\u4EF6\u66F4\u65B0\u6210\u529F",m(()=>{const e=document==null?void 0:document.getElementById("statusArea");e&&(e.scrollTop=e==null?void 0:e.scrollHeight)}),F(a),u.updateSettings({connectState:!1})};return(a,r)=>{const i=B,o=N,e=P,l=S,d=k,n=T,h=H;return v(),C("div",L,[s(i,{items:["\u5C0F\u5DE5\u5177","\u56FA\u4EF6\u5347\u7EA7"]}),s(h,{gutter:20,align:"stretch"},{default:c(()=>[s(n,{span:24},{default:c(()=>[s(d,{class:"general-card",title:"\u56FA\u4EF6\u5347\u7EA7"},{default:c(()=>[s(e,null,{default:c(()=>[s(o,{onClick:f},{default:c(()=>[p(x(t.binaryFile?t.binaryName:"\u9009\u62E9\u56FA\u4EF6"),1)]),_:1}),s(o,{type:"primary",disabled:!t.binaryFile,onClick:y},{default:c(()=>[p("\u66F4\u65B0")]),_:1},8,["disabled"])]),_:1}),s(l),D("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:t.status},null,8,R)]),_:1})]),_:1})]),_:1})])}}});const Y=E(q,[["__scopeId","data-v-dacccb62"]]);export{Y as default};
import{e as g,q as B,_ as E}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as w,r as A,bC as k,C as v,D as C,aI as s,aH as c,aM as p,aN as x,G as D,n as m,aZ as N,b8 as P,bA as S,bD as T,bM as H}from"./arco.a5c2f283.js";import{d as F,c as I,r as _,j as M,k as b,l as V,m as j}from"./serial.bad97c4e.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const L={class:"container"},R=["innerHTML"],U={name:"Flash"},q=w({...U,setup(z){const u=g(),t=A({status:"\u70B9\u51FB\u66F4\u65B0\u6309\u94AE\u66F4\u65B0\u56FA\u4EF6\u5230\u8BBE\u5907<br/><br/>",binaryFile:void 0,binaryName:""}),f=()=>{const a=document.createElement("input");a.type="file",a.onchange=async()=>{const r=new Blob([a.files[0]],{type:"application/octet-stream"}),i=new Uint8Array(await r.arrayBuffer());t.binaryFile=i,t.binaryName=a.files[0].name},a.click()},y=async()=>{if(!t.binaryFile){alert("\u8BF7\u9009\u62E9\u6587\u4EF6");return}u.connectPort&&await F(u.connectPort);let a=await I();await _(a,24,1e3);const r=M(t.binaryFile),i=new Uint8Array([48,5,r.length,0,...r]);await b(a,i),await _(a,24);const o=V(t.binaryFile);if(o.length>61439)throw new Error("Last resort boundary check failed. Whoever touched the code is an idiot.");for(let e=0;e<o.length;e+=256){const l=o.slice(e,e+256),d=j(l,e,o.length);try{await b(a,d),await _(a,26)}catch(n){return console.log("Flash command rejected. Aborting."),Promise.reject(n)}t.status=t.status+`\u66F4\u65B0\u8FDB\u5EA6 ${(e/o.length*100).toFixed(1)}%<br/>`,m(()=>{const n=document==null?void 0:document.getElementById("statusArea");n&&(n.scrollTop=n==null?void 0:n.scrollHeight)})}t.status=t.status+"\u66F4\u65B0\u8FDB\u5EA6 100.0%<br/>",t.status=t.status+"\u56FA\u4EF6\u66F4\u65B0\u6210\u529F",m(()=>{const e=document==null?void 0:document.getElementById("statusArea");e&&(e.scrollTop=e==null?void 0:e.scrollHeight)}),F(a),u.updateSettings({connectState:!1})};return(a,r)=>{const i=B,o=N,e=P,l=S,d=k,n=T,h=H;return v(),C("div",L,[s(i,{items:["\u5C0F\u5DE5\u5177","\u56FA\u4EF6\u5347\u7EA7"]}),s(h,{gutter:20,align:"stretch"},{default:c(()=>[s(n,{span:24},{default:c(()=>[s(d,{class:"general-card",title:"\u56FA\u4EF6\u5347\u7EA7"},{default:c(()=>[s(e,null,{default:c(()=>[s(o,{onClick:f},{default:c(()=>[p(x(t.binaryFile?t.binaryName:"\u9009\u62E9\u56FA\u4EF6"),1)]),_:1}),s(o,{type:"primary",disabled:!t.binaryFile,onClick:y},{default:c(()=>[p("\u66F4\u65B0")]),_:1},8,["disabled"])]),_:1}),s(l),D("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:t.status},null,8,R)]),_:1})]),_:1})]),_:1})])}}});const Y=E(q,[["__scopeId","data-v-dacccb62"]]);export{Y as default};

BIN
assets/index.0587074b.js.gz Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
assets/index.274b289c.js.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
import{_ as r}from"./index.5f619d1e.js";/* empty css */import{d as p,r as _,o as f,bA as h,aZ as m,D as g,bw as c,bx as i,G as a,aI as e,aN as n,aH as F,bc as y,bd as v,C as A,aM as D}from"./arco.a5c2f283.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const b=s=>(y("data-v-14f2aa44"),s=s(),v(),s),S={class:"container"},x={style:{"background-color":"#fff",padding:"10%"}},B={style:{"background-color":"#fff",padding:"10%"}},C=b(()=>a("p",{style:{"font-size":"1.5rem","font-weight":"bold"}}," \u83B7\u53D6\u4FE1\u606F ",-1)),E={name:"SatLoc"},w=p({...E,setup(s){const t=_({lat:0,lng:0,alt:0,type:0,uuid:""});f(()=>{t.uuid=new URLSearchParams(location.hash.replace("#/satloc?","")).get("uuid"),navigator.geolocation.getCurrentPosition(o=>{o.coords&&(t.lat=o.coords.latitude,t.lng=o.coords.longitude,o.coords.altitude&&(t.alt=o.coords.altitude))})});const d=async()=>{await fetch("https://k5.vicicode.com/api/lol",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({func:0,uuid:t.uuid,cache:JSON.stringify([t.lng,t.lat,t.alt])})}),t.type=1};return(o,k)=>{const u=h,l=m;return A(),g("div",S,[c(a("div",x," \u8BF7\u70B9\u51FB\u7F51\u9875\u201C\u5DF2\u626B\u7801\u4E0A\u4F20\u201D\u6309\u94AE ",512),[[i,t.type!=0]]),c(a("div",B,[C,e(u),a("p",null," \u53F0\u7AD9\u7ECF\u5EA6\uFF1A"+n(t.lng),1),e(u),a("p",null," \u53F0\u7AD9\u7EAC\u5EA6\uFF1A"+n(t.lat),1),e(u),a("p",null," \u53F0\u7AD9\u6D77\u62D4\uFF1A"+n(t.alt),1),e(u),e(l,{type:"primary",onClick:d},{default:F(()=>[D("\u4E0A\u4F20")]),_:1})],512),[[i,t.type==0]])])}}});const V=r(w,[["__scopeId","data-v-14f2aa44"]]);export{V as default};
import{_ as r}from"./index.661e2444.js";/* empty css */import{d as p,r as _,o as f,bA as h,aZ as m,D as g,bw as c,bx as i,G as a,aI as e,aN as n,aH as F,bc as y,bd as v,C as A,aM as D}from"./arco.a5c2f283.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const b=s=>(y("data-v-14f2aa44"),s=s(),v(),s),S={class:"container"},x={style:{"background-color":"#fff",padding:"10%"}},B={style:{"background-color":"#fff",padding:"10%"}},C=b(()=>a("p",{style:{"font-size":"1.5rem","font-weight":"bold"}}," \u83B7\u53D6\u4FE1\u606F ",-1)),E={name:"SatLoc"},w=p({...E,setup(s){const t=_({lat:0,lng:0,alt:0,type:0,uuid:""});f(()=>{t.uuid=new URLSearchParams(location.hash.replace("#/satloc?","")).get("uuid"),navigator.geolocation.getCurrentPosition(o=>{o.coords&&(t.lat=o.coords.latitude,t.lng=o.coords.longitude,o.coords.altitude&&(t.alt=o.coords.altitude))})});const d=async()=>{await fetch("https://k5.vicicode.com/api/lol",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({func:0,uuid:t.uuid,cache:JSON.stringify([t.lng,t.lat,t.alt])})}),t.type=1};return(o,k)=>{const u=h,l=m;return A(),g("div",S,[c(a("div",x," \u8BF7\u70B9\u51FB\u7F51\u9875\u201C\u5DF2\u626B\u7801\u4E0A\u4F20\u201D\u6309\u94AE ",512),[[i,t.type!=0]]),c(a("div",B,[C,e(u),a("p",null," \u53F0\u7AD9\u7ECF\u5EA6\uFF1A"+n(t.lng),1),e(u),a("p",null," \u53F0\u7AD9\u7EAC\u5EA6\uFF1A"+n(t.lat),1),e(u),a("p",null," \u53F0\u7AD9\u6D77\u62D4\uFF1A"+n(t.alt),1),e(u),e(l,{type:"primary",onClick:d},{default:F(()=>[D("\u4E0A\u4F20")]),_:1})],512),[[i,t.type==0]])])}}});const V=r(w,[["__scopeId","data-v-14f2aa44"]]);export{V as default};

BIN
assets/index.4ba9f2f6.js.gz Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
assets/index.661e2444.js.gz Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
import{_ as vp,i as Dr,g as un,a as mr,u as et,b as Kt,c as tt,o as ht,d as vx,e as Ot,w as It,f as rr,h as Xt,j as hp,k as hx,l as pp,m as ae,n as We,p as Ge,q as px,r as gp,s as za,t as gx,v as Uf,x as Vt,y as kn,z as mx,A as xx,B as wx,C as yx,D as bx,E as Ys,F as _x,G as Sx,H as qs,I as mp,J as xp,K as Cx,L as Ex,M as wp,N as Ox,O as Ka,P as Tx,Q as Dl,R as kx,S as ua,T as Fx,U as Ax,V as Dx,W as yp,X as Dc,Y as bp,Z as Pc,$ as _p,a0 as wo,a1 as Mo,a2 as Sp,a3 as Cp,a4 as dl,a5 as Oe,a6 as Yl,a7 as Rc,a8 as Ep,a9 as Ic,aa as Px,ab as Rx,ac as Gf,ad as Ix,ae as Op,af as Nx,ag as Xf,ah as Lx,ai as Mx,aj as Bx,ak as jx,al as $x,am as Vx}from"./index.48acc18f.js";import{e as Hx,q as Kx,_ as Wx}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{h as St,c as W,d as He,g as cn,aK as rl,f as ne,w as je,o as Mt,bE as zx,bF as Ux,b as Pa,aI as G,n as vr,p as mi,bG as Nc,r as Fn,t as Qe,bH as Tp,bI as kp,bg as da,bJ as Gx,i as ln,bp as yo,bw as ws,bx as Lc,bK as lt,bu as Fp,a as Xx,br as Yx,u as Zu,x as qx,y as Jx,z as Zx,bL as Qx,b2 as ew,s as tw,bm as rw,bC as aw,C as nw,D as iw,aH as Pt,aM as Xa,G as Ap,aN as lw,a6 as ow,aZ as sw,b8 as uw,bD as cw,O as fw,bM as dw,bc as vw,bd as hw}from"./arco.a5c2f283.js";import{u as pw}from"./loading.f6a97ff0.js";import{e as Yf,a as vu,u as qf,f as gw,h as hu,s as mw,b as pu,g as xw}from"./serial.ceb8d64a.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";/**
import{_ as vp,i as Dr,g as un,a as mr,u as et,b as Kt,c as tt,o as ht,d as vx,e as Ot,w as It,f as rr,h as Xt,j as hp,k as hx,l as pp,m as ae,n as We,p as Ge,q as px,r as gp,s as za,t as gx,v as Uf,x as Vt,y as kn,z as mx,A as xx,B as wx,C as yx,D as bx,E as Ys,F as _x,G as Sx,H as qs,I as mp,J as xp,K as Cx,L as Ex,M as wp,N as Ox,O as Ka,P as Tx,Q as Dl,R as kx,S as ua,T as Fx,U as Ax,V as Dx,W as yp,X as Dc,Y as bp,Z as Pc,$ as _p,a0 as wo,a1 as Mo,a2 as Sp,a3 as Cp,a4 as dl,a5 as Oe,a6 as Yl,a7 as Rc,a8 as Ep,a9 as Ic,aa as Px,ab as Rx,ac as Gf,ad as Ix,ae as Op,af as Nx,ag as Xf,ah as Lx,ai as Mx,aj as Bx,ak as jx,al as $x,am as Vx}from"./index.48acc18f.js";import{e as Hx,q as Kx,_ as Wx}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{h as St,c as W,d as He,g as cn,aK as rl,f as ne,w as je,o as Mt,bE as zx,bF as Ux,b as Pa,aI as G,n as vr,p as mi,bG as Nc,r as Fn,t as Qe,bH as Tp,bI as kp,bg as da,bJ as Gx,i as ln,bp as yo,bw as ws,bx as Lc,bK as lt,bu as Fp,a as Xx,br as Yx,u as Zu,x as qx,y as Jx,z as Zx,bL as Qx,b2 as ew,s as tw,bm as rw,bC as aw,C as nw,D as iw,aH as Pt,aM as Xa,G as Ap,aN as lw,a6 as ow,aZ as sw,b8 as uw,bD as cw,O as fw,bM as dw,bc as vw,bd as hw}from"./arco.a5c2f283.js";import{u as pw}from"./loading.f6a97ff0.js";import{e as Yf,a as vu,u as qf,f as gw,h as hu,s as mw,b as pu,g as xw}from"./serial.bad97c4e.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";/**
* tdesign v1.9.3
* (c) 2024 tdesign
* @license MIT

BIN
assets/index.779e7b78.js.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
import{_ as n}from"./index.5f619d1e.js";import{d as c,bB as _,aZ as r,D as u,aI as e,G as p,aH as i,C as d,aM as l}from"./arco.a5c2f283.js";import{f as m}from"./vue.f211dd49.js";import"./chart.ca3e4372.js";const f={class:"content"},x={class:"operation-row"},b=c({__name:"index",setup(k){const t=m(),o=()=>{t.push({name:"Workplace"})};return(h,v)=>{const s=_,a=r;return d(),u("div",f,[e(s,{class:"result",status:"404",subtitle:"\u627E\u4E0D\u5230\u7F51\u9875"}),p("div",x,[e(a,{key:"back",type:"primary",onClick:o},{default:i(()=>[l(" \u8FD4\u56DE ")]),_:1})])])}}});const E=n(b,[["__scopeId","data-v-8bef407f"]]);export{E as default};
import{_ as n}from"./index.661e2444.js";import{d as c,bB as _,aZ as r,D as u,aI as e,G as p,aH as i,C as d,aM as l}from"./arco.a5c2f283.js";import{f as m}from"./vue.f211dd49.js";import"./chart.ca3e4372.js";const f={class:"content"},x={class:"operation-row"},b=c({__name:"index",setup(k){const t=m(),o=()=>{t.push({name:"Workplace"})};return(h,v)=>{const s=_,a=r;return d(),u("div",f,[e(s,{class:"result",status:"404",subtitle:"\u627E\u4E0D\u5230\u7F51\u9875"}),p("div",x,[e(a,{key:"back",type:"primary",onClick:o},{default:i(()=>[l(" \u8FD4\u56DE ")]),_:1})])])}}});const E=n(b,[["__scopeId","data-v-8bef407f"]]);export{E as default};

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
assets/index.aa1c8fdb.js.gz Normal file

Binary file not shown.

View File

@ -1 +1 @@
import{d as V,r as q,bC as J,C as $,aE as Q,aH as u,aI as r,aM as d,aN as f,u as g,bw as W,bx as X,bl as Y,bD as tt,bA as ot,aZ as nt,b8 as at,bc as et,bd as rt,G as c,D as ut}from"./arco.a5c2f283.js";import{e as ct,_ as R}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{e as it,a as n,b as a}from"./serial.ceb8d64a.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const st=""+new URL("../gy.png",import.meta.url).href,B=i=>(et("data-v-63b01619"),i=i(),rt(),i),_t=B(()=>c("br",null,null,-1)),dt=B(()=>c("br",null,null,-1)),pt=B(()=>c("div",null,[c("img",{style:{"margin-bottom":"10px"},width:"600px",src:st})],-1)),mt=V({__name:"banner",setup(i){const t=ct(),h=q({eepromSize:"\u70B9\u51FB\u68C0\u6D4B\u6309\u94AE\u68C0\u6D4B"}),U=async()=>{var s,p,m,l,F,_,P,M,y,E,v,C,D,k,x,A,K,I,z,N,T;let e="\u672A\u77E5\u3001\u6545\u969C\u3001\u4E0D\u53EF\u7528";const S=[Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256)];await it(t.connectPort);const o=new Uint8Array(S);if(((s=t.configuration)==null?void 0:s.uart)=="official"){const b=await n(t.connectPort,0,8,(p=t.configuration)==null?void 0:p.uart);await a(t.connectPort,0,o,8,(m=t.configuration)==null?void 0:m.uart);const w=await n(t.connectPort,0,8,(l=t.configuration)==null?void 0:l.uart);o.toString()==w.toString()&&(e="8KB\uFF0864Kbit\uFF09"),await a(t.connectPort,0,b,8,(F=t.configuration)==null?void 0:F.uart)}else{const b=await n(t.connectPort,0,8,(_=t.configuration)==null?void 0:_.uart);await a(t.connectPort,0,o,8,(P=t.configuration)==null?void 0:P.uart);const w=await n(t.connectPort,0,8,(M=t.configuration)==null?void 0:M.uart);o.toString()==w.toString()&&(e="8KB\uFF0864Kbit\uFF09"),await a(t.connectPort,0,b,8,(y=t.configuration)==null?void 0:y.uart);const G=await n(t.connectPort,131064,8,(E=t.configuration)==null?void 0:E.uart);await a(t.connectPort,131064,o,8,(v=t.configuration)==null?void 0:v.uart);const H=await n(t.connectPort,131064,8,(C=t.configuration)==null?void 0:C.uart);o.toString()==H.toString()&&(e="128KB\uFF081Mbit\uFF09"),await a(t.connectPort,131064,G,8,(D=t.configuration)==null?void 0:D.uart);const L=await n(t.connectPort,262136,8,(k=t.configuration)==null?void 0:k.uart);await a(t.connectPort,262136,o,8,(x=t.configuration)==null?void 0:x.uart);const O=await n(t.connectPort,262136,8,(A=t.configuration)==null?void 0:A.uart);o.toString()==O.toString()&&(e="256KB\uFF082Mbit\uFF09"),await a(t.connectPort,262136,L,8,(K=t.configuration)==null?void 0:K.uart);const Z=await n(t.connectPort,524280,8,(I=t.configuration)==null?void 0:I.uart);await a(t.connectPort,524280,o,8,(z=t.configuration)==null?void 0:z.uart);const j=await n(t.connectPort,524280,8,(N=t.configuration)==null?void 0:N.uart);o.toString()==j.toString()&&(e="512KB\uFF084Mbit\uFF09"),await a(t.connectPort,524280,Z,8,(T=t.configuration)==null?void 0:T.uart)}h.eepromSize=e};return(e,S)=>{const o=Y,s=tt,p=ot,m=nt,l=J,F=at;return $(),Q(s,{class:"banner"},{default:u(()=>[r(s,null,{default:u(()=>[r(o,{heading:5,style:{"margin-top":"0"}},{default:u(()=>[d(f(g(t).connectState?"\u6B22\u8FCE\u4F60~\uFF0C\u8FDE\u63A5\u6210\u529F\uFF01":"\u6B22\u8FCE\u4F60~\uFF0C\u70B9\u51FB\u53F3\u4E0A\u89D2\u201C\u8FDE\u63A5\u201D\u6309\u94AE\u8FDE\u63A5\u624B\u53F0\u3002"),1)]),_:1})]),_:1}),r(p,{class:"panel-border"}),r(F,null,{default:u(()=>[W(r(l,{style:{marginTop:"2em",marginBottom:"2em"},title:"\u624B\u53F0\u4FE1\u606F"},{default:u(()=>{var _;return[d(" \u5F53\u524D\u56FA\u4EF6\u7248\u672C\uFF1A"+f(g(t).firmwareVersion)+" ",1),_t,d(" \u5339\u914D\u5199\u9891\u914D\u7F6E\uFF1A"+f((_=g(t).configuration)==null?void 0:_.name)+" ",1),dt,d(" \u5B58\u50A8\u5927\u5C0F\uFF1A"+f(h.eepromSize)+" ",1),r(m,{size:"mini",type:"primary",onClick:U},{default:u(()=>[d("\u68C0\u6D4B")]),_:1})]}),_:1},512),[[X,g(t).connectState]])]),_:1}),pt]),_:1})}}});const lt=R(mt,[["__scopeId","data-v-63b01619"]]),Ft={class:"container"},ft={class:"left-side"},gt={class:"panel"},ht={name:"Dashboard"},bt=V({...ht,setup(i){return(t,h)=>($(),ut("div",Ft,[c("div",ft,[c("div",gt,[r(lt)])])]))}});const xt=R(bt,[["__scopeId","data-v-8f743d99"]]);export{xt as default};
import{d as V,r as q,bC as J,C as $,aE as Q,aH as u,aI as r,aM as d,aN as f,u as g,bw as W,bx as X,bl as Y,bD as tt,bA as ot,aZ as nt,b8 as at,bc as et,bd as rt,G as c,D as ut}from"./arco.a5c2f283.js";import{e as ct,_ as R}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{e as it,a as n,b as a}from"./serial.bad97c4e.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const st=""+new URL("../gy.png",import.meta.url).href,B=i=>(et("data-v-63b01619"),i=i(),rt(),i),_t=B(()=>c("br",null,null,-1)),dt=B(()=>c("br",null,null,-1)),pt=B(()=>c("div",null,[c("img",{style:{"margin-bottom":"10px"},width:"600px",src:st})],-1)),mt=V({__name:"banner",setup(i){const t=ct(),h=q({eepromSize:"\u70B9\u51FB\u68C0\u6D4B\u6309\u94AE\u68C0\u6D4B"}),U=async()=>{var s,p,m,l,F,_,P,M,y,E,v,C,D,k,x,A,K,I,z,N,T;let e="\u672A\u77E5\u3001\u6545\u969C\u3001\u4E0D\u53EF\u7528";const S=[Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256)];await it(t.connectPort);const o=new Uint8Array(S);if(((s=t.configuration)==null?void 0:s.uart)=="official"){const b=await n(t.connectPort,0,8,(p=t.configuration)==null?void 0:p.uart);await a(t.connectPort,0,o,8,(m=t.configuration)==null?void 0:m.uart);const w=await n(t.connectPort,0,8,(l=t.configuration)==null?void 0:l.uart);o.toString()==w.toString()&&(e="8KB\uFF0864Kbit\uFF09"),await a(t.connectPort,0,b,8,(F=t.configuration)==null?void 0:F.uart)}else{const b=await n(t.connectPort,0,8,(_=t.configuration)==null?void 0:_.uart);await a(t.connectPort,0,o,8,(P=t.configuration)==null?void 0:P.uart);const w=await n(t.connectPort,0,8,(M=t.configuration)==null?void 0:M.uart);o.toString()==w.toString()&&(e="8KB\uFF0864Kbit\uFF09"),await a(t.connectPort,0,b,8,(y=t.configuration)==null?void 0:y.uart);const G=await n(t.connectPort,131064,8,(E=t.configuration)==null?void 0:E.uart);await a(t.connectPort,131064,o,8,(v=t.configuration)==null?void 0:v.uart);const H=await n(t.connectPort,131064,8,(C=t.configuration)==null?void 0:C.uart);o.toString()==H.toString()&&(e="128KB\uFF081Mbit\uFF09"),await a(t.connectPort,131064,G,8,(D=t.configuration)==null?void 0:D.uart);const L=await n(t.connectPort,262136,8,(k=t.configuration)==null?void 0:k.uart);await a(t.connectPort,262136,o,8,(x=t.configuration)==null?void 0:x.uart);const O=await n(t.connectPort,262136,8,(A=t.configuration)==null?void 0:A.uart);o.toString()==O.toString()&&(e="256KB\uFF082Mbit\uFF09"),await a(t.connectPort,262136,L,8,(K=t.configuration)==null?void 0:K.uart);const Z=await n(t.connectPort,524280,8,(I=t.configuration)==null?void 0:I.uart);await a(t.connectPort,524280,o,8,(z=t.configuration)==null?void 0:z.uart);const j=await n(t.connectPort,524280,8,(N=t.configuration)==null?void 0:N.uart);o.toString()==j.toString()&&(e="512KB\uFF084Mbit\uFF09"),await a(t.connectPort,524280,Z,8,(T=t.configuration)==null?void 0:T.uart)}h.eepromSize=e};return(e,S)=>{const o=Y,s=tt,p=ot,m=nt,l=J,F=at;return $(),Q(s,{class:"banner"},{default:u(()=>[r(s,null,{default:u(()=>[r(o,{heading:5,style:{"margin-top":"0"}},{default:u(()=>[d(f(g(t).connectState?"\u6B22\u8FCE\u4F60~\uFF0C\u8FDE\u63A5\u6210\u529F\uFF01":"\u6B22\u8FCE\u4F60~\uFF0C\u70B9\u51FB\u53F3\u4E0A\u89D2\u201C\u8FDE\u63A5\u201D\u6309\u94AE\u8FDE\u63A5\u624B\u53F0\u3002"),1)]),_:1})]),_:1}),r(p,{class:"panel-border"}),r(F,null,{default:u(()=>[W(r(l,{style:{marginTop:"2em",marginBottom:"2em"},title:"\u624B\u53F0\u4FE1\u606F"},{default:u(()=>{var _;return[d(" \u5F53\u524D\u56FA\u4EF6\u7248\u672C\uFF1A"+f(g(t).firmwareVersion)+" ",1),_t,d(" \u5339\u914D\u5199\u9891\u914D\u7F6E\uFF1A"+f((_=g(t).configuration)==null?void 0:_.name)+" ",1),dt,d(" \u5B58\u50A8\u5927\u5C0F\uFF1A"+f(h.eepromSize)+" ",1),r(m,{size:"mini",type:"primary",onClick:U},{default:u(()=>[d("\u68C0\u6D4B")]),_:1})]}),_:1},512),[[X,g(t).connectState]])]),_:1}),pt]),_:1})}}});const lt=R(mt,[["__scopeId","data-v-63b01619"]]),Ft={class:"container"},ft={class:"left-side"},gt={class:"panel"},ht={name:"Dashboard"},bt=V({...ht,setup(i){return(t,h)=>($(),ut("div",Ft,[c("div",ft,[c("div",gt,[r(lt)])])]))}});const xt=R(bt,[["__scopeId","data-v-8f743d99"]]);export{xt as default};

BIN
assets/index.b8c45ea0.js.gz Normal file

Binary file not shown.

View File

@ -1 +1 @@
import{e as g,q as E,_ as B}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as k,r as v,bC as C,C as A,D,aI as i,aH as d,G as h,aM as F,aZ as y,b8 as x,bA as R,bD as H,bM as M,n as T}from"./arco.a5c2f283.js";import{e as P,b as S,g as U}from"./serial.ceb8d64a.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const I={class:"container"},N=["innerHTML"],V={name:"Chi"},$=k({...V,setup(L){const a=g(),c=v({status:"\u70B9\u51FB\u5199\u5165\u6309\u94AE\u5199\u5165\u5B57\u5E93\u5230\u8BBE\u5907<br/><br/>",eepromType:"",showHide:0}),p=async(e=0,t)=>{var l;await P(a.connectPort);for(let n=e;n<t.length+e;n+=128)await S(a.connectPort,n,t.slice(n-e,n-e+128),128,(l=a.configuration)==null?void 0:l.uart),c.status=c.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((n-e)/t.length*100).toFixed(1)+"%<br/>",T(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)});c.status=c.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>",await U(a.connectPort)},m=async(e=1)=>{var l,n,o,b,w;if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(((l=a.configuration)==null?void 0:l.uart)=="official"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(e==1&&((n=a.configuration)==null?void 0:n.charset)!="losehu"||e==1&&((o=a.configuration)==null?void 0:o.K)!=!0){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(e==2&&((b=a.configuration)==null?void 0:b.charset)!="gb2312"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}c.status=c.status+"\u6B63\u5728\u4E0B\u8F7D\u5B57\u5E93...<br />";let t;if(e==1){t=await fetch("/old_font.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(8192,r);return}if(e==2){t=await fetch("/new_font_k.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(9344,r);return}if(e==3){t=await fetch("/new_font_h.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(9344,r);return}if(e==4){(w=a.configuration)!=null&&w.newpinyin?t=await fetch("/pinyin_plus.bin"):t=await fetch("/pinyin.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(131072,r);return}};return(e,t)=>{const l=E,n=y,o=x,b=R,w=C,s=H,u=M;return A(),D("div",I,[i(l,{items:["\u5C0F\u5DE5\u5177","\u5B57\u5E93\u5199\u5165"]}),i(u,{gutter:20,align:"stretch"},{default:d(()=>[i(s,{span:24},{default:d(()=>[i(w,{class:"general-card"},{title:d(()=>[h("span",{onClick:t[0]||(t[0]=()=>{c.showHide+=1})},"\u5B57\u5E93\u5199\u5165")]),default:d(()=>[i(o,null,{default:d(()=>[i(n,{onClick:t[1]||(t[1]=r=>m(1))},{default:d(()=>[F("\u5199\u5165 117 \u5B57\u5E93")]),_:1}),i(n,{onClick:t[2]||(t[2]=r=>m(2))},{default:d(()=>[F("\u5199\u5165 118+ \u5B57\u5E93")]),_:1}),i(n,{onClick:t[3]||(t[3]=r=>m(4))},{default:d(()=>[F("\u5199\u5165\u62FC\u97F3\u68C0\u7D22\u8868\uFF082Mbit EEPROM\u53EF\u7528\uFF09")]),_:1})]),_:1}),i(b),h("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:c.status},null,8,N)]),_:1})]),_:1})]),_:1})])}}});const W=B($,[["__scopeId","data-v-c9da2ebd"]]);export{W as default};
import{e as g,q as E,_ as B}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as k,r as v,bC as C,C as A,D,aI as i,aH as d,G as h,aM as F,aZ as y,b8 as x,bA as R,bD as H,bM as M,n as T}from"./arco.a5c2f283.js";import{e as P,b as S,g as U}from"./serial.bad97c4e.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const I={class:"container"},N=["innerHTML"],V={name:"Chi"},$=k({...V,setup(L){const a=g(),c=v({status:"\u70B9\u51FB\u5199\u5165\u6309\u94AE\u5199\u5165\u5B57\u5E93\u5230\u8BBE\u5907<br/><br/>",eepromType:"",showHide:0}),p=async(e=0,t)=>{var l;await P(a.connectPort);for(let n=e;n<t.length+e;n+=128)await S(a.connectPort,n,t.slice(n-e,n-e+128),128,(l=a.configuration)==null?void 0:l.uart),c.status=c.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((n-e)/t.length*100).toFixed(1)+"%<br/>",T(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)});c.status=c.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>",await U(a.connectPort)},m=async(e=1)=>{var l,n,o,b,w;if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(((l=a.configuration)==null?void 0:l.uart)=="official"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(e==1&&((n=a.configuration)==null?void 0:n.charset)!="losehu"||e==1&&((o=a.configuration)==null?void 0:o.K)!=!0){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(e==2&&((b=a.configuration)==null?void 0:b.charset)!="gb2312"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}c.status=c.status+"\u6B63\u5728\u4E0B\u8F7D\u5B57\u5E93...<br />";let t;if(e==1){t=await fetch("/old_font.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(8192,r);return}if(e==2){t=await fetch("/new_font_k.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(9344,r);return}if(e==3){t=await fetch("/new_font_h.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(9344,r);return}if(e==4){(w=a.configuration)!=null&&w.newpinyin?t=await fetch("/pinyin_plus.bin"):t=await fetch("/pinyin.bin");const s=t.body.getReader(),u=[];for(;;){const{done:_,value:f}=await s.read();if(_)break;u.push(...f)}const r=new Uint8Array(u);await p(131072,r);return}};return(e,t)=>{const l=E,n=y,o=x,b=R,w=C,s=H,u=M;return A(),D("div",I,[i(l,{items:["\u5C0F\u5DE5\u5177","\u5B57\u5E93\u5199\u5165"]}),i(u,{gutter:20,align:"stretch"},{default:d(()=>[i(s,{span:24},{default:d(()=>[i(w,{class:"general-card"},{title:d(()=>[h("span",{onClick:t[0]||(t[0]=()=>{c.showHide+=1})},"\u5B57\u5E93\u5199\u5165")]),default:d(()=>[i(o,null,{default:d(()=>[i(n,{onClick:t[1]||(t[1]=r=>m(1))},{default:d(()=>[F("\u5199\u5165 117 \u5B57\u5E93")]),_:1}),i(n,{onClick:t[2]||(t[2]=r=>m(2))},{default:d(()=>[F("\u5199\u5165 118+ \u5B57\u5E93")]),_:1}),i(n,{onClick:t[3]||(t[3]=r=>m(4))},{default:d(()=>[F("\u5199\u5165\u62FC\u97F3\u68C0\u7D22\u8868\uFF082Mbit EEPROM\u53EF\u7528\uFF09")]),_:1})]),_:1}),i(b),h("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:c.status},null,8,N)]),_:1})]),_:1})]),_:1})])}}});const W=B($,[["__scopeId","data-v-c9da2ebd"]]);export{W as default};

BIN
assets/index.c29a6135.js.gz Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
assets/index.c6ef1210.js.gz Normal file

Binary file not shown.

View File

@ -1 +1 @@
import{_ as t}from"./index.5f619d1e.js";import{C as a,aE as s,aH as _,be as c,bc as n,bd as r,G as d}from"./arco.a5c2f283.js";const p={},i=e=>(n("data-v-4b65ea7a"),e=e(),r(),e),b=i(()=>d("a",{href:"https://github.com/silenty4ng/k5web",target:"_blank"},"K5Web - V0.1.202404150050",-1));function f(e,l){const o=c;return a(),s(o,{class:"footer"},{default:_(()=>[b]),_:1})}const m=t(p,[["render",f],["__scopeId","data-v-4b65ea7a"]]);export{m as F};
import{_ as t}from"./index.661e2444.js";import{C as a,aE as s,aH as _,be as c,bc as n,bd as r,G as d}from"./arco.a5c2f283.js";const p={},i=e=>(n("data-v-4b65ea7a"),e=e(),r(),e),b=i(()=>d("a",{href:"https://github.com/silenty4ng/k5web",target:"_blank"},"K5Web - V0.1.202404150050",-1));function f(e,l){const o=c;return a(),s(o,{class:"footer"},{default:_(()=>[b]),_:1})}const m=t(p,[["render",f],["__scopeId","data-v-4b65ea7a"]]);export{m as F};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
import{d as x,c as q,b3 as R,C as i,D as m,G as s,aI as e,aH as n,aK as D,aJ as E,aE as j,aN as r,b4 as z,f as A,r as G,b5 as H,b6 as J,b7 as K,b8 as Q,b9 as T,u as C,aM as f,aY as W,ba as Y,bb as Z,aZ as O,bc as X,bd as ee}from"./arco.a5c2f283.js";import{F as oe}from"./index.1e378371.js";import{v as V,_ as k,u as se,I as ae,a as ne}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{f as te,g as re}from"./vue.f211dd49.js";import{u as le}from"./loading.f6a97ff0.js";import"./chart.ca3e4372.js";const S=""+new URL("login-banner.426fb77f.png",import.meta.url).href,ce={class:"banner"},ie={class:"banner-inner"},de={class:"carousel-title"},_e={class:"carousel-sub-title"},ue=["src"],me=x({__name:"banner",setup(c){const{t}=V.exports.useI18n(),g=q(()=>[{slogan:t("login.banner.slogan1"),subSlogan:t("login.banner.subSlogan1"),image:S},{slogan:t("login.banner.slogan2"),subSlogan:t("login.banner.subSlogan2"),image:S},{slogan:t("login.banner.slogan3"),subSlogan:t("login.banner.subSlogan3"),image:S}]);return(b,v)=>{const p=z,h=R;return i(),m("div",ce,[s("div",ie,[e(h,{class:"carousel","animation-name":"fade"},{default:n(()=>[(i(!0),m(D,null,E(g.value,a=>(i(),j(p,{key:a.slogan},{default:n(()=>[(i(),m("div",{key:a.slogan,class:"carousel-item"},[s("div",de,r(a.slogan),1),s("div",_e,r(a.subSlogan),1),s("img",{class:"carousel-image",src:a.image},null,8,ue)]))]),_:2},1024))),128))]),_:1})])])}}});const ge=k(me,[["__scopeId","data-v-741ef175"]]),pe={class:"login-form-wrapper"},fe={class:"login-form-title"},be={class:"login-form-sub-title"},ve={class:"login-form-error-msg"},he={class:"login-form-password-actions"},we=x({__name:"login-form",setup(c){const t=te(),{t:g}=V.exports.useI18n(),b=A(""),{loading:v,setLoading:p}=le(),h=se(),a=re("login-config",{rememberPassword:!0,username:"admin",password:"admin"}),d=G({username:a.value.username,password:a.value.password}),F=async({errors:o,values:l})=>{if(!v.value&&!o){p(!0);try{await h.login(l);const{redirect:_,...w}=t.currentRoute.value.query;t.push({name:_||"Workplace",query:{...w}}),W.success(g("login.form.login.success"));const{rememberPassword:u}=a.value,{username:y,password:$}=l;a.value.username=u?y:"",a.value.password=u?$:""}catch(_){b.value=_.message}finally{p(!1)}}},L=o=>{a.value.rememberPassword=o};return(o,l)=>{const _=ae,w=H,u=Y,y=ne,$=Z,B=J,N=K,P=O,M=Q,U=T;return i(),m("div",pe,[s("div",fe,r(o.$t("login.form.title")),1),s("div",be,r(o.$t("login.form.title")),1),s("div",ve,r(b.value),1),e(U,{ref:"loginForm",model:d,class:"login-form",layout:"vertical",onSubmit:F},{default:n(()=>[e(u,{field:"username",rules:[{required:!0,message:o.$t("login.form.userName.errMsg")}],"validate-trigger":["change","blur"],"hide-label":""},{default:n(()=>[e(w,{modelValue:d.username,"onUpdate:modelValue":l[0]||(l[0]=I=>d.username=I),placeholder:o.$t("login.form.userName.placeholder")},{prefix:n(()=>[e(_)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["rules"]),e(u,{field:"password",rules:[{required:!0,message:o.$t("login.form.password.errMsg")}],"validate-trigger":["change","blur"],"hide-label":""},{default:n(()=>[e($,{modelValue:d.password,"onUpdate:modelValue":l[1]||(l[1]=I=>d.password=I),placeholder:o.$t("login.form.password.placeholder"),"allow-clear":""},{prefix:n(()=>[e(y)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["rules"]),e(M,{size:16,direction:"vertical"},{default:n(()=>[s("div",he,[e(B,{checked:"rememberPassword","model-value":C(a).rememberPassword,onChange:L},{default:n(()=>[f(r(o.$t("login.form.rememberPassword")),1)]),_:1},8,["model-value","onChange"]),e(N,null,{default:n(()=>[f(r(o.$t("login.form.forgetPassword")),1)]),_:1})]),e(P,{type:"primary","html-type":"submit",long:"",loading:C(v)},{default:n(()=>[f(r(o.$t("login.form.login")),1)]),_:1},8,["loading"]),e(P,{type:"text",long:"",class:"login-form-register-btn"},{default:n(()=>[f(r(o.$t("login.form.register")),1)]),_:1})]),_:1})]),_:1},8,["model"])])}}});const ye=k(we,[["__scopeId","data-v-12db3177"]]),$e=c=>(X("data-v-24cebde1"),c=c(),ee(),c),Ie={class:"container"},Se=$e(()=>s("div",{class:"logo"},[s("img",{alt:"logo",src:"//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/dfdba5317c0c20ce20e64fac803d52bc.svg~tplv-49unhts6dw-image.image"}),s("div",{class:"logo-text"},"Arco Design Pro")],-1)),xe={class:"content"},ke={class:"content-inner"},Pe={class:"footer"},Ce=x({__name:"index",setup(c){return(t,g)=>(i(),m("div",Ie,[Se,e(ge),s("div",xe,[s("div",ke,[e(ye)]),s("div",Pe,[e(oe)])])]))}});const je=k(Ce,[["__scopeId","data-v-24cebde1"]]);export{je as default};
import{d as x,c as q,b3 as R,C as i,D as m,G as s,aI as e,aH as n,aK as D,aJ as E,aE as j,aN as r,b4 as z,f as A,r as G,b5 as H,b6 as J,b7 as K,b8 as Q,b9 as T,u as C,aM as f,aY as W,ba as Y,bb as Z,aZ as O,bc as X,bd as ee}from"./arco.a5c2f283.js";import{F as oe}from"./index.c7af0790.js";import{v as V,_ as k,u as se,I as ae,a as ne}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{f as te,g as re}from"./vue.f211dd49.js";import{u as le}from"./loading.f6a97ff0.js";import"./chart.ca3e4372.js";const S=""+new URL("login-banner.426fb77f.png",import.meta.url).href,ce={class:"banner"},ie={class:"banner-inner"},de={class:"carousel-title"},_e={class:"carousel-sub-title"},ue=["src"],me=x({__name:"banner",setup(c){const{t}=V.exports.useI18n(),g=q(()=>[{slogan:t("login.banner.slogan1"),subSlogan:t("login.banner.subSlogan1"),image:S},{slogan:t("login.banner.slogan2"),subSlogan:t("login.banner.subSlogan2"),image:S},{slogan:t("login.banner.slogan3"),subSlogan:t("login.banner.subSlogan3"),image:S}]);return(b,v)=>{const p=z,h=R;return i(),m("div",ce,[s("div",ie,[e(h,{class:"carousel","animation-name":"fade"},{default:n(()=>[(i(!0),m(D,null,E(g.value,a=>(i(),j(p,{key:a.slogan},{default:n(()=>[(i(),m("div",{key:a.slogan,class:"carousel-item"},[s("div",de,r(a.slogan),1),s("div",_e,r(a.subSlogan),1),s("img",{class:"carousel-image",src:a.image},null,8,ue)]))]),_:2},1024))),128))]),_:1})])])}}});const ge=k(me,[["__scopeId","data-v-741ef175"]]),pe={class:"login-form-wrapper"},fe={class:"login-form-title"},be={class:"login-form-sub-title"},ve={class:"login-form-error-msg"},he={class:"login-form-password-actions"},we=x({__name:"login-form",setup(c){const t=te(),{t:g}=V.exports.useI18n(),b=A(""),{loading:v,setLoading:p}=le(),h=se(),a=re("login-config",{rememberPassword:!0,username:"admin",password:"admin"}),d=G({username:a.value.username,password:a.value.password}),F=async({errors:o,values:l})=>{if(!v.value&&!o){p(!0);try{await h.login(l);const{redirect:_,...w}=t.currentRoute.value.query;t.push({name:_||"Workplace",query:{...w}}),W.success(g("login.form.login.success"));const{rememberPassword:u}=a.value,{username:y,password:$}=l;a.value.username=u?y:"",a.value.password=u?$:""}catch(_){b.value=_.message}finally{p(!1)}}},L=o=>{a.value.rememberPassword=o};return(o,l)=>{const _=ae,w=H,u=Y,y=ne,$=Z,B=J,N=K,P=O,M=Q,U=T;return i(),m("div",pe,[s("div",fe,r(o.$t("login.form.title")),1),s("div",be,r(o.$t("login.form.title")),1),s("div",ve,r(b.value),1),e(U,{ref:"loginForm",model:d,class:"login-form",layout:"vertical",onSubmit:F},{default:n(()=>[e(u,{field:"username",rules:[{required:!0,message:o.$t("login.form.userName.errMsg")}],"validate-trigger":["change","blur"],"hide-label":""},{default:n(()=>[e(w,{modelValue:d.username,"onUpdate:modelValue":l[0]||(l[0]=I=>d.username=I),placeholder:o.$t("login.form.userName.placeholder")},{prefix:n(()=>[e(_)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["rules"]),e(u,{field:"password",rules:[{required:!0,message:o.$t("login.form.password.errMsg")}],"validate-trigger":["change","blur"],"hide-label":""},{default:n(()=>[e($,{modelValue:d.password,"onUpdate:modelValue":l[1]||(l[1]=I=>d.password=I),placeholder:o.$t("login.form.password.placeholder"),"allow-clear":""},{prefix:n(()=>[e(y)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["rules"]),e(M,{size:16,direction:"vertical"},{default:n(()=>[s("div",he,[e(B,{checked:"rememberPassword","model-value":C(a).rememberPassword,onChange:L},{default:n(()=>[f(r(o.$t("login.form.rememberPassword")),1)]),_:1},8,["model-value","onChange"]),e(N,null,{default:n(()=>[f(r(o.$t("login.form.forgetPassword")),1)]),_:1})]),e(P,{type:"primary","html-type":"submit",long:"",loading:C(v)},{default:n(()=>[f(r(o.$t("login.form.login")),1)]),_:1},8,["loading"]),e(P,{type:"text",long:"",class:"login-form-register-btn"},{default:n(()=>[f(r(o.$t("login.form.register")),1)]),_:1})]),_:1})]),_:1},8,["model"])])}}});const ye=k(we,[["__scopeId","data-v-12db3177"]]),$e=c=>(X("data-v-24cebde1"),c=c(),ee(),c),Ie={class:"container"},Se=$e(()=>s("div",{class:"logo"},[s("img",{alt:"logo",src:"//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/dfdba5317c0c20ce20e64fac803d52bc.svg~tplv-49unhts6dw-image.image"}),s("div",{class:"logo-text"},"Arco Design Pro")],-1)),xe={class:"content"},ke={class:"content-inner"},Pe={class:"footer"},Ce=x({__name:"index",setup(c){return(t,g)=>(i(),m("div",Ie,[Se,e(ge),s("div",xe,[s("div",ke,[e(ye)]),s("div",Pe,[e(oe)])])]))}});const je=k(Ce,[["__scopeId","data-v-24cebde1"]]);export{je as default};

BIN
assets/index.eb0aa41e.js.gz Normal file

Binary file not shown.

View File

@ -1 +1 @@
import{e as A,q as P,_ as K}from"./index.5f619d1e.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as L,r as N,bP as U,bC as H,bN as M,C as v,D as O,aI as r,aH as _,aE as D,aM as x,bQ as R,aZ as T,b8 as V,bD as j,bM as q,bc as z,bd as G,G as C}from"./arco.a5c2f283.js";import{e as Q,b as Z,g as J}from"./serial.ceb8d64a.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const I=b=>(z("data-v-208cc1d9"),b=b(),G(),b),W={class:"container"},X=I(()=>C("div",{id:"canvasDiv",style:{zoom:"250%"}},null,-1)),Y=I(()=>C("br",null,null,-1)),$={name:"Backup"},tt=L({...$,setup(b){const l=A(),a=N({activeKey:1,binaryFile:void 0,loading:!1}),k=()=>{const n=document.createElement("input");n.type="file",n.onchange=async()=>{const p=new Blob([n.files[0]],{type:"application/octet-stream"}),f=URL.createObjectURL(p),t=document.createElement("canvas");t.width=128,t.height=64;const u=t.cloneNode(),c=document.getElementById("canvasDiv");c.innerHTML="",c==null||c.append(t,u);const o=new Image;o.src=f,o.onload=()=>{const d=t.getContext("2d");d==null||d.drawImage(o,0,0,128,64);const g=d==null?void 0:d.getImageData(0,0,t.width,t.height).data;function y(i,s){const e=(s*128+i)*4;return g[e]+g[e+1]+g[e+2]>128*3?0:1}const h=u.getContext("2d"),m=h.getImageData(0,0,u.width,u.height);for(let i=0;i<64;i++)for(let s=0;s<128;s++){const e=(i*128+s)*4,F=!y(s,i);m.data[e]=F*255,m.data[e+1]=F*255,m.data[e+2]=F*255,m.data[e+3]=255}h.putImageData(m,0,0);const w=new Uint8Array(1024);let S=0;for(let i=0;i<64;i+=8)for(let s=0;s<128;s++){let E=0;for(let e=0;e<8;e++)E|=y(s,i+e)<<e;w[S++]=E}a.binaryFile=w}},n.click()},B=async()=>{var f,t,u,c;if(l.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(((f=l.configuration)==null?void 0:f.uart)=="official"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==2&&((t=l.configuration)==null?void 0:t.charset)!="gb2312"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==1&&((u=l.configuration)==null?void 0:u.charset)!="losehu"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}a.loading=!0;let n=123728;a.activeKey==2&&(n=8320),await Q(l.connectPort);const p=a.binaryFile;for(let o=n;o<p.length+n;o+=128)await Z(l.connectPort,o,p.slice(o-n,o-n+128),128,(c=l.configuration)==null?void 0:c.uart);await J(l.connectPort),a.loading=!1};return(n,p)=>{const f=P,t=R,u=U,c=T,o=V,d=H,g=M,y=j,h=q;return v(),O("div",W,[r(f,{items:["\u5C0F\u5DE5\u5177","\u5F00\u673A\u56FE\u7247"]}),r(h,{gutter:20,align:"stretch"},{default:_(()=>[r(y,{span:24},{default:_(()=>[r(g,{loading:a.loading,tip:"\u5199\u5165\u4E2D...",style:{width:"100%"}},{default:_(()=>[r(d,{class:"general-card",title:"\u5F00\u673A\u56FE\u7247"},{default:_(()=>[r(u,{"active-key":a.activeKey,onChange:p[0]||(p[0]=m=>{a.activeKey=m})},{default:_(()=>[(v(),D(t,{key:1,title:"LOSEHU 117"})),(v(),D(t,{key:2,title:"LOSEHU 118+"}))]),_:1},8,["active-key"]),X,Y,r(o,null,{default:_(()=>[r(c,{onClick:k},{default:_(()=>[x("\u9009\u62E9\u56FE\u7247")]),_:1}),r(c,{type:"primary",disabled:!a.binaryFile,onClick:B},{default:_(()=>[x("\u5199\u5165")]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["loading"])]),_:1})]),_:1})])}}});const lt=K(tt,[["__scopeId","data-v-208cc1d9"]]);export{lt as default};
import{e as A,q as P,_ as K}from"./index.661e2444.js";/* empty css *//* empty css *//* empty css *//* empty css */import{d as L,r as N,bP as U,bC as H,bN as M,C as v,D as O,aI as r,aH as _,aE as D,aM as x,bQ as R,aZ as T,b8 as V,bD as j,bM as q,bc as z,bd as G,G as C}from"./arco.a5c2f283.js";import{e as Q,b as Z,g as J}from"./serial.bad97c4e.js";import"./chart.ca3e4372.js";import"./vue.f211dd49.js";const I=b=>(z("data-v-208cc1d9"),b=b(),G(),b),W={class:"container"},X=I(()=>C("div",{id:"canvasDiv",style:{zoom:"250%"}},null,-1)),Y=I(()=>C("br",null,null,-1)),$={name:"Backup"},tt=L({...$,setup(b){const l=A(),a=N({activeKey:1,binaryFile:void 0,loading:!1}),k=()=>{const n=document.createElement("input");n.type="file",n.onchange=async()=>{const p=new Blob([n.files[0]],{type:"application/octet-stream"}),f=URL.createObjectURL(p),t=document.createElement("canvas");t.width=128,t.height=64;const u=t.cloneNode(),c=document.getElementById("canvasDiv");c.innerHTML="",c==null||c.append(t,u);const o=new Image;o.src=f,o.onload=()=>{const d=t.getContext("2d");d==null||d.drawImage(o,0,0,128,64);const g=d==null?void 0:d.getImageData(0,0,t.width,t.height).data;function y(i,s){const e=(s*128+i)*4;return g[e]+g[e+1]+g[e+2]>128*3?0:1}const h=u.getContext("2d"),m=h.getImageData(0,0,u.width,u.height);for(let i=0;i<64;i++)for(let s=0;s<128;s++){const e=(i*128+s)*4,F=!y(s,i);m.data[e]=F*255,m.data[e+1]=F*255,m.data[e+2]=F*255,m.data[e+3]=255}h.putImageData(m,0,0);const w=new Uint8Array(1024);let S=0;for(let i=0;i<64;i+=8)for(let s=0;s<128;s++){let E=0;for(let e=0;e<8;e++)E|=y(s,i+e)<<e;w[S++]=E}a.binaryFile=w}},n.click()},B=async()=>{var f,t,u,c;if(l.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(((f=l.configuration)==null?void 0:f.uart)=="official"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==2&&((t=l.configuration)==null?void 0:t.charset)!="gb2312"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}if(a.activeKey==1&&((u=l.configuration)==null?void 0:u.charset)!="losehu"){alert("\u56FA\u4EF6\u7248\u672C\u4E0D\u5339\u914D");return}a.loading=!0;let n=123728;a.activeKey==2&&(n=8320),await Q(l.connectPort);const p=a.binaryFile;for(let o=n;o<p.length+n;o+=128)await Z(l.connectPort,o,p.slice(o-n,o-n+128),128,(c=l.configuration)==null?void 0:c.uart);await J(l.connectPort),a.loading=!1};return(n,p)=>{const f=P,t=R,u=U,c=T,o=V,d=H,g=M,y=j,h=q;return v(),O("div",W,[r(f,{items:["\u5C0F\u5DE5\u5177","\u5F00\u673A\u56FE\u7247"]}),r(h,{gutter:20,align:"stretch"},{default:_(()=>[r(y,{span:24},{default:_(()=>[r(g,{loading:a.loading,tip:"\u5199\u5165\u4E2D...",style:{width:"100%"}},{default:_(()=>[r(d,{class:"general-card",title:"\u5F00\u673A\u56FE\u7247"},{default:_(()=>[r(u,{"active-key":a.activeKey,onChange:p[0]||(p[0]=m=>{a.activeKey=m})},{default:_(()=>[(v(),D(t,{key:1,title:"LOSEHU 117"})),(v(),D(t,{key:2,title:"LOSEHU 118+"}))]),_:1},8,["active-key"]),X,Y,r(o,null,{default:_(()=>[r(c,{onClick:k},{default:_(()=>[x("\u9009\u62E9\u56FE\u7247")]),_:1}),r(c,{type:"primary",disabled:!a.binaryFile,onClick:B},{default:_(()=>[x("\u5199\u5165")]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["loading"])]),_:1})]),_:1})])}}});const lt=K(tt,[["__scopeId","data-v-208cc1d9"]]);export{lt as default};

BIN
assets/index.ebac9653.js.gz Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -22,7 +22,8 @@
background-color: var(--color-text-3);
}
</style>
<script type="module" crossorigin src="./assets/index.5f619d1e.js"></script>
<script src="serial.js"></script>
<script type="module" crossorigin src="./assets/index.661e2444.js"></script>
<link rel="modulepreload" crossorigin href="./assets/arco.a5c2f283.js">
<link rel="modulepreload" crossorigin href="./assets/chart.ca3e4372.js">
<link rel="modulepreload" crossorigin href="./assets/vue.f211dd49.js">

Binary file not shown.

387
serial.js Normal file
View File

@ -0,0 +1,387 @@
window.addEventListener("load", initiate, false);
//The different hardware we support + their specific data/configs
const table = {
0x0403: {"FTDI": {
0x6001: "FT232R",
0x6010: "FT2232H",
0x6011: "FT4232H",
0x6014: "FT232H",
0x6015: "FT231X", // same ID for FT230X, FT231X, FT234XD
}},
0x1a86: {"Quinheng": {
0x7523: "CH340",
0x5523: "CH341A",
}},
0x10c4: {"Silicon Labs": {
0xea60: "CP210x", // same ID for CP2101, CP2103, CP2104, CP2109
0xea70: "CP2105",
0xea71: "CP2108",
}},
0x067b: {"Prolific": {
0x2303: "PL2303"
}}
}
const config = {
"DEBUG" : true,
"DEFAULT_BAUD_RATE" : 38400,
"BAUD_RATES" : [600,1200,2400,4800,9600,14400,19200,38400,57600,115200,230400], // highest is 300 0000 limited by the BAUD_RATE_MAX_BPS
//CH34x --> https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c <-- we have used the linux driver and made into a webUSB driver
// plus --> https://github.com/felHR85/UsbSerial/tree/master/usbserial/src/main/java/com/felhr/usbserial <--
"CH340": {
"REQUEST_READ_VERSION": 0x5F,
"REQUEST_READ_REGISTRY": 0x95,
"REQUEST_WRITE_REGISTRY": 0x9A,
"REQUEST_SERIAL_INITIATION": 0xA1,
"REG_SERIAL": 0xC29C,
"REG_MODEM_CTRL": 0xA4,
"REG_MODEM_VALUE_OFF": 0xFF,
"REG_MODEM_VALUE_ON": 0xDF,
"REG_MODEM_VALUE_CALL": 0x9F,
"REG_BAUD_FACTOR": 0x1312,
"REG_BAUD_OFFSET": 0x0F2C,
"REG_BAUD_LOW": 0x2518,
"REG_CONTROL_STATUS": 0x2727,
"BAUD_RATE": {
600: {"FACTOR": 0x6481, "OFFSET": 0x76},
1200: {"FACTOR": 0xB281, "OFFSET": 0x3B},
2400: {"FACTOR": 0xD981, "OFFSET": 0x1E},
4800: {"FACTOR": 0x6482, "OFFSET": 0x0F},
9600: {"FACTOR": 0xB282, "OFFSET": 0x08},
14400: {"FACTOR": 0xd980, "OFFSET": 0xEB},
19200: {"FACTOR": 0xD982, "OFFSET": 0x07},
38400: {"FACTOR": 0x6483, "OFFSET": null},
57600: {"FACTOR": 0x9883, "OFFSET": null},
115200: {"FACTOR": 0xCC83, "OFFSET": null},
230500: {"FACTOR": 0xE683, "OFFSET": null},
}
}
}
const serial = {};
let device = {};
let port;
(function() {
'use strict';
serial.getPorts = function() {
return navigator.usb.getDevices().then(devices => {
return devices.map(device => new serial.Port(device));
});
};
serial.requestPort = function() {
let supportedHardware = [];
//This one create the filter of hardware based on the hardware table
Object.keys(table).map(vendorId => {
Object.keys(table[vendorId]).map(vendorName => {
Object.keys(table[vendorId][vendorName]).map(productId => {
supportedHardware.push({
"vendorId": vendorId,
"productId": productId
})
})
})});
//device contains the "device descriptor" (see USB standard), add as a new device to be able to control
return navigator.usb.requestDevice({ 'filters': supportedHardware }).then(
device => new serial.Port(device)
);
}
//set it to the active device..
serial.Port = function(device) {
this.device_ = device;
};
//here's the config + read loop is taking place....
serial.Port.prototype.connect = function() {
//this is the read loop on whatever port is currently used... it will repeat itself
let readLoop = () => {
this.device_.transferIn(this.endpointIn_, this.endpointInPacketSize_).then(result => {
readLoop();
if(sessionStorage.getItem('webusb')){
sessionStorage.setItem('webusb', sessionStorage.getItem('webusb') + ',' + (new Uint8Array(result.data.buffer)).toString())
}else{
sessionStorage.setItem('webusb', (new Uint8Array(result.data.buffer)).toString())
}
}, error => {
this.onReceiveError(error);
});
};
return this.device_.open()
.then(() => {
//first we get some GUI stuff populated, we use "device" for that... serial and port are used for the configuration elsewhere
device.hostName = port.device_.productName;
device.vendorName = Object.keys(table[port.device_.vendorId])[0];
device.chip = table[port.device_.vendorId][device.vendorName][port.device_.productId];
device.serialNumber = port.device_.serialNumber;
device.manufacturerName = port.device_.manufacturerName;
//1: we set an configuration (configuration descriptor in the USB standard)
if (this.device_.configuration === null) {
return this.device_.selectConfiguration(1);
}
})
.then(() => {
//2: we set what endpoints for data we will use, we use only "bulk" transfer and thus we parse their addresses
let configInterfaces = this.device_.configuration.interfaces;
configInterfaces.forEach(element => {
element.alternates.forEach(elementalt => {
if (elementalt.interfaceClass === 0xff) {
this.interfaceNumber_ = element.interfaceNumber;
elementalt.endpoints.forEach(elementendpoint => {
//This part here get the bulk in and out endpoints programmatically
if (elementendpoint.direction === "out" && elementendpoint.type === "bulk") {
this.endpointOut_ = elementendpoint.endpointNumber;
this.endpointOutPacketSize_ = elementendpoint.packetSize;
}
if (elementendpoint.direction === "in" && elementendpoint.type === "bulk") {
this.endpointIn_ = elementendpoint.endpointNumber;
this.endpointInPacketSize_ = elementendpoint.packetSize;
}
})
}
})
})
})
//3: we claim this interface and select the alternative interface
.then(() => this.device_.claimInterface(this.interfaceNumber_))
.then(() => this.device_.selectAlternateInterface(this.interfaceNumber_, 0))
//4: we configure in and out transmissions, based on detected hardware
.then(() => serial[device.chip](this))
//5: we start the loop
.then(() => {
//console.log(this);
readLoop();
})
};
//upon disconnect, what to do
serial.Port.prototype.disconnect = async function() {
await serial[device.chip](this).DISCONNECT;
};
//send data, what to do
serial.Port.prototype.send = function(data) {
return this.device_.transferOut(this.endpointOut_, data);
};
serial.controlledTransfer = async function (object, direction, type, recipient, request, value = 0, data = new DataView(new ArrayBuffer(0)), index = object.interfaceNumber_) {
direction = direction.charAt(0).toUpperCase() + direction.slice(1);
type = type.toLowerCase();
recipient = recipient.toLowerCase();
if (data.byteLength === 0 && direction === "In") {
// we set how many bits we want back for an "in"
// so set data = 0....N in the call otherwise it will default to 0
data = 0;
}
return await object.device_["controlTransfer" + direction]({
'requestType': type,
'recipient': recipient,
'request': request,
'value': value,
'index': index
}, data)
.then(res => {
if (config.DEBUG) {
//debugger; // remove comment for extra debugging tools
console.log(res);
}
if (res.status !== "ok") {
let errorRequest = `
controlTransfer` + direction + `
'requestType': ` + type + `,
'recipient': ` + recipient + `,
'request': 0x` + request.toString(16) + `,
'value': 0x` + value.toString(16) + `,
'index': 0x` + index.toString(16) + `
}`;
console.warn("error!", errorRequest, data) // add more here
}
if (res.data !== undefined && res.data.buffer !== undefined) {
return res.data.buffer;
}
return null;
});
};
// you can really use any numerical value since JS treat them the same:
// dec = 15 // dec will be set to 15
// bin = 0b1111; // bin will be set to 15
// oct = 0o17; // oct will be set to 15
// oxx = 017; // oxx will be set to 15
// hex = 0xF; // hex will be set to 15
// note: bB oO xX are all valid
serial.hexToDataView = function (number) {
if (number === 0) {
let array = new Uint8Array([0]);
return new DataView(array.buffer)
}
let hexString = number.toString(16);
// split the string into pairs of octets
let pairs = hexString.match(/[\dA-F]{2}/gi);
// convert the octets to integers
let integers = pairs.map(function(s) {
return parseInt(s, 16);
});
let array = new Uint8Array(integers);
return new DataView(array.buffer);
}
// you can give this method a string like "00 AA F2 01 23" or "0x00 0xAA 0xF2 0x01 0x23" and it will turn it into a DataView for the webUSB API transfer data
serial.hexStringArrayToDataView = function (hexString) {
// remove the leading 0x (if any)
hexString = hexString.replace(/^0x/, '');
// split the string into pairs of octets
let pairs = hexString.split(/ /);
// convert the octets to integers
let integers = pairs.map(function(s) {
return parseInt(s, 16);
});
let array = new Uint8Array(integers);
return new DataView(array.buffer);
}
serial.arrayBufferToHex = function (arrayBuffer) {
let hex = "0x0" + Array.prototype.map.call(new Uint8Array(arrayBuffer), x => ('00' + x.toString(16)).slice(-2)).join('');
return parseInt(hex);
}
// these are the hardware specific initialization procedures...
serial["CH340"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
let data = serial.hexToDataView(0); // null data
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_SERIAL_INITIATION, config.CH340.REG_SERIAL, data, 0xB2B9) // first request...
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REG_MODEM_CTRL, config.CH340.REG_MODEM_VALUE_ON);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REG_MODEM_CTRL, config.CH340.REG_MODEM_VALUE_CALL);
let r = await serial.controlledTransfer(obj,"in", "vendor", "device", config.CH340.REQUEST_READ_REGISTRY, 0x0706, 2);
r = serial.arrayBufferToHex(r);
if (r < 0) {
// we have an error
return;
}
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_CONTROL_STATUS, data);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_BAUD_FACTOR, data, 0xB282);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_BAUD_OFFSET, data, 0x0008);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_BAUD_LOW, data, 0x00C3);
r = await serial.controlledTransfer(obj,"in", "vendor", "device", config.CH340.REQUEST_READ_REGISTRY, 0x0706, 2);
r = serial.arrayBufferToHex(r);
if (r < 0) {
// we have an error
return;
}
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_CONTROL_STATUS, data);
await serial["CH340"].setBaudRate(obj, baudRate);
// now what? all the control transfers came back "ok"?
}
serial["CH340"].setBaudRate = async function (obj, baudRate) {
let data = serial.hexToDataView(0);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_BAUD_FACTOR, data, config.CH340.BAUD_RATE[baudRate].FACTOR);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_BAUD_OFFSET, data, config.CH340.BAUD_RATE[baudRate].OFFSET);
await serial.controlledTransfer(obj,"out", "vendor", "device", config.CH340.REQUEST_WRITE_REGISTRY, config.CH340.REG_CONTROL_STATUS, data);
}
serial["CH340"].DISCONNECT = async function (obj) {
await serial.controlledTransfer(obj,"in", "vendor", "device", config.CH340.REG_MODEM_CTRL, config.CH340.REG_MODEM_VALUE_OFF);
}
serial["CP210x"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["CP2105"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["CP2108"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["PL2303"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["FT2232H"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["FT4232H"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["FT232H"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
serial["FT231X"] = async function (obj, baudRate = config.DEFAULT_BAUD_RATE) {
}
})();
//GUI function "connect"
function connect() {
port.connect().then(() => {
document.getElementById('editor').value = "connected to: " + device.hostName + "\nvendor name: " + device.vendorName + "\nchip type: " + device.chip;
port.onReceive = data => {
console.log(data);
document.getElementById('output').value += new TextDecoder().decode(data);
}
port.onReceiveError = error => {
//console.error(error);
port.disconnect();
};
});
}
//GUI function "disconnect"
function disconnect() {
port.disconnect();
}
//GUI function "send"
function send(string) {
console.log("sending to serial:" + string.length);
if (string.length === 0)
return;
console.log("sending to serial: [" + string +"]\n");
let data = new TextEncoder('utf-8').encode(string);
console.log(data);
if (port) {
port.send(data);
}
}
//the init function which we have an event listener connected to
function initiate(){
serial.getPorts()
.then(ports => {
//these are devices already paired, let's try the first one...
if (ports.length > 0) {
port = ports[0];
connect();
}
});
document.querySelector("#connect").onclick = async function () {
await serial.requestPort().then(selectedPort => {
if (port === undefined || port.device_ !== selectedPort.device_) {
port = selectedPort;
connect();
} else {
// port already selected...
}
});
}
document.querySelector("#disconnect").onclick = function() {
disconnect()
}
document.querySelector("#submit").onclick = () => {
let source = document.querySelector("#editor").value;
send(source);
}
}

BIN
serial.js.gz Normal file

Binary file not shown.