Add deep linking

This commit is contained in:
kwaroran
2024-10-09 21:19:58 +09:00
parent 19d1c1ef7a
commit a66f1664ef
13 changed files with 251 additions and 11 deletions

View File

@@ -28,6 +28,7 @@
"@smithy/protocol-http": "^3.0.12",
"@smithy/signature-v4": "^2.0.19",
"@tauri-apps/api": "2.0.0",
"@tauri-apps/plugin-deep-link": "~2",
"@tauri-apps/plugin-dialog": "~2",
"@tauri-apps/plugin-fs": "~2",
"@tauri-apps/plugin-http": "~2",

10
pnpm-lock.yaml generated
View File

@@ -44,6 +44,9 @@ importers:
'@tauri-apps/api':
specifier: 2.0.0
version: 2.0.0
'@tauri-apps/plugin-deep-link':
specifier: ~2
version: 2.0.0
'@tauri-apps/plugin-dialog':
specifier: ~2
version: 2.0.0
@@ -1003,6 +1006,9 @@ packages:
engines: {node: '>= 10'}
hasBin: true
'@tauri-apps/plugin-deep-link@2.0.0':
resolution: {integrity: sha512-cDa2k1OrRU5DoKc0IXl1Y8RlFOU107u2phdZfT7FkApsC6TL/VAPs3YOUTT8p9/PZ50EjOKP104HFMqVqnQ0bw==}
'@tauri-apps/plugin-dialog@2.0.0':
resolution: {integrity: sha512-ApNkejXP2jpPBSifznPPcHTXxu9/YaRW+eJ+8+nYwqp0lLUtebFHG4QhxitM43wwReHE81WAV1DQ/b+2VBftOA==}
@@ -4469,6 +4475,10 @@ snapshots:
'@tauri-apps/cli-win32-ia32-msvc': 2.0.2
'@tauri-apps/cli-win32-x64-msvc': 2.0.2
'@tauri-apps/plugin-deep-link@2.0.0':
dependencies:
'@tauri-apps/api': 2.0.0
'@tauri-apps/plugin-dialog@2.0.0':
dependencies:
'@tauri-apps/api': 2.0.0

119
src-tauri/Cargo.lock generated
View File

@@ -650,6 +650,26 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom 0.2.15",
"once_cell",
"tiny-keccak",
]
[[package]]
name = "constant_time_eq"
version = "0.1.5"
@@ -773,6 +793,12 @@ version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-common"
version = "0.1.6"
@@ -987,6 +1013,15 @@ dependencies = [
"syn 2.0.74",
]
[[package]]
name = "dlv-list"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
"const-random",
]
[[package]]
name = "downcast-rs"
version = "1.2.1"
@@ -2735,6 +2770,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "ordered-multimap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
dependencies = [
"dlv-list",
"hashbrown 0.14.5",
]
[[package]]
name = "ordered-stream"
version = "0.2.0"
@@ -3472,7 +3517,7 @@ dependencies = [
"wasm-streams",
"web-sys",
"webpki-roots",
"windows-registry",
"windows-registry 0.2.0",
]
[[package]]
@@ -3526,6 +3571,7 @@ dependencies = [
"tar",
"tauri",
"tauri-build",
"tauri-plugin-deep-link",
"tauri-plugin-dialog",
"tauri-plugin-fs",
"tauri-plugin-http",
@@ -3540,6 +3586,17 @@ dependencies = [
"zip 0.6.6",
]
[[package]]
name = "rust-ini"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f"
dependencies = [
"cfg-if",
"ordered-multimap",
"trim-in-place",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@@ -4434,6 +4491,26 @@ dependencies = [
"walkdir",
]
[[package]]
name = "tauri-plugin-deep-link"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31a9b5725027c6e9e075b06cb2d5c2cd3b5c29daa8012b404e1ff755cc56082f"
dependencies = [
"dunce",
"log",
"rust-ini",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"tauri-utils",
"thiserror",
"url",
"windows-registry 0.3.0",
"windows-result",
]
[[package]]
name = "tauri-plugin-dialog"
version = "2.0.1"
@@ -4554,6 +4631,7 @@ dependencies = [
"serde",
"serde_json",
"tauri",
"tauri-plugin-deep-link",
"thiserror",
"windows-sys 0.59.0",
"zbus",
@@ -4776,6 +4854,15 @@ dependencies = [
"time-core",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]]
name = "tinyvec"
version = "1.8.0"
@@ -4991,6 +5078,12 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"
[[package]]
name = "try-lock"
version = "0.2.5"
@@ -5515,7 +5608,7 @@ dependencies = [
"windows-implement",
"windows-interface",
"windows-result",
"windows-strings",
"windows-strings 0.1.0",
"windows-targets 0.52.6",
]
@@ -5548,7 +5641,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
dependencies = [
"windows-result",
"windows-strings",
"windows-strings 0.1.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-registry"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bafa604f2104cf5ae2cc2db1dee84b7e6a5d11b05f737b60def0ffdc398cbc0a"
dependencies = [
"windows-result",
"windows-strings 0.2.0",
"windows-targets 0.52.6",
]
@@ -5571,6 +5675,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-strings"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978d65aedf914c664c510d9de43c8fd85ca745eaff1ed53edf409b479e441663"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.45.0"

View File

@@ -31,6 +31,8 @@ tauri-plugin-dialog = "2"
tauri-plugin-process = "2"
tauri-plugin-shell = "2"
tauri-plugin-http = "2"
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\"))".dependencies]
tauri-plugin-deep-link = "2"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem
@@ -42,5 +44,5 @@ custom-protocol = ["tauri/custom-protocol"]
# crate-type = ["staticlib", "cdylib", "rlib", "lib"]
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-single-instance = "2"
tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
tauri-plugin-updater = "2"

View File

@@ -9,6 +9,7 @@
"updater:default",
"process:default",
"shell:default",
"http:default"
"http:default",
"deep-link:default"
]
}

