Glanceway Glanceway
所有信息源

Earthquake Alerts

新闻 v1.0.0

Recent significant earthquakes worldwide from USGS

@codytseng #earthquake #alerts #science

安装与配置方法

  1. 先在 Mac 上安装并打开 Glanceway,再使用上方的安装链接。
  2. 点击“安装到 Glanceway”。如果浏览器无法唤起应用,下载 .gwsrc 文件并在信息源管理中导入。
  3. 填写下列必填字段并保存,设置刷新间隔,等待首次成功获取。

配置检查

  • MIN_MAGNITUDE — 可选. Minimum earthquake magnitude to display
  • TIME_RANGE — 可选. Time range for earthquake data

没有显示内容时如何排查

  • 对照当前版本配置表核对字段、列表项和凭据。下方示例不包含可用的真实凭据。
  • 检查网络与上游服务状态。认证失败或速率限制可能导致刷新失败,应根据上游限制调整间隔。
  • 空列表也可能表示没有符合条件的条目。内容和更新时间取决于数据提供方及信息源实现。

配置项

名称 键 类型 必填 默认值 描述
Min Magnitude MIN_MAGNITUDE select 否 4.5 Minimum earthquake magnitude to display
significant4.52.51.0all
Time Range TIME_RANGE select 否 day Time range for earthquake data
hourdayweekmonth

源代码

id: codytseng/earthquake-usgs
version: 1.0.0
name: Earthquake Alerts
description: Recent significant earthquakes worldwide from USGS
author: codytseng
author_url: https://github.com/codytseng
category: News
tags:
  - earthquake
  - alerts
  - science

config:
  - key: MIN_MAGNITUDE
    name: Min Magnitude
    type: select
    required: false
    default: "4.5"
    description: Minimum earthquake magnitude to display
    options:
      - significant
      - "4.5"
      - "2.5"
      - "1.0"
      - all
  - key: TIME_RANGE
    name: Time Range
    type: select
    required: false
    default: day
    description: Time range for earthquake data
    options:
      - hour
      - day
      - week
      - month
module.exports = async (api) => {
  const minMagnitude = api.config.get("MIN_MAGNITUDE") || "4.5";
  const timeRange = api.config.get("TIME_RANGE") || "day";

  async function fetchData() {
    const res = await api.fetch(
      `https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/${minMagnitude}_${timeRange}.geojson`,
    );
    if (!res.ok || !res.json) {
      throw new Error(`Failed to fetch earthquake data (HTTP ${res.status})`);
    }

    const items = res.json.features.map((feature) => ({
      id: feature.id,
      title: feature.properties.title,
      subtitle: feature.properties.place,
      url: feature.properties.url,
      timestamp: feature.properties.time,
    }));

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

相关信息源