Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

✨ feat(search): 搜索显示文档标题 (#15969)

Achuan-2bf1172b05ecd
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index beedd4fe57..9528eb0f40 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -91,6 +91,17 @@ export const onGet = (options: {
isSyncing: options.data.data.isSyncing,
afterCB: options.afterCB,
}, options.protyle);
+
+ // 如果需要渲染标题且包含 CB_GET_HTML,需要获取文档信息来更新标题
+ if (options.protyle.options.render.title && options.action.includes(Constants.CB_GET_HTML)) {
+ fetchPost("/api/block/getDocInfo", {
+ id: options.protyle.block.rootID
+ }, (response) => {
+ options.protyle.title.element.removeAttribute("data-render");
+ options.protyle.title.render(options.protyle, response);
+ });
+ }
+
removeLoading(options.protyle);
return;
}
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 9d7e46d396..664d9ee30c 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -239,7 +239,8 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
blockId: "",
render: {
gutter: true,
- breadcrumbDocName: true
+ breadcrumbDocName: true,
+ title: true
},
});
edit.resize();
@@ -247,7 +248,8 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
blockId: "",
render: {
gutter: true,
- breadcrumbDocName: true
+ breadcrumbDocName: true,
+ title: true
},
});
unRefEdit.resize();