View File

@@ -68,6 +68,7 @@
"dialog:default",
"process:default",
"shell:default",
"http:default"
"http:default",
"deep-link:default"
]
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"permissions":["updater:default","process:default","shell:default","http:default"],"platforms":["macOS","windows","linux"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists",{"identifier":"fs:scope","allow":["$APPDATA","$APPDATA/*","$APPDATA/**/*","$DOWNLOAD/*","/data/**/*","$RESOURCE/*"]},"core:window:allow-maximize","core:window:allow-set-fullscreen","shell:allow-open","dialog:allow-open","dialog:allow-save","dialog:allow-message","dialog:allow-ask","dialog:allow-confirm",{"identifier":"http:default","allow":[{"url":"https://*/*"},{"url":"https://*/**/*"},{"url":"http://*/*"},{"url":"http://*/**/*"}]},"os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","process:allow-restart","core:app:allow-app-show","core:app:allow-app-hide","fs:default","os:default","dialog:default","process:default","shell:default","http:default"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"permissions":["updater:default","process:default","shell:default","http:default","deep-link:default"],"platforms":["macOS","windows","linux"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists",{"identifier":"fs:scope","allow":["$APPDATA","$APPDATA/*","$APPDATA/**/*","$DOWNLOAD/*","/data/**/*","$RESOURCE/*"]},"core:window:allow-maximize","core:window:allow-set-fullscreen","shell:allow-open","dialog:allow-open","dialog:allow-save","dialog:allow-message","dialog:allow-ask","dialog:allow-confirm",{"identifier":"http:default","allow":[{"url":"https://*/*"},{"url":"https://*/**/*"},{"url":"http://*/*"},{"url":"http://*/**/*"}]},"os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","process:allow-restart","core:app:allow-app-show","core:app:allow-app-hide","fs:default","os:default","dialog:default","process:default","shell:default","http:default","deep-link:default"]}}

View File

@@ -3474,6 +3474,51 @@
"type": "string",
"const": "core:window:deny-unminimize"
},
{
"description": "Allows reading the opened deep link via the get_current command",
"type": "string",
"const": "deep-link:default"
},
{
"description": "Enables the get_current command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-get-current"
},
{
"description": "Enables the is_registered command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-is-registered"
},
{
"description": "Enables the register command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-register"
},
{
"description": "Enables the unregister command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-unregister"
},
{
"description": "Denies the get_current command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-get-current"
},
{
"description": "Denies the is_registered command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-is-registered"
},
{
"description": "Denies the register command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-register"
},
{
"description": "Denies the unregister command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-unregister"
},
{
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n",
"type": "string",

View File

@@ -3474,6 +3474,51 @@
"type": "string",
"const": "core:window:deny-unminimize"
},
{
"description": "Allows reading the opened deep link via the get_current command",
"type": "string",
"const": "deep-link:default"
},
{
"description": "Enables the get_current command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-get-current"
},
{
"description": "Enables the is_registered command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-is-registered"
},
{
"description": "Enables the register command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-register"
},
{
"description": "Enables the unregister command without any pre-configured scope.",
"type": "string",
"const": "deep-link:allow-unregister"
},
{
"description": "Denies the get_current command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-get-current"
},
{
"description": "Denies the is_registered command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-is-registered"
},
{
"description": "Denies the register command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-register"
},
{
"description": "Denies the unregister command without any pre-configured scope.",
"type": "string",
"const": "deep-link:deny-unregister"
},
{
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n",
"type": "string",

View File

@@ -465,14 +465,16 @@ fn main() {
#[cfg(desktop)]
{
builder = builder.plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
let _ = app.get_webview_window("main")
.expect("no main window")
.set_focus();
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
}));
}
builder
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_deep_link::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_updater::Builder::new().build())

View File

@@ -40,6 +40,11 @@
"windows": {
"installMode": "passive"
}
},
"deep-link": {
"desktop": {
"schemes": ["risuailocal"]
}
}
},
"app": {

View File

@@ -16,6 +16,7 @@ import { CharXReader, CharXWriter } from "./process/processzip"
import { Capacitor } from "@capacitor/core"
import { exportModule, readModule, type RisuModule } from "./process/modules"
import { readFile } from "@tauri-apps/plugin-fs"
import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
export const hubURL = "https://sv.risuai.xyz"
@@ -445,6 +446,20 @@ export async function characterURLImport() {
}
}
if(isTauri){
await onOpenUrl((urls) => {
for(const url of urls){
const splited = url.split('/')
const id = splited[splited.length - 1]
const type = splited[splited.length - 2]
switch(type){
case 'realm':{
downloadRisuHub(id)
}
}
}
})
}
}