|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+package admin
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "Gwen/global"
|
|
|
5
|
+ "Gwen/http/response"
|
|
|
6
|
+ "Gwen/service"
|
|
|
7
|
+ "github.com/gin-gonic/gin"
|
|
|
8
|
+ "os"
|
|
|
9
|
+ "strings"
|
|
|
10
|
+)
|
|
|
11
|
+
|
|
|
12
|
+type Config struct {
|
|
|
13
|
+}
|
|
|
14
|
+
|
|
|
15
|
+// ServerConfig RUSTDESK服务配置
|
|
|
16
|
+// @Tags ADMIN
|
|
|
17
|
+// @Summary RUSTDESK服务配置
|
|
|
18
|
+// @Description 服务配置,给webclient提供api-server
|
|
|
19
|
+// @Accept json
|
|
|
20
|
+// @Produce json
|
|
|
21
|
+// @Success 200 {object} response.Response
|
|
|
22
|
+// @Failure 500 {object} response.Response
|
|
|
23
|
+// @Router /admin/config/server [get]
|
|
|
24
|
+// @Security token
|
|
|
25
|
+func (co *Config) ServerConfig(c *gin.Context) {
|
|
|
26
|
+ cf := &response.ServerConfigResponse{
|
|
|
27
|
+ IdServer: global.Config.Rustdesk.IdServer,
|
|
|
28
|
+ Key: global.Config.Rustdesk.Key,
|
|
|
29
|
+ RelayServer: global.Config.Rustdesk.RelayServer,
|
|
|
30
|
+ ApiServer: global.Config.Rustdesk.ApiServer,
|
|
|
31
|
+ }
|
|
|
32
|
+ response.Success(c, cf)
|
|
|
33
|
+}
|
|
|
34
|
+
|
|
|
35
|
+// AppConfig APP服务配置
|
|
|
36
|
+// @Tags ADMIN
|
|
|
37
|
+// @Summary APP服务配置
|
|
|
38
|
+// @Description APP服务配置
|
|
|
39
|
+// @Accept json
|
|
|
40
|
+// @Produce json
|
|
|
41
|
+// @Success 200 {object} response.Response
|
|
|
42
|
+// @Failure 500 {object} response.Response
|
|
|
43
|
+// @Router /admin/config/app [get]
|
|
|
44
|
+// @Security token
|
|
|
45
|
+func (co *Config) AppConfig(c *gin.Context) {
|
|
|
46
|
+ response.Success(c, &gin.H{
|
|
|
47
|
+ "web_client": global.Config.App.WebClient,
|
|
|
48
|
+ })
|
|
|
49
|
+}
|
|
|
50
|
+
|
|
|
51
|
+// AdminConfig ADMIN服务配置
|
|
|
52
|
+// @Tags ADMIN
|
|
|
53
|
+// @Summary ADMIN服务配置
|
|
|
54
|
+// @Description ADMIN服务配置
|
|
|
55
|
+// @Accept json
|
|
|
56
|
+// @Produce json
|
|
|
57
|
+// @Success 200 {object} response.Response
|
|
|
58
|
+// @Failure 500 {object} response.Response
|
|
|
59
|
+// @Router /admin/config/admin [get]
|
|
|
60
|
+// @Security token
|
|
|
61
|
+func (co *Config) AdminConfig(c *gin.Context) {
|
|
|
62
|
+
|
|
|
63
|
+ u := service.AllService.UserService.CurUser(c)
|
|
|
64
|
+ hello := global.Config.Admin.Hello
|
|
|
65
|
+ helloFile := global.Config.Admin.HelloFile
|
|
|
66
|
+ if helloFile != "" {
|
|
|
67
|
+ b, err := os.ReadFile(helloFile)
|
|
|
68
|
+ if err == nil && len(b) > 0 {
|
|
|
69
|
+ hello = string(b)
|
|
|
70
|
+ }
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ //replace {{username}} to username
|
|
|
74
|
+ hello = strings.Replace(hello, "{{username}}", u.Username, -1)
|
|
|
75
|
+ response.Success(c, &gin.H{
|
|
|
76
|
+ "title": global.Config.Admin.Title,
|
|
|
77
|
+ "hello": hello,
|
|
|
78
|
+ })
|
|
|
79
|
+}
|