无编辑摘要
无编辑摘要
第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