1
0
Fork 0
mirror of https://github.com/silenty4ng/k5web synced 2025-04-13 14:30:33 +00:00
This commit is contained in:
Silent YANG 2024-01-25 23:32:43 +08:00
parent 0932d9e91f
commit ec83f702e5
5 changed files with 33 additions and 3 deletions
src
components/navbar
config
drivers
views/dashboard/workplace/components

View file

@ -82,6 +82,7 @@
import useUser from '@/hooks/user';
import Menu from '@/components/menu/index.vue';
import { connect, disconnect, sendPacket, readPacket } from '@/utils/serial.js';
const drivers = import.meta.glob('@/drivers/*.json', { eager: true });
const appStore = useAppStore();
const userStore = useUserStore();
@ -129,6 +130,12 @@
};
const toggleDrawerMenu = inject('toggleDrawerMenu') as () => void;
const configuration_list : any = {
"LOSEHU.*P.*" : "silenty4ng.json",
"LOSEHU.*K" : "todo.json",
"LOSEHU.*" : "todo.json"
}
const connectIt = async () => {
if(appStore.connectState == false){
const _connect = await connect();
@ -138,8 +145,23 @@
return;
}
const driversList : any = {};
Object.keys(drivers).forEach((key) => {
driversList[key.substring(key.lastIndexOf('/') + 1)] = drivers[key].default;
})
let _configuration = null;
const version = await eeprom_init(_connect);
appStore.updateSettings({ connectState: true, connectPort: _connect, firmwareVersion: version });
Object.keys(configuration_list).some(e=>{
const _re = new RegExp(e);
if(_re.test(version)){
_configuration = driversList[configuration_list[e]];
return true
}
})
appStore.updateSettings({ connectState: true, connectPort: _connect, firmwareVersion: version, configuration: _configuration });
}else{
disconnect(appStore.connectPort);
appStore.updateSettings({ connectState: false, connectPort: null, firmwareVersion: "" });

View file

@ -16,5 +16,6 @@
"serverMenu": [],
"connectState": false,
"firmwareVersion": "",
"connectPort": null
"connectPort": null,
"configuration": null
}

View file

@ -0,0 +1,3 @@
{
"name": "LoseHu PatchBD8DFN"
}

3
src/drivers/todo.json Normal file
View file

@ -0,0 +1,3 @@
{
"name": "TODO"
}

View file

@ -7,7 +7,8 @@
</a-col>
<a-divider class="panel-border" />
<a-card v-show="appStore.connectState" :style="{ width: '360px', marginTop: '2em', marginBottom: '2em' }" title="手台信息">
当前固件版本{{ appStore.firmwareVersion }}
当前固件版本{{ appStore.firmwareVersion }} <br />
匹配写频配置{{ appStore.configuration?.name }}
</a-card>
</a-col>
</template>