diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e035e56..adbdd83 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4753,6 +4753,7 @@ dependencies = [ "image", "notify", "raw-window-handle", + "regex", "reqwest 0.12.28", "rusqlite", "serde", @@ -4773,6 +4774,7 @@ dependencies = [ "tokio", "url", "walkdir", + "windows 0.52.0", "windows-sys 0.52.0", "winreg 0.52.0", "zip", @@ -5590,6 +5592,16 @@ dependencies = [ "windows-version", ] +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core 0.52.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.57.0" @@ -5622,6 +5634,15 @@ dependencies = [ "windows-core 0.61.2", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.57.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 333151e..d181b0c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,6 +26,7 @@ tauri-plugin-global-shortcut = "2" tauri-plugin-notification = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" +regex = "1" serde_yaml = "0.9" specta = { version = "=2.0.0-rc.25", features = ["derive", "function", "serde_json"] } specta-typescript = "0.0.12" @@ -65,6 +66,15 @@ windows-sys = { version = "0.52", features = [ "Win32_Storage_Xps", "Win32_Storage_FileSystem", ] } +# Explorer 前台目录检测(IShellWindows COM):仅引入用到的 feature,控制编译体积 +windows = { version = "0.52", features = [ + "Win32_Foundation", + "Win32_System_Com", + "Win32_System_Ole", + "Win32_System_Variant", + "Win32_UI_Shell", + "Win32_UI_WindowsAndMessaging", +] } [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-autostart = "2" diff --git a/src-tauri/binaries/.gitkeep b/src-tauri/binaries/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src-tauri/binaries/7z.dll b/src-tauri/binaries/7z.dll new file mode 100644 index 0000000..859c48b Binary files /dev/null and b/src-tauri/binaries/7z.dll differ diff --git a/src-tauri/binaries/7z.exe b/src-tauri/binaries/7z.exe new file mode 100644 index 0000000..064a135 Binary files /dev/null and b/src-tauri/binaries/7z.exe differ diff --git a/src-tauri/resources/thing-extension/background.js b/src-tauri/resources/thing-extension/background.js index c3b0f6e..0ce0917 100644 --- a/src-tauri/resources/thing-extension/background.js +++ b/src-tauri/resources/thing-extension/background.js @@ -16,7 +16,6 @@ const DEFAULT_CONFIG = { interceptDownload: true, minSize: 0, excludeDomains: [], - showNotifications: true, // 嗅探开关 sniffEnabled: true, // 嗅探的资源类型:只保留视频/音频/图片/压缩包/种子/安装包 @@ -386,28 +385,13 @@ async function handleDownloadCreated(downloadItem) { const filename = downloadItem.filename || '' try { - const id = await addDownload(url, filename, downloadItem.referrer, '') - await notify('已添加到 Thing', `${filename || url}`) + await addDownload(url, filename, downloadItem.referrer, '') } catch (e) { - await notify('Thing 添加失败', `${filename || url}\n${e.message}`) + // 添加失败:回退到浏览器自带下载,不弹通知 try { await chrome.downloads.download({ url }) } catch { /* ignore */ } } } -// ===== 通知 ===== -async function notify(title, message) { - const config = await getConfig() - if (!config.showNotifications) return - try { - await chrome.notifications.create({ - type: 'basic', - iconUrl: 'icons/icon-128.png', - title, - message - }) - } catch { /* ignore */ } -} - // ===== 右键菜单 ===== chrome.runtime.onInstalled.addListener(() => { chrome.contextMenus.create({ @@ -428,10 +412,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { const filename = url.split('/').pop()?.split('?')[0] || '' try { await addDownload(url, filename, info.pageUrl, '') - await notify('已添加到 Thing', `${filename || url}`) - } catch (e) { - await notify('Thing 添加失败', `${e.message}`) - } + } catch (e) { /* 忽略:添加失败时不打扰用户 */ } } }) diff --git a/src-tauri/resources/thing-extension/manifest.json b/src-tauri/resources/thing-extension/manifest.json index 38483f3..39bd603 100644 --- a/src-tauri/resources/thing-extension/manifest.json +++ b/src-tauri/resources/thing-extension/manifest.json @@ -11,9 +11,7 @@ "permissions": [ "downloads", "storage", - "notifications", "webRequest", - "webNavigation", "contextMenus", "tabs", "scripting" diff --git a/src-tauri/resources/thing-extension/popup.html b/src-tauri/resources/thing-extension/popup.html index b04af8c..8497522 100644 --- a/src-tauri/resources/thing-extension/popup.html +++ b/src-tauri/resources/thing-extension/popup.html @@ -87,11 +87,6 @@ 启用资源嗅探 - -