mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-08 08:48:11 +08:00
♻️ 姑且没登录的功能都给试了下
This commit is contained in:
87
src-tauri/Cargo.lock
generated
87
src-tauri/Cargo.lock
generated
@@ -18,6 +18,8 @@ dependencies = [
|
||||
"tauri-plugin-http",
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-process",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-sql",
|
||||
"tauri-utils",
|
||||
"url",
|
||||
@@ -2242,6 +2244,25 @@ version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
|
||||
|
||||
[[package]]
|
||||
name = "is-docker"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-wsl"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
|
||||
dependencies = [
|
||||
"is-docker",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
@@ -2921,6 +2942,17 @@ version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "5.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d2c909a3fce3bd80efef4cd1c6c056bd9376a8fe06fcfdbebaf32cb485a7e37"
|
||||
dependencies = [
|
||||
"is-wsl",
|
||||
"libc",
|
||||
"pathdiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
@@ -2958,6 +2990,16 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_pipe"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
@@ -3024,6 +3066,12 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "0.7.0"
|
||||
@@ -4155,6 +4203,16 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_child"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
@@ -4977,6 +5035,35 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-process"
|
||||
version = "2.0.0-beta.7"
|
||||
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#8f6d341e45865c852170e8bbf2c8ffa9aca907d6"
|
||||
dependencies = [
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-shell"
|
||||
version = "2.0.0-beta.8"
|
||||
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#8f6d341e45865c852170e8bbf2c8ffa9aca907d6"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"log",
|
||||
"open",
|
||||
"os_pipe",
|
||||
"regex",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shared_child",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-sql"
|
||||
version = "2.0.0-beta.8"
|
||||
|
||||
@@ -41,6 +41,7 @@ branch = "v2"
|
||||
[dependencies.tauri-plugin-http]
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
branch = "v2"
|
||||
features = ["unsafe-headers"]
|
||||
|
||||
# log 插件
|
||||
[dependencies.tauri-plugin-log]
|
||||
@@ -52,6 +53,16 @@ branch = "v2"
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
branch = "v2"
|
||||
|
||||
# process 插件
|
||||
[dependencies.tauri-plugin-process]
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
branch = "v2"
|
||||
|
||||
# shell 插件
|
||||
[dependencies.tauri-plugin-shell]
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
branch = "v2"
|
||||
|
||||
# sqlite 插件
|
||||
[dependencies.tauri-plugin-sql]
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"identifier": "Mys",
|
||||
"description": "Capability for the mys client window",
|
||||
"windows": ["mhy_client"],
|
||||
"permissions": [],
|
||||
"permissions": ["event:allow-emit"],
|
||||
"remote": {
|
||||
"urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*"]
|
||||
},
|
||||
|
||||
37
src-tauri/capabilities/SubWindow.json
Normal file
37
src-tauri/capabilities/SubWindow.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "./schemas/desktop-schema.json",
|
||||
"identifier": "SubWindow",
|
||||
"description": "Capability for the sub window",
|
||||
"windows": ["Sub_window"],
|
||||
"permissions": [
|
||||
"app:allow-version",
|
||||
"app:default",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"http:allow-fetch",
|
||||
"log:allow-log",
|
||||
"log:default",
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"sql:allow-load",
|
||||
"sql:allow-execute",
|
||||
"sql:default",
|
||||
"window:allow-close",
|
||||
"window:allow-destroy",
|
||||
"window:allow-set-title",
|
||||
"window:allow-set-fullscreen",
|
||||
"window:allow-show",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [
|
||||
{
|
||||
"url": "https://*.miyoushe.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://*.mihoyo.com/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"platforms": ["windows", "macOS"]
|
||||
}
|
||||
@@ -4,19 +4,32 @@
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["TeyvatGuide"],
|
||||
"permissions": [
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"app:allow-version",
|
||||
"app:default",
|
||||
"window:allow-set-title",
|
||||
"sql:allow-load",
|
||||
"sql:default",
|
||||
"sql:allow-execute",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"fs:allow-remove",
|
||||
"fs:default",
|
||||
"fs:scope-cache-recursive",
|
||||
"fs:scope-document-recursive",
|
||||
"http:allow-fetch",
|
||||
"log:allow-log",
|
||||
"log:default",
|
||||
"http:allow-fetch",
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"process:allow-exit",
|
||||
"process:allow-restart",
|
||||
"process:default",
|
||||
"shell:allow-execute",
|
||||
"shell:allow-open",
|
||||
"shell:default",
|
||||
"sql:allow-load",
|
||||
"sql:allow-execute",
|
||||
"sql:default",
|
||||
"window:allow-close",
|
||||
"window:allow-destroy",
|
||||
"window:allow-set-title",
|
||||
"window:allow-show",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [
|
||||
@@ -25,8 +38,27 @@
|
||||
},
|
||||
{
|
||||
"url": "https://*.mihoyo.com/*"
|
||||
},
|
||||
{
|
||||
"url": "https://homa.snapgenshin.com/*"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{
|
||||
"name": "win_open",
|
||||
"cmd": "explorer",
|
||||
"args": true
|
||||
},
|
||||
{
|
||||
"name": "mac_open",
|
||||
"cmd": "open",
|
||||
"args": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"platforms": ["windows", "macOS"]
|
||||
}
|
||||
|
||||
@@ -2466,6 +2466,37 @@
|
||||
"permission_sets": {},
|
||||
"global_scope_schema": null
|
||||
},
|
||||
"process": {
|
||||
"default_permission": {
|
||||
"identifier": "default",
|
||||
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
|
||||
"permissions": ["allow-exit", "allow-restart"]
|
||||
},
|
||||
"permissions": {
|
||||
"allow-exit": {
|
||||
"identifier": "allow-exit",
|
||||
"description": "Enables the exit command without any pre-configured scope.",
|
||||
"commands": { "allow": ["exit"], "deny": [] }
|
||||
},
|
||||
"allow-restart": {
|
||||
"identifier": "allow-restart",
|
||||
"description": "Enables the restart command without any pre-configured scope.",
|
||||
"commands": { "allow": ["restart"], "deny": [] }
|
||||
},
|
||||
"deny-exit": {
|
||||
"identifier": "deny-exit",
|
||||
"description": "Denies the exit command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["exit"] }
|
||||
},
|
||||
"deny-restart": {
|
||||
"identifier": "deny-restart",
|
||||
"description": "Denies the restart command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["restart"] }
|
||||
}
|
||||
},
|
||||
"permission_sets": {},
|
||||
"global_scope_schema": null
|
||||
},
|
||||
"resources": {
|
||||
"default_permission": {
|
||||
"identifier": "default",
|
||||
@@ -2487,6 +2518,125 @@
|
||||
"permission_sets": {},
|
||||
"global_scope_schema": null
|
||||
},
|
||||
"shell": {
|
||||
"default_permission": {
|
||||
"identifier": "default",
|
||||
"description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
|
||||
"permissions": ["allow-open"]
|
||||
},
|
||||
"permissions": {
|
||||
"allow-execute": {
|
||||
"identifier": "allow-execute",
|
||||
"description": "Enables the execute command without any pre-configured scope.",
|
||||
"commands": { "allow": ["execute"], "deny": [] }
|
||||
},
|
||||
"allow-kill": {
|
||||
"identifier": "allow-kill",
|
||||
"description": "Enables the kill command without any pre-configured scope.",
|
||||
"commands": { "allow": ["kill"], "deny": [] }
|
||||
},
|
||||
"allow-open": {
|
||||
"identifier": "allow-open",
|
||||
"description": "Enables the open command without any pre-configured scope.",
|
||||
"commands": { "allow": ["open"], "deny": [] }
|
||||
},
|
||||
"allow-spawn": {
|
||||
"identifier": "allow-spawn",
|
||||
"description": "Enables the spawn command without any pre-configured scope.",
|
||||
"commands": { "allow": ["spawn"], "deny": [] }
|
||||
},
|
||||
"allow-stdin-write": {
|
||||
"identifier": "allow-stdin-write",
|
||||
"description": "Enables the stdin_write command without any pre-configured scope.",
|
||||
"commands": { "allow": ["stdin_write"], "deny": [] }
|
||||
},
|
||||
"deny-execute": {
|
||||
"identifier": "deny-execute",
|
||||
"description": "Denies the execute command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["execute"] }
|
||||
},
|
||||
"deny-kill": {
|
||||
"identifier": "deny-kill",
|
||||
"description": "Denies the kill command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["kill"] }
|
||||
},
|
||||
"deny-open": {
|
||||
"identifier": "deny-open",
|
||||
"description": "Denies the open command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["open"] }
|
||||
},
|
||||
"deny-spawn": {
|
||||
"identifier": "deny-spawn",
|
||||
"description": "Denies the spawn command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["spawn"] }
|
||||
},
|
||||
"deny-stdin-write": {
|
||||
"identifier": "deny-stdin-write",
|
||||
"description": "Denies the stdin_write command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["stdin_write"] }
|
||||
}
|
||||
},
|
||||
"permission_sets": {},
|
||||
"global_scope_schema": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"ShellAllowedArg": {
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A non-configurable argument that is passed to the command in the order it was specified.",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"description": "A variable that is set while calling the command from the webview API.",
|
||||
"properties": {
|
||||
"validator": {
|
||||
"description": "[regex] validator to require passed values to conform to an expected input.\n\nThis will require the argument value passed to this variable to match the `validator` regex before it will be executed.\n\n[regex]: https://docs.rs/regex/latest/regex/#syntax",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["validator"],
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"description": "A command argument allowed to be executed by the webview API."
|
||||
},
|
||||
"ShellAllowedArgs": {
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Use a simple boolean to allow all or disable all arguments to this command configuration.",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "A specific set of [`ShellAllowedArg`] that are valid to call for the command configuration.",
|
||||
"items": { "$ref": "#/definitions/ShellAllowedArg" },
|
||||
"type": "array"
|
||||
}
|
||||
],
|
||||
"description": "A set of command arguments allowed to be executed by the webview API.\n\nA value of `true` will allow any arguments to be passed to the command. `false` will disable all arguments. A list of [`ShellAllowedArg`] will set those arguments as the only valid arguments to be passed to the attached command configuration."
|
||||
}
|
||||
},
|
||||
"description": "A command allowed to be executed by the webview API.",
|
||||
"properties": {
|
||||
"args": {
|
||||
"allOf": [{ "$ref": "#/definitions/ShellAllowedArgs" }],
|
||||
"description": "The allowed arguments for the command execution."
|
||||
},
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.",
|
||||
"type": "string"
|
||||
},
|
||||
"sidecar": { "description": "If this command is a sidecar command.", "type": "boolean" }
|
||||
},
|
||||
"required": ["args", "cmd", "name", "sidecar"],
|
||||
"title": "Entry",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"sql": {
|
||||
"default_permission": {
|
||||
"identifier": "default",
|
||||
|
||||
@@ -5,7 +5,37 @@
|
||||
"remote": { "urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*"] },
|
||||
"local": true,
|
||||
"windows": ["mhy_client"],
|
||||
"permissions": [],
|
||||
"permissions": ["event:allow-emit"],
|
||||
"platforms": ["windows", "macOS"]
|
||||
},
|
||||
"SubWindow": {
|
||||
"identifier": "SubWindow",
|
||||
"description": "Capability for the sub window",
|
||||
"local": true,
|
||||
"windows": ["Sub_window"],
|
||||
"permissions": [
|
||||
"app:allow-version",
|
||||
"app:default",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"http:allow-fetch",
|
||||
"log:allow-log",
|
||||
"log:default",
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"sql:allow-load",
|
||||
"sql:allow-execute",
|
||||
"sql:default",
|
||||
"window:allow-close",
|
||||
"window:allow-destroy",
|
||||
"window:allow-set-title",
|
||||
"window:allow-set-fullscreen",
|
||||
"window:allow-show",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [{ "url": "https://*.miyoushe.com/*" }, { "url": "https://*.mihoyo.com/*" }]
|
||||
}
|
||||
],
|
||||
"platforms": ["windows", "macOS"]
|
||||
},
|
||||
"TeyvatGuide": {
|
||||
@@ -14,23 +44,48 @@
|
||||
"local": true,
|
||||
"windows": ["TeyvatGuide"],
|
||||
"permissions": [
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"app:allow-version",
|
||||
"app:default",
|
||||
"window:allow-set-title",
|
||||
"sql:allow-load",
|
||||
"sql:default",
|
||||
"sql:allow-execute",
|
||||
"event:allow-listen",
|
||||
"event:default",
|
||||
"fs:allow-remove",
|
||||
"fs:default",
|
||||
"fs:scope-cache-recursive",
|
||||
"fs:scope-document-recursive",
|
||||
"http:allow-fetch",
|
||||
"log:allow-log",
|
||||
"log:default",
|
||||
"http:allow-fetch",
|
||||
"path:allow-resolve-directory",
|
||||
"path:default",
|
||||
"process:allow-exit",
|
||||
"process:allow-restart",
|
||||
"process:default",
|
||||
"shell:allow-execute",
|
||||
"shell:allow-open",
|
||||
"shell:default",
|
||||
"sql:allow-load",
|
||||
"sql:allow-execute",
|
||||
"sql:default",
|
||||
"window:allow-close",
|
||||
"window:allow-destroy",
|
||||
"window:allow-set-title",
|
||||
"window:allow-show",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [{ "url": "https://*.miyoushe.com/*" }, { "url": "https://*.mihoyo.com/*" }]
|
||||
"allow": [
|
||||
{ "url": "https://*.miyoushe.com/*" },
|
||||
{ "url": "https://*.mihoyo.com/*" },
|
||||
{ "url": "https://homa.snapgenshin.com/*" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{ "args": true, "cmd": "explorer", "name": "win_open" },
|
||||
{ "args": true, "cmd": "open", "name": "mac_open" }
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"platforms": ["windows", "macOS"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1706,6 +1706,131 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["identifier"],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
|
||||
"type": "string",
|
||||
"enum": ["shell:default"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-open -> Enables the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-spawn -> Enables the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-open -> Denies the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-spawn -> Denies the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-stdin-write"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"allow": {
|
||||
"items": {
|
||||
"title": "Entry",
|
||||
"description": "A command allowed to be executed by the webview API.",
|
||||
"type": "object",
|
||||
"required": ["args", "cmd", "name", "sidecar"],
|
||||
"properties": {
|
||||
"args": {
|
||||
"description": "The allowed arguments for the command execution.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ShellAllowedArgs"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.",
|
||||
"type": "string"
|
||||
},
|
||||
"sidecar": {
|
||||
"description": "If this command is a sidecar command.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"items": {
|
||||
"title": "Entry",
|
||||
"description": "A command allowed to be executed by the webview API.",
|
||||
"type": "object",
|
||||
"required": ["args", "cmd", "name", "sidecar"],
|
||||
"properties": {
|
||||
"args": {
|
||||
"description": "The allowed arguments for the command execution.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ShellAllowedArgs"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.",
|
||||
"type": "string"
|
||||
},
|
||||
"sidecar": {
|
||||
"description": "If this command is a sidecar command.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -3863,6 +3988,31 @@
|
||||
"type": "string",
|
||||
"enum": ["path:deny-resolve-directory"]
|
||||
},
|
||||
{
|
||||
"description": "process:default -> This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
|
||||
"type": "string",
|
||||
"enum": ["process:default"]
|
||||
},
|
||||
{
|
||||
"description": "process:allow-exit -> Enables the exit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:allow-exit"]
|
||||
},
|
||||
{
|
||||
"description": "process:allow-restart -> Enables the restart command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:allow-restart"]
|
||||
},
|
||||
{
|
||||
"description": "process:deny-exit -> Denies the exit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:deny-exit"]
|
||||
},
|
||||
{
|
||||
"description": "process:deny-restart -> Denies the restart command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:deny-restart"]
|
||||
},
|
||||
{
|
||||
"description": "resources:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
@@ -3878,6 +4028,61 @@
|
||||
"type": "string",
|
||||
"enum": ["resources:deny-close"]
|
||||
},
|
||||
{
|
||||
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
|
||||
"type": "string",
|
||||
"enum": ["shell:default"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-open -> Enables the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-spawn -> Enables the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-open -> Denies the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-spawn -> Denies the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "sql:default -> # Tauri SQL Default Permissions\n\nThis permission set configures what kind of\ndatabase operations are available from the sql plugin.\n\n### Granted Permissions\n\nAll reading related operations are enabled.\nAlso allows to load or close a connection.\n\n",
|
||||
"type": "string",
|
||||
@@ -4883,6 +5088,43 @@
|
||||
"enum": ["iOS"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ShellAllowedArg": {
|
||||
"description": "A command argument allowed to be executed by the webview API.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A non-configurable argument that is passed to the command in the order it was specified.",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "A variable that is set while calling the command from the webview API.",
|
||||
"type": "object",
|
||||
"required": ["validator"],
|
||||
"properties": {
|
||||
"validator": {
|
||||
"description": "[regex] validator to require passed values to conform to an expected input.\n\nThis will require the argument value passed to this variable to match the `validator` regex before it will be executed.\n\n[regex]: https://docs.rs/regex/latest/regex/#syntax",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"ShellAllowedArgs": {
|
||||
"description": "A set of command arguments allowed to be executed by the webview API.\n\nA value of `true` will allow any arguments to be passed to the command. `false` will disable all arguments. A list of [`ShellAllowedArg`] will set those arguments as the only valid arguments to be passed to the attached command configuration.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Use a simple boolean to allow all or disable all arguments to this command configuration.",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "A specific set of [`ShellAllowedArg`] that are valid to call for the command configuration.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ShellAllowedArg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1706,6 +1706,131 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["identifier"],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
|
||||
"type": "string",
|
||||
"enum": ["shell:default"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-open -> Enables the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-spawn -> Enables the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-open -> Denies the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-spawn -> Denies the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-stdin-write"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"allow": {
|
||||
"items": {
|
||||
"title": "Entry",
|
||||
"description": "A command allowed to be executed by the webview API.",
|
||||
"type": "object",
|
||||
"required": ["args", "cmd", "name", "sidecar"],
|
||||
"properties": {
|
||||
"args": {
|
||||
"description": "The allowed arguments for the command execution.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ShellAllowedArgs"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.",
|
||||
"type": "string"
|
||||
},
|
||||
"sidecar": {
|
||||
"description": "If this command is a sidecar command.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"items": {
|
||||
"title": "Entry",
|
||||
"description": "A command allowed to be executed by the webview API.",
|
||||
"type": "object",
|
||||
"required": ["args", "cmd", "name", "sidecar"],
|
||||
"properties": {
|
||||
"args": {
|
||||
"description": "The allowed arguments for the command execution.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ShellAllowedArgs"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.",
|
||||
"type": "string"
|
||||
},
|
||||
"sidecar": {
|
||||
"description": "If this command is a sidecar command.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -3863,6 +3988,31 @@
|
||||
"type": "string",
|
||||
"enum": ["path:deny-resolve-directory"]
|
||||
},
|
||||
{
|
||||
"description": "process:default -> This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
|
||||
"type": "string",
|
||||
"enum": ["process:default"]
|
||||
},
|
||||
{
|
||||
"description": "process:allow-exit -> Enables the exit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:allow-exit"]
|
||||
},
|
||||
{
|
||||
"description": "process:allow-restart -> Enables the restart command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:allow-restart"]
|
||||
},
|
||||
{
|
||||
"description": "process:deny-exit -> Denies the exit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:deny-exit"]
|
||||
},
|
||||
{
|
||||
"description": "process:deny-restart -> Denies the restart command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["process:deny-restart"]
|
||||
},
|
||||
{
|
||||
"description": "resources:default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
@@ -3878,6 +4028,61 @@
|
||||
"type": "string",
|
||||
"enum": ["resources:deny-close"]
|
||||
},
|
||||
{
|
||||
"description": "shell:default -> This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
|
||||
"type": "string",
|
||||
"enum": ["shell:default"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-open -> Enables the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-spawn -> Enables the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:allow-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-execute"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-kill"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-open -> Denies the open command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-open"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-spawn -> Denies the spawn command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-spawn"]
|
||||
},
|
||||
{
|
||||
"description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["shell:deny-stdin-write"]
|
||||
},
|
||||
{
|
||||
"description": "sql:default -> # Tauri SQL Default Permissions\n\nThis permission set configures what kind of\ndatabase operations are available from the sql plugin.\n\n### Granted Permissions\n\nAll reading related operations are enabled.\nAlso allows to load or close a connection.\n\n",
|
||||
"type": "string",
|
||||
@@ -4883,6 +5088,43 @@
|
||||
"enum": ["iOS"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ShellAllowedArg": {
|
||||
"description": "A command argument allowed to be executed by the webview API.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "A non-configurable argument that is passed to the command in the order it was specified.",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "A variable that is set while calling the command from the webview API.",
|
||||
"type": "object",
|
||||
"required": ["validator"],
|
||||
"properties": {
|
||||
"validator": {
|
||||
"description": "[regex] validator to require passed values to conform to an expected input.\n\nThis will require the argument value passed to this variable to match the `validator` regex before it will be executed.\n\n[regex]: https://docs.rs/regex/latest/regex/#syntax",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"ShellAllowedArgs": {
|
||||
"description": "A set of command arguments allowed to be executed by the webview API.\n\nA value of `true` will allow any arguments to be passed to the command. `false` will disable all arguments. A list of [`ShellAllowedArg`] will set those arguments as the only valid arguments to be passed to the attached command configuration.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Use a simple boolean to allow all or disable all arguments to this command configuration.",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "A specific set of [`ShellAllowedArg`] that are valid to call for the command configuration.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ShellAllowedArg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! @since Beta v0.5.0
|
||||
|
||||
use tauri::{AppHandle, Manager, WebviewWindowBuilder};
|
||||
use tauri_utils::config::WindowConfig;
|
||||
use tauri_utils::config::{WebviewUrl, WindowConfig};
|
||||
|
||||
// 放一个常数,用来判断应用是否初始化
|
||||
static mut APP_INITIALIZED: bool = false;
|
||||
@@ -20,7 +20,7 @@ pub async fn init_app(app_handle: AppHandle) {
|
||||
let _mhy = app_handle.get_webview_window("mhy_client");
|
||||
if _mhy.is_some() {
|
||||
// todo 这里应该延时,否则可能造成 macOS 平台的崩溃
|
||||
// _mhy.unwrap().close().unwrap();
|
||||
_mhy.unwrap().destroy().unwrap();
|
||||
}
|
||||
app_handle.emit("initApp", ()).unwrap();
|
||||
unsafe {
|
||||
@@ -30,17 +30,27 @@ pub async fn init_app(app_handle: AppHandle) {
|
||||
|
||||
// 创建窗口
|
||||
#[tauri::command]
|
||||
pub async fn create_window(app_handle: tauri::AppHandle, label: String, mut option: WindowConfig) {
|
||||
let window_old = app_handle.get_webview_window(&label);
|
||||
option.label = label.clone();
|
||||
if window_old.is_some() {
|
||||
dbg!("window exists");
|
||||
window_old.unwrap().close().unwrap();
|
||||
pub async fn create_window(
|
||||
app_handle: AppHandle,
|
||||
label: String,
|
||||
url: String,
|
||||
option: WindowConfig,
|
||||
) {
|
||||
let window_find = app_handle.get_webview_window(&label);
|
||||
if window_find.is_some() {
|
||||
let window = window_find.unwrap();
|
||||
window.destroy().unwrap();
|
||||
return;
|
||||
}
|
||||
let window_new =
|
||||
Some(WebviewWindowBuilder::from_config(&app_handle, &option).expect("failed to create window"));
|
||||
window_new.unwrap();
|
||||
let url_parse = WebviewUrl::App(url.parse().unwrap());
|
||||
WebviewWindowBuilder::new(&app_handle, &label, url_parse)
|
||||
.inner_size(option.width, option.height)
|
||||
.resizable(option.resizable)
|
||||
.visible(option.visible)
|
||||
.title(option.title)
|
||||
.center()
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// 执行 js
|
||||
|
||||
@@ -22,11 +22,11 @@ fn window_event_handler(app: &tauri::Window, event: &tauri::WindowEvent) {
|
||||
for label in SUB_WINDOW_LABELS.iter() {
|
||||
let sub = app.get_webview_window(label);
|
||||
if sub.is_some() {
|
||||
sub.unwrap().close().unwrap();
|
||||
sub.unwrap().destroy().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
app.close().unwrap();
|
||||
app.destroy().unwrap();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -36,10 +36,12 @@ fn main() {
|
||||
tauri::Builder::default()
|
||||
.on_window_event(move |app, event| window_event_handler(app, event))
|
||||
.plugin(tauri_plugin_deep_link::init())
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(plugins::build_sql_plugin())
|
||||
.plugin(plugins::build_log_plugin())
|
||||
.setup(|_app| {
|
||||
|
||||
@@ -62,13 +62,13 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"capabilities": ["TeyvatGuide", "Mys"]
|
||||
"capabilities": ["TeyvatGuide", "Mys", "SubWindow"]
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"deep-link": {
|
||||
"desktop": {
|
||||
"schemes": ["teyvatguide"]
|
||||
"schemes": ["teyvatguide", "test"]
|
||||
},
|
||||
"mobile": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user