mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: number indexed
This commit is contained in:
1 parent
5bbe5c2720
commit
52c3a0abe0
1 file changed
+19
-1
@@ -23,6 +23,8 @@ interface ContentProps {
|
|||||||
skeleton?: boolean;
|
skeleton?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const indexingPattern = /.+_(\d+)$/;
|
||||||
|
|
||||||
function Content({ skeleton }: ContentProps) {
|
function Content({ skeleton }: ContentProps) {
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
const { avatars } = useAwait(() => api.avatars(), "avatars");
|
const { avatars } = useAwait(() => api.avatars(), "avatars");
|
||||||
@@ -51,7 +53,23 @@ function Content({ skeleton }: ContentProps) {
|
|||||||
.map(([name, avatars]) => ({
|
.map(([name, avatars]) => ({
|
||||||
name,
|
name,
|
||||||
avatars: avatars.sort((a, b) => {
|
avatars: avatars.sort((a, b) => {
|
||||||
return a.stuff_ui!.grade - b.stuff_ui!.grade;
|
const gradeA = a.stuff_ui!.grade;
|
||||||
|
const gradeB = b.stuff_ui!.grade;
|
||||||
|
let diff = gradeA - gradeB;
|
||||||
|
|
||||||
|
if (diff === 0) {
|
||||||
|
const matchesA = a.name.match(indexingPattern);
|
||||||
|
const matchesB = b.name.match(indexingPattern);
|
||||||
|
|
||||||
|
if (matchesA && matchesB) {
|
||||||
|
const indexA = Number(matchesA[1]);
|
||||||
|
const indexB = Number(matchesB[1]);
|
||||||
|
|
||||||
|
diff = indexA - indexB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in new issue
Block a user