diff --git a/conf/config.yaml b/conf/config.yaml
index 61a9551..f6d2710 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -2,6 +2,10 @@ lang: "zh-CN"
app:
web-client: 1 # 1:启用 0:禁用
register: false #是否开启注册
+admin:
+ title: "RustDesk Api Admin"
+ hello-file: "./conf/hello.html" #优先使用file
+ hello: "👏 你好 {{username}}, 欢迎使用 RustDesk Api Admin。 Github"
gin:
api-addr: "0.0.0.0:21114"
mode: "release" #release,debug,test
diff --git a/conf/hello.html b/conf/hello.html
new file mode 100644
index 0000000..8f0f1ac
--- /dev/null
+++ b/conf/hello.html
@@ -0,0 +1 @@
+👏👏👏 你好 {{username}}, 欢迎使用 RustDesk Api Admin。 Github
\ No newline at end of file
diff --git a/config/config.go b/config/config.go
index 9362b0a..6190ae0 100644
--- a/config/config.go
+++ b/config/config.go
@@ -17,10 +17,15 @@ type App struct {
WebClient int `mapstructure:"web-client"`
Register bool `mapstructure:"register"`
}
-
+type Admin struct {
+ Title string `mapstructure:"title"`
+ Hello string `mapstructure:"hello"`
+ HelloFile string `mapstructure:"hello-file"`
+}
type Config struct {
Lang string `mapstructure:"lang"`
App App
+ Admin Admin
Gorm Gorm
Mysql Mysql
Gin Gin
diff --git a/http/controller/admin/config.go b/http/controller/admin/config.go
new file mode 100644
index 0000000..cb67d98
--- /dev/null
+++ b/http/controller/admin/config.go
@@ -0,0 +1,79 @@
+package admin
+
+import (
+ "Gwen/global"
+ "Gwen/http/response"
+ "Gwen/service"
+ "github.com/gin-gonic/gin"
+ "os"
+ "strings"
+)
+
+type Config struct {
+}
+
+// ServerConfig RUSTDESK服务配置
+// @Tags ADMIN
+// @Summary RUSTDESK服务配置
+// @Description 服务配置,给webclient提供api-server
+// @Accept json
+// @Produce json
+// @Success 200 {object} response.Response
+// @Failure 500 {object} response.Response
+// @Router /admin/config/server [get]
+// @Security token
+func (co *Config) ServerConfig(c *gin.Context) {
+ cf := &response.ServerConfigResponse{
+ IdServer: global.Config.Rustdesk.IdServer,
+ Key: global.Config.Rustdesk.Key,
+ RelayServer: global.Config.Rustdesk.RelayServer,
+ ApiServer: global.Config.Rustdesk.ApiServer,
+ }
+ response.Success(c, cf)
+}
+
+// AppConfig APP服务配置
+// @Tags ADMIN
+// @Summary APP服务配置
+// @Description APP服务配置
+// @Accept json
+// @Produce json
+// @Success 200 {object} response.Response
+// @Failure 500 {object} response.Response
+// @Router /admin/config/app [get]
+// @Security token
+func (co *Config) AppConfig(c *gin.Context) {
+ response.Success(c, &gin.H{
+ "web_client": global.Config.App.WebClient,
+ })
+}
+
+// AdminConfig ADMIN服务配置
+// @Tags ADMIN
+// @Summary ADMIN服务配置
+// @Description ADMIN服务配置
+// @Accept json
+// @Produce json
+// @Success 200 {object} response.Response
+// @Failure 500 {object} response.Response
+// @Router /admin/config/admin [get]
+// @Security token
+func (co *Config) AdminConfig(c *gin.Context) {
+
+ u := service.AllService.UserService.CurUser(c)
+ hello := global.Config.Admin.Hello
+ helloFile := global.Config.Admin.HelloFile
+ if helloFile != "" {
+ b, err := os.ReadFile(helloFile)
+ if err == nil && len(b) > 0 {
+ hello = string(b)
+ }
+ }
+
+ //replace {{username}} to username
+ hello = strings.Replace(hello, "{{username}}", u.Username, -1)
+ response.Success(c, &gin.H{
+ "title": global.Config.Admin.Title,
+ "hello": hello,
+ })
+}
diff --git a/http/router/admin.go b/http/router/admin.go
index 938bd9c..9049159 100644
--- a/http/router/admin.go
+++ b/http/router/admin.go
@@ -31,9 +31,14 @@ func Init(g *gin.Engine) {
AddressBookCollectionBind(adg)
AddressBookCollectionRuleBind(adg)
UserTokenBind(adg)
+ ConfigBind(adg)
+
+ //deprecated by ConfigBind
rs := &admin.Rustdesk{}
adg.GET("/server-config", rs.ServerConfig)
adg.GET("/app-config", rs.AppConfig)
+ //deprecated end
+
//访问静态文件
//g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload"))
}
@@ -188,6 +193,13 @@ func UserTokenBind(rg *gin.RouterGroup) {
aR.GET("/list", cont.List)
aR.POST("/delete", cont.Delete)
}
+func ConfigBind(rg *gin.RouterGroup) {
+ aR := rg.Group("/config")
+ rs := &admin.Config{}
+ aR.GET("/server", rs.ServerConfig)
+ aR.GET("/app", rs.AppConfig)
+ aR.GET("/admin", rs.AdminConfig)
+}
/*
func FileBind(rg *gin.RouterGroup) {