无编辑摘要
无编辑摘要
第84行: 第84行:
local function formatSingleValue(value, fieldType)
local function formatSingleValue(value, fieldType)
     if value == nil then
     if value == nil then
         return i18n['none']
         return i18n['none'] -- 将 nil 转换为 '无'
     elseif type(value) == 'boolean' then
     elseif type(value) == 'boolean' then
         return value and i18n['true'] or i18n['false']
         return value and i18n['true'] or i18n['false']
第95行: 第95行:


-- 仅在表格中应用的BPM样式
-- 仅在表格中应用的BPM样式
local function formatBPMValue(rawValue)
local function formatBPMValue(valueString)
     local strValue = tostring(rawValue)
     -- valueString 预期是经过 formatSingleValue 处理的字符串
     if string.find(strValue, '-') then
     if string.find(valueString, '-') then
         return '<span style="color:red;">' .. strValue .. '</span>'
         return '<span style="color:red;">' .. valueString .. '</span>'
     end
     end
     return rawValue
     return valueString
end
end


第127行: 第127行:


-- **核心功能:根据难度和数值应用内联样式 (仅用于表格)**
-- **核心功能:根据难度和数值应用内联样式 (仅用于表格)**
local function formatDifficultyValue(rawValue, btn, mode)
local function formatDifficultyValue(valueString, btn, mode)
     -- rawValue 预期是纯数字或非数字字符串 (' - ', '无')
     -- valueString 预期是经过 formatSingleValue 处理的字符串 (例如 '15', ' - ', '无')
     local numValue = tonumber(rawValue)
     local numValue = tonumber(valueString)
   
    -- 如果无法转换为数字,则返回原始字符串 (例如: ' - ' 或 '无')
     if numValue == nil then
     if numValue == nil then
         return rawValue -- 如果不是数字则返回原始值 (例如: ' - ' 或 '无')
         return valueString
     end
     end


第165行: 第167行:
     end
     end
      
      
     local displayValue = tostring(numValue)
     -- displayValue 已经是纯数字字符串 (例如 '15')
 
     if style ~= '' then
     if style ~= '' then
         -- 返回带样式的纯数字字符串 (不包含 'sc' 前缀)
         -- 返回带样式的纯数字字符串 (不包含 'sc' 前缀)
         return '<span style="' .. style .. '">' .. displayValue .. '</span>'
         return '<span style="' .. style .. '">' .. valueString .. '</span>'
     end
     end
      
      
     return displayValue -- 返回纯数字字符串(如果没有样式应用)
     return valueString -- 返回纯数字字符串(如果没有样式应用)
end
end


第228行: 第229行:
         local value = ValueFromValuesByKey(songEntry, argType)
         local value = ValueFromValuesByKey(songEntry, argType)
          
          
         -- 在 p.value 中,只进行基础格式化,不应用任何颜色或加粗样式
         -- 核心:p.value 只进行基础格式化,不应用 BPM 或难度样式
         local formattedValue = formatSingleValue(value, argType)  
         local formattedValue = formatSingleValue(value, argType)  
          
          
第349行: 第350行:
             local rawValue = ValueFromValuesByKey(songEntry, field)
             local rawValue = ValueFromValuesByKey(songEntry, field)
              
              
            -- 步骤 1: 基础格式化 (处理 nil, boolean, duration 等)
             local formattedValue = formatSingleValue(rawValue, field)
             local formattedValue = formatSingleValue(rawValue, field)
              
              
             -- **应用 BPM 样式** (仅在表格中)
             -- 步骤 2: **仅在表格中**应用特殊样式
           
            -- 应用 BPM 样式
             if field == 'bpm' then
             if field == 'bpm' then
                 formattedValue = formatBPMValue(formattedValue)
                 formattedValue = formatBPMValue(formattedValue)
             end
             end


             -- **应用难度样式** (仅在表格中)
             -- 应用难度样式
             local btn, mode = getDifficultyDetails(field)
             local btn, mode = getDifficultyDetails(field)
             if btn and mode then
             if btn and mode then
                 -- 在表格中调用 formatDifficultyValue,它只应用样式和颜色,不添加 'sc' 前缀
                 -- CRITICAL FIX: 传入已经过基础格式化的 formattedValue
                 formattedValue = formatDifficultyValue(rawValue, btn, mode)
                 formattedValue = formatDifficultyValue(formattedValue, btn, mode)
             end
             end