Skip to content

Conversation

@hmr-BH
Copy link

@hmr-BH hmr-BH commented Sep 2, 2025

PixPin_2025-09-03_07-54-41

@Wulian233
Copy link
Contributor

注释用英文写

@hmr-BH
Copy link
Author

hmr-BH commented Sep 3, 2025

注释用英文写

已完成

@hmr-BH hmr-BH changed the title 实现语言切换后提示用户重启的功能 切换语言后提示用户重启软件 Sep 3, 2025
@hmr-BH
Copy link
Author

hmr-BH commented Sep 3, 2025

@Glavo


if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
JFXButton restartButton = new JFXButton(i18n("button.restart"));
restartButton.getStyleClass().add("dialog-success");
Copy link
Member

Choose a reason for hiding this comment

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

这个 dialog-success 是什么东西?你没注意到你的重启按钮没应用到样式吗?

Copy link
Author

Choose a reason for hiding this comment

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

欸我操,记错了,应该是dialog-accept
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

@burningtnt
Copy link
Member

不建议修改更新链逻辑上的相关逻辑。这些代码一旦出错,我们将无法将用户从错误的版本提升至新版本

@hmr-BH
Copy link
Author

hmr-BH commented Sep 5, 2025

不建议修改更新链逻辑上的相关逻辑。这些代码一旦出错,我们将无法将用户从错误的版本提升至新版本

我已经还原了update相关的代码,希望以后可以考虑迁移使用Restarter

import static org.jackhuang.hmcl.setting.ConfigHolder.config;

/**
* Common restart tool class, used for:
Copy link
Member

Choose a reason for hiding this comment

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

/** 的 Javadoc 中应当使用 HTML 标签。如果你想使用 Markdown 文档,请使用 /// 开头的 Markdown 文档

builder().restart();
}

public static void restartWithLocale(Locales.SupportedLocale locale) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

这样一个方法非常奇怪。有什么理由不在 SettingsPage 中更新 config,而非要创建一个新的方法呢?

} catch (IOException ex) {
LOG.log(Level.WARNING, "Failed to restart", ex);
ignoreLanguageChange = true;
cboLanguage.getSelectionModel().select(oldValue);
Copy link
Member

Choose a reason for hiding this comment

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

重启失败的时候为什么要跳回去?我觉得应该提示用户手动重启完成切换。


Runnable cancelAction = () -> {
ignoreLanguageChange = true;
cboLanguage.getSelectionModel().select(newValue);
Copy link
Member

Choose a reason for hiding this comment

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

这里的意义是什么?这时候 cboLanguage 不是已经切换到新的语言上了吗?

@Glavo
Copy link
Member

Glavo commented Sep 12, 2025

你的实现没有注意 Config 保存的问题,旧进程和拉起来的新进程可能会发生冲突。如果后台 Config 保存进程保存的比较慢的话(虽然概率很小),那新进程甚至有可能读不到新的语言设置。

一个更明显的例子是启动器的退出的时候会保存一次 Config(主要是保存窗口大小)。你在旧窗口中调整了窗口大小的话,新进程是读不到的。

@hmr-BH
Copy link
Author

hmr-BH commented Sep 29, 2025

你的实现没有注意 Config 保存的问题,旧进程和拉起来的新进程可能会发生冲突。如果后台 Config 保存进程保存的比较慢的话(虽然概率很小),那新进程甚至有可能读不到新的语言设置。

一个更明显的例子是启动器的退出的时候会保存一次 Config(主要是保存窗口大小)。你在旧窗口中调整了窗口大小的话,新进程是读不到的。

这确实是一个很大的问题。我目前无法解决此问题。因为这可能涉及到较大范围的代码修改,会导致该PR更难以通过审查

@hmr-BH
Copy link
Author

hmr-BH commented Sep 29, 2025

你的实现没有注意 Config 保存的问题,旧进程和拉起来的新进程可能会发生冲突。如果后台 Config 保存进程保存的比较慢的话(虽然概率很小),那新进程甚至有可能读不到新的语言设置。

一个更明显的例子是启动器的退出的时候会保存一次 Config(主要是保存窗口大小)。你在旧窗口中调整了窗口大小的话,新进程是读不到的。

#4513 或许可以替代本PR

@hmr-BH hmr-BH closed this Sep 29, 2025
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.

4 participants