Skip to content

feat: Java有关重构 - #11

Merged
lxdklp merged 28 commits into
lxdklp:mainfrom
futrw4v:feature/java_manager
Jun 20, 2026
Merged

feat: Java有关重构#11
lxdklp merged 28 commits into
lxdklp:mainfrom
futrw4v:feature/java_manager

Conversation

@futrw4v

@futrw4v futrw4v commented May 3, 2026

Copy link
Copy Markdown
Contributor

重构内容:

  • 将Java初始化有关任务与UI分离,抽出至java_service.dart,将java_manager.dart重命名为java_utils.dart
  • 移除搜索Java(searchPotentialJavaExecutables)内的遍历,在Windows下采用搜索注册表的方法(参考PCL2),对于Mac与Linux没有地方测试(
  • 将SharedPreference中的java更改为javaSelectedPath,添加javaRuntimes缓存Java的信息
  • 重构java.dart,添加了刷新Java与手动添加Java
  • 更改了MainStartPageState内检测Java是否存在的逻辑
  • 优化代码与部分逻辑
  • 添加了插件open_filex,win32_registry

实在是铲不动了太多东西要改的了
没有ChangeNotifier真的很难改,这算前面挖的坑了
所以Java部分先改到这 (•_•),我打算开始改UI了

对了最好在contribution.md里面提一嘴统一PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL,在我这里很容易因为pub get一下pubspec.lock就会迎来大变

实际上还是有点问题的 在初始化java的时候会阻塞UI,但是改这个要动很多东西所以没打算在现在弄

希望能早点合并喵

@lxdklp

lxdklp commented May 3, 2026

Copy link
Copy Markdown
Owner

/gemini review

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

Copy link
Copy Markdown

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 a robust Java management system, featuring a new JavaService for runtime state management and enhanced discovery logic in JavaUtils that includes Windows registry scanning. The UI has been updated to support manual Java path selection, runtime refreshing, and macOS-specific menu integrations. My feedback highlights several critical issues: the use of Isolate.run for refreshing runtimes will fail due to memory isolation and plugin limitations, a layout conflict exists between MainAxisSize.min and Spacer in the settings page, Platform.version is incorrectly used for architecture detection, registry handles lack proper resource cleanup, and the javaSelectedPath setter fails to persist changes to storage.

Comment thread lib/pages/setting/java.dart Outdated
Comment thread lib/pages/setting/java.dart Outdated
Comment thread lib/function/java/java_utils.dart
Comment thread lib/function/java/java_utils.dart Outdated
Comment thread lib/function/java/java_service.dart Outdated
@lxdklp

lxdklp commented May 3, 2026

Copy link
Copy Markdown
Owner

镜像源这个倒是没必要规定,自己觉得哪个镜像源快或者是用官方源也没啥所谓,反正应该也没人看pubspec.lock的变更

@futrw4v

futrw4v commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

镜像源这个倒是没必要规定,自己觉得哪个镜像源快或者是用官方源也没啥所谓,反正应该也没人看pubspec.lock的变更

主要是会一直在提交列表里

Comment thread CONTRIBUTING.md
@lxdklp

lxdklp commented May 31, 2026

Copy link
Copy Markdown
Owner

/gemini review

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

Copy link
Copy Markdown

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 a robust JavaService and JavaUtils to manage, search, and configure Java runtimes across different platforms, updating the launchers and settings UI accordingly. The code review identified several critical issues, including a UX bug in _pickAndAddJavaRuntime that unexpectedly closes the settings page, potential launcher crashes from saving empty system Java paths, a registry handle leak in JavaUtils, and a race condition where the main UI becomes interactive before Java initialization completes. Additionally, feedback was provided regarding improper reset logic when deleting non-active Java runtimes, and the need for better error handling during JSON parsing and background isolate execution.

Comment thread lib/pages/setting/java.dart
Comment thread lib/function/java/java_service.dart
Comment thread lib/function/java/java_utils.dart Outdated
Comment thread lib/main.dart Outdated
Comment thread lib/pages/setting/java.dart
Comment thread lib/function/java/java_service.dart
Comment thread lib/pages/setting/java.dart
@lxdklp
lxdklp merged commit 8596446 into lxdklp:main Jun 20, 2026
1 check passed
@futrw4v
futrw4v deleted the feature/java_manager branch June 23, 2026 12:46
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.

2 participants