File tree Expand file tree Collapse file tree
MaiChartManager/Front/src/store Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,7 +60,20 @@ export const modInfo = ref<GameModInfo>();
6060export type MusicSortMode = 'id' | 'name' | 'version' ;
6161export 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+ ) ;
6477export const selectedMusic = computed ( ( ) => musicList . value . find ( m => m . id === selectMusicId . value ) ) ;
6578export const selectedLevel = ref ( 0 ) ;
6679
You can’t perform that action at this time.
0 commit comments