跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
451
条目
806
文件
22
用户
9167
编辑
Blockland Wiki
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
打开/关闭外观设置菜单
无法加载外观设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁MediaWiki:Common.css”︁的源代码
MediaWiki界面页面
查看
阅读
查看源代码
查看历史
相关页面
系统消息
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
Cargo数据
←
MediaWiki:Common.css
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此CSS页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
local p = {} function p.renderSidebar(frame) local extData = mw.ext.externalData if not extData or not extData.getDbData then return "错误:未找到 External Data 接口" end -- 1. 获取最新期数 local latest_data = extData.getDbData{ db = 'wp_db', from = 'wp_owmc_currency_rates', ['order by'] = 'year DESC, month DESC', limit = 1, data = 'year=year, month=month' } if not latest_data or not latest_data[1] then return "暂无行情数据" end local max_y = tonumber(latest_data[1].year) local max_m = tonumber(latest_data[1].month) -- 2. 计算 8 期前(1 个月前)的期数 local current_abs = max_y * 104 + max_m local old_abs = current_abs - 8 local old_y = math.floor((old_abs - 1) / 104) local old_m = ((old_abs - 1) % 104) + 1 -- 3. 抓取本期和上月的数据 local current_rates = extData.getDbData{ db = 'wp_db', from = 'wp_owmc_currency_rates', where = string.format("year=%d AND month=%d", max_y, max_m), limit = 200, data = 'currency_code=currency_code, rate=rate' } local old_rates = extData.getDbData{ db = 'wp_db', from = 'wp_owmc_currency_rates', where = string.format("year=%d AND month=%d", old_y, old_m), limit = 200, data = 'currency_code=currency_code, rate=rate' } local meta_data = extData.getDbData{ db = 'wp_db', from = 'wp_owmc_currency_meta', limit = 200, data = 'currency_code=currency_code, currency_name=currency_name' } -- 4. 数据映射与处理 local meta_map, old_map = {}, {} if meta_data then for _, r in ipairs(meta_data) do meta_map[r.currency_code] = r.currency_name end end if old_rates then for _, r in ipairs(old_rates) do old_map[r.currency_code] = tonumber(r.rate) end end local stats = {} if current_rates then for _, row in ipairs(current_rates) do local code = row.currency_code local c_rate = tonumber(row.rate) local o_rate = old_map[code] if c_rate and o_rate and c_rate > 0 then local val_current = 1 / c_rate local val_old = 1 / o_rate local pct = ((val_current - val_old) / val_old) * 100 table.insert(stats, { code = code, name = meta_map[code] or code, val = val_current, pct = pct }) end end end table.sort(stats, function(a, b) return a.pct > b.pct end) -- 5. 渲染 HTML (去掉了固定宽度、边框和阴影,默认撑满 100%) local html = mw.html.create('div') :cssText("width: 100%; margin: 0 0 16px 0; background: transparent; font-family: -apple-system, 'Segoe UI', sans-serif;") local function renderRow(item) local is_up = item.pct >= 0 local color = is_up and "#f43f5e" or "#10b981" local sign = is_up and "▲ +" or "▼ " local pct_str = string.format("%.2f%%", item.pct) local val_str = string.format("%.4f", item.val) -- 引入 RemixIcon 图标作为趋势线 local icon_class = is_up and "ri-trend-up-line" or "ri-trend-down-line" if item.pct == 0 then icon_class = "ri-subtract-line" end local sparkline = string.format('<i class="%s" style="color: %s; font-size: 24px; opacity: 0.8;"></i>', icon_class, color) return string.format([[ <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9;"> <div style="flex: 1; text-align: left;"> <div style="font-weight: 900; color: #0f172a; font-size: 14px; font-family: 'Courier New', monospace;">%s</div> <div style="font-size: 11px; color: #64748b; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px;">%s</div> </div> <div style="flex: 0 0 50px; text-align: center;">%s</div> <div style="flex: 1; text-align: right;"> <div style="font-weight: bold; font-family: 'Courier New', monospace; font-size: 14px; color: #0f172a;">%s</div> <div style="font-size: 11px; font-weight: 800; color: %s; letter-spacing: -0.5px;">%s%s</div> </div> </div> ]], item.code, item.name, sparkline, val_str, color, sign, pct_str) end -- 渲染区块标题样式 local function renderHeader(title, color) return mw.html.create('div'):cssText(string.format("font-size: 12px; font-weight: 800; color: %s; text-transform: uppercase; margin-top: 12px; margin-bottom: 4px;", color)):wikitext(title) end html:node(renderHeader("Core Assets / 主币", "#94a3b8")) local cores = {WMC=true, KCK=true, SKV=true, COS=true} for _, item in ipairs(stats) do if cores[item.code] then html:node(mw.html.create('div'):wikitext(renderRow(item))) end end html:node(renderHeader("Top Gainers / 领涨", "#f43f5e")) local count = 0 for _, item in ipairs(stats) do if not cores[item.code] and item.pct > 0 then html:node(mw.html.create('div'):wikitext(renderRow(item))) count = count + 1 if count >= 3 then break end end end html:node(renderHeader("Top Losers / 领跌", "#10b981")) count = 0 for i = #stats, 1, -1 do local item = stats[i] if not cores[item.code] and item.pct < 0 then html:node(mw.html.create('div'):wikitext(renderRow(item))) count = count + 1 if count >= 3 then break end end end return tostring(html) end return p
此页面嵌入的页面:
模板:IPA
(
查看源代码
)
返回
MediaWiki:Common.css
。
查看“︁MediaWiki:Common.css”︁的源代码
MediaWiki界面页面