Add my satellite

This commit is contained in:
Silent YANG 2024-11-15 23:08:32 +08:00
parent 77b5f7eb88
commit bc10274ba6
3 changed files with 59 additions and 7 deletions

View file

@ -180,6 +180,8 @@ export default {
'bl.onlyEnglish': 'Firmware names are supported in English only',
'bl.drag': 'Select the firmware and drag the firmware card to the EEPROM grid',
'bl.bootloader': 'Bootloader Use',
'sat.selfSatInfo': 'My satellite parameters',
'sat.addSelfSat': 'Add my satellite',
...localeSettings,
...localeMessageBox,
...localeLogin,

View file

@ -180,6 +180,8 @@ export default {
'bl.onlyEnglish': '固件名称仅支持英文',
'bl.drag': '选择固件后将固件卡片拖拽到上方 EEPROM',
'bl.bootloader': '引导程序占用区',
'sat.selfSatInfo': '我的卫星参数',
'sat.addSelfSat': '添加我的卫星',
...localeSettings,
...localeMessageBox,
...localeLogin,

View file

@ -1,5 +1,15 @@
<template>
<div class="container">
<a-modal width="650px" v-model:visible="state.selfSatModal" @ok="addSelfSat">
<template #title>
{{ $t("sat.selfSatInfo") }}
</template>
<div>
<a-textarea v-model="state.selfSatInfo" style="height: 120px;"placeholder="ISS (ZARYA)
1 25544U 98067A 24320.36274227 .00015569 00000+0 28188-3 0 9999
2 25544 51.6413 286.4173 0007936 217.3657 298.3197 15.49809951481990"/>
</div>
</a-modal>
<a-modal v-model:visible="state.visible" @ok="handleOk" :ok-text="$t('tool.scaned')">
<template #title>
{{ $t('tool.scanqr') }}
@ -30,9 +40,12 @@
</div>
</a-form-item>
<a-form-item :label-col-style="{ width: '25%' }" field="sat" :label="$t('tool.selectSatellite')">
<a-select v-model="state.sat" @change="changeSat" :placeholder="$t('tool.selectSatellite') + '...'" allow-search allow-clear>
<a-option v-for="item in state.satData" :key="item.name" :value="item.name">{{ item.name }}</a-option>
</a-select>
<div style="width: 100%;">
<a-select v-model="state.sat" @change="changeSat" :placeholder="$t('tool.selectSatellite') + '...'" allow-search allow-clear>
<a-option v-for="item in state.satData" :key="item.name" :value="item.name">{{ item.name }}</a-option>
</a-select>
<a-link @click="()=>{state.selfSatModal = true}" style="margin-top: 10px;">{{ $t("sat.addSelfSat") }}</a-link>
</div>
</a-form-item>
<a-form-item :label-col-style="{ width: '25%' }" field="lng" :label="$t('tool.longitude')">
<a-input-number ref="lngRef" :precision="6" v-model="state.lng" />
@ -135,6 +148,8 @@ const state: {
dtCustom: any,
freqDb: any,
visible: boolean,
selfSatModal: boolean,
selfSatInfo: string,
} = reactive({
uuid: '',
qrcode: '',
@ -163,13 +178,20 @@ const state: {
timer: undefined,
passCustom: undefined,
dtCustom: undefined,
freqDb: []
freqDb: [],
selfSatModal: false,
selfSatInfo: '',
})
onMounted(async ()=>{
try{
const rst = await (await fetch('https://github.jobcher.com/gh/https://raw.githubusercontent.com/palewire/ham-satellite-database/main/data/amsat-active-frequencies.json')).text()
state.freqDb = JSON.parse(rst)
if(sessionStorage.getItem('satFrequenciesRst')){
state.freqDb = JSON.parse(sessionStorage.getItem('satFrequenciesRst') || "[]")
}else{
const rst = await (await fetch('https://github.jobcher.com/gh/https://raw.githubusercontent.com/palewire/ham-satellite-database/main/data/amsat-active-frequencies.json')).text()
state.freqDb = JSON.parse(rst)
sessionStorage.setItem("satFrequenciesRst", rst)
}
}
catch{}
@ -254,7 +276,13 @@ const changeSat = async (sat: any) => {
const initSat = async () => {
setLoading(true)
const rst = await (await fetch('https://celestrak.org/NORAD/elements/amateur.txt')).text()
let rst = ''
if(sessionStorage.getItem('satRst')){
rst = sessionStorage.getItem('satRst') || ""
}else{
rst = await (await fetch('https://celestrak.org/NORAD/elements/amateur.txt')).text()
sessionStorage.setItem('satRst', rst)
}
const lines = rst.split(/\r?\n/);
const sat = [];
let _sat: any = {};
@ -471,6 +499,26 @@ const writeIt = async () => {
await eeprom_reboot(appStore.connectPort);
setLoading(false)
}
const addSelfSat = () => {
const lines = (state.selfSatInfo + "\n").split(/\r?\n/);
const sat = [];
let _sat: any = {};
for (let i = 0; i < lines.length; i++) {
if (Number.isNaN(parseInt(lines[i].substring(0, 1)))) {
if (_sat.name && _sat.name != '') {
sat.push(_sat)
_sat = {}
}
_sat.name = lines[i]
} else {
if (!_sat.path) { _sat.path = [] }
_sat.path.push(lines[i])
}
}
state.satData = sat.concat(state.satData)
state.selfSatInfo = ''
}
</script>
<script lang="ts">