diff --git a/package.json b/package.json index 053638c..2e3288a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clippy", - "version": "1.3.0", + "version": "1.3.1", "description": "Clipboard Manager built with Rust & Typescript", "license": "MIT", "type": "module", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index c422039..8213dd8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -929,7 +929,7 @@ dependencies = [ [[package]] name = "clippy" -version = "1.3.0" +version = "1.3.1" dependencies = [ "base64 0.22.1", "chrono", @@ -4144,9 +4144,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -4389,9 +4389,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "3d3536321cfc54baa8cf3e273d5e1f63f889067829c4b410fcdbac8ca7b80994" dependencies = [ "base64 0.22.1", "bytes", @@ -4415,6 +4415,7 @@ dependencies = [ "sync_wrapper", "tokio", "tokio-util", + "tower", "tower-service", "url", "wasm-bindgen", @@ -4793,9 +4794,9 @@ dependencies = [ [[package]] name = "sea-schema" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab1592d17860a9a8584d9b549aebcd06f7bdc3ff615f71752486ba0b05b1e6e" +checksum = "0ef5dd7848c993f3789d09a2616484c72c9330cae2b048df59d8c9b8c0343e95" dependencies = [ "futures", "sea-query", @@ -6242,6 +6243,27 @@ dependencies = [ "winnow 0.6.20", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6021643..c379eb3 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "1.3.0" +version = "1.3.1" description = "Clipboard Manager built with Rust & Typescript" authors = ["0-don"] license = "MIT" @@ -64,10 +64,3 @@ color-backtrace = "0" # lto = true # opt-level = "s" # strip = true - -[package.metadata.generate-rpm.requires] -# "webkit2gtk-4.1" = "*" -# "libappindicator-gtk3" = "*" -# "xdotool" = "*" -# "gtk3" = "*" -# "libxdo" = "*" diff --git a/src-tauri/Info.plist b/src-tauri/Info.plist new file mode 100644 index 0000000..2150c9d --- /dev/null +++ b/src-tauri/Info.plist @@ -0,0 +1,8 @@ + + + + + NSAppleEventsUsageDescription + Clippy needs access to send keyboard events + + \ No newline at end of file diff --git a/src-tauri/common/Cargo.toml b/src-tauri/common/Cargo.toml index 1c6ebf5..1338c90 100644 --- a/src-tauri/common/Cargo.toml +++ b/src-tauri/common/Cargo.toml @@ -10,7 +10,7 @@ path = "src/lib.rs" [dependencies] entity = { path = "../entity" } global-hotkey = "0" -sea-orm = { version = "1" } -serde = { version = "1" } -serde_json = { version = "1" } -tl = "0" \ No newline at end of file +sea-orm = "1" +serde = "1" +serde_json = "1" +tl = "0" diff --git a/src-tauri/common/src/language.rs b/src-tauri/common/src/language.rs index bbd5ee7..a46c238 100644 --- a/src-tauri/common/src/language.rs +++ b/src-tauri/common/src/language.rs @@ -1,82 +1,57 @@ use crate::types::enums::Language; pub use sea_orm::Iden; +impl Language { + fn from_iso_code(lang_code: &str) -> Self { + match &*lang_code { + code if code == Language::Mandarin.to_string() => Language::Mandarin, + code if code == Language::Hindi.to_string() => Language::Hindi, + code if code == Language::Spanish.to_string() => Language::Spanish, + code if code == Language::French.to_string() => Language::French, + code if code == Language::Arabic.to_string() => Language::Arabic, + code if code == Language::Bengali.to_string() => Language::Bengali, + code if code == Language::Portuguese.to_string() => Language::Portuguese, + code if code == Language::Russian.to_string() => Language::Russian, + code if code == Language::Urdu.to_string() => Language::Urdu, + code if code == Language::Japanese.to_string() => Language::Japanese, + code if code == Language::German.to_string() => Language::German, + code if code == Language::Korean.to_string() => Language::Korean, + code if code == Language::Vietnamese.to_string() => Language::Vietnamese, + code if code == Language::Turkish.to_string() => Language::Turkish, + code if code == Language::Italian.to_string() => Language::Italian, + code if code == Language::Thai.to_string() => Language::Thai, + code if code == Language::Polish.to_string() => Language::Polish, + code if code == Language::Dutch.to_string() => Language::Dutch, + _ => Language::English, + } + } +} + pub fn get_system_language() -> Language { if cfg!(target_os = "linux") { - if let Ok(lang) = std::env::var("LANG") { - let lang = lang.to_lowercase(); - match &lang[..2] { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } + std::env::var("LANG") + .map(|lang| Language::from_iso_code(&lang.to_lowercase()[..2])) + .unwrap_or(Language::English) } else if cfg!(target_os = "windows") { - let output = std::process::Command::new("powershell") + std::process::Command::new("powershell") .arg("-Command") .arg("(Get-Culture).TwoLetterISOLanguageName") - .output(); - - if let Ok(result) = output { - if let Ok(lang) = std::str::from_utf8(&result.stdout) { - let lang = lang.trim().to_lowercase(); - match lang.as_str() { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } - } else { - Language::English - } + .output() + .ok() + .and_then(|result| String::from_utf8(result.stdout).ok()) + .map(|lang| Language::from_iso_code(lang.trim())) + .unwrap_or(Language::English) } else if cfg!(target_os = "macos") { - let output = std::process::Command::new("defaults") + std::process::Command::new("defaults") .arg("read") .arg(".GlobalPreferences") .arg("AppleLanguages") - .output(); - - if let Ok(result) = output { - if let Ok(lang) = std::str::from_utf8(&result.stdout) { - let lang = lang.to_lowercase(); - match &lang[..2] { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } - } else { - Language::English - } + .output() + .ok() + .and_then(|result| String::from_utf8(result.stdout).ok()) + .map(|lang| Language::from_iso_code(&lang.to_lowercase()[..2])) + .unwrap_or(Language::English) } else { - println!("{} default English", std::env::consts::OS); Language::English } } diff --git a/src-tauri/migration/Cargo.toml b/src-tauri/migration/Cargo.toml index 6ab5230..92efa37 100644 --- a/src-tauri/migration/Cargo.toml +++ b/src-tauri/migration/Cargo.toml @@ -14,7 +14,7 @@ entity = { path = "../entity" } common = { path = "../common" } async-std = { version = "1", features = ["attributes", "tokio1"] } serde = { version = "1", features = ["derive"] } -serde_json = { version = "1" } +serde_json = "1" [dependencies.sea-orm-migration] version = "1" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f7d1d01..ef39ff0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "clippy", - "version": "1.3.0", + "version": "1.3.1", "identifier": "clippy", "build": { "beforeDevCommand": "npm run dev", @@ -28,7 +28,7 @@ }, "bundle": { "active": true, - "targets": "all", + "targets": ["app", "deb", "rpm", "dmg", "appimage", "nsis"], "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"], "linux": { "deb": { @@ -37,6 +37,29 @@ "rpm": { "depends": ["xdotool"] } + }, + "macOS": { + "minimumSystemVersion": "10.13", + "exceptionDomain": "", + "frameworks": [] + }, + "windows": { + "nsis": { + "languages": [ + "English", + "SimpChinese", + "Spanish", + "French", + "Arabic", + "Russian", + "Japanese", + "German", + "Korean", + "Turkish", + "Italian", + "Dutch" + ] + } } } } diff --git a/src/components/pages/app/clipboard/clipboards.tsx b/src/components/pages/app/clipboard/clipboards.tsx index d87821c..55e4039 100644 --- a/src/components/pages/app/clipboard/clipboards.tsx +++ b/src/components/pages/app/clipboard/clipboards.tsx @@ -12,7 +12,6 @@ import { BaseClipboard } from "./base-clipboard"; export const Clipboards: Component = () => { const { t } = useLanguage(); - const { globalHotkeyEvent, hotkeys } = HotkeyStore; const [scrollToTop, setScrollToTop] = createSignal(false); const onScroll = async () => { @@ -58,9 +57,9 @@ export const Clipboards: Component = () => { >
- +
- {hotkeys().find((key) => key.event === HotkeyEvent.ScrollToTop)?.key} + {HotkeyStore.hotkeys().find((key) => key.event === HotkeyEvent.ScrollToTop)?.key}
diff --git a/src/components/utils/dark-mode.tsx b/src/components/utils/dark-mode.tsx index 87e64c1..11c0bc3 100644 --- a/src/components/utils/dark-mode.tsx +++ b/src/components/utils/dark-mode.tsx @@ -6,12 +6,12 @@ import { Toggle } from "../elements/toggle"; interface DarkModeProps {} export const DarkMode: Component = ({}) => { - const { settings, updateSettings } = SettingsStore; - const { darkMode } = AppStore; - - createEffect(darkMode); + createEffect(AppStore.darkMode); return ( - updateSettings({ ...settings()!, dark_mode })} /> + SettingsStore.updateSettings({ ...SettingsStore.settings()!, dark_mode })} + /> ); }; diff --git a/src/store/settings-store.ts b/src/store/settings-store.ts index 9fa5e0a..465c64f 100644 --- a/src/store/settings-store.ts +++ b/src/store/settings-store.ts @@ -9,7 +9,6 @@ import { Settings, SettingsTab } from "../types"; import { WebWindow } from "../types/enums"; import { InvokeCommand } from "../types/tauri-invoke"; import { SETTINGS_TAB, SettingsTabName } from "../utils/constants"; -import dayjs from "../utils/dayjs"; function createSettingsStore() { const [tabs, setTabs] = createSignal([ diff --git a/src/utils/constants.ts b/src/utils/constants.ts index a4a90dc..d0fbdb8 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1,4 @@ -import { DictionaryKey } from "../lib/i18n"; +import type { DictionaryKey } from "../lib/i18n"; import { HotkeyEvent } from "../types/enums"; export const LANGUAGE_KEY = "lang"; diff --git a/src/utils/index.ts b/src/utils/index.ts index 0201120..f0a18ca 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -9,7 +9,3 @@ export function formatBytes(bytes: number = 0, decimals = 2) { return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; } - -export async function sleep(milis: number) { - return new Promise((resolve) => setTimeout(resolve, milis)); -}