1076390229 2026-03-12 17:12:53 +08:00
parent 0eb369077d
commit 389ce15e23
5 changed files with 122 additions and 3 deletions

View File

@ -379,4 +379,113 @@ function printlog(...)
if debug_print then
print(...)
end
end
end
function TableToString(t, indent, visited)
if type(t) ~= "table" then
if type(t) == "string" then
return '"' .. t:gsub('["\\]', '\\%0') .. '"'
elseif type(t) == "number" or type(t) == "boolean" then
return tostring(t)
elseif type(t) == "function" then
-- 尝试获取函数名
local info = debug.getinfo(t, "n")
if info and info.name and info.name ~= "" then
return '"<function: ' .. info.name .. '>"'
else
return '"<function>"'
end
else
return '"<' .. type(t) .. '>"'
end
end
visited = visited or {}
if visited[t] then
return '"<cyclic reference>"'
end
visited[t] = true
indent = indent or ""
local nextIndent = indent .. " "
-- 更准确的数组检测
local isArray = true
local maxIndex = 0
for k in pairs(t) do
if type(k) ~= "number" or k < 1 or k ~= math.floor(k) then
isArray = false
break
end
if k > maxIndex then
maxIndex = k
end
end
-- 检查连续性
if isArray and maxIndex > 0 then
for i = 1, maxIndex do
if t[i] == nil then
isArray = false
break
end
end
end
local result = ""
if isArray then
result = result .. "["
local parts = {}
for i = 1, maxIndex do
parts[i] = TableToString(t[i], nextIndent, visited)
end
result = result .. table.concat(parts, ",")
result = result .. "]"
else
result = result .. "{\n"
local parts = {}
local count = 0
for k, v in pairs(t) do
count = count + 1
local key
if type(k) == "string" and string.match(k, "^[a-zA-Z_][a-zA-Z0-9_]*$") then
key = '"' .. k .. '"' -- 即使是标识符也加双引号保持JSON格式
else
key = '"' .. tostring(k):gsub('["\\]', '\\%0') .. '"'
end
local valueStr
if type(v) == "function" then
-- 对函数进行特殊处理,只显示方法名
local info = debug.getinfo(v, "n")
if info and info.name and info.name ~= "" then
valueStr = '"<function: ' .. info.name .. '>"'
else
valueStr = '"<function>"'
end
else
valueStr = TableToString(v, nextIndent, visited)
end
parts[count] = nextIndent .. key .. ": " .. valueStr
end
-- 按键名排序,使输出更一致
table.sort(parts, function(a, b)
local keyA = a:match('^%s*"([^"]+)"')
local keyB = b:match('^%s*"([^"]+)"')
return (keyA or "") < (keyB or "")
end)
result = result .. table.concat(parts, ",\n")
if count > 0 then
result = result .. "\n" .. indent
end
result = result .. "}"
end
visited[t] = nil
return result
end

View File

@ -0,0 +1,10 @@
{
"objectStatus": {
"n76_oqog": {
"collapsed": true
},
"n77_oqog": {
"collapsed": true
}
}
}

View File

@ -17,7 +17,7 @@
<relation target="" sidePair="center-center,bottom-bottom"/>
</component>
<component id="n37_n1ry" name="mask_liangpai" src="peuq59" fileName="component/Component1.xml" xy="868,-91" size="5,5"/>
<component id="n38_ey1o" name="n38" src="peuq5b" fileName="component/Main/component/PromptOutCard.xml" xy="16,-177" size="1577,170">
<component id="n38_ey1o" name="n38" src="peuq5b" fileName="component/Main/component/PromptOutCard.xml" xy="16,-177" size="1577,5">
<gearDisplay controller="chupai" pages="1"/>
</component>
<component id="n27" name="area_outcard_list" src="peuq59" fileName="component/Component1.xml" xy="1398,-838" size="218,155">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="678,162">
<displayList>
<list id="n1_lr5d" name="lit_fanzi" xy="0,0" size="678,162" layout="row" selectionMode="none" defaultItem="ui://lkq9ne9speuq9k" autoItemSize="false" align="right" vAlign="middle">
<list id="n1_lr5d" name="lit_fanzi" xy="0,0" size="678,162" layout="row" selectionMode="none" colGap="50" defaultItem="ui://lkq9ne9speuq9k" autoItemSize="false" align="right" vAlign="middle">
<item/>
<item/>
<item/>