Skip to content

Commit 56145ac

Browse files
committed
perf: update toast
1 parent c017a59 commit 56145ac

4 files changed

Lines changed: 42 additions & 10 deletions

File tree

ui/app.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export default defineAppConfig({
4444
},
4545
toast: {
4646
slots: {
47-
description: "text-sm text-muted whitespace-pre-wrap break-all"
47+
title: "select-text",
48+
description: "text-sm text-muted whitespace-pre-wrap break-all select-text"
4849
}
4950
},
5051
formField: {

ui/components/SettingItems/settingItems.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ function getImageByName(filename: string): string | undefined {
8383
}
8484
8585
const showExecutableNotFoundToast = () => {
86-
const description = t("Setting.ExecutableNotFound");
86+
const path = props.item?.path?.trim?.() || "";
87+
const description = path ? `${t("Setting.ExecutableNotFound")}\n${path}` : t("Setting.ExecutableNotFound");
8788
toast.add({
8889
title: t("Setting.EnableFailed"),
8990
description,

ui/composables/useApplicationConfig.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export const useApplicationConfig = () => {
1515
);
1616
};
1717

18+
const formatExecutableNotFound = (raw: string) => {
19+
const path = raw.replace(/^\s*executable not found:\s*/i, "").trim();
20+
return path ? `${t("Setting.ExecutableNotFound")}\n${path}` : t("Setting.ExecutableNotFound");
21+
};
22+
1823
const getConfig = async () => {
1924
const config = await useTauriCoreInvoke("get_config");
2025

@@ -59,7 +64,7 @@ export const useApplicationConfig = () => {
5964
} catch (error) {
6065
const message = String(error ?? "");
6166
const description = message.toLowerCase().includes("executable not found")
62-
? t("Setting.ExecutableNotFound")
67+
? formatExecutableNotFound(message)
6368
: message || t("Common.OperationFailed");
6469

6570
toast.add({

ui/composables/useAssetAction.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,27 +630,52 @@ export const useAssetAction = () => {
630630
const payload = event.payload as eventPayload;
631631
const raw = payload.error || "";
632632
const lower = raw.toLowerCase();
633+
const extractClientPath = () => {
634+
const selectedPathToken = "selected path:";
635+
const selectedPathStart = lower.indexOf(selectedPathToken);
636+
if (selectedPathStart >= 0) {
637+
const valueStart = selectedPathStart + selectedPathToken.length;
638+
const reasonStart = lower.indexOf(", reason:", valueStart);
639+
const closeStart = lower.indexOf(")", valueStart);
640+
const valueEnd = reasonStart >= 0 ? reasonStart : closeStart >= 0 ? closeStart : raw.length;
641+
const path = raw.slice(valueStart, valueEnd).trim();
642+
if (path) return path;
643+
}
644+
645+
const executableToken = "executable not found:";
646+
const executableStart = lower.indexOf(executableToken);
647+
if (executableStart >= 0) {
648+
const path = raw.slice(executableStart + executableToken.length).trim();
649+
if (path) return path;
650+
}
651+
652+
return "";
653+
};
654+
const withPath = (base: string) => {
655+
const path = extractClientPath();
656+
return path ? `${base}\n${path}` : base;
657+
};
633658

634659
let description = raw || t("ConnectError.ConnectFailed");
635660

636661
if (lower.includes("executable not found")) {
637-
description = t("Setting.ExecutableNotFound");
662+
description = withPath(t("Setting.ExecutableNotFound"));
638663
} else if (lower.includes("failed to launch client")) {
639664
description = t("ConnectError.ClientLaunchFailed");
640665
} else if (lower.includes("client process exited")) {
641666
description = t("ConnectError.ClientExited");
642667
} else if (lower.includes("no rdp application")) {
643-
description = t("ConnectError.RdpAppMissing");
668+
description = withPath(t("ConnectError.RdpAppMissing"));
644669
} else if (lower.includes("no vnc application")) {
645-
description = t("ConnectError.VncAppMissing");
670+
description = withPath(t("ConnectError.VncAppMissing"));
646671
} else if (lower.includes("no database application")) {
647-
description = t("ConnectError.DbAppMissing");
672+
description = withPath(t("ConnectError.DbAppMissing"));
648673
} else if (lower.includes("failed to execute rdp application")) {
649-
description = t("ConnectError.RdpAppFailed");
674+
description = withPath(t("ConnectError.RdpAppFailed"));
650675
} else if (lower.includes("failed to execute vnc application")) {
651-
description = t("ConnectError.VncAppFailed");
676+
description = withPath(t("ConnectError.VncAppFailed"));
652677
} else if (lower.includes("failed to execute database application")) {
653-
description = t("ConnectError.DbAppFailed");
678+
description = withPath(t("ConnectError.DbAppFailed"));
654679
}
655680

656681
toast.add({

0 commit comments

Comments
 (0)