fix(route): fix utils for xhu (#15623)

This commit is contained in:
JimenezLi
2024-05-18 19:05:10 +08:00
committed by GitHub
parent ea87eb8dbc
commit 70c4fe93d7
7 changed files with 20 additions and 16 deletions
+2
View File
@@ -139,6 +139,8 @@ async function handler(ctx) {
description = detail.description;
url = `https://www.zhihu.com/roundtable/${detail.id}`;
break;
default:
description = `未知类型 ${item.target.type},请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue`;
}
return {
+8 -6
View File
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
@@ -37,7 +37,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/activities?before_id=0&limit=20`;
@@ -62,7 +62,7 @@ async function handler(ctx) {
let title;
let description;
let url;
const images = [];
const images: string[] = [];
let text = '';
let link = '';
let author = '';
@@ -71,13 +71,13 @@ async function handler(ctx) {
case 'answer':
title = detail.question.title;
author = detail.author.name;
description = utils.ProcessImage(detail.content);
description = processImage(detail.content);
url = `https://www.zhihu.com/question/${detail.question.id}/answer/${detail.id}`;
break;
case 'article':
title = detail.title;
author = detail.author.name;
description = utils.ProcessImage(detail.content);
description = processImage(detail.content);
url = `https://zhuanlan.zhihu.com/p/${detail.id}`;
break;
case 'pin':
@@ -119,7 +119,7 @@ async function handler(ctx) {
case 'question':
title = detail.title;
author = detail.author.name;
description = utils.ProcessImage(detail.detail);
description = processImage(detail.detail);
url = `https://www.zhihu.com/question/${detail.id}`;
break;
case 'collection':
@@ -146,6 +146,8 @@ async function handler(ctx) {
description = detail.description;
url = `https://www.zhihu.com/roundtable/${detail.id}`;
break;
default:
description = `未知类型 ${item.target.type},请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue`;
}
return {
+1 -1
View File
@@ -28,7 +28,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}/answers`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/answers?limit=20&offset=0`;
+1 -1
View File
@@ -28,7 +28,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const id = ctx.req.param('id');
const link = `https://www.zhihu.com/collection/${id}`;
+1 -1
View File
@@ -22,7 +22,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const hexId = ctx.req.param('hexId');
const link = `https://www.zhihu.com/people/${hexId}/posts`;
const url = `https://api.zhihuvvv.workers.dev/people/${hexId}/articles?limit=20&offset=0`;
+3 -3
View File
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
@@ -29,7 +29,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const {
questionId,
sortBy = 'default', // default,created,updated
@@ -54,7 +54,7 @@ async function handler(ctx) {
const link = `https://www.zhihu.com/question/${questionId}/answer/${item.id}`;
const author = item.author.name;
const title = `${author}的回答:${item.excerpt}`;
const description = `${author}的回答<br/><br/>${utils.ProcessImage(item.excerpt)}`;
const description = `${author}的回答<br/><br/>${processImage(item.excerpt)}`;
return {
title,
+4 -4
View File
@@ -1,7 +1,7 @@
import { Route } from '@/types';
import got from '@/utils/got';
import auth from './auth';
import utils from '../utils';
import { processImage } from '../utils';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
@@ -28,7 +28,7 @@ export const route: Route = {
};
async function handler(ctx) {
const xhuCookie = await auth.getCookie(ctx);
const xhuCookie = await auth.getCookie();
const topicId = ctx.req.param('topicId');
const link = `https://www.zhihu.com/topic/${topicId}/newest`;
const url = `https://api.zhihuvvv.workers.dev/topics/${topicId}/feeds/timeline_activity?before_id=0&limit=20`;
@@ -51,13 +51,13 @@ async function handler(ctx) {
let title = '';
let description = '';
let link = '';
let pubDate = '';
let pubDate = new Date();
let author = '';
switch (type) {
case 'answer':
title = `${item.question.title}-${item.author.name}的回答:${item.excerpt}`;
description = `<strong>${item.question.title}</strong><br>${item.author.name}的回答<br/>${utils.ProcessImage(item.content)}`;
description = `<strong>${item.question.title}</strong><br>${item.author.name}的回答<br/>${processImage(item.content)}`;
link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
pubDate = parseDate(item.updated_time * 1000);
author = item.author.name;