project restructure with Rust workspaces
This commit is contained in:
parent
3ffbe876f3
commit
09f72622bc
428 changed files with 19372 additions and 6061 deletions
61
frontend/src/functions.ts
Normal file
61
frontend/src/functions.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { invoke } from "@tauri-apps/api/core"
|
||||
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