diff --git a/package.json b/package.json index d8f86f85..a123eccc 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "@tauri-apps/api": "2.8.0", "@tauri-apps/plugin-dialog": "2.4.0", + "@tauri-apps/plugin-opener": "~2.5.0", "@tauri-apps/plugin-shell": "2.3.1", "jquery": "^3.7.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eabc4be1..88e578be 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@tauri-apps/plugin-dialog': specifier: 2.4.0 version: 2.4.0 + '@tauri-apps/plugin-opener': + specifier: ~2.5.0 + version: 2.5.0 '@tauri-apps/plugin-shell': specifier: 2.3.1 version: 2.3.1 @@ -447,6 +450,9 @@ packages: '@tauri-apps/plugin-dialog@2.4.0': resolution: {integrity: sha512-OvXkrEBfWwtd8tzVCEXIvRfNEX87qs2jv6SqmVPiHcJjBhSF/GUvjqUNIDmKByb5N8nvDqVUM7+g1sXwdC/S9w==} + '@tauri-apps/plugin-opener@2.5.0': + resolution: {integrity: sha512-B0LShOYae4CZjN8leiNDbnfjSrTwoZakqKaWpfoH6nXiJwt6Rgj6RnVIffG3DoJiKsffRhMkjmBV9VeilSb4TA==} + '@tauri-apps/plugin-shell@2.3.1': resolution: {integrity: sha512-jjs2WGDO/9z2pjNlydY/F5yYhNsscv99K5lCmU5uKjsVvQ3dRlDhhtVYoa4OLDmktLtQvgvbQjCFibMl6tgGfw==} @@ -1233,6 +1239,10 @@ snapshots: dependencies: '@tauri-apps/api': 2.8.0 + '@tauri-apps/plugin-opener@2.5.0': + dependencies: + '@tauri-apps/api': 2.8.0 + '@tauri-apps/plugin-shell@2.3.1': dependencies: '@tauri-apps/api': 2.8.0 diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 2337b0a4..cc4b0f80 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -10,6 +10,23 @@ "shell:allow-open", "dialog:default", "shell:allow-execute", - "shell:allow-spawn" + "shell:allow-spawn", + "opener:allow-open-path", + { + "identifier": "opener:allow-open-path", + "allow": [ + { + "path": "**" + } + ] + }, + { + "identifier": "opener:allow-open-url", + "allow": [ + { + "url": "**" + } + ] + } ] } \ No newline at end of file diff --git a/src/ts/main.ts b/src/ts/main.ts index a069fe14..9dc8ecce 100644 --- a/src/ts/main.ts +++ b/src/ts/main.ts @@ -1,7 +1,7 @@ import $ from "jquery"; import {invoke} from "@tauri-apps/api/core"; import {open as openDialog} from "@tauri-apps/plugin-dialog"; -import {open as openShell} from "@tauri-apps/plugin-shell"; +import {openPath, openUrl} from '@tauri-apps/plugin-opener'; import {listen} from "@tauri-apps/api/event"; function setLoader(state: boolean) { @@ -103,7 +103,7 @@ $(async () => { console.log(`Checking path: ${downloadDirectory}`); if (downloadDirectory != null) { - await openShell(downloadDirectory); + await openPath(downloadDirectory); } else { $("#checkpath").prop("ariaDisabled", true); } @@ -176,7 +176,7 @@ $(async () => { }); $("#opium-btn").on("click", () => { - openShell("https://aphex.cc"); + openUrl("https://l.aphex.cc/index.html"); }); diff --git a/src/ts/preload.ts b/src/ts/preload.ts index 6ecb3ab0..1a37e92c 100644 --- a/src/ts/preload.ts +++ b/src/ts/preload.ts @@ -1,7 +1,7 @@ import {message} from "@tauri-apps/plugin-dialog"; import {invoke} from "@tauri-apps/api/core"; -import {open} from "@tauri-apps/plugin-shell"; import $ from "jquery"; +import {openUrl} from "@tauri-apps/plugin-opener"; $(async () => { @@ -15,20 +15,20 @@ $(async () => { } /* eslint-enable indent */ - //discord + // discord $("#smbtn1").on("click", () => { - open("https://discord.com/invite/3qCt4DT5qe"); + openUrl("https://discord.com/invite/3qCt4DT5qe"); }); // steamdb $("#smbtn2").on("click", () => { - open("https://steamdb.info/instantsearch"); + openUrl("https://steamdb.info/instantsearch"); }); // donate $("#smbtn3").on("click", () => { - open("https://paypal.me/onderkin"); + openUrl("https://paypal.me/onderkin"); }); // tutorial $("#smbtn4").on("click", () => { - open("https://youtube.com/playlist?list=PLRAjc5plLScj967hnsYX-I3Vjw9C1v7Ca"); + openUrl("https://youtube.com/playlist?list=PLRAjc5plLScj967hnsYX-I3Vjw9C1v7Ca"); }); }); \ No newline at end of file diff --git a/src/ts/settings.ts b/src/ts/settings.ts index c059a90e..bd24356c 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -1,6 +1,6 @@ import {getVersion} from "@tauri-apps/api/app"; -import {open} from "@tauri-apps/plugin-shell"; import $ from "jquery"; +import {openUrl} from "@tauri-apps/plugin-opener"; $(async () => { @@ -34,7 +34,7 @@ $(async () => { console.log(await getVersion()); $("#version-info").on("click", async () => { - await open(`https://github.com/mmvanheusden/SteamDepotDownloaderGUI/releases/v${await getVersion()}`); + await openUrl(`https://github.com/mmvanheusden/SteamDepotDownloaderGUI/releases/v${await getVersion()}`); }); });