Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix: dependency-row process storm, command palette labels, bilibili collections, macOS auth cookies (#293)

antonio2a955fcf53fc
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 8dfdc80b..08a75f99 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -4267,6 +4267,7 @@ dependencies = [
"async-trait",
"axum",
"base64 0.22.1",
+ "block2",
"cbc",
"chrono",
"constant_time_eq",
@@ -4284,6 +4285,9 @@ dependencies = [
"md-5",
"murmur3",
"native-tls",
+ "objc2",
+ "objc2-foundation",
+ "objc2-web-kit",
"omniget-core",
"omniget-plugin-sdk",
"once_cell",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 9798c975..9437d03d 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -79,6 +79,15 @@ fs4 = "1"
webview2-com = "0.38"
windows = { version = "0.61", features = ["Win32_System_Com", "Win32_UI_WindowsAndMessaging"] }
+# Reading WKWebView's cookie store directly — document.cookie cannot see
+# HttpOnly cookies, which is the whole point of the auth webview (#287).
+# Versions track what wry already resolves, so this adds no new build cost.
+[target.'cfg(target_os = "macos")'.dependencies]
+objc2 = "0.6"
+objc2-foundation = { version = "0.3", features = ["NSHTTPCookie", "NSArray", "NSString"] }
+objc2-web-kit = { version = "0.3", features = ["WKWebView", "WKWebViewConfiguration", "WKWebsiteDataStore", "WKHTTPCookieStore"] }
+block2 = "0.6"
+
[target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies]
tauri-plugin-process = "2.3.1"
tauri-plugin-updater = "2.10.0"
diff --git a/src-tauri/omniget-core/src/core/ytdlp.rs b/src-tauri/omniget-core/src/core/ytdlp.rs
index d67c9426..bc173f68 100644
--- a/src-tauri/omniget-core/src/core/ytdlp.rs
+++ b/src-tauri/omniget-core/src/core/ytdlp.rs
@@ -943,7 +943,11 @@ pub async fn find_ytdlp_cached() -> Option<PathBuf> {
result
}
-fn managed_ytdlp_path() -> Option<PathBuf> {
+/// Where the managed yt-dlp lives. Pure path resolution — it does not check
+/// for the file, download it, or start anything. Callers that only need to
+/// locate the binary must use this rather than [`ensure_ytdlp`], which spawns
+/// a freshness check and a JS-runtime check on every call (#281).
+pub fn managed_ytdlp_path() -> Option<PathBuf> {
// Issue #222: se o usuario apontou um binario proprio, ele ganha do
// gerenciado. Referenciado no lugar, entao um `apt upgrade` no yt-dlp dele
// vale imediatamente aqui, sem copia para envelhecer.
diff --git a/src-tauri/omniget-core/src/platforms/bilibili/url_kind.rs b/src-tauri/omniget-core/src/platforms/bilibili/url_kind.rs
index ac3f8aaf..0988749c 100644
--- a/src-tauri/omniget-core/src/platforms/bilibili/url_kind.rs
+++ b/src-tauri/omniget-core/src/platforms/bilibili/url_kind.rs
@@ -80,6 +80,12 @@ static RE_CHEESE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"bilibili\.com/cheese/play/(ss\d+|ep\d+)").unwrap());
static RE_LIST_LISTS: Lazy<Regex> =
Lazy::new(|| Regex::new(r"space\.bilibili\.com/(\d+)/lists(?:/(\d+))?").unwrap());
+// The link Bilibili puts on a 合集 outside the current space UI. Without it
+// these fell through to RE_SPACE and downloaded the uploader's entire channel
+// instead of the collection (#292).
+static RE_CHANNEL_DETAIL: Lazy<Regex> = Lazy::new(|| {
+ Regex::new(r"space\.bilibili\.com/(\d+)/channel/(collectiondetail|seriesdetail)").unwrap()
+});
static RE_FAVLIST_SPACE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"space\.bilibili\.com/\d+/favlist").unwrap());
static RE_FAVLIST_LIST: Lazy<Regex> = Lazy::new(|| {
@@ -171,6 +177,27 @@ fn detect_internal(url: &str, query_override: Option<&str>) -> Result<UrlKind> {
});
}
+ if let Some(cap) = RE_CHANNEL_DETAIL.captures(url) {
+ let mid: u64 = cap
+ .get(1)
+ .and_then(|m| m.as_str().parse().ok())
+ .unwrap_or(0);
+ let sid: u64 = extract_query_value(url, query_override, "sid")
+ .and_then(|s| s.parse().ok())
+ .unwrap_or(0);
+ // Only claim the URL once the sid is actually readable. Without it
+ // there is nothing to fetch, and falling through to Space at least
+ // downloads something the uploader published.
+ if sid != 0 {
+ let is_series = cap.get(2).map(|m| m.as_str()) == Some("seriesdetail");
+ return Ok(if is_series {
+ UrlKind::Series { mid, sid }
+ } else {
+ UrlKind::Collection { mid, sid }
+ });
+ }
+ }
+
if RE_FAVLIST_SPACE.is_match(url) {
let fid = extract_query_value(url, query_override, "fid")
.and_then(|s| s.parse().ok())
@@ -446,6 +473,29 @@ mod tests {
assert_eq!(detect(url).unwrap(), UrlKind::Series { mid: 123, sid: 456 });
}
+ #[test]
+ fn detects_collection_from_channel_detail_link() {
+ let url = "https://space.bilibili.com/123/channel/collectiondetail?sid=456";
+ assert_eq!(
+ detect(url).unwrap(),
+ UrlKind::Collection { mid: 123, sid: 456 }
+ );
+ }
+
+ #[test]
+ fn detects_series_from_channel_detail_link() {
+ let url = "https://space.bilibili.com/123/channel/seriesdetail?sid=456";
+ assert_eq!(detect(url).unwrap(), UrlKind::Series { mid: 123, sid: 456 });
+ }
+
+ #[test]
+ fn channel_detail_without_sid_stays_a_space_download() {
+ // Nothing to fetch without the sid, and the whole channel is a better
+ // answer than an error.
+ let url = "https://space.bilibili.com/123/channel/collectiondetail";
+ assert_eq!(detect(url).unwrap(), UrlKind::Space { mid: 123 });
+ }
+
#[test]
fn detects_popular() {
let url = "https://www.bilibili.com/v/popular?num=10";
diff --git a/src-tauri/src/commands/auth_webview.rs b/src-tauri/src/commands/auth_webview.rs
index bfe9c768..339f18f9 100644
--- a/src-tauri/src/commands/auth_webview.rs
+++ b/src-tauri/src/commands/auth_webview.rs
@@ -270,10 +270,10 @@ async fn extract_cookies(
default_domain: &str,
domains: &[String],
) -> Vec<AuthCookie> {
- #[cfg(not(windows))]
+ #[cfg(not(any(windows, target_os = "macos")))]
let _ = domains;
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "macos"))]
{
let native = extract_cookies_native(window, domains).await;
if !native.is_empty() {
@@ -541,3 +541,152 @@ async fn extract_cookies_for_uri(
.map_err(|_| "GetCookies timed out".to_string())?
.map_err(|_| "Cookie channel closed".to_string())
}
+
+/// Reads the cookies out of WKWebView's own cookie store.
+///
+/// `document.cookie` cannot see HttpOnly cookies by definition, so the JS
+/// fallback silently returns an authenticated session minus exactly the
+/// cookies that prove it is authenticated. Hotmart's `hmVlcIntegration` is
+/// one of those, which is why a visibly logged-in webview still reported
+/// `not_authenticated` on macOS (#287) while Windows — which has had native
+/// extraction all along — worked.
+#[cfg(target_os = "macos")]
+async fn extract_cookies_native(
+ window: &tauri::WebviewWindow,
+ domains: &[String],
+) -> Vec<AuthCookie> {
+ let (tx, rx) = tokio::sync::oneshot::channel::<Vec<AuthCookie>>();
+ let wanted = normalize_cookie_domains(domains);
+
+ let result = window.with_webview(move |platform_webview| {
+ use block2::RcBlock;
+ use objc2::rc::Retained;
+ use objc2_foundation::{NSArray, NSHTTPCookie};
+ use objc2_web_kit::WKWebView;
+
+ // with_webview hands us the WKWebView on the main thread, which is the
+ // only thread WebKit permits here.
+ let webview: &WKWebView = unsafe { &*(platform_webview.inner() as *mut WKWebView) };
+ let store = unsafe { webview.configuration().websiteDataStore().httpCookieStore() };
+
+ let tx = std::cell::RefCell::new(Some(tx));
+ let handler = RcBlock::new(move |cookies: std::ptr::NonNull<NSArray<NSHTTPCookie>>| {
+ let cookies: Retained<NSArray<NSHTTPCookie>> =
+ unsafe { Retained::retain(cookies.as_ptr()) }.expect("cookie array");
+ let mut out = Vec::new();
+ for cookie in cookies.iter() {
+ let domain = cookie.domain().to_string();
+ if !cookie_domain_matches(&domain, &wanted) {
+ continue;
+ }
+ out.push(AuthCookie {
+ name: cookie.name().to_string(),
+ value: cookie.value().to_string(),
+ domain,
+ path: cookie.path().to_string(),
+ http_only: cookie.isHTTPOnly(),
+ secure: cookie.isSecure(),
+ });
+ }
+ if let Some(tx) = tx.borrow_mut().take() {
+ let _ = tx.send(out);
+ }
+ });
+
+ unsafe { store.getAllCookies(&handler) };
+ });
+
+ if let Err(e) = result {
+ tracing::warn!("[auth_webview] with_webview failed: {}", e);
+ return Vec::new();
+ }
+
+ match tokio::time::timeout(std::time::Duration::from_secs(10), rx).await {
+ Ok(Ok(cookies)) => {
+ tracing::debug!(
+ "[auth_webview] native cookies from WKWebView: {}",
+ cookies.len()
+ );
+ cookies
+ }
+ Ok(Err(_)) => {
+ tracing::warn!("[auth_webview] cookie channel closed");
+ Vec::new()
+ }
+ Err(_) => {
+ tracing::warn!("[auth_webview] getAllCookies timed out");
+ Vec::new()
+ }
+ }
+}
+
+/// Strips scheme and leading dot so a configured `.hotmart.com` and a cookie's
+/// `hotmart.com` compare equal.
+#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
+fn normalize_cookie_domains(domains: &[String]) -> Vec<String> {
+ domains
+ .iter()
+ .map(|d| {
+ d.trim_start_matches("https://")
+ .trim_start_matches("http://")
+ .trim_start_matches('.')
+ .to_lowercase()
+ })
+ .filter(|d| !d.is_empty())
+ .collect()
+}
+
+/// Whether a cookie's domain belongs to one of the requested domains.
+///
+/// An empty list means "everything this window has" — the auth webview is
+/// opened for one login, so there is nothing else in its store to leak.
+#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
+fn cookie_domain_matches(cookie_domain: &str, wanted: &[String]) -> bool {
+ if wanted.is_empty() {
+ return true;
+ }
+ let normalized = cookie_domain.trim_start_matches('.').to_lowercase();
+ wanted
+ .iter()
+ .any(|w| normalized == *w || normalized.ends_with(&format!(".{w}")))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn normalizes_scheme_and_leading_dot() {
+ let got = normalize_cookie_domains(&[
+ "https://consumer.hotmart.com".into(),
+ ".hotmart.com".into(),
+ "HOTMART.com".into(),
+ "".into(),
+ ]);
+ assert_eq!(
+ got,
+ vec!["consumer.hotmart.com", "hotmart.com", "hotmart.com"]
+ );
+ }
+
+ #[test]
+ fn matches_exact_and_subdomains() {
+ let wanted = normalize_cookie_domains(&[".hotmart.com".into()]);
+ assert!(cookie_domain_matches("hotmart.com", &wanted));
+ assert!(cookie_domain_matches(".hotmart.com", &wanted));
+ assert!(cookie_domain_matches("consumer.hotmart.com", &wanted));
+ }
+
+ #[test]
+ fn rejects_lookalike_domains() {
+ // The substring check this replaced accepted both of these.
+ let wanted = normalize_cookie_domains(&["hotmart.com".into()]);
+ assert!(!cookie_domain_matches("nothotmart.com", &wanted));
+ assert!(!cookie_domain_matches("hotmart.com.evil.net", &wanted));
+ }
+
+ #[test]
+ fn empty_wanted_keeps_everything() {
+ assert!(cookie_domain_matches("anything.example", &[]));
+ }
+}
diff --git a/src-tauri/src/commands/dependencies.rs b/src-tauri/src/commands/dependencies.rs
index ebbbc94d..33e6be3b 100644
--- a/src-tauri/src/commands/dependencies.rs
+++ b/src-tauri/src/commands/dependencies.rs
@@ -167,9 +167,14 @@ pub async fn install_dependency(
}
/// Caminho do binario gerenciado de uma dependencia, quando ha um.
+/// Locates the managed binary without touching it. Previously this called
+/// `ensure_ytdlp`, which downloads a missing binary and spawns a freshness
+/// check plus a JS-runtime check (yt-dlp and deno processes) on every call.
+/// Listing archived versions is a read, and the Plugins tab does it on
+/// render, so that turned a UI refresh into a process storm (#281).
async fn managed_binary_path(name: &str) -> Option<PathBuf> {
match name {
- "yt-dlp" => crate::core::ytdlp::ensure_ytdlp().await.ok(),
+ "yt-dlp" => omniget_core::core::ytdlp::managed_ytdlp_path(),
_ => None,
}
}
diff --git a/src/components/settings/DependencyRow.svelte b/src/components/settings/DependencyRow.svelte
index c66da41d..4b8df19e 100644
--- a/src/components/settings/DependencyRow.svelte
+++ b/src/components/settings/DependencyRow.svelte
@@ -1,4 +1,5 @@
<script lang="ts">
+ import { untrack } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import { open as openDialog } from "@tauri-apps/plugin-dialog";
import { showToast } from "$lib/stores/toast-store.svelte";
@@ -61,13 +62,19 @@
}
}
+ // Only `name` may retrigger this. The loaders read and write their own
+ // state, so tracking them turns each completed round trip into the next
+ // one — an unbounded loop that reaches ensure_ytdlp() and spawns a
+ // yt-dlp and a deno process every pass (#281).
$effect(() => {
- if (name) {
+ const dep = name;
+ untrack(() => {
+ if (!dep) return;
void loadVariants();
void loadInstallDir();
void loadArchived();
void loadCustomPath();
- }
+ });
});
async function handleInstall() {
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index 727b0552..2d5e596d 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Επικόλληση URL από το πρόχειρο"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "Ετοιμο! Το {{name}} ειναι στον φακελο σας",
"download_error": "Δεν μπορεσα να κατεβασω {{name}}. Θελετε να δοκιμασετε ξανα;",
"clipboard_url_detected": "Εντοπιστηκε συνδεσμος! Επικολληστε για ληψη",
+ "clipboard_empty": "Το πρόχειρο είναι άδειο",
"auto_download_started": "Αυτόματη λήψη ξεκίνησε",
"external_url_ready": "Το URL λήφθηκε και είναι έτοιμο για λήψη",
"external_url_queued": "Η λήψη προστέθηκε από την επέκταση Chrome",
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 7f1444f8..36952ef8 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -381,9 +381,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Paste URL from clipboard"
},
"home": {
"mode_url": "URL",
@@ -574,6 +572,7 @@
"download_complete": "Done! {{name}} is in your folder",
"download_error": "Couldn't download {{name}}. Want to retry?",
"clipboard_url_detected": "Link detected! Paste to download",
+ "clipboard_empty": "Clipboard is empty",
"auto_download_started": "Auto-download started",
"external_url_ready": "URL received and ready to download",
"external_url_queued": "Download added from the Chrome extension",
diff --git a/src/lib/i18n/es.json b/src/lib/i18n/es.json
index 32928658..18dfb6c0 100644
--- a/src/lib/i18n/es.json
+++ b/src/lib/i18n/es.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Pegar URL del portapapeles"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "¡Listo! {{name}} está en tu carpeta",
"download_error": "No se pudo descargar {{name}}. ¿Reintentar?",
"clipboard_url_detected": "¡Enlace detectado! Pega para descargar",
+ "clipboard_empty": "El portapapeles está vacío",
"auto_download_started": "Auto-download started",
"external_url_ready": "URL recibida y lista para descargar",
"external_url_queued": "Descarga añadida desde la extensión de Chrome",
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index ff782f6a..dd947bc1 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Coller l'URL du presse-papiers"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "Fini ! {{name}} est dans votre dossier",
"download_error": "Impossible de telecharger {{name}}. Reessayer ?",
"clipboard_url_detected": "Lien detecte ! Collez pour telecharger",
+ "clipboard_empty": "Le presse-papiers est vide",
"auto_download_started": "Téléchargement automatique lancé",
"external_url_ready": "URL reçue et prête à être téléchargée",
"external_url_queued": "Téléchargement ajouté depuis l'extension Chrome",
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index db0367c1..6bda8952 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Incolla URL dagli appunti"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "Fatto! {{name}} e nella tua cartella",
"download_error": "Non riesco a scaricare {{name}}. Riprovare?",
"clipboard_url_detected": "Link rilevato! Incolla per scaricare",
+ "clipboard_empty": "Gli appunti sono vuoti",
"auto_download_started": "Download automatico avviato",
"external_url_ready": "URL ricevuto e pronto per il download",
"external_url_queued": "Download aggiunto dall'estensione Chrome",
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index 7d190bb5..84629b4f 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "クリップボードから URL を貼り付け"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "完了!{{name}} はフォルダに保存されました",
"download_error": "{{name}} をダウンロードできませんでした。再試行しますか?",
"clipboard_url_detected": "リンクを検出!貼り付けてダウンロード",
+ "clipboard_empty": "クリップボードが空です",
"auto_download_started": "自動ダウンロードを開始しました",
"external_url_ready": "URLを受信し、ダウンロードの準備ができました",
"external_url_queued": "Chrome拡張機能からダウンロードを追加しました",
diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts
index c4b6443a..c4f9cae7 100644
--- a/src/lib/i18n/keys.ts
+++ b/src/lib/i18n/keys.ts
@@ -74,9 +74,7 @@ export type TranslationKeys =
| 'changelog.empty'
| 'changelog.title'
- | 'command_palette.action_downloads'
| 'command_palette.action_paste'
- | 'command_palette.action_settings'
| 'command_palette.close'
| 'command_palette.empty'
| 'command_palette.group_action'
@@ -3695,6 +3693,7 @@ export type TranslationKeys =
| 'toast.auto_download_started'
| 'toast.channel_new'
| 'toast.channel_new_auto'
+ | 'toast.clipboard_empty'
| 'toast.clipboard_url_detected'
| 'toast.download_complete'
| 'toast.download_error'
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index 42d6882d..39d34fd0 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "Colar URL da área de transferência"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "Pronto! {{name}} está na sua pasta",
"download_error": "Não consegui baixar {{name}}. Tente novamente?",
"clipboard_url_detected": "Link detectado! Cole para baixar",
+ "clipboard_empty": "A área de transferência está vazia",
"auto_download_started": "Download automático iniciado",
"external_url_ready": "URL recebida e pronta para download",
"external_url_queued": "Download adicionado pela extensão do Chrome",
diff --git a/src/lib/i18n/ru.json b/src/lib/i18n/ru.json
index e7473793..53e6047f 100644
--- a/src/lib/i18n/ru.json
+++ b/src/lib/i18n/ru.json
@@ -363,9 +363,7 @@
"close": "закрыть",
"group_nav": "Навигация",
"group_action": "Действия",
- "action_paste": "Вставить URL из буфера обмена",
- "action_downloads": "Открыть загрузки",
- "action_settings": "Открыть настройки"
+ "action_paste": "Вставить URL из буфера обмена"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "Готово! {{name}} в вашей папке",
"download_error": "Не удалось скачать {{name}}. Повторить?",
"clipboard_url_detected": "Ссылка обнаружена! Вставьте, чтобы скачать",
+ "clipboard_empty": "Буфер обмена пуст",
"auto_download_started": "Автозагрузка начата",
"external_url_ready": "URL получен, готов к скачиванию",
"external_url_queued": "Загрузка добавлена из расширения Chrome",
diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.json
index 08edf795..04033568 100644
--- a/src/lib/i18n/zh-TW.json
+++ b/src/lib/i18n/zh-TW.json
@@ -363,9 +363,7 @@
"close": "close",
"group_nav": "Navigate",
"group_action": "Actions",
- "action_paste": "Paste URL from clipboard",
- "action_downloads": "Open downloads",
- "action_settings": "Open settings"
+ "action_paste": "從剪貼簿貼上 URL"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "下載完成: {{name}}",
"download_error": "下載失敗: {{name}}",
"clipboard_url_detected": "在剪貼簿中偵測到 URL",
+ "clipboard_empty": "剪貼簿是空的",
"auto_download_started": "已啟動自動下載",
"external_url_ready": "已收到 URL,可以开始下载",
"external_url_queued": "已从 Chrome 扩展添加下载",
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index 9c24b548..a3710105 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -363,9 +363,7 @@
"close": "关闭",
"group_nav": "导航",
"group_action": "操作",
- "action_paste": "从剪贴板粘贴 URL",
- "action_downloads": "打开下载",
- "action_settings": "打开设置"
+ "action_paste": "从剪贴板粘贴 URL"
},
"home": {
"mode_url": "URL",
@@ -556,6 +554,7 @@
"download_complete": "完成!{{name}} 已保存到你的文件夹",
"download_error": "无法下载 {{name}}。要重试吗?",
"clipboard_url_detected": "检测到链接!粘贴即可下载",
+ "clipboard_empty": "剪贴板是空的",
"auto_download_started": "已启动自动下载",
"external_url_ready": "已收到 URL,可以开始下载",
"external_url_queued": "已从 Chrome 扩展添加下载",
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 6903d4ab..74c56a41 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -18,6 +18,7 @@
import { setCommandPaletteItems } from "$lib/stores/command-palette-store.svelte";
import { refreshUpdateInfo } from "$lib/stores/update-store.svelte";
import { startClipboardMonitor, stopClipboardMonitor, onClipboardUrl } from "$lib/stores/clipboard-monitor";
+ import { readText } from "@tauri-apps/plugin-clipboard-manager";
import { initChangelog } from "$lib/stores/changelog-store.svelte";
import { needsOnboarding } from "$lib/stores/onboarding-store.svelte";
import { isYtdlpAvailable, isDepsChecked, refreshYtdlpStatus } from "$lib/stores/dependency-store.svelte";
@@ -176,62 +177,59 @@
setCommandPaletteItems([
{
id: "nav-home",
- label: get(t)("command_palette.nav_home"),
+ label: get(t)("nav.home"),
group: get(t)("command_palette.group_nav"),
keywords: "index main prefill",
action: () => goto("/"),
},
{
id: "nav-downloads",
- label: get(t)("command_palette.nav_downloads"),
+ label: get(t)("nav.downloads"),
group: get(t)("command_palette.group_nav"),
keywords: "queue active history",
action: () => goto("/downloads"),
},
{
id: "nav-settings",
- label: get(t)("command_palette.nav_settings"),
+ label: get(t)("nav.settings"),
group: get(t)("command_palette.group_nav"),
keywords: "preferences options config",
action: () => goto("/settings"),
},
{
id: "nav-marketplace",
- label: get(t)("command_palette.nav_marketplace"),
+ label: get(t)("nav.marketplace"),
group: get(t)("command_palette.group_nav"),
keywords: "plugins extensions store",
action: () => goto("/marketplace"),
},
{
id: "nav-about",
- label: get(t)("command_palette.nav_about"),
+ label: get(t)("nav.about"),
group: get(t)("command_palette.group_nav"),
keywords: "info version changelog project",
action: () => goto("/about"),
},
+ // The three former "action" entries ran the same goto() as the
+ // navigation entries above them, so the palette listed Downloads and
+ // Settings twice and Home three times. Only the paste action does
+ // something navigation cannot — `command_palette.action_paste` was
+ // already translated in every locale, just never wired up.
{
- id: "action-prefill",
- label: get(t)("command_palette.action_prefill"),
+ id: "action-paste",
+ label: get(t)("command_palette.action_paste"),
group: get(t)("command_palette.group_action"),
- keywords: "url link add download",
- action: () => {
+ keywords: "url link add download clipboard prefill",
+ action: async () => {
+ const text = (await readText().catch(() => null))?.trim();
+ if (!text) {
+ showToast("info", get(t)("toast.clipboard_empty") as string);
+ return;
+ }
+ queueExternalPrefill({ action: "prefill", url: text, source: "clipboard" });
goto("/");
},
},
- {
- id: "action-downloads",
- label: get(t)("command_palette.action_downloads"),
- group: get(t)("command_palette.group_action"),
- keywords: "queue",
- action: () => goto("/downloads"),
- },
- {
- id: "action-settings",
- label: get(t)("command_palette.action_settings"),
- group: get(t)("command_palette.group_action"),
- keywords: "preferences",
- action: () => goto("/settings"),
- },
]);
}