From 090f8f3498dab32a96ee733ee6525b260f426e37 Mon Sep 17 00:00:00 2001 From: xizeyoupan <44920131+xizeyoupan@users.noreply.github.com> Date: Sun, 20 Oct 2024 04:01:52 +0800 Subject: [PATCH] docs: add require config for coolapk (#17197) --- lib/routes/coolapk/dyh.ts | 8 +++++++- lib/routes/coolapk/hot.ts | 8 +++++++- lib/routes/coolapk/huati.ts | 8 +++++++- lib/routes/coolapk/namespace.ts | 6 ++++++ lib/routes/coolapk/toutiao.ts | 8 +++++++- lib/routes/coolapk/tuwen.ts | 15 ++++++++++----- lib/routes/coolapk/user-dynamic.ts | 8 +++++++- 7 files changed, 51 insertions(+), 10 deletions(-) diff --git a/lib/routes/coolapk/dyh.ts b/lib/routes/coolapk/dyh.ts index 8b386a72505c26..ba865265aa5ab5 100644 --- a/lib/routes/coolapk/dyh.ts +++ b/lib/routes/coolapk/dyh.ts @@ -9,7 +9,13 @@ export const route: Route = { example: '/coolapk/dyh/1524', parameters: { dyhId: '看看号ID' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, diff --git a/lib/routes/coolapk/hot.ts b/lib/routes/coolapk/hot.ts index e12624ad9fe4b2..fa7211abe9513d 100644 --- a/lib/routes/coolapk/hot.ts +++ b/lib/routes/coolapk/hot.ts @@ -72,7 +72,13 @@ export const route: Route = { example: '/coolapk/hot', parameters: { type: '默认为`jrrm`', period: '默认为`daily`' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, diff --git a/lib/routes/coolapk/huati.ts b/lib/routes/coolapk/huati.ts index 7fc9820e895ffe..67dc7d951ce692 100644 --- a/lib/routes/coolapk/huati.ts +++ b/lib/routes/coolapk/huati.ts @@ -9,7 +9,13 @@ export const route: Route = { example: '/coolapk/huati/iPhone', parameters: { tag: '话题名称' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, diff --git a/lib/routes/coolapk/namespace.ts b/lib/routes/coolapk/namespace.ts index f9969354ad5a3c..bc71d210bc9f7b 100644 --- a/lib/routes/coolapk/namespace.ts +++ b/lib/routes/coolapk/namespace.ts @@ -3,4 +3,10 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: '酷安', url: 'coolapk.com', + description: ` +:::tip +即日起,多数路由图片防盗链。 +需要将 \`ALLOW_USER_HOTLINK_TEMPLATE\` 环境变量设置为 \`true\` ,然后配置\`image_hotlink_template\` 。 +详见 [#16715](https://github.com/DIYgod/RSSHub/issues/16715) +:::`, }; diff --git a/lib/routes/coolapk/toutiao.ts b/lib/routes/coolapk/toutiao.ts index e4a6fd8104c4bf..74da783ff1d595 100644 --- a/lib/routes/coolapk/toutiao.ts +++ b/lib/routes/coolapk/toutiao.ts @@ -8,7 +8,13 @@ export const route: Route = { example: '/coolapk/toutiao', parameters: { type: '默认为history' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, diff --git a/lib/routes/coolapk/tuwen.ts b/lib/routes/coolapk/tuwen.ts index ece427b0d6abbd..65a87d081cafaf 100644 --- a/lib/routes/coolapk/tuwen.ts +++ b/lib/routes/coolapk/tuwen.ts @@ -3,12 +3,18 @@ import got from '@/utils/got'; import utils from './utils'; export const route: Route = { - path: ['/tuwen/:type?', '/tuwen-xinxian'], + path: ['/tuwen/:type?'], categories: ['social-media'], example: '/coolapk/tuwen', parameters: { type: '默认为hot' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false, @@ -25,16 +31,15 @@ export const route: Route = { async function handler(ctx) { const type = ctx.req.param('type') || 'hot'; - const requestPath = ctx.req.path; let feedTitle; const fullUrl = new URL('/v6/page/dataList', utils.base_url); - if (requestPath.startsWith('/coolapk/tuwen-xinxian') || type === 'latest') { + if (type === 'latest') { // 实时 fullUrl.searchParams.append('url', `/feed/digestList?${new URLSearchParams('cacheExpires=300&type=12&message_status=all&is_html_article=1&filterEmptyPicture=1&filterTag=二手交易,酷安自贸区,薅羊毛小分队').toString()}`); fullUrl.searchParams.append('title', '新鲜图文'); fullUrl.searchParams.append('subTitle', ''); feedTitle = '酷安 - 新鲜图文'; - } else if (requestPath.startsWith('/coolapk/tuwen')) { + } else { // 精选 fullUrl.searchParams.append('url', `#/feed/digestList?${new URLSearchParams('type=12&is_html_article=1&recommend=3,4').toString()}`); fullUrl.searchParams.append('title', '图文'); diff --git a/lib/routes/coolapk/user-dynamic.ts b/lib/routes/coolapk/user-dynamic.ts index 965df483525cc9..a23425839d561b 100644 --- a/lib/routes/coolapk/user-dynamic.ts +++ b/lib/routes/coolapk/user-dynamic.ts @@ -9,7 +9,13 @@ export const route: Route = { example: '/coolapk/user/3177668/dynamic', parameters: { uid: '在个人界面右上分享-复制链接获取' }, features: { - requireConfig: false, + requireConfig: [ + { + name: 'ALLOW_USER_HOTLINK_TEMPLATE', + optional: true, + description: '设置为`true`并添加`image_hotlink_template`参数来代理图片', + }, + ], requirePuppeteer: false, antiCrawler: false, supportBT: false,