模块:Db:修订间差异
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
||
| (未显示同一用户的2个中间版本) | |||
| 第328行: | 第328行: | ||
-- ** 预处理 conditionValue ** | -- ** 预处理 conditionValue ** | ||
if type(conditionValue) == 'string' then | if type(conditionValue) == 'string' then | ||
local trimmedValue = mw.text.trim(conditionValue) | local trimmedValue = mw.text.trim(conditionValue) | ||
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 | ||
if isPackFilter | -- 2a. Pack 字段: 缩写解析后的精确匹配 (Case-insensitive Exact Match) | ||
-- | if isPackFilter then | ||
local targetValue = resolvedConditionValue -- 这会是完整的包名或原始输入 | |||
if string.upper(currentValue) == string.upper(targetValue) then | |||
match = true | |||
end | |||
-- 模糊匹配:只要 currentValue 包含 searchString(不区分大小写) | -- 2b. 其他字符串字段: 模糊匹配 (Case-insensitive Fuzzy Match) | ||
else | |||
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 -- 宽度要求失效检查 | ||
-- BPM/Key/Duration 字段,固定宽度 6% | |||
if field == 'bpm' or field == 'key' or field == 'duration' then | |||
headerStyle = ' style="width: 6%;"' | |||
separator = ' | ' | |||
-- Pack 字段,固定宽度 10% | |||
elseif field == 'pack' then | |||
headerStyle = ' style="width: 10%;"' | |||
separator = ' | ' | |||
elseif mode then -- 谱面难度字段 (3.2% 固定宽度) | |||
headerStyle = ' style="width: 3.2%;"' | |||
separator = ' | ' | |||
elseif string.match(field, '_notes$') then -- NOTES 字段 (4% 固定宽度) | |||
headerStyle = ' style="width: 4%;"' | |||
separator = ' | ' | |||
end | |||
end | end | ||