用途

可网站导航栏(navbar)显示天气预报插件。其基本配置如下:

配置

1
2
3
4
5
6
7
8
9
weather:
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:

plugin可选值weatherqweather

weather-中国天气

因中国天气插件平台无法使用,使用该选项将报错。

qweather-和风天气

  1. 登录
    登录/注册和风天气开发平台,并绑定邮箱和手机号。

  2. 创建插件
    打开https://widget.qweather.com/create-simple/,设置插件名称和所需样式

  3. 生成代码
    点击生成代码,将在下方生成一段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>
  4. 复制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
    31
    weather:
    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"
    }
    }