k5web/assets/index.d3b3f2da.js

2 lines
10 KiB
JavaScript
Raw Normal View History

2024-02-04 18:59:32 +00:00
import{e as rt,q as lt,_ as ut}from"./index.a77b0867.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as it,r as pt,bU as ct,aU as dt,bB as _t,bN as ft,bC as mt,C as m,D as h,aI as s,aH as r,u as gt,aK as S,aJ as A,aE as C,aM as g,aN as D,G as bt,n as Y,bX as yt,ba as wt,aZ as Ft,b8 as ht,bD as xt,bM as St}from"./arco.f883ed21.js";import{e as $,s as At,f as p,h as c,g as Ct}from"./serial.3518333f.js";import{u as Dt}from"./loading.50b9fdaf.js";import"./chart.977fd17b.js";import"./vue.170d1f1d.js";const Bt={class:"container"},Et=["innerHTML"],Vt={name:"Sat"},Tt=it({...Vt,setup(vt){const{loading:tt,setLoading:b}=Dt(!0),a=rt(),t=pt({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:[]}),at=async u=>{const e=t.satData.find(o=>o.name==u);e&&e.path&&(t.status+="<br/>\u536B\u661F\u53C2\u6570\uFF1A<br/>",e.path.map(o=>{t.status+=o+"<br/>"})),Y(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)})};(async()=>{b(!0);const e=(await(await fetch("https://celestrak.org/NORAD/elements/amateur.txt")).text()).split(/\r?\n/),o=[];let l={};for(let i=0;i<e.length;i++)Number.isNaN(parseInt(e[i].substring(0,1)))?(l.name&&l.name!=""&&(o.push(l),l={}),l.name=e[i]):(l.path||(l.path=[]),l.path.push(e[i]));t.satData=o,b(!1)})();const P=async()=>{b(!0),navigator.geolocation.getCurrentPosition(u=>{u.coords&&(t.lat=u.coords.latitude,t.lng=u.coords.longitude,u.coords.altitude&&(t.alt=u.coords.altitude))}),b(!1)};P();const et=async(u=0,e)=>{var o;await $(a.connectPort);for(let l=u;l<e.length+u;l+=128)await p(a.connectPort,l,e.slice(l-u,l-u+128),128,(o=a.configuration)==null?void 0:o.uart),t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((l-u)/e.length*100).toFixed(1)+"%<br/>",Y(()=>{const i=document==null?void 0:document.getElementById("statusArea");i&&(i.scrollTop=i==null?void 0:i.scrollHeight)});t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>",await Ct(a.connectPort)},ot=async()=>{if(!t.sat){alert("\u8BF7\u9009\u62E9\u536B\u661F\uFF01");return}b(!0);const u=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(o=>o.name==t.sat).path[0],sat_line_2:t.satData.find(o=>o.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt})})).json(),e=[];for(let o=0;o<u.pass_times.length;o++)try{let l;Date.parse(u.departure_times[o])-Date.parse(u.pass_times[o])>0?l=[u.pass_times[o],u.departure_times[o]]:l=[u.pass_times[o],u.departure_times[o+1]],e.push(l)}catch{}e.length>0?t.pass=e[0][0]+"|"+e[0][1]:t.pass=void 0,t.passOption=e,b(!1)},nt=async()=>{var U,k,O,N,L,H,j,M,R,J,q,z,G,K,X,Z,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}b(!0);const u=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(w=>w.name==t.sat).path[0],sat_line_2:t.satData.find(w=>w.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,o=t.pass.split("|")[0],l=o.split("-")[0].substring(2,4),i=o.split("-")[1],_=o.split("-")[2].split(" ")[0],y=o.split(" ")[1].split(":")[0],F=o.split(" ")[1].split(":")[1],B=o.sp