| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package admin
- import (
- "github.com/gin-gonic/gin"
- "github.com/lejianwen/rustdesk-api/global"
- "github.com/lejianwen/rustdesk-api/http/response"
- "github.com/lejianwen/rustdesk-api/service"
- "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,
- })
- }
|