打开/关闭搜索
搜索
打开/关闭菜单
933
1525
112
1.4万
植物大战僵尸杂交版Wiki
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
notifications
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁微件:Weather”︁的源代码
来自植物大战僵尸杂交版Wiki
查看
阅读
查看源代码
查看历史
associated-pages
微件
讨论
更多操作
←
微件:Weather
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您没有权限编辑
微件
命名空间内的页面。
您可以查看和复制此页面的源代码。
<includeonly> <div class="weather-widget" style=" display:inline-block; padding:12px 20px; background:linear-gradient(135deg,#e8f4fd,#b8d8e8); border-radius:12px; border:1px solid #80b8d0; min-width:200px; text-align:center; "> <div style="font-size:14px;font-weight:bold;color:#2c5a7a;"><!--{$city|default:'北京'}--></div> <div style="font-size:32px;margin:4px 0;" id="weather-icon-<!--{$id|default:''}-->">🌤️</div> <div style="font-size:20px;font-weight:bold;color:#1a3a4a;" id="weather-temp-<!--{$id|default:''}-->">--°C</div> <div style="font-size:12px;color:#4a7a8a;" id="weather-desc-<!--{$id|default:''}-->">加载中...</div> <div style="font-size:10px;color:#6a9aaa;margin-top:4px;">数据来自 wttr.in</div> </div> <script> (function() { const id = '<!--{$id|default:''}-->'; const city = '<!--{$city|default:'北京'}-->'; const tempEl = document.getElementById('weather-temp-' + id); const descEl = document.getElementById('weather-desc-' + id); const iconEl = document.getElementById('weather-icon-' + id); if (!tempEl) return; fetch('https://wttr.in/' + encodeURIComponent(city) + '?format=j1&lang=zh') .then(res => res.json()) .then(data => { const current = data.current_condition[0]; const temp = current.temp_C; const desc = current.weatherDesc[0].value; const code = current.weatherCode; // 天气图标映射 const icons = { '113': '☀️', '116': '⛅', '119': '☁️', '122': '☁️', '176': '🌦️', '179': '🌨️', '182': '🌧️', '185': '🌧️', '200': '⛈️', '227': '🌨️', '230': '🌨️', '248': '🌫️', '260': '🌫️', '263': '🌦️', '266': '🌧️', '281': '🌧️', '284': '🌧️', '293': '🌦️', '296': '🌧️', '299': '🌧️', '302': '🌧️', '305': '🌧️', '308': '🌧️', '311': '🌧️', '314': '🌧️', '317': '🌧️', '320': '🌨️', '323': '🌨️', '326': '🌨️', '329': '🌨️', '332': '🌨️', '335': '🌨️', '338': '🌨️', '350': '🌧️', '353': '🌦️', '356': '🌧️', '359': '🌧️', '362': '🌧️', '365': '🌧️', '368': '🌨️', '371': '🌨️', '374': '🌧️', '377': '🌧️', '386': '⛈️', '389': '⛈️', '392': '⛈️', '395': '🌨️' }; if (iconEl) iconEl.textContent = icons[code] || '🌤️'; tempEl.textContent = temp + '°C'; descEl.textContent = desc; }) .catch(() => { tempEl.textContent = '--°C'; descEl.textContent = '加载失败'; }); })(); </script> </includeonly>
返回
微件:Weather
。
查看“︁微件:Weather”︁的源代码
来自植物大战僵尸杂交版Wiki