打开/关闭搜索
搜索
打开/关闭菜单
5
6
1
403
夜幕之下
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁模块:HttpTest”︁的源代码
来自夜幕之下
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:HttpTest
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
管理员
您可以查看和复制此页面的源代码。
local p = {} local function val(v, fallback) if v == nil or v == "" then return fallback or "—" end return v end -- 用于调试输出表格结构 local function dump(tbl, indent) indent = indent or 0 local formatting = string.rep(" ", indent) if type(tbl) ~= "table" then return tostring(tbl) end local str = "{\n" for k,v in pairs(tbl) do if type(v) == "table" then str = str .. formatting .. " " .. tostring(k) .. " = " .. dump(v, indent+1) .. ",\n" else str = str .. formatting .. " " .. tostring(k) .. " = " .. tostring(v) .. ",\n" end end str = str .. formatting .. "}" return str end function p.get(frame) local cardname = frame.args[1] or "" local url = "https://data.saltedkiss.org/items/cards?filter[stylename][_eq]=" .. mw.uri.encode(cardname) .. "&limit=1&fields=stylename,rarity,character.name,profession.name,desire.name," .. "skill_normal_attack.name,skill_normal_attack.description,skill_normal_attack.levels," .. "skill_passive.name,skill_passive.description,skill_passive.levels," .. "skill_ultimate.name,skill_ultimate.description,skill_ultimate.levels," .. "feats.stages,stories.text" -- 调用 External API local response = mw.ext.jsonapi.get(url) if not response or not response.data then return "API 请求失败或返回为空" end local card = response.data[1] or {} -- 变量映射 local stylename = val(card.stylename) local rarity = val(card.rarity) local character = val(card.character and card.character.name) local profession = val(card.profession and card.profession.name) local desire = val(card.desire and card.desire.name) -- 技能 local skill_normal_attack = { name = val(card.skill_normal_attack and card.skill_normal_attack.name), description = val(card.skill_normal_attack and card.skill_normal_attack.description), levels = card.skill_normal_attack and card.skill_normal_attack.levels or {} } local skill_passive = { name = val(card.skill_passive and card.skill_passive.name), description = val(card.skill_passive and card.skill_passive.description), levels = card.skill_passive and card.skill_passive.levels or {} } local skill_ultimate = { name = val(card.skill_ultimate and card.skill_ultimate.name), description = val(card.skill_ultimate and card.skill_ultimate.description), levels = card.skill_ultimate and card.skill_ultimate.levels or {} } -- feats local feats = {} if card.feats and #card.feats > 0 then for i, featEntry in ipairs(card.feats) do feats[i] = {} if featEntry.stages then feats[i].stages = {} for j, stage in ipairs(featEntry.stages) do feats[i].stages[j] = { stage = stage.stage, extra_name = stage.extra_name, stat_boosts = stage.stat_boosts or {}, value = stage.value or {} } end end end end -- stories local stories = {} if card.stories and #card.stories > 0 then for i, s in ipairs(card.stories) do stories[i] = s.text or "" end end -- 调试输出 local output_table = { stylename = stylename, rarity = rarity, character = character, profession = profession, desire = desire, skill_normal_attack = skill_normal_attack, skill_passive = skill_passive, skill_ultimate = skill_ultimate, feats = feats, stories = stories } -- 直接返回调试字符串 return dump(output_table) end return p
该页面嵌入的页面:
模块:HttpTest/doc
(
查看源代码
)
返回
模块:HttpTest
。
查看“︁模块:HttpTest”︁的源代码
来自夜幕之下