lejianwen 1 год назад
Родитель
Сommit
22e470fee5
4 измененных файлов с 24 добавлено и 0 удалено
  1. 1 0
      .gitignore
  2. 20 0
      http/controller/api/webClient.go
  3. 2 0
      http/controller/web/index.go
  4. 1 0
      http/router/api.go

+ 1 - 0
.gitignore

@@ -7,6 +7,7 @@ go.sum
7
 resources/*
7
 resources/*
8
 !resources/public/upload/.gitignore
8
 !resources/public/upload/.gitignore
9
 !resources/web
9
 !resources/web
10
+!resources/web2
10
 !resources/i18n
11
 !resources/i18n
11
 release
12
 release
12
 data
13
 data

+ 20 - 0
http/controller/api/webClient.go

@@ -85,3 +85,23 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
85
 		"peer":      pp,
85
 		"peer":      pp,
86
 	})
86
 	})
87
 }
87
 }
88
+
89
+// ServerConfigV2 服务配置
90
+// @Tags WEBCLIENT_V2
91
+// @Summary 服务配置
92
+// @Description 服务配置,给webclient提供api-server
93
+// @Accept  json
94
+// @Produce  json
95
+// @Success 200 {object} response.Response
96
+// @Failure 500 {object} response.Response
97
+// @Router /server-config [get]
98
+// @Security token
99
+func (i *WebClient) ServerConfigV2(c *gin.Context) {
100
+	response.Success(
101
+		c,
102
+		gin.H{
103
+			"id_server": global.Config.Rustdesk.IdServer,
104
+			"key":       global.Config.Rustdesk.Key,
105
+		},
106
+	)
107
+}

+ 2 - 0
http/controller/web/index.go

@@ -17,6 +17,8 @@ func (i *Index) ConfigJs(c *gin.Context) {
17
 
17
 
18
 	tmp := `
18
 	tmp := `
19
 localStorage.setItem('api-server', "` + apiServer + `")
19
 localStorage.setItem('api-server', "` + apiServer + `")
20
+const ws2_prefix = 'wc-'
21
+localStorage.setItem(ws2_prefix+'api-server', "` + apiServer + `")
20
 `
22
 `
21
 	c.String(200, tmp)
23
 	c.String(200, tmp)
22
 }
24
 }

+ 1 - 0
http/router/api.go

@@ -121,6 +121,7 @@ func WebClientRoutes(frg *gin.RouterGroup) {
121
 	}
121
 	}
122
 	{
122
 	{
123
 		frg.POST("/server-config", middleware.RustAuth(), w.ServerConfig)
123
 		frg.POST("/server-config", middleware.RustAuth(), w.ServerConfig)
124
+		frg.POST("/server-config-v2", middleware.RustAuth(), w.ServerConfigV2)
124
 	}
125
 	}
125
 
126
 
126
 }
127
 }