From 88765302e8545ef9c36b7726e36ab3f55073f821 Mon Sep 17 00:00:00 2001 From: lejianwen <84855512@qq.com> Date: Sat, 21 Dec 2024 21:15:06 +0800 Subject: [PATCH] feat(webclient): add new query_online function There may be a loss of performance Therefore, it is not enabled by default --- conf/config.yaml | 1 + config/rustdesk.go | 2 ++ http/controller/web/index.go | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index ecef3ef..2befe9f 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -28,6 +28,7 @@ rustdesk: key: "" key-file: "./conf/data/id_ed25519.pub" personal: 1 + webclient-magic-queryonline: 0 logger: path: "./runtime/log.txt" level: "warn" #trace,debug,info,warn,error,fatal diff --git a/config/rustdesk.go b/config/rustdesk.go index 59056d4..f1903d1 100644 --- a/config/rustdesk.go +++ b/config/rustdesk.go @@ -11,6 +11,8 @@ type Rustdesk struct { Key string `mapstructure:"key"` KeyFile string `mapstructure:"key-file"` Personal int `mapstructure:"personal"` + //webclient-magic-queryonline + WebclientMagicQueryonline int `mapstructure:"webclient-magic-queryonline"` } func LoadKeyFile(rustdesk *Rustdesk) { diff --git a/http/controller/web/index.go b/http/controller/web/index.go index 8b6b326..af3b1b6 100644 --- a/http/controller/web/index.go +++ b/http/controller/web/index.go @@ -3,6 +3,7 @@ package web import ( "Gwen/global" "github.com/gin-gonic/gin" + "strconv" ) type Index struct { @@ -14,11 +15,13 @@ func (i *Index) Index(c *gin.Context) { func (i *Index) ConfigJs(c *gin.Context) { apiServer := global.Config.Rustdesk.ApiServer - + magicQueryonline := strconv.Itoa(global.Config.Rustdesk.WebclientMagicQueryonline) tmp := ` localStorage.setItem('api-server', "` + apiServer + `") const ws2_prefix = 'wc-' localStorage.setItem(ws2_prefix+'api-server', "` + apiServer + `") -` + +window.webclient_magic_queryonline = ` + magicQueryonline + `` + c.String(200, tmp) }