41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import dayjs from 'dayjs';
|
|
import { HotListItem } from "../type";
|
|
|
|
export const label = {
|
|
name: '夸克-今日热点',
|
|
icon: 'https://quark.com/favicon.ico',
|
|
color: '#4B9EFF',
|
|
};
|
|
|
|
export const main = async function(): Promise<HotListItem[]> {
|
|
const url = 'https://iflow.quark.cn/iflow/api/v1/article/aggregation?aggregation_id=16665090098771297825&count=50&bottom_pos=0';
|
|
try {
|
|
const response = await fetch(url);
|
|
if (!response.ok) {
|
|
throw new Error(`请求错误 ${label.name}`);
|
|
}
|
|
const responseBody = await response.json();
|
|
if (responseBody.status === 0) {
|
|
const result: HotListItem[] = responseBody.data.articles.map((v: any) => {
|
|
return {
|
|
id: v.id,
|
|
title: v.title,
|
|
tip: dayjs(v.publish_time).format('HH:mm'),
|
|
url: `https://123.quark.cn/detail?item_id=${v.id}`,
|
|
mobileUrl: `https://123.quark.cn/detail?item_id=${v.id}`,
|
|
originData: v,
|
|
};
|
|
});
|
|
return result;
|
|
}
|
|
return [];
|
|
} catch {
|
|
return [];
|
|
}
|
|
};
|
|
|
|
if (import.meta.main) {
|
|
main().then(console.log).catch(console.error);
|
|
|
|
}
|