Skip to content

改善启动脚本导出#5906

Merged
Glavo merged 10 commits intoHMCL-dev:mainfrom
WhatDamon:export
Apr 18, 2026
Merged

改善启动脚本导出#5906
Glavo merged 10 commits intoHMCL-dev:mainfrom
WhatDamon:export

Conversation

@WhatDamon
Copy link
Copy Markdown
Contributor

@WhatDamon WhatDamon commented Apr 4, 2026

Resolve #5200

下图已过期,对话框已删除

当无法判断应该导出什么格式的启动脚本时,直接基于操作系统添加合适的后缀

同时把 bash 这个后缀也纳入了可通过检测确定文件后缀的范围

@WhatDamon
Copy link
Copy Markdown
Contributor Author

CC @3gf8jv4dv 或许需要检查本地化文件

Comment thread HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 4, 2026

我觉得做个弹窗的必要性不大,而且会给用户造成困惑。我们可以考虑

  1. 自动对没有后缀的文件添加后缀;
  2. 增强对各种后缀的支持(比如 .command)。

@WhatDamon
Copy link
Copy Markdown
Contributor Author

WhatDamon commented Apr 4, 2026 via email

@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 4, 2026

Windows 上 bat 更合适,ps1 默认情况下应该没办法双击运行。

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Outdated
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 5, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automatic file extension validation for launch scripts, appending a default extension if the provided one is invalid for the current operating system. It also expands the allowed extensions on macOS/Linux to include ".bash". The review feedback correctly identifies that the extension checks are case-sensitive, which could cause issues with uppercase extensions; using case-insensitive comparisons is suggested to improve robustness.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java
Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java Outdated
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 17, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a448248b04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +268 to +269
String defaultExt = getDefaultScriptExtension();
file = file.resolveSibling(file.getFileName().toString() + "." + defaultExt);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use selected export format when appending missing suffix

When the user saves a launch script without typing an extension, this branch always appends the OS default (bat/command/sh) and ignores which file type was selected in the save dialog. In practice, selecting the *.ps1 filter and saving launch will still produce a non-PowerShell script, silently changing script semantics (and on Windows can re-introduce cmd length limits). The fallback suffix should come from the chooser’s selected extension filter before falling back to OS defaults.

Useful? React with 👍 / 👎.

@Glavo Glavo merged commit 292288d into HMCL-dev:main Apr 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 生成启动脚本时若无.sh后缀则导出失败

3 participants