Skip to content

Commit 5ae72be

Browse files
committed
close #35
1 parent 68742f5 commit 5ae72be

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • MaiChartManager/Front/src/store

‎MaiChartManager/Front/src/store/refs.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,20 @@ export const modInfo = ref<GameModInfo>();
6060
export type MusicSortMode = 'id' | 'name' | 'version';
6161
export const musicSortMode = useStorage<MusicSortMode>('musicSortMode', 'id');
6262

63-
export const musicList = computed(() => musicListAll.value.filter(m => m.assetDir === selectedADir.value).sort((a, b) => { switch (musicSortMode.value) { case 'name': return (a.sortName ?? '').localeCompare(b.sortName ?? ''); case 'version': return (a.version ?? 0) - (b.version ?? 0) || (a.id! % 10000) - (b.id! % 10000); case 'id': default: return (a.id! % 10000) - (b.id! % 10000); } }));
63+
const sortByNonDxId = (a: MusicXmlWithABJacket, b: MusicXmlWithABJacket) =>
64+
(a.id! % 10000) - (b.id! % 10000);
65+
66+
const musicSortComparators: Record<MusicSortMode, (a: MusicXmlWithABJacket, b: MusicXmlWithABJacket) => number> = {
67+
id: sortByNonDxId,
68+
name: (a, b) => (a.sortName ?? '').localeCompare(b.sortName ?? ''),
69+
version: (a, b) => (a.version ?? 0) - (b.version ?? 0) || sortByNonDxId(a, b),
70+
};
71+
72+
export const musicList = computed(() =>
73+
musicListAll.value
74+
.filter(m => m.assetDir === selectedADir.value)
75+
.sort(musicSortComparators[musicSortMode.value] ?? sortByNonDxId)
76+
);
6477
export const selectedMusic = computed(() => musicList.value.find(m => m.id === selectMusicId.value));
6578
export const selectedLevel = ref(0);
6679

0 commit comments

Comments
 (0)