Skip to content

Commit 42dd103

Browse files
committed
fix: 欢迎页面最近文件路径不存在时增加报错弹窗
1 parent e1e85c6 commit 42dd103

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/src/components/welcome-page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Earth, FilePlus, FolderOpen, Info, Settings } from "lucide-react";
77
import { useEffect, useState } from "react";
88
import { useTranslation } from "react-i18next";
99
import SettingsWindow from "../sub/SettingsWindow";
10+
import { toast } from "sonner";
1011

1112
export default function WelcomePage() {
1213
const [recentFiles, setRecentFiles] = useState<RecentFileManager.RecentFile[]>([]);
@@ -54,8 +55,12 @@ export default function WelcomePage() {
5455
<div
5556
key={index}
5657
onClick={async () => {
57-
await onOpenFile(file.uri, "欢迎页面-最近打开的文件");
58-
await refresh();
58+
try {
59+
await onOpenFile(file.uri, "欢迎页面-最近打开的文件");
60+
await refresh();
61+
} catch (e) {
62+
toast.error(e as string);
63+
}
5964
}}
6065
>
6166
<span>{new Path(file.uri).nameWithoutExt}</span>

0 commit comments

Comments
 (0)