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,
  };
};

相關資料來源