From 22e470fee50e893c59b7e63cfbf09151db15187b Mon Sep 17 00:00:00 2001 From: lejianwen <84855512@qq.com> Date: Sat, 16 Nov 2024 18:33:02 +0800 Subject: [PATCH] add webclientv2 --- .gitignore | 1 + http/controller/api/webClient.go | 20 ++++++++++++++++++++ http/controller/web/index.go | 2 ++ http/router/api.go | 1 + 4 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index e395f58..efdbf0e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ go.sum resources/* !resources/public/upload/.gitignore !resources/web +!resources/web2 !resources/i18n release data \ No newline at end of file diff --git a/http/controller/api/webClient.go b/http/controller/api/webClient.go index ead1eb5..1c029e3 100644 --- a/http/controller/api/webClient.go +++ b/http/controller/api/webClient.go @@ -85,3 +85,23 @@ func (i *WebClient) SharedPeer(c *gin.Context) { "peer": pp, }) } + +// ServerConfigV2 服务配置 +// @Tags WEBCLIENT_V2 +// @Summary 服务配置 +// @Description 服务配置,给webclient提供api-server +// @Accept json +// @Produce json +// @Success 200 {object} response.Response +// @Failure 500 {object} response.Response +// @Router /server-config [get] +// @Security token +func (i *WebClient) ServerConfigV2(c *gin.Context) { + response.Success( + c, + gin.H{ + "id_server": global.Config.Rustdesk.IdServer, + "key": global.Config.Rustdesk.Key, + }, + ) +} diff --git a/http/controller/web/index.go b/http/controller/web/index.go index 80a967f..8b6b326 100644 --- a/http/controller/web/index.go +++ b/http/controller/web/index.go @@ -17,6 +17,8 @@ func (i *Index) ConfigJs(c *gin.Context) { tmp := ` localStorage.setItem('api-server', "` + apiServer + `") +const ws2_prefix = 'wc-' +localStorage.setItem(ws2_prefix+'api-server', "` + apiServer + `") ` c.String(200, tmp) } diff --git a/http/router/api.go b/http/router/api.go index 8593115..e25b457 100644 --- a/http/router/api.go +++ b/http/router/api.go @@ -121,6 +121,7 @@ func WebClientRoutes(frg *gin.RouterGroup) { } { frg.POST("/server-config", middleware.RustAuth(), w.ServerConfig) + frg.POST("/server-config-v2", middleware.RustAuth(), w.ServerConfigV2) } }