From d9872f1ce5892a06d6e77e6e6ba753bd049a55f7 Mon Sep 17 00:00:00 2001 From: cdle Date: Thu, 8 Jun 2023 07:22:34 +0800 Subject: [PATCH] x --- core/node_os.go | 3 +++ core/web.go | 16 ++++++++++++++++ main.go | 15 --------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/core/node_os.go b/core/node_os.go index 28649f8..c323e6d 100644 --- a/core/node_os.go +++ b/core/node_os.go @@ -4,6 +4,7 @@ import ( "errors" "os" "path/filepath" + "runtime" "github.com/dop251/goja" ) @@ -41,5 +42,7 @@ func getJsOs(vm *goja.Runtime, running func() bool) *goja.Object { } return dir }) + jsos.Set("name", runtime.GOOS) + jsos.Set("arch", runtime.GOARCH) return jsos } diff --git a/core/web.go b/core/web.go index fcd447e..e9883ad 100644 --- a/core/web.go +++ b/core/web.go @@ -7,6 +7,7 @@ import ( "io" "net" "net/http" + "os" "regexp" "strings" "time" @@ -43,6 +44,21 @@ func Cors() gin.HandlerFunc { var Server *gin.Engine func init() { + for _, arg := range os.Args { //处理升级 + if arg == "-r" { //准备程序->原程序 + rfix := ".ready.exe" + ofix := ".exe" + if strings.Contains(os.Args[0], rfix) { + err := utils.CopyFile(utils.ProcessName, strings.Replace(utils.ProcessName, rfix, ofix, -1)) + if err == nil { + utils.Daemon("reset") + } + } else { + os.Remove(strings.ReplaceAll(os.Args[0], ofix, rfix)) + } + continue + } + } gin.SetMode(gin.ReleaseMode) Server = gin.New() // Server.Use(gin.Recovery()) diff --git a/main.go b/main.go index 38b7f19..3d4ccf4 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "os" "os/exec" "runtime" - "strings" "time" _ "github.com/cdle/sillyplus/adapters/qq" @@ -19,7 +18,6 @@ import ( var sillyplus = core.MakeBucket("sillyplus") func main() { - loc, _ := time.LoadLocation("Asia/Shanghai") time.Local = loc core.Init() @@ -31,19 +29,6 @@ func main() { if arg == "-d" { d = true } - if arg == "-r" { //准备程序->原程序 - rfix := ".ready.exe" - ofix := ".exe" - if strings.Contains(os.Args[0], rfix) { - err := utils.CopyFile(utils.ProcessName, strings.Replace(utils.ProcessName, rfix, ofix, -1)) - if err == nil { - utils.Daemon("reset") - } - } else { - os.Remove(strings.ReplaceAll(os.Args[0], ofix, rfix)) - } - continue - } } go func() { //弹出浏览器 if runtime.GOOS != "windows" {