fix version compare

This commit is contained in:
lloydzhou
2024-10-11 11:42:36 +08:00
parent 2eebfcf6fe
commit bd9de4dc4d
2 changed files with 13 additions and 2 deletions

View File

@@ -409,3 +409,14 @@ export function clientUpdate() {
showToast(Locale.Settings.Update.Failed);
});
}
// https://gist.github.com/iwill/a83038623ba4fef6abb9efca87ae9ccb
export function semverCompare(a, b) {
if (a.startsWith(b + "-")) return -1;
if (b.startsWith(a + "-")) return 1;
return a.localeCompare(b, undefined, {
numeric: true,
sensitivity: "case",
caseFirst: "upper",
});
}