Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 版本列表页面排序 #3276

Open
Tidy-Bear opened this issue Sep 3, 2024 · 0 comments
Open

[Feature] 版本列表页面排序 #3276

Tidy-Bear opened this issue Sep 3, 2024 · 0 comments

Comments

@Tidy-Bear
Copy link

描述 | Description

版本列表页面目前完全是乱序的,希望能添加排序功能
image

我感觉原先是有默认顺序设计的,但实现有问题,更像个 bug

DefaultGameRepository#refreshVersionsImpl 中,先是定义了 TreeMap

Map<String, Version> versions = new TreeMap<>();

SimpleVersionProvider 默认是 HashMap

SimpleVersionProvider provider = new SimpleVersionProvider();

protected final Map<String, Version> versionMap = new HashMap<>();

方法的最后,直接以 HashMap 的顺序放入到 TreeMap

for (Version version : provider.getVersionMap().values()) {
try {
Version resolved = version.resolve(provider);
if (resolved.appliesToCurrentEnvironment() &&
EventBus.EVENT_BUS.fireEvent(new LoadedOneVersionEvent(this, resolved)) != Event.Result.DENY)
versions.put(version.getId(), version);
} catch (VersionNotFoundException e) {
LOG.warning("Ignoring version " + version.getId() + " because it inherits from a nonexistent version.");
}
}

改成 TreeMap 应该至少能以文件遍历顺序(A-Z)显示了
但既然提了 Feat,天马行空一点,搞个升序、降序,还有搜索、按标签(API,MC版本)搜索等等((

原因 | Reason

乱序找起来太难受了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant