App architecture modifications.
Now GUI and the app itself is divided into two different binaries. The app also provides system tray icon. Whereas the GUI can be used to configure the app.
This commit is contained in:
parent
4f3d572b26
commit
4e860d63c3
91 changed files with 5818 additions and 0 deletions
61
gui/src/functions.ts
Normal file
61
gui/src/functions.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { invoke } from "@tauri-apps/api/tauri"
|
||||
import { is_listening, isListening } from "@/stores"
|
||||
import { clearInterval, clearTimeout, setInterval, setTimeout } from 'worker-timers';
|
||||
|
||||
setInterval(() => {
|
||||
(async () => {
|
||||
is_listening.set(await invoke("is_listening"));
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
export function startListening() {
|
||||
(async () => {
|
||||
invoke('start_listening')
|
||||
.then((message) => {
|
||||
is_listening.set(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
is_listening.set(false);
|
||||
console.error(error);
|
||||
// alert("Ошибка: " + error);
|
||||
})
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
export function stopListening(callback) {
|
||||
(async () => {
|
||||
invoke('stop_listening')
|
||||
.then((message) => {
|
||||
is_listening.set(false);
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
})
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
export function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
export function showInExplorer(path) {
|
||||
(async () => {
|
||||
invoke('show_in_folder', {path: path})
|
||||
.then((message) => {})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
// alert("Ошибка: " + error);
|
||||
})
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue