跳转到内容

模块:Test:修订间差异

来自SS唯基
攸萨留言 | 贡献
无编辑摘要
标签已被回退
攸萨留言 | 贡献
清空全部内容
标签清空 手工回退
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
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 ''
    local html = mw.html.create()
    local cls = 'wiki-bg-outer'
    if animate ~= '' then cls = cls .. ' wiki-bg-anim-' .. animate end
    local outer = html:tag('div')
        :attr('class', cls)
        :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]]')
    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

2026年3月8日 (日) 06:28的最新版本

Documentation icon 模块文档 [-查看-] [编辑] [历史] [刷新]

这个模块是干什么用的?

该模块用于测试,测试完请清空模块内的内容

基本用法

local p = {}

function p.函数名()
return '返回内容'
end

function p.函数名2()
return '返回内容2'
end

return

以上为最基本的用法,其他请自行学习Lua语言

其他

同样也有一个用于测试模板的模板,点这里进入