模块:Test:修订间差异
外观
无编辑摘要 标签:已被回退 |
无编辑摘要 标签:手工回退 已被回退 |
||
| 第13行: | 第13行: | ||
local shadeColor = args.shadeColor and mw.text.trim(args.shadeColor) or 'white' | local shadeColor = args.shadeColor and mw.text.trim(args.shadeColor) or 'white' | ||
local color = args.color and mw.text.trim(args.color) or 'transparent' | local color = args.color and mw.text.trim(args.color) or 'transparent' | ||
local animate = args.animate and mw.text.trim(args.animate) or '' | local animate = args.animate and mw.text.trim(args.animate) or 'show' | ||
local action = args.action and mw.text.trim(args.action) | |||
local defaults = { | |||
show='2s', shrink='4s ease-out', clear='2s', appear='5s ease', look='5s ease', | |||
} | |||
local animTiming = action or defaults[animate] or '2s' | |||
local html = mw.html.create() | local html = mw.html.create() | ||
local outer = html:tag('div') | local outer = html:tag('div') | ||
:attr('class', | :attr('class', 'wiki-bg-outer wiki-bg-anim-' .. animate) | ||
:cssText( | :cssText( | ||
'position:fixed;top:0;left:0;width:100%;height:100%;' .. | 'position:fixed;top:0;left:0;width:100%;height:100%;' .. | ||
| 第30行: | 第34行: | ||
outer:wikitext('[[File:' .. imgFile .. '|link=|frameless]]') | outer:wikitext('[[File:' .. imgFile .. '|link=|frameless]]') | ||
-- Always-on auto overlay: white in light mode, dark in dark mode (via CSS @media) | |||
outer:tag('div'):attr('class', 'wiki-bg-shade-auto') | |||
if shade > 0 then | if shade > 0 then | ||
2026年3月3日 (二) 23:57的版本
这个模块是干什么用的?
该模块用于测试,测试完请清空模块内的内容
基本用法
local p = {}
function p.函数名()
return '返回内容'
end
function p.函数名2()
return '返回内容2'
end
return
以上为最基本的用法,其他请自行学习Lua语言
其他
同样也有一个用于测试模板的模板,点这里进入
local p = {}
function p.main(frame)
local args = frame:getParent() and frame:getParent().args or {}
for k, v in pairs(frame.args) do
if args[k] == nil then args[k] = v end
end
local imgFile = args.url or args[1] or 'Test-background.jpg'
local position = args.position and mw.text.trim(args.position) or 'center center'
local opacity = args.opacity and mw.text.trim(args.opacity) or '1'
local shade = tonumber(args.shade) or 0
local shadeColor = args.shadeColor and mw.text.trim(args.shadeColor) or 'white'
local color = args.color and mw.text.trim(args.color) or 'transparent'
local animate = args.animate and mw.text.trim(args.animate) or 'show'
local action = args.action and mw.text.trim(args.action)
local defaults = {
show='2s', shrink='4s ease-out', clear='2s', appear='5s ease', look='5s ease',
}
local animTiming = action or defaults[animate] or '2s'
local html = mw.html.create()
local outer = html:tag('div')
:attr('class', 'wiki-bg-outer wiki-bg-anim-' .. animate)
:cssText(
'position:fixed;top:0;left:0;width:100%;height:100%;' ..
'z-index:-1;pointer-events:none;' ..
'opacity:' .. opacity
)
outer:tag('div'):attr('class', 'wiki-bg-color')
:cssText('position:fixed;top:0;left:0;width:100%;height:100%;background:' .. color)
outer:wikitext('[[File:' .. imgFile .. '|link=|frameless]]')
-- Always-on auto overlay: white in light mode, dark in dark mode (via CSS @media)
outer:tag('div'):attr('class', 'wiki-bg-shade-auto')
if shade > 0 then
outer:tag('div'):attr('class', 'wiki-bg-shade')
:cssText(
'position:fixed;top:0;left:0;width:100%;height:100%;' ..
'background:' .. shadeColor .. ';opacity:' .. tostring(shade)
)
end
return tostring(html)
end
return p