k5web/assets/index.4427dda6.js
2024-02-05 22:30:46 +08:00

1 line
12 KiB
JavaScript

import{S as ut}from"./index.2af22349.js";import{e as lt,q as it,_ as ct}from"./index.074206ed.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as pt,r as dt,o as _t,bp as ft,bU as mt,aU as gt,bB as bt,bN as wt,bC as yt,C as w,D as S,aI as s,aH as u,u as Ft,aM as f,aN as x,aK as A,aJ as C,aE as B,G as ht,n as tt,ba as St,bX as xt,aZ as Dt,b8 as At,bD as Ct,bM as Bt}from"./arco.ad52411f.js";import{e as I,f as c,h as p,s as Et,g as Pt}from"./serial.b70f48dc.js";import{u as vt}from"./loading.c3da220e.js";import"./chart.a61d812b.js";import"./vue.e2942a0c.js";const Tt={class:"container"},Vt=["innerHTML"],It={name:"Sat"},Ut=pt({...It,setup(kt){const{loading:at,setLoading:m}=vt(!0),a=lt(),t=dt({status:"\u70B9\u51FB\u5199\u5165\u6309\u94AE\u5199\u5165\u536B\u661F\u6570\u636E\u5230\u8BBE\u5907<br/><br/>",sat:"",satData:[],lng:0,lat:0,alt:0,tx:0,rx:0,txTone:0,rxTone:0,CTCSSOption:[67,69.3,71.9,74.4,77,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100,103.5,107.2,110.9,114.8,118.8,123,127.3,131.8,136.5,141.3,146.2,151.4,156.7,159.8,162.2,165.5,167.9,171.3,173.8,177.3,179.9,183.5,186.2,189.9,192.8,196.6,199.5,203.5,206.5,210.7,218.1,225.7,229.1,233.6,241.8,250.3,254.1],pass:void 0,passOption:[],dt:"",timer:void 0});_t(()=>{t.timer=setInterval(()=>{t.dt=new Date().toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})},1e3)}),ft(()=>{try{clearInterval(t.timer)}catch{}});const et=async()=>{var e,n,i,l,_,g;if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}const r=new Date;m(!0),await I(a.connectPort),await c(a.connectPort,589824,p(parseInt(r.getFullYear().toString().substring(2,4)).toString(16)),1,(e=a.configuration)==null?void 0:e.uart),await c(a.connectPort,589825,p((r.getMonth()+1).toString(16)),1,(n=a.configuration)==null?void 0:n.uart),await c(a.connectPort,589826,p(r.getDate().toString(16)),1,(i=a.configuration)==null?void 0:i.uart),await c(a.connectPort,589827,p(r.getHours().toString(16)),1,(l=a.configuration)==null?void 0:l.uart),await c(a.connectPort,589828,p(r.getMinutes().toString(16)),1,(_=a.configuration)==null?void 0:_.uart),await c(a.connectPort,589829,p(r.getSeconds().toString(16)),1,(g=a.configuration)==null?void 0:g.uart),m(!1)},nt=async r=>{const e=t.satData.find(n=>n.name==r);e&&e.path&&(t.status+="<br/>\u536B\u661F\u53C2\u6570\uFF1A<br/>",e.path.map(n=>{t.status+=n+"<br/>"})),tt(()=>{const n=document==null?void 0:document.getElementById("statusArea");n&&(n.scrollTop=n==null?void 0:n.scrollHeight)})};(async()=>{m(!0);const e=(await(await fetch("https://celestrak.org/NORAD/elements/amateur.txt")).text()).split(/\r?\n/),n=[];let i={};for(let l=0;l<e.length;l++)Number.isNaN(parseInt(e[l].substring(0,1)))?(i.name&&i.name!=""&&(n.push(i),i={}),i.name=e[l]):(i.path||(i.path=[]),i.path.push(e[l]));t.satData=n,m(!1)})();const U=async()=>{m(!0),navigator.geolocation.getCurrentPosition(r=>{r.coords&&(t.lat=r.coords.latitude,t.lng=r.coords.longitude,r.coords.altitude&&(t.alt=r.coords.altitude))}),m(!1)};U();const ot=async(r=0,e)=>{var n;await I(a.connectPort);for(let i=r;i<e.length+r;i+=128)await c(a.connectPort,i,e.slice(i-r,i-r+128),128,(n=a.configuration)==null?void 0:n.uart),t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((i-r)/e.length*100).toFixed(1)+"%<br/>",tt(()=>{const l=document==null?void 0:document.getElementById("statusArea");l&&(l.scrollTop=l==null?void 0:l.scrollHeight)});t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>",await Pt(a.connectPort)},st=async()=>{if(!t.sat){alert("\u8BF7\u9009\u62E9\u536B\u661F\uFF01");return}m(!0);const r=await(await fetch("https://k5.vicicode.com/api/pass",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({sat:t.sat,sat_line_1:t.satData.find(n=>n.name==t.sat).path[0],sat_line_2:t.satData.find(n=>n.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt})})).json(),e=[];for(let n=0;n<r.pass_times.length;n++)try{let i;Date.parse(r.departure_times[n])-Date.parse(r.pass_times[n])>0?i=[r.pass_times[n],r.departure_times[n]]:i=[r.pass_times[n],r.departure_times[n+1]],e.push(i)}catch{}e.length>0?t.pass=e[0][0]+"|"+e[0][1]:t.pass=void 0,t.passOption=e,m(!1)},rt=async()=>{var O,N,L,M,H,j,R,z,J,Z,q,G,K,X,Y,$,Q;if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(!t.pass){alert("\u8BF7\u9009\u62E9\u8FC7\u5883\u65F6\u95F4\uFF01");return}m(!0);const r=await(await fetch("https://k5.vicicode.com/api/doppler",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({sat:t.sat,sat_line_1:t.satData.find(F=>F.name==t.sat).path[0],sat_line_2:t.satData.find(F=>F.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt,tx:t.tx,rx:t.rx,pass_time:t.pass.split("|")[0],departure_time:t.pass.split("|")[1]})})).json(),e=t.sat,n=t.pass.split("|")[0],i=n.split("-")[0].substring(2,4),l=n.split("-")[1],_=n.split("-")[2].split(" ")[0],g=n.split(" ")[1].split(":")[0],y=n.split(" ")[1].split(":")[1],h=n.split(" ")[1].split(":")[2],b=t.pass.split("|")[1],E=b.split("-")[0].substring(2,4),P=b.split("-")[1],v=b.split("-")[2].split(" ")[0],T=b.split(" ")[1].split(":")[0],V=b.split(" ")[1].split(":")[1],o=b.split(" ")[1].split(":")[2];await I(a.connectPort);let d=new Uint8Array(10);d.set(Et(e.trim()).subarray(0,9)),await c(a.connectPort,11168,d,10,(O=a.configuration)==null?void 0:O.uart),await c(a.connectPort,11178,p(parseInt(i).toString(16)).subarray(0,1),1,(N=a.configuration)==null?void 0:N.uart),await c(a.connectPort,11179,p(parseInt(l).toString(16)).subarray(0,1),1,(L=a.configuration)==null?void 0:L.uart),await c(a.connectPort,11180,p(parseInt(_).toString(16)).subarray(0,1),1,(M=a.configuration)==null?void 0:M.uart),await c(a.connectPort,11181,p(parseInt(g).toString(16)).subarray(0,1),1,(H=a.configuration)==null?void 0:H.uart),await c(a.connectPort,11182,p(parseInt(y).toString(16)).subarray(0,1),1,(j=a.configuration)==null?void 0:j.uart),await c(a.connectPort,11183,p(parseInt(h).toString(16)).subarray(0,1),1,(R=a.configuration)==null?void 0:R.uart),await c(a.connectPort,11184,p(parseInt(E).toString(16)).subarray(0,1),1,(z=a.configuration)==null?void 0:z.uart),await c(a.connectPort,11185,p(parseInt(P).toString(16)).subarray(0,1),1,(J=a.configuration)==null?void 0:J.uart),await c(a.connectPort,11186,p(parseInt(v).toString(16)).subarray(0,1),1,(Z=a.configuration)==null?void 0:Z.uart),await c(a.connectPort,11187,p(parseInt(T).toString(16)).subarray(0,1),1,(q=a.configuration)==null?void 0:q.uart),await c(a.connectPort,11188,p(parseInt(V).toString(16)).subarray(0,1),1,(G=a.configuration)==null?void 0:G.uart),await c(a.connectPort,11189,p(parseInt(o).toString(16)).subarray(0,1),1,(K=a.configuration)==null?void 0:K.uart),d=new Uint8Array(2),d.set(p(((Date.parse(b)-Date.parse(n))/1e3).toString(16)).subarray(0,2)),await c(a.connectPort,11190,d,2,(X=a.configuration)==null?void 0:X.uart),d=new Uint8Array(2),t.txTone&&t.txTone>0&&d.set(p(t.txTone.toString(16)).subarray(0,2)),await c(a.connectPort,11192,d,2,(Y=a.configuration)==null?void 0:Y.uart),d=new Uint8Array(2),t.rxTone&&t.rxTone>0&&d.set(p(t.rxTone.toString(16)).subarray(0,2)),await c(a.connectPort,11194,d,2,($=a.configuration)==null?void 0:$.uart),d=new Uint8Array(4),d.set(p(((Date.parse(n)-Date.parse("2000-01-01 00:00:00"))/1e3).toString(16)).subarray(0,4)),await c(a.connectPort,11196,d,4,(Q=a.configuration)==null?void 0:Q.uart);const k=[];r.shift_array.filter((F,D)=>D%2===0).map(F=>{const D=new Uint8Array(4),W=new Uint8Array(4);D.set(p(parseInt(((t.tx*1e6+F[0])/10).toFixed(0)).toString(16))),W.set(p(parseInt(((t.rx*1e6+F[1])/10).toFixed(0)).toString(16))),k.push(...D,...W)}),d=new Uint8Array(7680),d.set(new Uint8Array(k).subarray(0,7680)),await ot(123392,d),m(!1)};return(r,e)=>{const n=it,i=ut,l=St,_=xt,g=mt,y=gt,h=Dt,b=At,E=bt,P=wt,v=yt,T=Ct,V=Bt;return w(),S("div",Tt,[s(n,{items:["\u5C0F\u5DE5\u5177","\u536B\u661F\u5199\u5165"]}),s(V,{gutter:20,align:"stretch"},{default:u(()=>[s(T,{span:24},{default:u(()=>[s(v,{class:"general-card",title:"\u536B\u661F\u5199\u5165"},{default:u(()=>[s(P,{loading:Ft(at),style:{width:"100%"},tip:"\u6B63\u5728\u5904\u7406 ..."},{default:u(()=>[s(l,{"label-col-style":{width:"25%"},field:"dt",label:"\u6D4F\u89C8\u5668\u65F6\u95F4"},{default:u(()=>[f(x(t.dt)+"\xA0\xA0",1),s(i,{size:"small",theme:"success",onClick:et},{default:u(()=>[f("\u540C\u6B65\u65F6\u95F4\u5230\u53F0\u7AD9")]),_:1})]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"sat",label:"\u9009\u62E9\u536B\u661F"},{default:u(()=>[s(g,{modelValue:t.sat,"onUpdate:modelValue":e[0]||(e[0]=o=>t.sat=o),onChange:nt,placeholder:"\u9009\u62E9\u536B\u661F ...","allow-search":"","allow-clear":""},{default:u(()=>[(w(!0),S(A,null,C(t.satData,o=>(w(),B(_,{key:o.name,value:o.name},{default:u(()=>[f(x(o.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"lng",label:"\u53F0\u7AD9\u7ECF\u5EA6"},{default:u(()=>[s(y,{precision:6,modelValue:t.lng,"onUpdate:modelValue":e[1]||(e[1]=o=>t.lng=o)},null,8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"lat",label:"\u53F0\u7AD9\u7EAC\u5EA6"},{default:u(()=>[s(y,{precision:6,modelValue:t.lat,"onUpdate:modelValue":e[2]||(e[2]=o=>t.lat=o)},null,8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"alt",label:"\u53F0\u7AD9\u6D77\u62D4"},{default:u(()=>[s(y,{precision:0,modelValue:t.alt,"onUpdate:modelValue":e[3]||(e[3]=o=>t.alt=o)},null,8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},label:""},{default:u(()=>[s(b,null,{default:u(()=>[s(h,{onClick:U},{default:u(()=>[f("\u6D4F\u89C8\u5668\u83B7\u53D6\u7ECF\u7EAC\u5EA6")]),_:1}),s(h,{onClick:st},{default:u(()=>[f("\u83B7\u53D6\u536B\u661F\u8FC7\u5883\u65F6\u95F4")]),_:1})]),_:1})]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"pass",label:"\u9009\u62E9\u8FC7\u5883\u65F6\u95F4"},{default:u(()=>[s(g,{modelValue:t.pass,"onUpdate:modelValue":e[4]||(e[4]=o=>t.pass=o),"allow-search":"","allow-clear":""},{default:u(()=>[(w(!0),S(A,null,C(t.passOption,o=>(w(),B(_,{key:o[0]+"|"+o[1],value:o[0]+"|"+o[1]},{default:u(()=>[f(x(o[0]+" - "+o[1]),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"tx",label:"\u4E0A\u884C\u9891\u7387"},{default:u(()=>[s(y,{precision:5,modelValue:t.tx,"onUpdate:modelValue":e[5]||(e[5]=o=>t.tx=o)},null,8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"txTone",label:"\u4E0A\u884C\u4E9A\u97F3"},{default:u(()=>[s(g,{modelValue:t.txTone,"onUpdate:modelValue":e[6]||(e[6]=o=>t.txTone=o),"allow-search":"","allow-clear":""},{default:u(()=>[s(_,{value:0},{default:u(()=>[f("\u5173\u95ED")]),_:1}),(w(!0),S(A,null,C(t.CTCSSOption,o=>(w(),B(_,{key:o,value:o},{default:u(()=>[f(x(o.toFixed(1)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"rx",label:"\u4E0B\u884C\u9891\u7387"},{default:u(()=>[s(y,{precision:5,modelValue:t.rx,"onUpdate:modelValue":e[7]||(e[7]=o=>t.rx=o)},null,8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},field:"rxTone",label:"\u4E0B\u884C\u4E9A\u97F3"},{default:u(()=>[s(g,{modelValue:t.rxTone,"onUpdate:modelValue":e[8]||(e[8]=o=>t.rxTone=o),"allow-search":"","allow-clear":""},{default:u(()=>[s(_,{value:0},{default:u(()=>[f("\u5173\u95ED")]),_:1}),(w(!0),S(A,null,C(t.CTCSSOption,o=>(w(),B(_,{key:o,value:o},{default:u(()=>[f(x(o.toFixed(1)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(l,{"label-col-style":{width:"25%"},label:""},{default:u(()=>[s(h,{onClick:rt},{default:u(()=>[f("\u5199\u5165\u6570\u636E")]),_:1})]),_:1}),s(E),ht("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:t.status},null,8,Vt)]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1})])}}});const Wt=ct(Ut,[["__scopeId","data-v-df53b836"]]);export{Wt as default};