mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
✨ feat: 展示排序 close #29
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/patrickmn/go-cache"
|
||||
@@ -25,7 +26,8 @@ var Cache *cache.Cache
|
||||
var DB *gorm.DB
|
||||
|
||||
// ServerList ..
|
||||
var ServerList map[string]*model.Server
|
||||
var ServerList map[uint64]*model.Server
|
||||
var SortedServerList []*model.Server
|
||||
|
||||
// ServerLock ..
|
||||
var ServerLock sync.RWMutex
|
||||
@@ -39,6 +41,17 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func ReSortServer() {
|
||||
SortedServerList = []*model.Server{}
|
||||
for _, s := range ServerList {
|
||||
SortedServerList = append(SortedServerList, s)
|
||||
}
|
||||
|
||||
sort.SliceStable(SortedServerList, func(i, j int) bool {
|
||||
return SortedServerList[i].DisplayIndex > SortedServerList[j].DisplayIndex
|
||||
})
|
||||
}
|
||||
|
||||
// SendCommand ..
|
||||
func SendCommand(cmd *pb.Command) {
|
||||
ServerLock.RLock()
|
||||
|
||||
Reference in New Issue
Block a user