修复无用户信息时主菜单获取临时头像报错

This commit is contained in:
MrZ626
2021-04-28 21:53:50 +08:00
parent e50f1d9f50
commit 602c321067

View File

@@ -28,18 +28,18 @@ for i=1,29 do
end
local db_img={}
local db=setmetatable({},{__index=function(self,k)
if not k then
db_img[k]=defaultAvatar[(k-26)%29+1]
local db=setmetatable({},{__index=function(self,uid)
if not uid then
db_img[uid]=defaultAvatar[1]
return emptyUser
end
local file="cache/user"..k..".dat"
local file="cache/user"..uid..".dat"
local d=fs.getInfo(file)and JSON.decode(fs.read(file))or TABLE.copy(emptyUser)
rawset(self,k,d)
db_img[k]=
rawset(self,uid,d)
db_img[uid]=
type(d.hash)=="string"and #d.hash>0 and fs.getInfo("cache/"..d.hash)and
loadAvatar("cache/"..d.hash)or
defaultAvatar[(k-26)%29+1]
defaultAvatar[(uid-26)%29+1]
return d
end})