模块:Db:修订间差异
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
MJ Hamster(留言 | 贡献) 小无编辑摘要 标签:已被回退 |
||
| 第80行: | 第80行: | ||
end | end | ||
-- 格式化单个值的私有函数 ( | -- 格式化单个值的私有函数 (基础格式化,不应用BPM或难度样式) | ||
local function formatSingleValue(value, fieldType) | local function formatSingleValue(value, fieldType) | ||
if value == nil then | if value == nil then | ||
| 第89行: | 第89行: | ||
return p.valueMappingMethod[fieldType](value) | return p.valueMappingMethod[fieldType](value) | ||
else | else | ||
return tostring(value) | |||
end | end | ||
end | end | ||
-- 仅在表格中应用的BPM样式 | |||
local function formatBPMValue(rawValue) | |||
local strValue = tostring(rawValue) | |||
if string.find(strValue, '-') then | |||
return '<span style="color:red;">' .. strValue .. '</span>' | |||
end | |||
return rawValue | |||
end | |||
-- 获取难度模式 (使用哈希表检查,使用 sub 提取模式) | -- 获取难度模式 (使用哈希表检查,使用 sub 提取模式) | ||
| 第213行: | 第216行: | ||
local value = ValueFromValuesByKey(songEntry, argType) | local value = ValueFromValuesByKey(songEntry, argType) | ||
-- | -- 在 p.value 中,只进行基础格式化,不应用任何颜色或加粗样式 | ||
local formattedValue = formatSingleValue(value, argType) | local formattedValue = formatSingleValue(value, argType) | ||
| 第219行: | 第222行: | ||
end | end | ||
return table.concat(resultTable, ' / ') | -- FIX: 使用 / 代替 / 来防止非数字值导致自动换行 | ||
return table.concat(resultTable, ' / ') | |||
end | end | ||
| 第318行: | 第322行: | ||
for _, songId in ipairs(matchingKeys) do | for _, songId in ipairs(matchingKeys) do | ||
local songEntry = songData[songId] | local songEntry = songData[songId] | ||
table.insert(output, '|-') | table.insert(output, '\n|-') -- 确保新行开始 | ||
local rowCells = {} | local rowCells = {} | ||
| 第328行: | 第332行: | ||
local formattedValue = formatSingleValue(rawValue, field) | local formattedValue = formatSingleValue(rawValue, field) | ||
-- | -- **应用 BPM 样式** (仅在表格中) | ||
if field == 'bpm' then | |||
formattedValue = formatBPMValue(formattedValue) | |||
end | |||
-- **应用难度样式** (仅在表格中) | |||
local btn, mode = getDifficultyDetails(field) | local btn, mode = getDifficultyDetails(field) | ||
if btn and mode then | if btn and mode then | ||
| 第346行: | 第355行: | ||
end | end | ||
table.insert(output, '|}') | table.insert(output, '\n|}') | ||
return table.concat(output, ' | return table.concat(output, '') | ||
end | end | ||
return p | return p | ||