模块:Test:修订间差异

来自夜幕之下
跳到导航跳到搜索
Rin留言 | 贡献
无编辑摘要
Rin留言 | 贡献
无编辑摘要
第1行: 第1行:
-- Module:CardFullscreen
local p = {}
local p = {}


-- 最简单的全屏卡面模块
--[[
function p.main(frame)
  最简全屏卡面模块
    -- 创建外层容器
  使用示例:{{#invoke:CardFullscreen|main|file=示例卡面.jpg}}
    local html = mw.html.create('div')
--]]
        :addClass('card-fullscreen-wrapper')
        :css('position', 'relative')
        :css('width', '100%')
        :css('height', '100vh')  -- 全屏高度
        :css('overflow', 'hidden')


     -- 卡面图片
-- 生成全屏卡面
     html:tag('div')
local function cardFullscreenImg(fileName)
         :addClass('card-fullscreen-img')
     fileName = fileName or "test卡面.jpg"  -- 默认图片
         :css('background-image', 'url([[File:test卡面.jpg]])')  -- 替换为你的文件名
     local section = mw.html.create()
        :css('background-size', 'cover')
    section:tag('div')
        :css('background-position', 'center')
         :addClass('card-fullscreen-img') -- CSS 类,可在 wiki 里定义样式
        :css('width', '100%')
         :wikitext('[[File:' .. fileName .. '|center|frameless]]')
        :css('height', '100%')
         :done()
         :done()
    return section
end


    -- 遮罩层(可加渐变或半透明黑色)
-- 输出函数
    html:tag('div')
function p.main(frame)
        :addClass('card-fullscreen-overlay')
    local args = frame:getParent().args or {}  -- 获取模板参数
        :css('position', 'absolute')
    local fileName = args.file or args[1]    -- 支持 {{#invoke:CardFullscreen|main|file=xxx}}
        :css('top', '0')
   
        :css('left', '0')
    local finalSection = mw.html.create()
        :css('width', '100%')
    finalSection:node(cardFullscreenImg(fileName))
        :css('height', '100%')
     return finalSection
        :css('background', 'rgba(0,0,0,0.3)') -- 半透明黑色
        :done()
 
     return html
end
end


return p
return p

2026年3月2日 (一) 22:51的版本

此模块的文档可以在模块:Test/doc创建

-- Module:CardFullscreen
local p = {}

--[[ 
  最简全屏卡面模块
  使用示例:{{#invoke:CardFullscreen|main|file=示例卡面.jpg}}
--]]

-- 生成全屏卡面
local function cardFullscreenImg(fileName)
    fileName = fileName or "test卡面.jpg"  -- 默认图片
    local section = mw.html.create()
    section:tag('div')
        :addClass('card-fullscreen-img')  -- CSS 类,可在 wiki 里定义样式
        :wikitext('[[File:' .. fileName .. '|center|frameless]]')
        :done()
    return section
end

-- 输出函数
function p.main(frame)
    local args = frame:getParent().args or {}  -- 获取模板参数
    local fileName = args.file or args[1]     -- 支持 {{#invoke:CardFullscreen|main|file=xxx}}
    
    local finalSection = mw.html.create()
    finalSection:node(cardFullscreenImg(fileName))
    return finalSection
end

return p