feat: set version dialog

This commit is contained in:
trafficlunar 2024-12-28 21:07:12 +00:00
parent cf83d2fc7c
commit a7e5dfd3d6
10 changed files with 908 additions and 27 deletions

18
src/utils/version.ts Normal file
View file

@ -0,0 +1,18 @@
export function versionToNumber(version: string) {
const parts = version.split(".").map(Number);
return parts[0] * 1000 + (parts[1] || 0) * 10 + (parts[2] || 0);
}
export function numberToVersion(version: number) {
const major = Math.floor(version / 1000);
const minor = version % 1000; // Remainder becomes the minor and patch version
// If minor is a multiple of 10, it's just minor with no patch
if (minor % 10 === 0) {
return `${major}.${Math.floor(minor / 10)}`;
}
// Otherwise, split into minor and patch
const patch = minor % 10;
return `${major}.${Math.floor(minor / 10)}.${patch}`;
}