mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 22:55:48 +05:30
refactor: use different opener command for links
This commit is contained in:
@@ -15,6 +15,7 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
import { SlidingButton } from "@/components/custom/slidingButton";
|
||||
import clsx from "clsx";
|
||||
import { NumberInput } from "@/components/custom/numberInput";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
|
||||
const websocketPortSchema = z.object({
|
||||
port: z.coerce.number<number>({
|
||||
@@ -31,9 +32,9 @@ const websocketPortSchema = z.object({
|
||||
});
|
||||
|
||||
function ExtInstallSettings() {
|
||||
const openLink = async (url: string, app: string | undefined) => {
|
||||
const openLink = async (url: string, app: string | null) => {
|
||||
try {
|
||||
await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => {
|
||||
await invoke('open_link_with_app', { url: url, appName: app }).then(() => {
|
||||
toast.info("Opening link", {
|
||||
description: `Opening link with ${app ? app : 'default app'}.`,
|
||||
})
|
||||
@@ -58,7 +59,11 @@ function ExtInstallSettings() {
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'chrome')}
|
||||
onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
const currentPlatform = platform();
|
||||
openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', isFlatpak ? null : currentPlatform === "linux" ? 'google-chrome' : 'chrome');
|
||||
}}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-primary-foreground" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
@@ -75,7 +80,10 @@ function ExtInstallSettings() {
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'firefox')}
|
||||
onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', isFlatpak ? null : 'firefox');
|
||||
}}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-primary-foreground" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
@@ -87,13 +95,38 @@ function ExtInstallSettings() {
|
||||
</SlidingButton>
|
||||
</div>
|
||||
<div className="flex gap-2 mb-4">
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'msedge')}>Edge</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'opera')}>Opera</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'brave')}>Brave</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'vivaldi')}>Vivaldi</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'zen')}>Zen</Button>
|
||||
<Button variant="outline" onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', isFlatpak ? null : 'msedge');
|
||||
}}>
|
||||
Edge
|
||||
</Button>
|
||||
<Button variant="outline" onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', isFlatpak ? null : 'opera');
|
||||
}}>
|
||||
Opera
|
||||
</Button>
|
||||
<Button variant="outline" onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', isFlatpak ? null : 'brave');
|
||||
}}>
|
||||
Brave
|
||||
</Button>
|
||||
<Button variant="outline" onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', isFlatpak ? null : 'vivaldi');
|
||||
}}>
|
||||
Vivaldi
|
||||
</Button>
|
||||
<Button variant="outline" onClick={async() => {
|
||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||
openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', isFlatpak ? null : 'zen');
|
||||
}}>
|
||||
Zen
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mb-2">* These links opens with coresponding browsers only. Make sure the browser is installed before clicking the link</p>
|
||||
<p className="text-xs text-muted-foreground mb-2">* These links opens with coresponding browsers only (except on flatpak). Make sure the browser is installed before clicking the link</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user