diff --git a/public/icons/gamerpower.png b/public/icons/gamerpower.png new file mode 100644 index 000000000..f53f1ae2c Binary files /dev/null and b/public/icons/gamerpower.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index f3529fd13..6a82cd5ec 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -12,6 +12,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const douyin: typeof import('./sources/douyin') export const fastbull: typeof import('./sources/fastbull') export const freebuf: typeof import('./sources/freebuf') + export const gamerpower: typeof import('./sources/gamerpower') export const gelonghui: typeof import('./sources/gelonghui') export const ghxi: typeof import('./sources/ghxi') export const github: typeof import('./sources/github') diff --git a/server/sources/gamerpower.ts b/server/sources/gamerpower.ts new file mode 100644 index 000000000..dcfa6a06c --- /dev/null +++ b/server/sources/gamerpower.ts @@ -0,0 +1,33 @@ +// 定义 GamerPower 返回的数据结构 +interface GamerPowerItem { + id: number + title: string + worth: string // 原价,例如 "$29.99" + thumbnail: string // 缩略图 URL + description: string + open_giveaway_url: string // 领取链接 + published_date: string + platforms: string // 平台,例如 "PC, Steam" + end_date: string // 截止日期 +} + +export default defineSource(async () => { + // 调用 GamerPower 的公开 API + // 参数 platform=pc 表示只看电脑游戏,type=game 表示只看完整游戏 + const url = "https://www.gamerpower.com/api/giveaways?platform=pc&type=game&sort-by=popularity" + + const response = await fetch(url) + const data: GamerPowerItem[] = await response.json() + + // 转换为 newsnow 需要的格式 + return data.map(item => ({ + id: item.id.toString(), + title: `[${item.platforms}] ${item.title} (原价 ${item.worth})`, + url: item.open_giveaway_url, + mobileUrl: item.open_giveaway_url, + pubDate: item.published_date, + extra: { + info: item.end_date !== "N/A" ? `截止: ${item.end_date}` : "长期有效", + }, + })) +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 05d19334b..171e73189 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -47,6 +47,7 @@ "steam": "Steam-zaixianrenshu", "tencent-hot": "tengxunxinwen-zonghezaobao", "freebuf": "Freebuf-wangluoanquan", - "qqvideo-tv-hotsearch": "tengxunshipin-dianshiju-resoubang", + "gamerpower": "GamerPower (xijiayi)", + "qqvideo-tv-hotsearch": "tengxunshipin-resoubang", "iqiyi-hot-ranklist": "aiqiyi-rebobang" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index 7e519d424..e18a01ac6 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -453,7 +453,12 @@ export const originSources = { type: "hottest", home: "https://www.freebuf.com/", }, - + "gamerpower": { + name: "GamerPower (喜加一)", + column: "world", + color: "green", + home: "https://www.gamerpower.com", + }, "qqvideo": { name: "腾讯视频", column: "china", diff --git a/shared/sources.json b/shared/sources.json index 3718b7ecb..fdd268bb0 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -526,6 +526,13 @@ "color": "green", "interval": 600000 }, + "gamerpower": { + "name": "GamerPower (喜加一)", + "column": "world", + "home": "https://www.gamerpower.com", + "color": "green", + "interval": 600000 + }, "qqvideo": { "redirect": "qqvideo-tv-hotsearch", "name": "腾讯视频", @@ -534,7 +541,7 @@ "home": "https://v.qq.com/channel/tv", "color": "blue", "interval": 1800000, - "title": "电视剧-热搜榜" + "title": "热搜榜" }, "qqvideo-tv-hotsearch": { "name": "腾讯视频", @@ -543,7 +550,7 @@ "home": "https://v.qq.com/channel/tv", "color": "blue", "interval": 1800000, - "title": "电视剧-热搜榜" + "title": "热搜榜" }, "iqiyi": { "redirect": "iqiyi-hot-ranklist",