mirror of
https://github.com/lights0123/n-link.git
synced 2025-01-03 15:15:26 +00:00
Final touches
This commit is contained in:
parent
84d5e82d1a
commit
944e3a39c5
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -3,7 +3,7 @@ on:
|
|||
push:
|
||||
branches-ignore:
|
||||
- 'dependabot/**'
|
||||
- publish
|
||||
- release
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
@ -11,7 +11,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-18.04, windows-latest]
|
||||
platform: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
|
|
|
@ -9,7 +9,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-18.04, windows-latest]
|
||||
platform: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
|
@ -1,7 +1,7 @@
|
|||
// #![cfg_attr(
|
||||
// all(not(debug_assertions), target_os = "windows"),
|
||||
// windows_subsystem = "windows"
|
||||
// )]
|
||||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use std::fs::File;
|
||||
|
@ -88,22 +88,22 @@ impl Hotplug<GlobalContext> for DeviceMon {
|
|||
}
|
||||
|
||||
fn device_left(&mut self, device: rusb::Device<GlobalContext>) {
|
||||
// if let Some((dev, _)) = DEVICES
|
||||
// .write()
|
||||
// .unwrap()
|
||||
// .remove_entry(&(device.bus_number(), device.address()))
|
||||
// {
|
||||
// if let Err(msg) = tauri::event::emit(
|
||||
// &mut self.handle,
|
||||
// "removeDevice",
|
||||
// Some(DevId {
|
||||
// bus_number: dev.0,
|
||||
// address: dev.1,
|
||||
// }),
|
||||
// ) {
|
||||
// eprintln!("{}", msg);
|
||||
// };
|
||||
// }
|
||||
if let Some((dev, _)) = DEVICES
|
||||
.write()
|
||||
.unwrap()
|
||||
.remove_entry(&(device.bus_number(), device.address()))
|
||||
{
|
||||
if let Err(msg) = tauri::event::emit(
|
||||
&mut self.handle,
|
||||
"removeDevice",
|
||||
Some(DevId {
|
||||
bus_number: dev.0,
|
||||
address: dev.1,
|
||||
}),
|
||||
) {
|
||||
eprintln!("{}", msg);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,9 +119,10 @@ let queueId = 0;
|
|||
class Devices extends Vue {
|
||||
devices: Record<string, Device> = {};
|
||||
enumerating = false;
|
||||
hasEnumerated = false;
|
||||
|
||||
created() {
|
||||
this.enumerate().catch(console.error);
|
||||
this.enumerate().then(() => this.hasEnumerated = true, console.error);
|
||||
listen('addDevice', dev => {
|
||||
const payload = dev.payload as Device & DevId;
|
||||
const str = devToString(payload);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</p>
|
||||
</div>
|
||||
<div v-else-if="calculator && !calculator.info" class="flex items-center justify-center h-full">
|
||||
<div class="lds-dual-ring" />
|
||||
<div class="lds-dual-ring"/>
|
||||
</div>
|
||||
<div v-else-if="calculator && calculator.info">
|
||||
<calc-info :info="calculator.info" :dev="selectedCalculator"/>
|
||||
|
@ -39,6 +39,10 @@ import CalcInfo from '@/components/CalcInfo.vue';
|
|||
import FileBrowser from '@/components/FileBrowser.vue';
|
||||
import DeviceSelect from "@/components/DeviceSelect.vue";
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
DeviceSelect,
|
||||
|
@ -50,9 +54,17 @@ export default class Home extends Vue {
|
|||
selectedCalculator: string | null = null;
|
||||
showHidden = false;
|
||||
|
||||
@Watch('$devices.hasEnumerated')
|
||||
onEnumerated() {
|
||||
const first = Object.keys(this.$devices.devices)[0];
|
||||
if (first) this.selectedCalculator = first;
|
||||
}
|
||||
|
||||
@Watch('$devices.devices')
|
||||
onDeviceChange() {
|
||||
async onDeviceChange() {
|
||||
if (!this.selectedCalculator) {
|
||||
await sleep(1000);
|
||||
if (this.selectedCalculator) return;
|
||||
const first = Object.keys(this.$devices.devices)[0];
|
||||
if (first) this.selectedCalculator = first;
|
||||
} else if (!Object.keys(this.$devices.devices).includes(this.selectedCalculator)) {
|
||||
|
@ -67,7 +79,7 @@ export default class Home extends Vue {
|
|||
if (dev && !this.$devices.devices[dev].info && !this.$devices.devices[dev].needsDrivers) {
|
||||
try {
|
||||
await this.$devices.open(dev);
|
||||
}catch(e) {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.selectedCalculator = null;
|
||||
}
|
||||
|
@ -83,7 +95,7 @@ export default class Home extends Vue {
|
|||
}
|
||||
|
||||
installDrivers() {
|
||||
open('https://zadig.akeo.ie/');
|
||||
open('https://lights0123.com/n-link/#windows');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue