【优化】服务器列表排序

dev_chengFeng
ZhangBiao 2021-10-11 15:01:49 +08:00
parent 4ff2e1dc8d
commit 853933b0ea
2 changed files with 19 additions and 6 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9e51bffc03022dd4a811ab704bbec993
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -603,13 +603,18 @@ function this.CacheLoginData(data)
for i = 1, #data.serverList do
this.serverList[i] = data.serverList[i]
end
table.sort(this.serverList, function(a, b)
if a.isnew == b.isnew then
return a.server_id < b.server_id
else
return a.isnew > b.isnew
--取消serverId排序改用后端原数据手动把isnew的数据插入到第一个
local tempList = {}
for i = 1, #this.serverList do
if this.serverList[i].isnew > 0 then
local tempData = this.serverList[i]
for j = i, 2, -1 do
this.serverList[j] = this.serverList[j-1]
end
this.serverList[1] = tempData
break
end
end)
end
this.myServerList = {}
for i = 1, #data.myServerList do
this.myServerList[i] = data.myServerList[i]