配置天气预报
用途
可网站导航栏(navbar)显示天气预报插件。其基本配置如下:
配置
1 | weather: |
plugin可选值weather或qweather。
weather为中国天气插件平台的网页简约插件,该平台目前暂不可用。qweather为和风天气开发平台简约版天气插件
weather-中国天气
因中国天气插件平台无法使用,使用该选项将报错。
qweather-和风天气
登录
登录/注册和风天气开发平台,并绑定邮箱和手机号。创建插件
打开https://widget.qweather.com/create-simple/,设置插件名称和所需样式生成代码
点击生成代码,将在下方生成一段html代码,如下所示:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27<div id="he-plugin-simple"></div>
<script>
WIDGET = {
"CONFIG": {
"modules": "01234",
"background": "1",
"tmpColor": "FFFFFF",
"tmpSize": "16",
"cityColor": "FFFFFF",
"citySize": "16",
"aqiColor": "FFFFFF",
"aqiSize": "16",
"weatherIconSize": "24",
"alertIconSize": "18",
"padding": "10px 10px 10px 10px",
"shadow": "1",
"language": "auto",
"borderRadius": "30",
"fixed": "false",
"vertical": "center",
"horizontal": "left",
"key": "3dd3fa00d5c14d7e962478a6e6bad3b3"
}
}
</script>
<script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script>复制WIDGET
复制其中的WIDGET部分,并在配置文件中进行设置。最终配置文件的weather部分如下所示(注意缩进):1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31weather:
enable: true # 是否显示天气插件
plugin: qweather # weather / qweather
weather: # <https://cj.weather.com.cn/plugin/simple>
# 只需粘贴WIDGET部分
widget:
qweather: # <https://widget.qweather.com/create-simple/>
# 只需粘贴WIDGET部分
widget: >
WIDGET = {
"CONFIG": {
"modules": "01234",
"background": "1",
"tmpColor": "FFFFFF",
"tmpSize": "16",
"cityColor": "FFFFFF",
"citySize": "16",
"aqiColor": "FFFFFF",
"aqiSize": "16",
"weatherIconSize": "24",
"alertIconSize": "18",
"padding": "10px 10px 10px 10px",
"shadow": "1",
"language": "auto",
"borderRadius": "30",
"fixed": "false",
"vertical": "center",
"horizontal": "left",
"key": "3dd3fa00d5c14d7e962478a6e6bad3b3"
}
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Firefly!
