Skip to content

Commit e8dffcd

Browse files
committed
fix: prevent access to mods page without selected version
1 parent 865a7dd commit e8dffcd

File tree

7 files changed

+49
-30
lines changed

7 files changed

+49
-30
lines changed

frontend/src/assets/locales/en_US.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@
102102
"tip": {
103103
"general": "Tip: First launch may be slow. Please wait.",
104104
"choose_version_dropdown": "Use the dropdown on the right to switch versions quickly.",
105-
"open_version_settings_gear": "Click the gear to open Version Settings; customize icon and enable isolation.",
106-
"mods_drag": "On the Mods page, drag-and-drop .zip/.dll onto the card to import.",
105+
"open_version_settings_gear": "Hover the Current Version badge and click the gear in the tooltip to open Version Settings; supports icon customization and isolation.",
107106
"mods_import_button": "Use the “Import .zip/.dll” button on the Mods card to pick files.",
108-
"mods_open_folder": "Click “Open Folder” on the Mods card to manage plugin files directly.",
107+
"mods_open_folder_requirement": "Select a version before opening the Mods folder.",
109108
"download_versions": "Install Release/Preview on the Download page; it appears in the dropdown afterward.",
110109
"content_counts_card": "The Content card shows counts of worlds, resource and behavior packs.",
111-
"file_manager_pick": "File Manager supports multi-select and returns paths to Mods import."
110+
"file_manager_pick": "File Manager supports multi-select and returns paths to Mods import.",
111+
"settings_base_root": "Settings lets you change content base path; default %LOCALAPPDATA%\\LeviLauncher.",
112+
"directory_write_check": "Save only to writable directories; non-writable directories are disabled.",
113+
"drag_import_unsupported": "Drag-and-drop import is unsupported; use Import .zip/.dll or File Manager."
112114
}
113115
},
114116
"moddedcard": {

frontend/src/assets/locales/zh_CN.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@
103103
"tip": {
104104
"general": "提示:首次启动可能较慢,请耐心等待。",
105105
"choose_version_dropdown": "右侧下拉按钮可快速切换当前版本。",
106-
"open_version_settings_gear": "点击齿轮打开“版本设置”,可更换图标并启用版本隔离。",
107-
"mods_drag": "在 Mods 页面拖拽 .zip/.dll 到卡片即可导入。",
106+
"open_version_settings_gear": "悬停“当前版本”徽章,点击气泡内齿轮打开版本设置;支持更换图标与启用版本隔离。",
108107
"mods_import_button": "点击 Mods 卡片的“导入 .zip/.dll”选择文件。",
109-
"mods_open_folder": " Mods 卡片点击“打开目录”直接管理插件文件",
108+
"mods_open_folder_requirement": "打开 Mods 目录前需先选择版本",
110109
"download_versions": "在“下载”页安装 Release/Preview,安装后出现在下拉列表。",
111110
"content_counts_card": "主页“内容管理”显示世界、资源包、行为包数量。",
112-
"file_manager_pick": "文件管理器支持多选并回传路径到 Mods 导入。"
111+
"file_manager_pick": "文件管理器支持多选并回传路径到 Mods 导入。",
112+
"settings_base_root": "设置页可修改内容存储路径,默认使用 %LOCALAPPDATA%\\LeviLauncher。",
113+
"directory_write_check": "仅可保存到可写目录;不可写目录将被禁用。",
114+
"drag_import_unsupported": "拖拽导入暂不支持,请使用“导入 .zip/.dll”或文件管理器。"
113115
}
114116
},
115117
"moddedcard": {

frontend/src/components/ModdedCard.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ export const ModCard = (args: {
1515
const [modsInfo, setModsInfo] = React.useState<Array<types.ModInfo>>([]);
1616
const [isModded, setIsModded] = React.useState<boolean>(false);
1717
useEffect(() => {
18-
let name =
18+
const name =
1919
args.localVersionMap.get(args.currentVersion)?.name.valueOf() || "";
20-
GetMods(name).then((data) => {
21-
setModsInfo(data);
22-
});
20+
if (name) {
21+
GetMods(name)
22+
.then((data) => setModsInfo(data || []))
23+
.catch(() => setModsInfo([]));
24+
} else {
25+
setModsInfo([]);
26+
}
2327

2428
setIsModded(
2529
args.localVersionMap.get(args.currentVersion)?.isPreLoader.valueOf() ||
@@ -75,10 +79,13 @@ export const ModCard = (args: {
7579
variant="light"
7680
radius="full"
7781
onPress={() => navigate("/mods")}
82+
isDisabled={!args.currentVersion}
7883
aria-label={
79-
t("moddedcard.manage", {
80-
defaultValue: "管理模组",
81-
}) as unknown as string
84+
(args.currentVersion
85+
? t("moddedcard.manage", { defaultValue: "管理模组" })
86+
: t("launcherpage.currentVersion_choose_version_aria", {
87+
defaultValue: "选择版本",
88+
})) as unknown as string
8289
}
8390
>
8491
<LuFolderPlus size={20} />

frontend/src/pages/LauncherPage.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,29 @@ export const LauncherPage = (args: any) => {
9090
t("launcherpage.tip.open_version_settings_gear", {
9191
defaultValue: "点击齿轮打开“版本设置”,可更换图标并启用版本隔离。",
9292
}) as unknown as string,
93-
t("launcherpage.tip.mods_drag", {
94-
defaultValue: "在 Mods 页面拖拽 .zip/.dll 到卡片即可导入。",
95-
}) as unknown as string,
9693
t("launcherpage.tip.mods_import_button", {
9794
defaultValue: "点击 Mods 卡片的“导入 .zip/.dll”选择文件。",
9895
}) as unknown as string,
99-
t("launcherpage.tip.mods_open_folder", {
100-
defaultValue: "在 Mods 卡片点击“打开目录”直接管理插件文件。",
96+
t("launcherpage.tip.mods_open_folder_requirement", {
97+
defaultValue: "打开 Mods 目录前需先选择版本。",
98+
}) as unknown as string,
99+
t("launcherpage.tip.file_manager_pick", {
100+
defaultValue: "文件管理器支持多选并回传路径到 Mods 导入。",
101101
}) as unknown as string,
102102
t("launcherpage.tip.download_versions", {
103103
defaultValue: "在“下载”页安装 Release/Preview,安装后出现在下拉列表。",
104104
}) as unknown as string,
105105
t("launcherpage.tip.content_counts_card", {
106106
defaultValue: "主页“内容管理”显示世界、资源包、行为包数量。",
107107
}) as unknown as string,
108-
t("launcherpage.tip.file_manager_pick", {
109-
defaultValue: "文件管理器支持多选并回传路径到 Mods 导入。",
108+
t("launcherpage.tip.settings_base_root", {
109+
defaultValue: "设置页可修改内容存储路径,默认使用 %LOCALAPPDATA%\\LeviLauncher。",
110+
}) as unknown as string,
111+
t("launcherpage.tip.directory_write_check", {
112+
defaultValue: "仅可保存到可写目录;不可写目录将被禁用。",
113+
}) as unknown as string,
114+
t("launcherpage.tip.drag_import_unsupported", {
115+
defaultValue: "拖拽导入暂不支持,请使用“导入 .zip/.dll”或文件管理器。",
110116
}) as unknown as string,
111117
t("launcherpage.tip.general", {
112118
defaultValue: "首次启动可能较慢,请耐心等待。",

frontend/src/pages/ModsPage.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ export const ModsPage: React.FC = () => {
112112

113113
useEffect(() => {
114114
const name = readCurrentVersionName();
115-
setCurrentVersionName(name);
116-
if (name) {
117-
GetMods(name)
118-
.then((data) => setModsInfo(data || []))
119-
.catch(() => setModsInfo([]));
115+
if (!name) {
116+
navigate("/versions", { replace: true });
117+
return;
120118
}
119+
setCurrentVersionName(name);
120+
GetMods(name)
121+
.then((data) => setModsInfo(data || []))
122+
.catch(() => setModsInfo([]));
121123
}, []);
122124

123125
const resolveImportError = (err: string): string => {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/mouuff/go-rocket-update v1.5.6
7-
github.com/wailsapp/wails/v3 v3.0.0-alpha.39
7+
github.com/wailsapp/wails/v3 v3.0.0-alpha.40
88
)
99

1010
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6N
114114
github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
115115
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
116116
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
117-
github.com/wailsapp/wails/v3 v3.0.0-alpha.39 h1:Hql2h1I6gal0fsyMn1MKrfmbhSq0Q+f7EcUf68M2w78=
118-
github.com/wailsapp/wails/v3 v3.0.0-alpha.39/go.mod h1:7i8tSuA74q97zZ5qEJlcVZdnO+IR7LT2KU8UpzYMPsw=
117+
github.com/wailsapp/wails/v3 v3.0.0-alpha.40 h1:LY0hngVwihlSXveshL5LM8ivjLTHAN6VDjOSF6szI9k=
118+
github.com/wailsapp/wails/v3 v3.0.0-alpha.40/go.mod h1:7i8tSuA74q97zZ5qEJlcVZdnO+IR7LT2KU8UpzYMPsw=
119119
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
120120
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
121121
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

0 commit comments

Comments
 (0)