mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
feat: set version dialog
This commit is contained in:
parent
cf83d2fc7c
commit
a7e5dfd3d6
10 changed files with 908 additions and 27 deletions
18
src/utils/version.ts
Normal file
18
src/utils/version.ts
Normal 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}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue