♻️ use opener instead of window.open/shell

This commit is contained in:
目棃
2025-03-18 14:52:00 +08:00
parent 765c860473
commit 01dc6a6ea7
17 changed files with 213 additions and 217 deletions

22
src-tauri/Cargo.lock generated
View File

@@ -17,6 +17,7 @@ dependencies = [
"tauri-plugin-fs",
"tauri-plugin-http",
"tauri-plugin-log",
"tauri-plugin-opener",
"tauri-plugin-os",
"tauri-plugin-process",
"tauri-plugin-shell",
@@ -4981,6 +4982,27 @@ dependencies = [
"time",
]
[[package]]
name = "tauri-plugin-opener"
version = "2.2.6"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#c245f123ea944b5c103a0661adcdcab6f10efbf9"
dependencies = [
"dunce",
"glob",
"objc2-app-kit",
"objc2-foundation 0.3.0",
"open",
"schemars",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.12",
"url",
"windows",
"zbus",
]
[[package]]
name = "tauri-plugin-os"
version = "2.2.1"

View File

@@ -59,6 +59,11 @@ features = ["unsafe-headers"]
git = "ssh://git@github.com/tauri-apps/plugins-workspace.git"
branch = "v2"
# opener 插件
[dependencies.tauri-plugin-opener]
git = "ssh://git@github.com/tauri-apps/plugins-workspace.git"
branch = "v2"
# os 插件
[dependencies.tauri-plugin-os]
git = "ssh://git@github.com/tauri-apps/plugins-workspace.git"

View File

@@ -14,6 +14,7 @@
"core:window:default",
"core:path:allow-resolve-directory",
"core:path:default",
"opener:default",
{ "identifier": "fs:allow-exists", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-mkdir", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-read-dir", "allow": [{ "path": "**" }] },

View File

@@ -37,6 +37,7 @@
"core:window:allow-set-focus",
"core:window:allow-show",
"core:window:allow-unminimize",
"opener:default",
{ "identifier": "fs:allow-exists", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-mkdir", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-read-dir", "allow": [{ "path": "**" }] },
@@ -44,6 +45,7 @@
{ "identifier": "fs:allow-remove", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-write-file", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-write-text-file", "allow": [{ "path": "**" }] },
{ "identifier": "opener:allow-open-path", "allow": [{ "path": "**" }] },
{
"identifier": "http:default",
"allow": [
@@ -55,11 +57,7 @@
},
{
"identifier": "shell:allow-execute",
"allow": [
{ "name": "win_open", "cmd": "explorer", "args": true },
{ "name": "mac_open", "cmd": "open", "args": true },
{ "name": "exec-sh", "cmd": "powershell", "args": true }
]
"allow": [{ "name": "exec-sh", "cmd": "powershell", "args": true }]
}
],
"platforms": ["windows", "macOS"]

View File

@@ -42,6 +42,7 @@ pub fn run() {
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_shell::init())