mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
update: 代码格式|前端入口移动至用户名下拉菜单
This commit is contained in:
@@ -32,14 +32,10 @@ func (v *apiV1) serve() {
|
||||
// header: Authorization: Token
|
||||
// query: tag (服务器分组)
|
||||
func (v *apiV1) serverList(c *gin.Context) {
|
||||
token, _ := c.Cookie("Authorization")
|
||||
tag := c.Query("tag")
|
||||
serverAPI := &singleton.ServerAPI{
|
||||
Token: token,
|
||||
Tag: tag,
|
||||
}
|
||||
serverAPI := &singleton.ServerAPI{}
|
||||
if tag != "" {
|
||||
c.JSON(200, serverAPI.GetListByTag())
|
||||
c.JSON(200, serverAPI.GetListByTag(tag))
|
||||
return
|
||||
}
|
||||
c.JSON(200, serverAPI.GetAllList())
|
||||
@@ -50,7 +46,6 @@ func (v *apiV1) serverList(c *gin.Context) {
|
||||
// query: id (服务器ID,逗号分隔,优先级高于tag查询)
|
||||
// query: tag (服务器分组)
|
||||
func (v *apiV1) serverDetails(c *gin.Context) {
|
||||
token, _ := c.Cookie("Authorization")
|
||||
var idList []uint64
|
||||
idListStr := strings.Split(c.Query("id"), ",")
|
||||
if c.Query("id") != "" {
|
||||
@@ -61,17 +56,13 @@ func (v *apiV1) serverDetails(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
tag := c.Query("tag")
|
||||
serverAPI := &singleton.ServerAPI{
|
||||
Token: token,
|
||||
IDList: idList,
|
||||
Tag: tag,
|
||||
}
|
||||
serverAPI := &singleton.ServerAPI{}
|
||||
if tag != "" {
|
||||
c.JSON(200, serverAPI.GetStatusByTag())
|
||||
c.JSON(200, serverAPI.GetStatusByTag(tag))
|
||||
return
|
||||
}
|
||||
if len(idList) != 0 {
|
||||
c.JSON(200, serverAPI.GetStatusByIDList())
|
||||
c.JSON(200, serverAPI.GetStatusByIDList(idList))
|
||||
return
|
||||
}
|
||||
c.JSON(200, serverAPI.GetAllStatus())
|
||||
|
||||
@@ -176,8 +176,21 @@ func (ma *memberAPI) delete(c *gin.Context) {
|
||||
if err == nil {
|
||||
// 删除服务器
|
||||
singleton.ServerLock.Lock()
|
||||
tag := singleton.ServerList[id].Tag
|
||||
delete(singleton.SecretToID, singleton.ServerList[id].Secret)
|
||||
delete(singleton.ServerList, id)
|
||||
index := 0
|
||||
for index < len(singleton.ServerTagToIDList[tag]) {
|
||||
if singleton.ServerTagToIDList[tag][index] == id {
|
||||
break
|
||||
}
|
||||
index++
|
||||
}
|
||||
// 删除旧 Tag-ID 绑定关系
|
||||
singleton.ServerTagToIDList[tag] = append(singleton.ServerTagToIDList[tag][:index], singleton.ServerTagToIDList[tag][index+1:]...)
|
||||
if len(singleton.ServerTagToIDList[tag]) == 0 {
|
||||
delete(singleton.ServerTagToIDList, tag)
|
||||
}
|
||||
singleton.ServerLock.Unlock()
|
||||
singleton.ReSortServer()
|
||||
// 删除循环流量状态中的此服务器相关的记录
|
||||
|
||||
Reference in New Issue
Block a user