modify
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
DBTextures = {}
|
||||
DBAttachment = {} -- 附件相关
|
||||
local db = {}
|
||||
|
||||
local dbUploadStatus = {}
|
||||
@@ -6,14 +6,16 @@ local isUploading = {}
|
||||
local isDownoading = {}
|
||||
local downloadCallback = {}
|
||||
local downloadDir = Utl.chgToSDCard(Path.Combine(Application.persistentDataPath, CLPathCfg.self.basePath, "download"))
|
||||
local _TimeOutSec = 6 * 60 * 60 * 1000
|
||||
local invokeSec = 60
|
||||
|
||||
function DBTextures.init()
|
||||
InvokeEx.cancelInvoke(DBTextures.releaseTimeout)
|
||||
InvokeEx.invoke(DBTextures.releaseTimeout, 60)
|
||||
function DBAttachment.init()
|
||||
InvokeEx.cancelInvoke(DBAttachment.releaseTimeout)
|
||||
InvokeEx.invoke(DBAttachment.releaseTimeout, invokeSec)
|
||||
end
|
||||
|
||||
function DBTextures.clean()
|
||||
InvokeEx.cancelInvoke(DBTextures.releaseTimeout)
|
||||
function DBAttachment.clean()
|
||||
InvokeEx.cancelInvoke(DBAttachment.releaseTimeout)
|
||||
for k, v in ipairs(db) do
|
||||
GameObject.DestroyImmediate(v)
|
||||
end
|
||||
@@ -29,17 +31,33 @@ function DBTextures.clean()
|
||||
dbUploadStatus = {}
|
||||
end
|
||||
|
||||
function DBTextures.releaseTimeout()
|
||||
function DBAttachment.releaseTimeout()
|
||||
for k, v in ipairs(db) do
|
||||
if DateEx.nowMS - v.lastUseTime > 300000 then
|
||||
if DateEx.nowMS - v.lastUseTime > 3000000 then
|
||||
GameObject.DestroyImmediate(v.texture)
|
||||
db[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 删掉超时的文件
|
||||
local files = FileEx.GetFiles(downloadDir)
|
||||
local count = files.Length
|
||||
for i = 0, count - 1 do
|
||||
---@type System.IO.FileInfo
|
||||
local fi = FileInfo(files[i])
|
||||
if fi then
|
||||
local diff = (DateTime.Now:ToFileTime() - fi.LastAccessTime:ToFileTime()) / 10000
|
||||
if diff > _TimeOutSec then
|
||||
FileEx.Delete(files[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
InvokeEx.invoke(DBAttachment.releaseTimeout, invokeSec)
|
||||
end
|
||||
|
||||
---@return UnityEngine.UnityWebRequest
|
||||
function DBTextures.getByUrl(url, callback, orgs)
|
||||
function DBAttachment.getByUrl(url, callback, orgs)
|
||||
local tt = db[url]
|
||||
if tt then
|
||||
tt.lastUseTime = DateEx.nowMS
|
||||
@@ -65,7 +83,7 @@ function DBTextures.getByUrl(url, callback, orgs)
|
||||
return request
|
||||
end
|
||||
|
||||
function DBTextures.upload(path, uploadPath, finishCallback)
|
||||
function DBAttachment.upload(path, uploadPath, finishCallback)
|
||||
local key = joinStr(path, "_", uploadPath)
|
||||
if (not dbUploadStatus[key]) and (not isUploading[key]) then
|
||||
local www =
|
||||
@@ -91,7 +109,7 @@ function DBTextures.upload(path, uploadPath, finishCallback)
|
||||
end
|
||||
end
|
||||
|
||||
function DBTextures.cancelUpload(path, uploadPath)
|
||||
function DBAttachment.cancelUpload(path, uploadPath)
|
||||
local key = joinStr(path, "_", uploadPath)
|
||||
local www = isUploading[key]
|
||||
if www then
|
||||
@@ -102,7 +120,7 @@ function DBTextures.cancelUpload(path, uploadPath)
|
||||
end
|
||||
end
|
||||
|
||||
function DBTextures.hadDownloaded(name)
|
||||
function DBAttachment.hadDownloaded(name)
|
||||
local localPath = Path.Combine(downloadDir, name)
|
||||
if File.Exists(localPath) then
|
||||
return true, localPath
|
||||
@@ -110,7 +128,7 @@ function DBTextures.hadDownloaded(name)
|
||||
return false, localPath
|
||||
end
|
||||
|
||||
function DBTextures.download(name, url, callback)
|
||||
function DBAttachment.download(name, url, callback)
|
||||
downloadCallback[name] = callback
|
||||
if isDownoading[name] then
|
||||
return isDownoading[name]
|
||||
@@ -153,4 +171,4 @@ function DBTextures.download(name, url, callback)
|
||||
return www
|
||||
end
|
||||
|
||||
return DBTextures
|
||||
return DBAttachment
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c5a5751e2f924a6abdab89e00841a0f
|
||||
guid: cac9f1511b28342cf8dcf803d0838654
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -4,14 +4,14 @@ require "db.DBCust"
|
||||
require "db.DBStatistics"
|
||||
require "db.DBUser"
|
||||
require "db.DBOrder"
|
||||
require "db.DBTextures"
|
||||
require "db.DBAttachment"
|
||||
|
||||
---@class DBRoot
|
||||
DBRoot = {}
|
||||
DBRoot.db = {}
|
||||
DBRoot.init = function()
|
||||
DBMessage.init()
|
||||
DBTextures.init()
|
||||
DBAttachment.init()
|
||||
NetProto.setReceiveCMDCallback(DBRoot.onReceiveData)
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ DBRoot.clean = function()
|
||||
DBMessage.clean()
|
||||
DBCust.clean()
|
||||
DBStatistics.clean()
|
||||
DBTextures.clean()
|
||||
DBAttachment.clean()
|
||||
end
|
||||
|
||||
DBRoot.funcs = {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
---@field loginName
|
||||
---@field groupId
|
||||
---@field imageUrl string 头像
|
||||
---@field char string 首字母
|
||||
|
||||
DBUser = {}
|
||||
local db = {}
|
||||
local icons = {}
|
||||
@@ -22,13 +24,17 @@ function DBUser.clean()
|
||||
rolePermission = {}
|
||||
end
|
||||
|
||||
function DBUser.onGetUsers(list, groupList, permissions)
|
||||
function DBUser.onGetUsers(userlist, groupList, permissions)
|
||||
local options = ArrayList()
|
||||
local values = ArrayList()
|
||||
db.filters = {}
|
||||
local name
|
||||
db.filters[DBUser.FilterGroup.user] = {}
|
||||
for i, v in ipairs(list) do
|
||||
|
||||
--------------------------------------------
|
||||
for i, v in ipairs(userlist) do
|
||||
v.PY = CLUIFormUtl.GetChineseSpell(v.loginName) -- 拼音首字母
|
||||
v.PYFirst = v.PY[1] -- 设置首字母
|
||||
if v.loginName == "系统生成" then
|
||||
name = joinStr(v.loginNo, "_", v.loginName)
|
||||
else
|
||||
@@ -62,6 +68,20 @@ function DBUser.onGetUsers(list, groupList, permissions)
|
||||
for i, v in ipairs(permissions) do
|
||||
rolePermission[v] = true
|
||||
end
|
||||
DBUser.wrapUserList(userlist, groupList)
|
||||
end
|
||||
|
||||
function DBUser.wrapUserList(userlist, groupList)
|
||||
table.sort(
|
||||
userlist,
|
||||
function(a, b)
|
||||
return string.byte(a.PY) < string.byte(b.PY)
|
||||
end
|
||||
)
|
||||
|
||||
-- for i, v in ipairs(userlist) do
|
||||
-- printe(v.PY)
|
||||
-- end
|
||||
end
|
||||
|
||||
function DBUser.getFilters(group)
|
||||
|
||||
Reference in New Issue
Block a user