Compare commits

...

8 Commits

Author SHA1 Message Date
ljw
1a1856257d fix write when heartbeat #14 2024-10-16 21:32:55 +08:00
ljw
24f570b64f fix pc add #13 2024-10-16 10:10:20 +08:00
ljw
6322177b71 fix pc add #13 2024-10-16 09:28:39 +08:00
ljw
d2390d1cb3 Revert "add webclient v2 preview"
This reverts commit 399c32da7d.
2024-10-15 16:35:34 +08:00
ljw
6fe6f6b708 Revert "up readme"
This reverts commit a656f4fec3.
2024-10-15 16:35:34 +08:00
ljw
a656f4fec3 up readme 2024-10-15 16:13:42 +08:00
ljw
399c32da7d add webclient v2 preview 2024-10-15 16:11:40 +08:00
ljw
62167836dc fix docs 2024-10-15 14:51:19 +08:00
10 changed files with 438 additions and 18 deletions

View File

@@ -244,6 +244,51 @@ const docTemplateadmin = `{
}
}
},
"/admin/address_book/share": {
"post": {
"security": [
{
"token": []
}
],
"description": "地址簿分享",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"地址簿"
],
"summary": "地址簿分享",
"parameters": [
{
"description": "地址簿信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.ShareByWebClientForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/address_book/update": {
"post": {
"security": [
@@ -301,6 +346,40 @@ const docTemplateadmin = `{
}
}
},
"/admin/app-config": {
"get": {
"security": [
{
"token": []
}
],
"description": "APP服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "APP服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/file/oss_token": {
"get": {
"security": [
@@ -1371,6 +1450,18 @@ const docTemplateadmin = `{
"description": "时间",
"name": "time_ago",
"in": "query"
},
{
"type": "string",
"description": "ID",
"name": "id",
"in": "query"
},
{
"type": "string",
"description": "主机名",
"name": "hostname",
"in": "query"
}
],
"responses": {
@@ -1475,7 +1566,7 @@ const docTemplateadmin = `{
"tags": [
"ADMIN"
],
"summary": "服务配置",
"summary": "RUSTDESK服务配置",
"responses": {
"200": {
"description": "OK",
@@ -2456,6 +2547,33 @@ const docTemplateadmin = `{
}
}
},
"admin.ShareByWebClientForm": {
"type": "object",
"required": [
"id",
"password",
"password_type"
],
"properties": {
"expire": {
"type": "integer"
},
"id": {
"type": "string"
},
"password": {
"type": "string"
},
"password_type": {
"description": "只能是once,fixed",
"type": "string",
"enum": [
"once",
"fixed"
]
}
}
},
"admin.TagForm": {
"type": "object",
"required": [

View File

@@ -237,6 +237,51 @@
}
}
},
"/admin/address_book/share": {
"post": {
"security": [
{
"token": []
}
],
"description": "地址簿分享",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"地址簿"
],
"summary": "地址簿分享",
"parameters": [
{
"description": "地址簿信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/admin.ShareByWebClientForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/address_book/update": {
"post": {
"security": [
@@ -294,6 +339,40 @@
}
}
},
"/admin/app-config": {
"get": {
"security": [
{
"token": []
}
],
"description": "APP服务配置",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ADMIN"
],
"summary": "APP服务配置",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/admin/file/oss_token": {
"get": {
"security": [
@@ -1364,6 +1443,18 @@
"description": "时间",
"name": "time_ago",
"in": "query"
},
{
"type": "string",
"description": "ID",
"name": "id",
"in": "query"
},
{
"type": "string",
"description": "主机名",
"name": "hostname",
"in": "query"
}
],
"responses": {
@@ -1468,7 +1559,7 @@
"tags": [
"ADMIN"
],
"summary": "服务配置",
"summary": "RUSTDESK服务配置",
"responses": {
"200": {
"description": "OK",
@@ -2449,6 +2540,33 @@
}
}
},
"admin.ShareByWebClientForm": {
"type": "object",
"required": [
"id",
"password",
"password_type"
],
"properties": {
"expire": {
"type": "integer"
},
"id": {
"type": "string"
},
"password": {
"type": "string"
},
"password_type": {
"description": "只能是once,fixed",
"type": "string",
"enum": [
"once",
"fixed"
]
}
}
},
"admin.TagForm": {
"type": "object",
"required": [

View File

@@ -141,6 +141,25 @@ definitions:
version:
type: string
type: object
admin.ShareByWebClientForm:
properties:
expire:
type: integer
id:
type: string
password:
type: string
password_type:
description: 只能是once,fixed
enum:
- once
- fixed
type: string
required:
- id
- password
- password_type
type: object
admin.TagForm:
properties:
color:
@@ -618,6 +637,34 @@ paths:
summary: 地址簿列表
tags:
- 地址簿
/admin/address_book/share:
post:
consumes:
- application/json
description: 地址簿分享
parameters:
- description: 地址簿信息
in: body
name: body
required: true
schema:
$ref: '#/definitions/admin.ShareByWebClientForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 地址簿分享
tags:
- 地址簿
/admin/address_book/update:
post:
consumes:
@@ -651,6 +698,27 @@ paths:
summary: 地址簿编辑
tags:
- 地址簿
/admin/app-config:
get:
consumes:
- application/json
description: APP服务配置
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: APP服务配置
tags:
- ADMIN
/admin/file/oss_token:
get:
consumes:
@@ -1283,6 +1351,14 @@ paths:
in: query
name: time_ago
type: integer
- description: ID
in: query
name: id
type: string
- description: 主机名
in: query
name: hostname
type: string
produces:
- application/json
responses:
@@ -1355,7 +1431,7 @@ paths:
$ref: '#/definitions/response.Response'
security:
- token: []
summary: 服务配置
summary: RUSTDESK服务配置
tags:
- ADMIN
/admin/tag/create:

View File

@@ -945,13 +945,37 @@ const docTemplateapi = `{
}
}
},
"/shared-peer": {
"post": {
"description": "分享的peer",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"WEBCLIENT"
],
"summary": "分享的peer",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/sysinfo": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "提交系统信息",
"consumes": [
"application/json"

View File

@@ -938,13 +938,37 @@
}
}
},
"/shared-peer": {
"post": {
"description": "分享的peer",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"WEBCLIENT"
],
"summary": "分享的peer",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.Response"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.Response"
}
}
}
}
},
"/sysinfo": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "提交系统信息",
"consumes": [
"application/json"

View File

@@ -727,6 +727,25 @@ paths:
summary: 服务配置
tags:
- WEBCLIENT
/shared-peer:
post:
consumes:
- application/json
description: 分享的peer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.Response'
summary: 分享的peer
tags:
- WEBCLIENT
/sysinfo:
post:
consumes:
@@ -750,8 +769,6 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
security:
- BearerAuth: []
summary: 提交系统信息
tags:
- 地址

View File

@@ -77,6 +77,8 @@ func (ct *Peer) Create(c *gin.Context) {
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param time_ago query int false "时间"
// @Param id query string false "ID"
// @Param hostname query string false "主机名"
// @Success 200 {object} response.Response{data=model.PeerList}
// @Failure 500 {object} response.Response
// @Router /admin/peer/list [get]

View File

@@ -393,7 +393,7 @@ func (a *Ab) PTags(c *gin.Context) {
// @Router /ab/peer/add/{guid} [post]
// @Security BearerAuth
func (a *Ab) PeerAdd(c *gin.Context) {
// forceAlwaysRelay永远是字符串"false",真是坑
// forceAlwaysRelay永远是字符串"false"
//f := &gin.H{}
f := &requstform.PersonalAddressBookForm{}
err := c.ShouldBindJSON(f)
@@ -405,6 +405,16 @@ func (a *Ab) PeerAdd(c *gin.Context) {
u := service.AllService.UserService.CurUser(c)
f.UserId = u.Id
ab := f.ToAddressBook()
if ab.Platform == "" || ab.Username == "" || ab.Hostname == "" {
peer := service.AllService.PeerService.FindById(ab.Id)
if peer.RowId != 0 {
ab.Platform = service.AllService.AddressBookService.PlatformFromOs(peer.Os)
ab.Username = peer.Username
ab.Hostname = peer.Hostname
}
}
err = service.AllService.AddressBookService.AddAddressBook(ab)
if err != nil {
response.Error(c, response.TranslateMsg(c, "OperationFailed")+err.Error())

View File

@@ -3,6 +3,7 @@ package api
import (
requstform "Gwen/http/request/api"
"Gwen/http/response"
"Gwen/model"
"Gwen/service"
"github.com/gin-gonic/gin"
"net/http"
@@ -53,7 +54,11 @@ func (i *Index) Heartbeat(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
return
}
peer.LastOnlineTime = time.Now().Unix()
service.AllService.PeerService.Update(peer)
//如果在一分钟以内则不更新
if time.Now().Unix()-peer.LastOnlineTime > 60 {
peer.LastOnlineTime = time.Now().Unix()
upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: peer.LastOnlineTime}
service.AllService.PeerService.Update(upp)
}
c.JSON(http.StatusOK, gin.H{})
}

View File

@@ -5,6 +5,7 @@ import (
"Gwen/model"
"github.com/google/uuid"
"gorm.io/gorm"
"strings"
)
type AddressBookService struct {
@@ -69,6 +70,14 @@ func (s *AddressBookService) UpdateAddressBook(abs []*model.AddressBook, userId
ab.UserId = userId
if !ok {
//添加
if ab.Platform == "" || ab.Username == "" || ab.Hostname == "" {
peer := AllService.PeerService.FindById(ab.Id)
if peer.RowId != 0 {
ab.Platform = AllService.AddressBookService.PlatformFromOs(peer.Os)
ab.Username = peer.Username
ab.Hostname = peer.Hostname
}
}
tx.Create(ab)
} else {
//更新
@@ -127,3 +136,20 @@ func (t *AddressBookService) SharedPeer(shareToken string) *model.ShareRecord {
global.DB.Where("share_token = ?", shareToken).First(m)
return m
}
// PlatformFromOs
func (t *AddressBookService) PlatformFromOs(os string) string {
if strings.Contains(os, "Android") || strings.Contains(os, "android") {
return "Android"
}
if strings.Contains(os, "Windows") || strings.Contains(os, "windows") {
return "Windows"
}
if strings.Contains(os, "Linux") || strings.Contains(os, "linux") {
return "Linux"
}
if strings.Contains(os, "mac") || strings.Contains(os, "Mac") {
return "Mac OS"
}
return ""
}