설정
| 이름 | 키 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|---|
| 节点名称 | NODE_NAME | list | 아니오 | — | 按节点筛选(如 python, apple, create)。留空则显示热门话题。 |
소스 코드
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)。留空则显示热门话题。 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,
};
}; 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,
};
}; 관련 소스
Dev.to
개발자Top articles from Dev.to developer community
#dev #articles #programming
GitHub Notifications
개발자Get GitHub notifications in your menu bar. Supports filtering by repository.
#github #notifications #developer
GitHub Trending
개발자Trending repositories on GitHub
#github #trending #programming
Lobsters
개발자Hottest stories from Lobsters
#news #tech #programming