fix version compare
This commit is contained in:
parent
2eebfcf6fe
commit
bd9de4dc4d
|
@ -49,7 +49,7 @@ import Locale, {
|
||||||
changeLang,
|
changeLang,
|
||||||
getLang,
|
getLang,
|
||||||
} from "../locales";
|
} from "../locales";
|
||||||
import { copyToClipboard, clientUpdate } from "../utils";
|
import { copyToClipboard, clientUpdate, semverCompare } from "../utils";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {
|
import {
|
||||||
Anthropic,
|
Anthropic,
|
||||||
|
@ -585,7 +585,7 @@ export function Settings() {
|
||||||
const [checkingUpdate, setCheckingUpdate] = useState(false);
|
const [checkingUpdate, setCheckingUpdate] = useState(false);
|
||||||
const currentVersion = updateStore.formatVersion(updateStore.version);
|
const currentVersion = updateStore.formatVersion(updateStore.version);
|
||||||
const remoteId = updateStore.formatVersion(updateStore.remoteVersion);
|
const remoteId = updateStore.formatVersion(updateStore.remoteVersion);
|
||||||
const hasNewVersion = currentVersion !== remoteId;
|
const hasNewVersion = semverCompare(currentVersion, remoteId) === -1;
|
||||||
const updateUrl = getClientConfig()?.isApp ? RELEASE_URL : UPDATE_URL;
|
const updateUrl = getClientConfig()?.isApp ? RELEASE_URL : UPDATE_URL;
|
||||||
|
|
||||||
function checkUpdate(force = false) {
|
function checkUpdate(force = false) {
|
||||||
|
|
11
app/utils.ts
11
app/utils.ts
|
@ -409,3 +409,14 @@ export function clientUpdate() {
|
||||||
showToast(Locale.Settings.Update.Failed);
|
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",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue