打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
Smalllqiang​(留言 | 贡献)2026年8月11日 (二) 02:24的版本 (创建页面,内容为“local p = {} -- 获取制品页面 -- 输入 制品名, 无父页面 -- 输出 制品页面 function p.getWorkPage(frame) local workName = frame.args[1] local targetPage = nil local currentTitle = mw.title.getCurrentTitle().prefixedText -- 如果当前页面下有同名子页面, 优先选择此 if mw.title.new(currentTitle .. '/' .. workName).exists then targetPage = currentTitle .. '/' .. workName -- 选择(主)命名空间下…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

local p = {}

-- 获取制品页面
-- 输入 制品名, 无父页面
-- 输出 制品页面
function p.getWorkPage(frame)
    local workName = frame.args[1]
    local targetPage = nil
    local currentTitle = mw.title.getCurrentTitle().prefixedText
    -- 如果当前页面下有同名子页面, 优先选择此
    if mw.title.new(currentTitle .. '/' .. workName).exists then
        targetPage = currentTitle .. '/' .. workName
    -- 选择(主)命名空间下的同名页面
    elseif mw.title.new(workName).exists then
    	targetPage = workName
    end

    return targetPage
end

return p