mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 13:14:04 +02:00
refactor: cleaning and formatting
This commit is contained in:
parent
e674e0a0ec
commit
00749a9d3a
12 changed files with 479 additions and 120 deletions
|
@ -14,7 +14,10 @@
|
|||
<p>Save</p>
|
||||
<div>
|
||||
<img alt="" src="../public/cmd.svg" v-if="os === 'macos'" />
|
||||
<img alt="" src="../public/ctrl.svg" v-if="os === 'linux' || os === 'windows'" />
|
||||
<img
|
||||
alt=""
|
||||
src="../public/ctrl.svg"
|
||||
v-if="os === 'linux' || os === 'windows'" />
|
||||
<img alt="" src="../public/enter.svg" />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -28,16 +31,14 @@
|
|||
@keydown="onKeyDown"
|
||||
class="keybind-input"
|
||||
ref="keybindInput"
|
||||
tabindex="0"
|
||||
>
|
||||
tabindex="0">
|
||||
<span class="key" v-if="keybind.length === 0">Click here</span>
|
||||
<template v-else>
|
||||
<span
|
||||
:key="index"
|
||||
class="key"
|
||||
:class="{ modifier: isModifier(key) }"
|
||||
v-for="(key, index) in keybind"
|
||||
>
|
||||
v-for="(key, index) in keybind">
|
||||
{{ keyToDisplay(key) }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -47,46 +48,54 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||
import { platform } from '@tauri-apps/plugin-os';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { onMounted, onUnmounted, reactive, ref } from "vue";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const activeModifiers = reactive<Set<string>>(new Set());
|
||||
const isKeybindInputFocused = ref(false);
|
||||
const keybind = ref<string[]>([]);
|
||||
const keybindInput = ref<HTMLElement | null>(null);
|
||||
const lastBlurTime = ref(0);
|
||||
const os = ref('');
|
||||
const os = ref("");
|
||||
const router = useRouter();
|
||||
const keyboard = useKeyboard();
|
||||
|
||||
const keyToDisplayMap: Record<string, string> = {
|
||||
' ': 'Space',
|
||||
Alt: 'Alt',
|
||||
AltLeft: 'Alt L',
|
||||
AltRight: 'Alt R',
|
||||
ArrowDown: '↓',
|
||||
ArrowLeft: '←',
|
||||
ArrowRight: '→',
|
||||
ArrowUp: '↑',
|
||||
Control: 'Ctrl',
|
||||
ControlLeft: 'Ctrl L',
|
||||
ControlRight: 'Ctrl R',
|
||||
Enter: '↵',
|
||||
Meta: 'Meta',
|
||||
MetaLeft: 'Meta L',
|
||||
MetaRight: 'Meta R',
|
||||
Shift: '⇧',
|
||||
ShiftLeft: '⇧ L',
|
||||
ShiftRight: '⇧ R',
|
||||
" ": "Space",
|
||||
Alt: "Alt",
|
||||
AltLeft: "Alt L",
|
||||
AltRight: "Alt R",
|
||||
ArrowDown: "↓",
|
||||
ArrowLeft: "←",
|
||||
ArrowRight: "→",
|
||||
ArrowUp: "↑",
|
||||
Control: "Ctrl",
|
||||
ControlLeft: "Ctrl L",
|
||||
ControlRight: "Ctrl R",
|
||||
Enter: "↵",
|
||||
Meta: "Meta",
|
||||
MetaLeft: "Meta L",
|
||||
MetaRight: "Meta R",
|
||||
Shift: "⇧",
|
||||
ShiftLeft: "⇧ L",
|
||||
ShiftRight: "⇧ R",
|
||||
};
|
||||
|
||||
const modifierKeySet = new Set([
|
||||
'Alt', 'AltLeft', 'AltRight',
|
||||
'Control', 'ControlLeft', 'ControlRight',
|
||||
'Meta', 'MetaLeft', 'MetaRight',
|
||||
'Shift', 'ShiftLeft', 'ShiftRight'
|
||||
"Alt",
|
||||
"AltLeft",
|
||||
"AltRight",
|
||||
"Control",
|
||||
"ControlLeft",
|
||||
"ControlRight",
|
||||
"Meta",
|
||||
"MetaLeft",
|
||||
"MetaRight",
|
||||
"Shift",
|
||||
"ShiftLeft",
|
||||
"ShiftRight",
|
||||
]);
|
||||
|
||||
const isModifier = (key: string): boolean => {
|
||||
|
@ -99,7 +108,7 @@ const keyToDisplay = (key: string): string => {
|
|||
|
||||
const updateKeybind = () => {
|
||||
const modifiers = Array.from(activeModifiers).sort();
|
||||
const nonModifiers = keybind.value.filter(key => !isModifier(key));
|
||||
const nonModifiers = keybind.value.filter((key) => !isModifier(key));
|
||||
keybind.value = [...modifiers, ...nonModifiers];
|
||||
};
|
||||
|
||||
|
@ -118,7 +127,7 @@ const onKeyDown = (event: KeyboardEvent) => {
|
|||
event.preventDefault();
|
||||
const key = event.code;
|
||||
|
||||
if (key === 'Escape') {
|
||||
if (key === "Escape") {
|
||||
if (keybindInput.value) {
|
||||
keybindInput.value.blur();
|
||||
}
|
||||
|
@ -128,7 +137,7 @@ const onKeyDown = (event: KeyboardEvent) => {
|
|||
if (isModifier(key)) {
|
||||
activeModifiers.add(key);
|
||||
} else if (!keybind.value.includes(key)) {
|
||||
keybind.value = keybind.value.filter(k => isModifier(k));
|
||||
keybind.value = keybind.value.filter((k) => isModifier(k));
|
||||
keybind.value.push(key);
|
||||
}
|
||||
|
||||
|
@ -136,40 +145,45 @@ const onKeyDown = (event: KeyboardEvent) => {
|
|||
};
|
||||
|
||||
const saveKeybind = async () => {
|
||||
console.log('New:', keybind.value);
|
||||
const oldKeybind = await invoke<string[]>('get_keybind');
|
||||
console.log('Old:', oldKeybind);
|
||||
await invoke('save_keybind', { keybind: keybind.value });
|
||||
console.log("New:", keybind.value);
|
||||
const oldKeybind = await invoke<string[]>("get_keybind");
|
||||
console.log("Old:", oldKeybind);
|
||||
await invoke("save_keybind", { keybind: keybind.value });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
os.value = platform();
|
||||
|
||||
keyboard.down('all', (event) => {
|
||||
const isMacSaveCombo = os.value === 'macos' &&
|
||||
(event.code === 'MetaLeft' || event.code === 'MetaRight') &&
|
||||
event.key === 'Enter';
|
||||
keyboard.down("all", (event) => {
|
||||
const isMacSaveCombo =
|
||||
os.value === "macos" &&
|
||||
(event.code === "MetaLeft" || event.code === "MetaRight") &&
|
||||
event.key === "Enter";
|
||||
|
||||
const isOtherOsSaveCombo = os.value !== 'macos' &&
|
||||
(event.code === 'ControlLeft' || event.code === 'ControlRight') &&
|
||||
event.key === 'Enter';
|
||||
const isOtherOsSaveCombo =
|
||||
os.value !== "macos" &&
|
||||
(event.code === "ControlLeft" || event.code === "ControlRight") &&
|
||||
event.key === "Enter";
|
||||
|
||||
if ((isMacSaveCombo || isOtherOsSaveCombo) && !isKeybindInputFocused.value) {
|
||||
if (
|
||||
(isMacSaveCombo || isOtherOsSaveCombo) &&
|
||||
!isKeybindInputFocused.value
|
||||
) {
|
||||
event.preventDefault();
|
||||
saveKeybind();
|
||||
}
|
||||
});
|
||||
|
||||
keyboard.down('Escape', (event) => {
|
||||
keyboard.down("Escape", (event) => {
|
||||
const now = Date.now();
|
||||
if (!isKeybindInputFocused.value && now - lastBlurTime.value > 100) {
|
||||
event.preventDefault();
|
||||
router.push('/');
|
||||
router.push("/");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '~/assets/css/settings.scss';
|
||||
@use "~/assets/css/settings.scss";
|
||||
</style>
|
|
@ -27,8 +27,12 @@ export default defineNuxtPlugin(() => {
|
|||
});
|
||||
},
|
||||
|
||||
async getImagePath(path: string): Promise<string> {
|
||||
return await invoke<string>("get_image_path", { path });
|
||||
async deleteHistoryItem(id: string): Promise<void> {
|
||||
await invoke<void>("delete_history_item", { id });
|
||||
},
|
||||
|
||||
async clearHistory(): Promise<void> {
|
||||
await invoke<void>("clear_history");
|
||||
},
|
||||
|
||||
async writeAndPaste(data: {
|
||||
|
|
360
src-tauri/Cargo.lock
generated
360
src-tauri/Cargo.lock
generated
|
@ -94,6 +94,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.86"
|
||||
|
@ -110,6 +119,31 @@ dependencies = [
|
|||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "applications"
|
||||
version = "0.2.3"
|
||||
source = "git+https://github.com/HuakunShen/applications-rs?branch=dev#ac41b051f0ebeac96213c6c32621b098634219ac"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cocoa 0.25.0",
|
||||
"core-foundation 0.9.4",
|
||||
"glob",
|
||||
"image",
|
||||
"ini",
|
||||
"lnk",
|
||||
"objc",
|
||||
"parselnk",
|
||||
"plist",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"tauri-icns",
|
||||
"thiserror 1.0.63",
|
||||
"walkdir",
|
||||
"winreg 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.3.2"
|
||||
|
@ -315,6 +349,17 @@ version = "1.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto-launch"
|
||||
version = "0.5.0"
|
||||
|
@ -496,6 +541,16 @@ dependencies = [
|
|||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "built"
|
||||
version = "0.7.4"
|
||||
|
@ -675,6 +730,15 @@ dependencies = [
|
|||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "circular-queue"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d34327ead1c743a10db339de35fb58957564b99d248a67985c55638b22c59b5"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.8.1"
|
||||
|
@ -686,6 +750,21 @@ dependencies = [
|
|||
"libloading 0.8.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags 1.3.2",
|
||||
"strsim 0.8.0",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-rs"
|
||||
version = "0.2.1"
|
||||
|
@ -725,6 +804,22 @@ dependencies = [
|
|||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"cocoa-foundation 0.1.2",
|
||||
"core-foundation 0.9.4",
|
||||
"core-graphics 0.23.2",
|
||||
"foreign-types 0.5.0",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.26.0"
|
||||
|
@ -733,7 +828,7 @@ checksum = "f79398230a6e2c08f5c9760610eb6924b52aa9e7950a619602baba59dcbbdbb2"
|
|||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"block",
|
||||
"cocoa-foundation",
|
||||
"cocoa-foundation 0.2.0",
|
||||
"core-foundation 0.10.0",
|
||||
"core-graphics 0.24.0",
|
||||
"foreign-types 0.5.0",
|
||||
|
@ -741,6 +836,20 @@ dependencies = [
|
|||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"core-foundation 0.9.4",
|
||||
"core-graphics-types 0.1.3",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.2.0"
|
||||
|
@ -780,6 +889,12 @@ dependencies = [
|
|||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "configparser"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe1d7dcda7d1da79e444bdfba1465f2f849a58b07774e1df473ee77030cb47a7"
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.9.6"
|
||||
|
@ -1065,7 +1180,7 @@ dependencies = [
|
|||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"strsim 0.11.1",
|
||||
"syn 2.0.87",
|
||||
]
|
||||
|
||||
|
@ -1931,6 +2046,19 @@ dependencies = [
|
|||
"x11-dl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"bstr",
|
||||
"log",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.18.0"
|
||||
|
@ -2060,6 +2188,15 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
|
@ -2233,6 +2370,25 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyperpolyglot"
|
||||
version = "0.1.7"
|
||||
source = "git+https://github.com/0pandadev/hyperpolyglot#f4f463d7430d870568584ffd55c901f4576a6bae"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"ignore",
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
"pcre2",
|
||||
"phf 0.11.2",
|
||||
"phf_codegen 0.11.2",
|
||||
"polyglot_tokenizer",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
|
@ -2411,6 +2567,22 @@ dependencies = [
|
|||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"globset",
|
||||
"log",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"same-file",
|
||||
"walkdir",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.5"
|
||||
|
@ -2500,6 +2672,15 @@ dependencies = [
|
|||
"cfb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ini"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a9271a5dfd4228fa56a78d7508a35c321639cc71f783bb7a5723552add87bce"
|
||||
dependencies = [
|
||||
"configparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.13"
|
||||
|
@ -2781,6 +2962,12 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
|
@ -2793,6 +2980,20 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
|
||||
|
||||
[[package]]
|
||||
name = "lnk"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e066ce29d4da51727b57c404c1270e3fa2a5ded0db1a4cb67c61f7a132421b2c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"log",
|
||||
"num-derive 0.3.3",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
|
@ -3068,6 +3269,17 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.2"
|
||||
|
@ -3120,6 +3332,16 @@ dependencies = [
|
|||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.9",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.3"
|
||||
|
@ -3509,12 +3731,47 @@ dependencies = [
|
|||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parselnk"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0088616e6efe53ab79907b9313f4743eb3f8a16eb1e0014af810164808906dc3"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"thiserror 1.0.63",
|
||||
"widestring",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pcre2"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be55c43ac18044541d58d897e8f4c55157218428953ebd39d86df3ba0286b2b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"pcre2-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pcre2-sys"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "550f5d18fb1b90c20b87e161852c10cde77858c3900c5059b5ad2a1449f11d8a"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
|
@ -3586,6 +3843,16 @@ dependencies = [
|
|||
"phf_shared 0.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
|
||||
dependencies = [
|
||||
"phf_generator 0.11.2",
|
||||
"phf_shared 0.11.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.8.0"
|
||||
|
@ -3781,6 +4048,14 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polyglot_tokenizer"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/0pandadev/hyperpolyglot#f4f463d7430d870568584ffd55c901f4576a6bae"
|
||||
dependencies = [
|
||||
"circular-queue",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
|
@ -3904,9 +4179,11 @@ name = "qopy"
|
|||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"active-win-pos-rs",
|
||||
"applications",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"global-hotkey",
|
||||
"hyperpolyglot",
|
||||
"image",
|
||||
"include_dir",
|
||||
"lazy_static",
|
||||
|
@ -4127,7 +4404,7 @@ dependencies = [
|
|||
"maybe-rayon",
|
||||
"new_debug_unreachable",
|
||||
"noop_proc_macro",
|
||||
"num-derive",
|
||||
"num-derive 0.4.2",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"paste",
|
||||
|
@ -4689,6 +4966,18 @@ dependencies = [
|
|||
"syn 2.0.87",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
|
||||
dependencies = [
|
||||
"indexmap 1.9.3",
|
||||
"ryu",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serialize-to-javascript"
|
||||
version = "0.1.1"
|
||||
|
@ -5147,6 +5436,12 @@ dependencies = [
|
|||
"unicode-properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
|
@ -5444,6 +5739,16 @@ dependencies = [
|
|||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-icns"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03b7eb4d0d43724ba9ba6a6717420ee68aee377816a3edbb45db8c18862b1431"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"png",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-macros"
|
||||
version = "2.0.3"
|
||||
|
@ -5580,9 +5885,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-plugin-prevent-default"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d16274f883d2810fa8357124361656074599f5f9b52c8dff381ad82491b8a43"
|
||||
checksum = "ce34a821424cdb5c74b390ddc8f08774d836030c07ab8dd35bd180690ef1331e"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"itertools 0.13.0",
|
||||
|
@ -5758,6 +6063,24 @@ dependencies = [
|
|||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thin-slice"
|
||||
version = "0.1.1"
|
||||
|
@ -6188,6 +6511,12 @@ version = "1.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode_categories"
|
||||
version = "0.1.1"
|
||||
|
@ -6269,6 +6598,12 @@ version = "0.2.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.0"
|
||||
|
@ -6604,6 +6939,12 @@ dependencies = [
|
|||
"wasite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
@ -7127,6 +7468,15 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
|
||||
dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.7.4"
|
||||
|
|
|
@ -3,9 +3,9 @@ use global_hotkey::{
|
|||
hotkey::{Code, HotKey, Modifiers},
|
||||
GlobalHotKeyEvent, GlobalHotKeyManager, HotKeyState,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
use std::cell::RefCell;
|
||||
use tauri::{AppHandle, Manager, Listener};
|
||||
use std::str::FromStr;
|
||||
use tauri::{AppHandle, Listener, Manager};
|
||||
|
||||
thread_local! {
|
||||
static HOTKEY_MANAGER: RefCell<Option<GlobalHotKeyManager>> = RefCell::new(None);
|
||||
|
@ -18,7 +18,8 @@ pub fn setup(app_handle: tauri::AppHandle) {
|
|||
HOTKEY_MANAGER.with(|m| *m.borrow_mut() = Some(manager));
|
||||
|
||||
let rt = app_handle.state::<tokio::runtime::Runtime>();
|
||||
let initial_keybind = rt.block_on(crate::db::settings::get_keybind(app_handle_clone.clone()))
|
||||
let initial_keybind = rt
|
||||
.block_on(crate::db::settings::get_keybind(app_handle_clone.clone()))
|
||||
.expect("Failed to get initial keybind");
|
||||
let initial_shortcut = initial_keybind.join("+");
|
||||
|
||||
|
@ -111,13 +112,16 @@ fn parse_hotkey(shortcut: &str) -> Result<HotKey, Box<dyn std::error::Error>> {
|
|||
key.to_string()
|
||||
};
|
||||
|
||||
code = Some(Code::from_str(&key_code)
|
||||
.map_err(|_| format!("Invalid key code: {}", key_code))?);
|
||||
code = Some(
|
||||
Code::from_str(&key_code)
|
||||
.map_err(|_| format!("Invalid key code: {}", key_code))?,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let key_code = code.ok_or_else(|| format!("No valid key code found in shortcut: {}", shortcut))?;
|
||||
let key_code =
|
||||
code.ok_or_else(|| format!("No valid key code found in shortcut: {}", shortcut))?;
|
||||
Ok(HotKey::new(Some(modifiers), key_code))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod updater;
|
||||
pub mod clipboard;
|
||||
pub mod tray;
|
||||
pub mod hotkeys;
|
||||
pub mod tray;
|
||||
pub mod updater;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use tauri::{
|
||||
menu::{MenuBuilder, MenuItemBuilder}, tray::TrayIconBuilder, Emitter, Manager
|
||||
menu::{MenuBuilder, MenuItemBuilder},
|
||||
tray::TrayIconBuilder,
|
||||
Emitter, Manager,
|
||||
};
|
||||
|
||||
pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use tauri::{AppHandle, async_runtime};
|
||||
use tauri_plugin_dialog::{DialogExt, MessageDialogKind, MessageDialogButtons};
|
||||
use tauri::{async_runtime, AppHandle};
|
||||
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
|
||||
use tauri_plugin_updater::UpdaterExt;
|
||||
|
||||
pub async fn check_for_updates(app: AppHandle) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use include_dir::{include_dir, Dir};
|
||||
use sqlx::sqlite::{SqlitePool, SqlitePoolOptions};
|
||||
use std::fs;
|
||||
use tauri::Manager;
|
||||
use tokio::runtime::Runtime as TokioRuntime;
|
||||
use include_dir::{include_dir, Dir};
|
||||
|
||||
static MIGRATIONS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/src/db/migrations");
|
||||
|
||||
|
@ -49,39 +49,32 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
|
||||
async fn apply_migrations(pool: &SqlitePool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Starting migration process");
|
||||
|
||||
// Create schema_version table
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS schema_version (
|
||||
version INTEGER PRIMARY KEY,
|
||||
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);"
|
||||
);",
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
let current_version: Option<i64> = sqlx::query_scalar(
|
||||
"SELECT MAX(version) FROM schema_version"
|
||||
)
|
||||
let current_version: Option<i64> =
|
||||
sqlx::query_scalar("SELECT MAX(version) FROM schema_version")
|
||||
.fetch_one(pool)
|
||||
.await?;
|
||||
|
||||
let current_version = current_version.unwrap_or(0);
|
||||
println!("Current database version: {}", current_version);
|
||||
|
||||
let mut migration_files: Vec<(i64, &str)> = MIGRATIONS_DIR
|
||||
.files()
|
||||
.filter_map(|file| {
|
||||
let file_name = file.path().file_name()?.to_str()?;
|
||||
println!("Processing file: {}", file_name);
|
||||
if file_name.ends_with(".sql") && file_name.starts_with("migration") {
|
||||
let version: i64 = file_name
|
||||
.trim_start_matches("migration")
|
||||
.trim_end_matches(".sql")
|
||||
.parse()
|
||||
.ok()?;
|
||||
println!("Found migration version: {}", version);
|
||||
Some((version, file.contents_utf8()?))
|
||||
} else {
|
||||
None
|
||||
|
@ -93,8 +86,6 @@ async fn apply_migrations(pool: &SqlitePool) -> Result<(), Box<dyn std::error::E
|
|||
|
||||
for (version, content) in migration_files {
|
||||
if version > current_version {
|
||||
println!("Applying migration {}", version);
|
||||
|
||||
let statements: Vec<&str> = content
|
||||
.split(';')
|
||||
.map(|s| s.trim())
|
||||
|
@ -102,7 +93,6 @@ async fn apply_migrations(pool: &SqlitePool) -> Result<(), Box<dyn std::error::E
|
|||
.collect();
|
||||
|
||||
for statement in statements {
|
||||
println!("Executing statement: {}", statement);
|
||||
sqlx::query(statement)
|
||||
.execute(pool)
|
||||
.await
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::SqlitePool;
|
||||
use serde_json;
|
||||
use tauri::{Emitter, Manager};
|
||||
use sqlx::Row;
|
||||
use sqlx::SqlitePool;
|
||||
use tauri::{Emitter, Manager};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
struct KeybindSetting {
|
||||
|
@ -15,9 +15,7 @@ pub async fn initialize_settings(pool: &SqlitePool) -> Result<(), Box<dyn std::e
|
|||
};
|
||||
let json = serde_json::to_string(&default_keybind)?;
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO settings (key, value) VALUES ('keybind', ?)"
|
||||
)
|
||||
sqlx::query("INSERT INTO settings (key, value) VALUES ('keybind', ?)")
|
||||
.bind(json)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
@ -50,7 +48,7 @@ pub async fn save_keybind(
|
|||
#[tauri::command]
|
||||
pub async fn get_setting(
|
||||
pool: tauri::State<'_, SqlitePool>,
|
||||
key: String
|
||||
key: String,
|
||||
) -> Result<String, String> {
|
||||
let row = sqlx::query("SELECT value FROM settings WHERE key = ?")
|
||||
.bind(key)
|
||||
|
@ -65,7 +63,7 @@ pub async fn get_setting(
|
|||
pub async fn save_setting(
|
||||
pool: tauri::State<'_, SqlitePool>,
|
||||
key: String,
|
||||
value: String
|
||||
value: String,
|
||||
) -> Result<(), String> {
|
||||
sqlx::query("INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)")
|
||||
.bind(key)
|
||||
|
@ -78,9 +76,7 @@ pub async fn save_setting(
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_keybind(
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<Vec<String>, String> {
|
||||
pub async fn get_keybind(app_handle: tauri::AppHandle) -> Result<Vec<String>, String> {
|
||||
let pool = app_handle.state::<SqlitePool>();
|
||||
|
||||
let row = sqlx::query("SELECT value FROM settings WHERE key = 'keybind'")
|
||||
|
@ -88,13 +84,10 @@ pub async fn get_keybind(
|
|||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let json = row
|
||||
.map(|r| r.get::<String, _>("value"))
|
||||
.unwrap_or_else(|| {
|
||||
let json = row.map(|r| r.get::<String, _>("value")).unwrap_or_else(|| {
|
||||
serde_json::to_string(&vec!["Meta".to_string(), "V".to_string()])
|
||||
.expect("Failed to serialize default keybind")
|
||||
});
|
||||
|
||||
serde_json::from_str::<Vec<String>>(&json)
|
||||
.map_err(|e| e.to_string())
|
||||
serde_json::from_str::<Vec<String>>(&json).map_err(|e| e.to_string())
|
||||
}
|
|
@ -4,7 +4,9 @@ use image::ImageFormat;
|
|||
use reqwest;
|
||||
use url::Url;
|
||||
|
||||
pub async fn fetch_favicon_as_base64(url: Url) -> Result<Option<String>, Box<dyn std::error::Error>> {
|
||||
pub async fn fetch_favicon_as_base64(
|
||||
url: Url,
|
||||
) -> Result<Option<String>, Box<dyn std::error::Error>> {
|
||||
let client = reqwest::Client::new();
|
||||
let favicon_url = format!("https://favicone.com/{}", url.host_str().unwrap());
|
||||
let response = client.get(&favicon_url).send().await?;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pub mod types;
|
||||
pub mod commands;
|
||||
pub mod favicon;
|
||||
pub mod types;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue