k5web/assets/index.46c3c9d4.js

2 lines
13 KiB
JavaScript
Raw Normal View History

2024-02-07 11:04:29 +00:00
import{S as mt}from"./index.c93dfeeb.js";import{e as _t,q as ft,_ as gt}from"./index.4f271108.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as wt,r as bt,o as yt,bp as Ft,bY as ht,bU as xt,aU as St,bB as Ct,bN as Dt,bC as At,C as g,D as h,aI as n,aH as r,u as Bt,aM as m,aN as x,bw as at,G as et,bx as ot,aK as C,aJ as D,aE as A,n as st,ba as Et,bX as Vt,aZ as vt,b8 as Tt,bZ as Pt,bD as It,bM as Ut}from"./arco.beabb834.js";import{e as U,g as nt,h as i,f as c,s as kt}from"./serial.b70f48dc.js";import{u as Ot}from"./loading.04079284.js";import"./chart.83b8c11b.js";import"./vue.30c84055.js";const Nt={class:"container"},Ht=["innerHTML"],Mt={name:"Sat"},Yt=wt({...Mt,setup(Lt){const{loading:ut,setLoading:f}=Ot(!0),a=_t(),t=bt({showh:0,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,passCustom:void 0,dtCustom:void 0});yt(()=>{t.timer=setInterval(()=>{t.dt=new Date().toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})},1e3)}),Ft(()=>{try{clearInterval(t.timer)}catch{}});const rt=()=>{t.showh+=1},lt=async()=>{if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}f(!0),await U(a.connectPort),await k(),await nt(a.connectPort),f(!1)},k=async()=>{var s;const l=t.dtCustom?new Date(t.dtCustom):new Date,e=[...i(parseInt(l.getFullYear().toString().substring(2,4)).toString(16)),...i((l.getMonth()+1).toString(16)),...i(l.getDate().toString(16)),...i(l.getHours().toString(16)),...i(l.getMinutes().toString(16)),...i(l.getSeconds().toString(16))];await c(a.connectPort,11200,new Uint8Array(e),6,(s=a.configuration)==null?void 0:s.uart)},it=async l=>{const e=t.satData.find(s=>s.name==l);e&&e.path&&(t.status+="<br/>\u536B\u661F\u53C2\u6570\uFF1A<br/>",e.path.map(s=>{t.status+=s+"<br/>"})),st(()=>{const s=document==null?void 0:document.getElementById("statusArea");s&&(s.scrollTop=s==null?void 0:s.scrollHeight)})};(async()=>{f(!0);const e=(await(await fetch("https://celestrak.org/NORAD/elements/amateur.txt")).text()).split(/\r?\n/),s=[];let u={};for(let d=0;d<e.length;d++)Number.isNaN(parseInt(e[d].substring(0,1)))?(u.name&&u.name!=""&&(s.push(u),u={}),u.name=e[d]):(u.path||(u.path=[]),u.path.push(e[d]));t.satData=s,f(!1)})();const O=async()=>{f(!0),navigator.geolocation.getCurrentPosition(l=>{l.coords&&(t.lat=l.coords.latitude,t.lng=l.coords.longitude,l.coords.altitude&&(t.alt=l.coords.altitude))}),f(!1)};O();const pt=async(l=0,e)=>{var s;await U(a.connectPort);for(let u=l;u<e.length+l;u+=128)await c(a.connectPort,u,e.slice(u-l,u-l+128),128,(s=a.configuration)==null?void 0:s.uart),t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((u-l)/e.length*100).toFixed(1)+"%<br/>",st(()=>{const d=document==null?void 0:document.getElementById("statusArea");d&&(d.scrollTop=d==null?void 0:d.scrollHeight)});t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>"},ct=async()=>{if(!t.sat){alert("\u8BF7\u9009\u62E9\u536B\u661F\uFF01");return}f(!0);const l=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(s=>s.name==t.sat).path[0],sat_line_2:t.satData.find(s=>s.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt})})).json(),e=[];for(let s=0;s<l.pass_times.length;s++)try{let u;Date.parse(l.departure_times[s])-Date.parse(l.pass_times[s])>0?u=[l.pass_times[s],l.departure_times[s]]:u=[l.pass_times[s],l.de