This commit is contained in:
cdle
2023-06-08 07:22:34 +08:00
parent bc96db7ba3
commit d9872f1ce5
3 changed files with 19 additions and 15 deletions
+3
View File
@@ -4,6 +4,7 @@ import (
"errors" "errors"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"github.com/dop251/goja" "github.com/dop251/goja"
) )
@@ -41,5 +42,7 @@ func getJsOs(vm *goja.Runtime, running func() bool) *goja.Object {
} }
return dir return dir
}) })
jsos.Set("name", runtime.GOOS)
jsos.Set("arch", runtime.GOARCH)
return jsos return jsos
} }
+16
View File
@@ -7,6 +7,7 @@ import (
"io" "io"
"net" "net"
"net/http" "net/http"
"os"
"regexp" "regexp"
"strings" "strings"
"time" "time"
@@ -43,6 +44,21 @@ func Cors() gin.HandlerFunc {
var Server *gin.Engine var Server *gin.Engine
func init() { 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) gin.SetMode(gin.ReleaseMode)
Server = gin.New() Server = gin.New()
// Server.Use(gin.Recovery()) // Server.Use(gin.Recovery())
-15
View File
@@ -6,7 +6,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"runtime" "runtime"
"strings"
"time" "time"
_ "github.com/cdle/sillyplus/adapters/qq" _ "github.com/cdle/sillyplus/adapters/qq"
@@ -19,7 +18,6 @@ import (
var sillyplus = core.MakeBucket("sillyplus") var sillyplus = core.MakeBucket("sillyplus")
func main() { func main() {
loc, _ := time.LoadLocation("Asia/Shanghai") loc, _ := time.LoadLocation("Asia/Shanghai")
time.Local = loc time.Local = loc
core.Init() core.Init()
@@ -31,19 +29,6 @@ func main() {
if arg == "-d" { if arg == "-d" {
d = true 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() { //弹出浏览器 go func() { //弹出浏览器
if runtime.GOOS != "windows" { if runtime.GOOS != "windows" {