Skip to content

Commit

Permalink
fix: Sort optifine version and select correct when load
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 27, 2023
1 parent 6c67fc8 commit 197ebf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion xmcl-keystone-ui/src/composables/versionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ export function useOptifineVersionList(minecraft: Ref<string>, forge: Ref<string
const { versions, installed, refreshing } = useOptifineVersions(minecraft, forge, local)

const items = computed(() => {
return versions.value.map((v) => {
return [...versions.value].sort((a, b) => {
const { patch, type } = a
// compare type first and then the patch
const result = type.localeCompare(b.type)
if (result === 0) {
return -patch.localeCompare(b.patch)
}
return -result
}).map((v) => {
const key = LockKey.version(`optifine-${minecraft.value}-${v.type}_${v.patch}`)
const name = v.type + '_' + v.patch
const result: VersionItem = reactive({
Expand Down
2 changes: 1 addition & 1 deletion xmcl-keystone-ui/src/views/ModDetailOptifine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const versions = computed(() => {
return all.reverse()
})
selectedVersion.value = versions.value[0]
selectedVersion.value = versions.value.find(v => v.installed) ?? versions.value[0]
const { data: optifineHome, isValidating: loadingDescription } = useSWRV('/optifine-home', async () => {
const response = await fetch('https://www.optifine.net/home')
Expand Down

0 comments on commit 197ebf5

Please sign in to comment.