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) } }