卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁词典”︁的源代码
←
模块:词典
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} function p.main(frame) local args = frame:getParent().args local term = args[1] or "" local category = args[2] or "" -- 可选参数 -- 加载词典数据 local data = require('Module:词典/data') local dictionary = data.dictionary -- 颜色映射(仅用于边框) local colorMap = { ["白"] = "#ffffff", ["蓝"] = "#0099ff", ["红"] = "#ff3333", ["橙"] = "#f2ba02" } -- 查找词条 local entries = dictionary[term] if not entries then return '<span style="color: red;">未找到词条: ' .. term .. '</span>' end -- 查找匹配的条目 local entry = nil if category == "" then -- 如果没有指定类型,使用第一个条目 entry = entries[1] else -- 如果指定了类型,查找匹配的类型 for _, e in ipairs(entries) do if e["类型"] == category then entry = e break end end end if not entry then return '<span style="color: red;">未找到类型: ' .. category .. ' - ' .. term .. '</span>' end -- 获取边框颜色 local lineColor = colorMap[entry["颜色"]] or colorMap["白"] -- 构建工具提示内容 local tooltipContent = "" -- 添加图标(如果有) if entry["icon"] and entry["icon"] ~= "" then tooltipContent = tooltipContent .. '[[File:' .. entry["icon"] .. '|25px|link=]] ' end tooltipContent = tooltipContent .. term .. '<br>' .. entry["描述"] -- 生成唯一ID local tooltipId = 'tooltip-' .. mw.uri.encode(term .. (category or "")):gsub('[%%%.%-%s]', '') -- 将tooltip内容存储在data属性中 local tooltipHtml = '<div style="width: 250px; height: 2px; background-color: ' .. lineColor .. ';"></div>' .. '<div style="width: 250px; background-color: #343434; color: white; padding: 5px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);">' .. tooltipContent .. '</div>' -- 生成HTML local html = mw.html.create('span') :addClass('dictionary-term') :attr('data-tooltip-content', tooltipHtml) :attr('data-tooltip-id', tooltipId) :css({ ['text-decoration'] = 'underline', ['cursor'] = 'help', ['display'] = 'inline-block' }) :wikitext(term) return tostring(html) end return p
该页面使用的模板:
模块:词典/doc
(
查看源代码
)
返回
模块:词典
。