无编辑摘要
无编辑摘要
 
(未显示同一用户的2个中间版本)
第328行: 第328行:


     -- ** 预处理 conditionValue **
     -- ** 预处理 conditionValue **
    local originalConditionValue = conditionValue
     if type(conditionValue) == 'string' then
     if type(conditionValue) == 'string' then
         local trimmedValue = mw.text.trim(conditionValue)
         local trimmedValue = mw.text.trim(conditionValue)
        originalConditionValue = trimmedValue -- 存储原始字符串值,以便在 Pack 缩写解析失败时使用
          
          
         local lowerValue = string.lower(trimmedValue)
         local lowerValue = string.lower(trimmedValue)
第374行: 第372行:
             local match = false
             local match = false
              
              
             -- 处理布尔值和数字的精确匹配
             -- 1. 数字和布尔值的精确匹配
             if currentValue == conditionValue then
             if currentValue == conditionValue then
                 match = true
                 match = true
             -- 处理字符串的模糊匹配(不区分大小写)
           
             -- 2. 字符串匹配
             elseif type(currentValue) == 'string' and type(conditionValue) == 'string' then
             elseif type(currentValue) == 'string' and type(conditionValue) == 'string' then
                local searchString = conditionValue
                  
                  
                 if isPackFilter and resolvedConditionValue ~= conditionValue then
                -- 2a. Pack 字段: 缩写解析后的精确匹配 (Case-insensitive Exact Match)
                     -- 如果是 Pack 筛选且成功解析了缩写,以解析后的完整包名作为搜索字符串
                 if isPackFilter then
                     searchString = resolvedConditionValue
                     local targetValue = resolvedConditionValue -- 这会是完整的包名或原始输入
                end
                   
                     if string.upper(currentValue) == string.upper(targetValue) then
                        match = true
                    end
                  
                  
                 -- 模糊匹配:只要 currentValue 包含 searchString(不区分大小写)
                 -- 2b. 其他字符串字段: 模糊匹配 (Case-insensitive Fuzzy Match)
                if string.find(string.upper(currentValue), string.upper(searchString), 1, true) then -- '1, true' 表示从第一个字符开始,且不使用 Lua 模式匹配
                else
                    match = true
                    local searchString = conditionValue
                   
                    -- 模糊匹配:只要 currentValue 包含 searchString(不区分大小写)
                    if string.find(string.upper(currentValue), string.upper(searchString), 1, true) then  
                        match = true
                    end
                 end
                 end
             end
             end
第405行: 第411行:


     local output = {}
     local output = {}
   
    -- 检查是否需要禁用宽度设置
    local disableWidths = (#displayFields <= 8)
      
      
     -- 表格样式
     -- 表格样式
第419行: 第428行:
         local separator = ' ' -- 默认分隔符是空格
         local separator = ' ' -- 默认分隔符是空格
          
          
         -- BPM/Key/Duration 字段,固定宽度 6%
         if not disableWidths then -- 宽度要求失效检查
        if field == 'bpm' or field == 'key' or field == 'duration' then  
            -- BPM/Key/Duration 字段,固定宽度 6%
            headerStyle = ' style="width: 6%;"'
            if field == 'bpm' or field == 'key' or field == 'duration' then  
            separator = ' | '  
                headerStyle = ' style="width: 6%;"'
        -- Pack 字段,固定宽度 8%
                separator = ' | '  
        elseif field == 'pack' then
            -- Pack 字段,固定宽度 10%
            headerStyle = ' style="width: 8%;"'
            elseif field == 'pack' then
            separator = ' | '  
                headerStyle = ' style="width: 10%;"'
        elseif mode then -- 谱面难度字段 (3.2% 固定宽度)
                separator = ' | '  
            headerStyle = ' style="width: 3.2%;"'
            elseif mode then -- 谱面难度字段 (3.2% 固定宽度)
            separator = ' | '  
                headerStyle = ' style="width: 3.2%;"'
        elseif string.match(field, '_notes$') then -- NOTES 字段 (4% 固定宽度)
                separator = ' | '  
            headerStyle = ' style="width: 4%;"'
            elseif string.match(field, '_notes$') then -- NOTES 字段 (4% 固定宽度)
            separator = ' | '  
                headerStyle = ' style="width: 4%;"'
                separator = ' | '  
            end
         end
         end