dsh-zhihu-search 1.2.5 → 1.2.6
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 +4 -2
- package/lib/tools/global-search.js +5 -4
- package/lib/tools/search.js +4 -3
- package/lib/types.d.ts +4 -2
- package/package.json +1 -1
package/lib/present/search.js
CHANGED
|
@@ -42,8 +42,10 @@ export function renderSearch(value) {
|
|
|
42
42
|
for (const item of value.items) {
|
|
43
43
|
lines.push(`### [${escapeLinkText(item.title)}](${item.url})`);
|
|
44
44
|
const meta = [`**作者**: ${item.author || '匿名'}`];
|
|
45
|
-
//
|
|
46
|
-
|
|
45
|
+
// 点赞段只对知乎内容渲染。
|
|
46
|
+
// 全网搜索会混进第三方网页:外站没有「知乎点赞」这回事,上游对它恒报 0,
|
|
47
|
+
// 渲染出来就是把「不适用」说成「没人赞」——所以连同缺失一起整段省略。
|
|
48
|
+
if (item.contentType !== '' && item.voteUpCount !== undefined)
|
|
47
49
|
meta.push(`**点赞**: ${String(item.voteUpCount)}`);
|
|
48
50
|
// 类型缺失时整段省略,而不是渲染成空的「类型: 」。
|
|
49
51
|
if (item.contentType !== '')
|
|
@@ -39,11 +39,12 @@ function projectItem(item) {
|
|
|
39
39
|
url,
|
|
40
40
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
41
41
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
42
|
-
// 上游没报点赞数时整个键省略,不兜底成 0
|
|
43
|
-
//
|
|
42
|
+
// 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
|
|
43
|
+
// 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
|
|
44
|
+
// 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
|
|
44
45
|
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
45
|
-
// ContentType
|
|
46
|
-
//
|
|
46
|
+
// ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)的类型是**空串**
|
|
47
|
+
// (字段在、值为空),兜底成 'Article' 会让模型把广告页当成知乎文章。
|
|
47
48
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
48
49
|
};
|
|
49
50
|
}
|
package/lib/tools/search.js
CHANGED
|
@@ -41,10 +41,11 @@ function projectItem(item) {
|
|
|
41
41
|
url,
|
|
42
42
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
43
43
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
44
|
-
// 上游没报点赞数时整个键省略,不兜底成 0
|
|
45
|
-
//
|
|
44
|
+
// 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
|
|
45
|
+
// 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
|
|
46
|
+
// 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
|
|
46
47
|
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
47
|
-
// ContentType
|
|
48
|
+
// ContentType 缺失时留空,不编造标签:实测外站网页的类型是**空串**(字段在、值为空),
|
|
48
49
|
// 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
|
|
49
50
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
50
51
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -115,8 +115,10 @@ export interface SearchOutput {
|
|
|
115
115
|
snippet: string;
|
|
116
116
|
author: string;
|
|
117
117
|
/**
|
|
118
|
-
* 点赞数。上游没报该字段时**整个键省略**,不兜底成 0
|
|
119
|
-
*
|
|
118
|
+
* 点赞数。上游没报该字段时**整个键省略**,不兜底成 0。
|
|
119
|
+
*
|
|
120
|
+
* 实测(30 条样本)上游**从未省略**该字段:外站网页也有这个键,值是占位的 `0`,
|
|
121
|
+
* 它不代表「没人赞」。省略分支是防伪造的兜底,外站那个 0 不在渲染层展示。
|
|
120
122
|
*/
|
|
121
123
|
voteUpCount?: number;
|
|
122
124
|
contentType: 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.6",
|
|
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",
|