dsh-zhihu-search 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/present/search.js +5 -1
- package/lib/tools/global-search.js +3 -1
- package/lib/tools/search.js +3 -1
- package/lib/types.d.ts +6 -4
- package/package.json +1 -1
package/lib/present/search.js
CHANGED
|
@@ -41,7 +41,11 @@ export function renderSearch(value) {
|
|
|
41
41
|
const lines = [`找到 ${String(value.items.length)} 条关于 "${value.query}" 的知乎结果:`, ''];
|
|
42
42
|
for (const item of value.items) {
|
|
43
43
|
lines.push(`### [${escapeLinkText(item.title)}](${item.url})`);
|
|
44
|
-
|
|
44
|
+
const meta = [`**作者**: ${item.author || '匿名'}`, `**点赞**: ${String(item.voteUpCount)}`];
|
|
45
|
+
// 类型缺失时整段省略,而不是渲染成空的「类型: 」。
|
|
46
|
+
if (item.contentType !== '')
|
|
47
|
+
meta.push(`**类型**: ${item.contentType}`);
|
|
48
|
+
lines.push(meta.join(' | '));
|
|
45
49
|
lines.push(`> ${item.snippet}`);
|
|
46
50
|
lines.push('');
|
|
47
51
|
}
|
|
@@ -40,7 +40,9 @@ function projectItem(item) {
|
|
|
40
40
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
41
41
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
42
42
|
voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
|
|
43
|
-
|
|
43
|
+
// ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)就没有这个字段,
|
|
44
|
+
// 兜底成 'Article' 会让模型把广告页当成知乎文章。
|
|
45
|
+
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
/**
|
package/lib/tools/search.js
CHANGED
|
@@ -42,7 +42,9 @@ function projectItem(item) {
|
|
|
42
42
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
43
43
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
44
44
|
voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
|
|
45
|
-
|
|
45
|
+
// ContentType 缺失时留空,不编造标签:实测外部网页根本没有这个字段,
|
|
46
|
+
// 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
|
|
47
|
+
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
/**
|
package/lib/types.d.ts
CHANGED
|
@@ -34,12 +34,14 @@ export interface ZhihuApiResponse<T> {
|
|
|
34
34
|
*/
|
|
35
35
|
export interface ZhihuSearchData {
|
|
36
36
|
/**
|
|
37
|
-
* ⚠
|
|
38
|
-
*
|
|
39
|
-
* 只有全网搜索的 HasMore 才是真实分页标识。
|
|
37
|
+
* ⚠ 站内搜索按官方文档**固定返回 false**;全网搜索在 12 个宽泛查询的实测里**也全部为 false**。
|
|
38
|
+
* 因此两个端点都不能据此翻页——全网搜索根本没有翻页参数(见 ARCHITECTURE 的防错清单)。
|
|
40
39
|
*/
|
|
41
40
|
HasMore: boolean;
|
|
42
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* 搜索请求标识,排障用,不面向模型。
|
|
43
|
+
* ⚠ 实测**不是游标**:原样传回不改变结果(试过 SearchHashId / HashId / Cursor / Offset / Page / Start)。
|
|
44
|
+
*/
|
|
43
45
|
SearchHashId?: string;
|
|
44
46
|
/** 无结果原因;有结果时为空串。 */
|
|
45
47
|
EmptyReason?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-zhihu-search",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "DSH plugin: Zhihu in-site search, global web search, and Zhida over the official Zhihu Open Platform API — with a native settings card and source-cited results.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|