Glanceway Glanceway
Toutes les sources

V2EX

Développement v1.0.0

V2EX 热门话题

@codytseng #v2ex #chinese #tech

Install and configure this source

  1. Install Glanceway and open it on your Mac before using the install link above.
  2. Choose Install in Glanceway. If the browser cannot open the app, download the .gwsrc file and import it through source management.
  3. Complete the required fields below, save, and choose a refresh interval. Check the source after its first successful fetch.

Configuration checklist

  • NODE_NAME — Optional. 按节点筛选(如 python, apple, create)。留空则显示热门话题。 Add each value as a separate list item.

If items are missing

  • Verify the field names, list entries, and credentials against the current version’s configuration table. Sample values below are examples, not active credentials.
  • Check network access and upstream service availability. Authentication failures and rate limits can prevent a refresh; use a slower interval when the provider limits requests.
  • An empty result can also mean there are no matching items. Fetched content and update timing depend on the provider and source implementation.

Configuration

Nom Clé Type Requis Défaut Description
节点名称 NODE_NAME list Non — 按节点筛选(如 python, apple, create)。留空则显示热门话题。

Code source

id: codytseng/v2ex
version: 1.0.0
name: V2EX
description: V2EX 热门话题
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
  - v2ex
  - chinese
  - tech

config:
  - key: NODE_NAME
    name: 节点名称
    type: list
    required: false
    description: 按节点筛选(如 python, apple, create)。留空则显示热门话题。
module.exports = async (api) => {
  const nodes = api.config.get("NODE_NAME") ?? [];

  async function fetchData() {
    const toItems = (topics) =>
      topics.map((topic) => ({
        id: topic.id.toString(),
        title: topic.title,
        subtitle: `${topic.node.title} · ${topic.replies} 回复 · ${topic.member.username}`,
        url: topic.url,
        timestamp: topic.created,
      }));

    if (nodes.length > 0) {
      await Promise.allSettled(
        nodes.map(async (node) => {
          const res = await api.fetch(
            `https://www.v2ex.com/api/topics/show.json?node_name=${encodeURIComponent(node)}`,
          );
          if (res.ok && res.json) {
            api.emit(toItems(res.json));
          }
        }),
      );
    } else {
      const res = await api.fetch(
        "https://www.v2ex.com/api/topics/hot.json",
      );
      if (!res.ok || !res.json) {
        throw new Error(`Failed to fetch V2EX hot topics (HTTP ${res.status})`);
      }
      api.emit(toItems(res.json));
    }
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

Sources similaires