mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
feat: change version API to generated version
This commit is contained in:
parent
de420ab6ff
commit
f9802e6b2b
4 changed files with 30 additions and 30 deletions
|
@ -1,12 +1,11 @@
|
|||
package upgrader
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/0xJacky/Nginx-UI/app"
|
||||
"github.com/pkg/errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type RuntimeInfo struct {
|
||||
|
@ -41,19 +40,3 @@ func GetRuntimeInfo() (r RuntimeInfo, err error) {
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func GetCurrentVersion() (c CurVersion, err error) {
|
||||
verJson, err := app.DistFS.ReadFile("dist/version.json")
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "service.GetCurrentVersion ReadFile err")
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(verJson, &c)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "service.GetCurrentVersion json.Unmarshal err")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,3 +5,22 @@ var (
|
|||
BuildId = 0
|
||||
TotalBuild = 0
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
Version string `json:"version"`
|
||||
BuildId int `json:"build_id"`
|
||||
TotalBuild int `json:"total_build"`
|
||||
}
|
||||
|
||||
var versionInfo *Info
|
||||
|
||||
func GetVersionInfo() *Info {
|
||||
if versionInfo == nil {
|
||||
versionInfo = &Info{
|
||||
Version: Version,
|
||||
BuildId: BuildId,
|
||||
TotalBuild: TotalBuild,
|
||||
}
|
||||
}
|
||||
return versionInfo
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue