Skip to content

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

:sparkles: fix https://github.com/siyuan-note/siyuan/issues/5505

Vanessafc98fed8178e
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 0fb2855915..7608568a03 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,5 @@
{
+ "findInDoc": "${x} matches in ${y} files",
"jumpToParentNext": "Jump to the next block in the previous level",
"initRepoKeyTip": "If the key has been initialized on other devices, please use [Import Key] or generate the key with the same passphrase, otherwise the data cannot be synced to the cloud, so be sure to use the same key on all devices",
"crossKeepLazyLoad": "Cross-page multi-selection needs to select [Keep Loaded Content] in the more menu",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 307d69b061..ed6e6bc600 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,5 @@
{
+ "findInDoc": "${x} coincidencias en ${y} archivos",
"jumpToParentNext": "Saltar al siguiente bloque en el nivel anterior",
"initRepoKeyTip": "Si la clave se ha inicializado en otros dispositivos, use [Importar la clave] o genere la clave con la misma contraseña; de lo contrario, los datos no se pueden sincronizar con la nube, así que asegúrese de usar la misma clave en todos los dispositivos.",
"crossKeepLazyLoad": "La selección múltiple entre páginas debe seleccionar [Mantener contenido cargado] en el menú más",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index ed5d22b5f2..81f267c2fd 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,5 @@
{
+ "findInDoc": "${x} correspond dans ${y} fichiers",
"jumpToParentNext": "Aller au bloc suivant du niveau précédent",
"initRepoKeyTip": "Si la clé a été initialisée sur d'autres appareils, veuillez utiliser [Importer la clé] ou générer la clé avec le même mot de passe, sinon les données ne peuvent pas être synchronisées avec le cloud, alors assurez-vous d'utiliser la même clé sur tous les appareils",
"crossKeepLazyLoad": "La multi-sélection sur plusieurs pages doit sélectionner [Conserver le contenu chargé] dans le menu plus",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index cca17b3926..cb888b3917 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,5 @@
{
+ "findInDoc": "${x} 個文檔中匹配 ${y} 項",
"jumpToParentNext": "跳轉到上一層級的下一個塊",
"initRepoKeyTip": "如果其他設備上已經初始化過密鑰,請使用 [導入密鑰] 或者通過相同的密碼生成密鑰,否則無法雲端同步數據,所以請務必在所有設備上使用相同的密鑰",
"crossKeepLazyLoad": "跨頁多選需在更多菜單中選中【保持已加載內容】",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 11b5ab70cb..023cec7105 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "findInDoc": "${x} 个文档中匹配 ${y} 项",
"jumpToParentNext": "跳转到上一层级的下一个块",
"initRepoKeyTip": "如果其他设备上已经初始化过密钥,请使用 [导入密钥] 或者通过相同的密码生成密钥,否则无法云端同步数据,所以请务必在所有设备上使用相同的密钥",
"crossKeepLazyLoad": "跨页多选需在更多菜单中选中 [保持已加载内容]",
diff --git a/app/src/mobile/util/search.ts b/app/src/mobile/util/search.ts
index d9001ca09f..2820c66ab2 100644
--- a/app/src/mobile/util/search.ts
+++ b/app/src/mobile/util/search.ts
@@ -5,9 +5,12 @@ import {fetchPost} from "../../util/fetch";
import {getIconByType} from "../../editor/getIcon";
import {preventScroll} from "../../protyle/scroll/preventScroll";
-const onRecentblocks = (data: IWebSocketData) => {
+const onRecentblocks = (data: IBlock[], matchedRootCount?:number, matchedBlockCount?:number) => {
let resultHTML = "";
- data.data.forEach((item: IBlock) => {
+ if (matchedBlockCount) {
+ resultHTML = '<div class="b3-list-item ft__smaller ft__on-surface">' + window.siyuan.languages.findInDoc.replace("${x}", matchedRootCount).replace("${y}", matchedBlockCount) + "</div>";
+ }
+ data.forEach((item: IBlock) => {
resultHTML += `<div class="b3-list-item b3-list-item--two" data-url="${item.box}" data-path="${item.path}" data-id="${item.id}">
<div class="b3-list-item__first">
<svg class="b3-list-item__graphic"><use xlink:href="#${getIconByType(item.type)}"></use></svg>
@@ -27,11 +30,11 @@ const toolbarSearchEvent = () => {
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
if (inputElement.value === "") {
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
- onRecentblocks(response);
+ onRecentblocks(response.data);
});
} else {
fetchPost("/api/search/fullTextSearchBlock", {query: inputElement.value,}, (response) => {
- onRecentblocks(response);
+ onRecentblocks(response.data.blocks, response.data.matchedRootCount,response.data.matchedBlockCount);
});
}
const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEDATA) || "{}");
@@ -44,7 +47,7 @@ const initToolbarSearch = () => {
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
inputElement.focus();
const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEDATA) || "{}");
- inputElement.value = localData.k||"";
+ inputElement.value = localData.k || "";
inputElement.addEventListener("compositionend", (event: InputEvent) => {
if (event && event.isComposing) {
return;
diff --git a/app/src/search/index.ts b/app/src/search/index.ts
index 7f7d215c6d..874c79a719 100644
--- a/app/src/search/index.ts
+++ b/app/src/search/index.ts
@@ -40,6 +40,7 @@ export class Search extends Model {
</span>
<div id="searchHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background" style="position: absolute;top: 30px;max-height: 50vh;overflow: auto"></div>
</div>
+ <div id="globalSearchResult" class="b3-list-item ft__smaller ft__on-surface"></div>
<div id="globalSearchList" class="fn__flex-1 b3-list b3-list--background"></div>
<div class="fn__loading fn__loading--top"><img width="120px" src="/stage/loading-pure.svg"></div>
</div>
@@ -238,7 +239,8 @@ export class Search extends Model {
this.parent.updateTitle(this.text);
loadElement.classList.remove("fn__none");
fetchPost("/api/search/fullTextSearchBlock", {query: this.text}, (response) => {
- this.onSearch(response.data);
+ this.onSearch(response.data.blocks);
+ this.element.querySelector("#globalSearchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);
loadElement.classList.add("fn__none");
});
}, Constants.TIMEOUT_SEARCH);
diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts
index d2dd5fa0ef..6a90e91c7d 100644
--- a/app/src/search/spread.ts
+++ b/app/src/search/spread.ts
@@ -123,7 +123,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
<div id="replaceHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background"></div>
</div>
<div class="fn__flex b3-form__space--small">
- <span id="searchPathInput" class="ft__on-surface fn__flex-1 fn__flex-center ft__smaller fn__ellipsis" style="white-space: nowrap;" title="${localData.hPath}">${localData.hPath}</span>
+ <span id="searchResult" style="white-space: nowrap;"></span>
+ <span class="fn__space"></span>
+ <span class="fn__flex-1"></span>
+ <span id="searchPathInput" class="ft__on-surface fn__flex-center ft__smaller fn__ellipsis" style="white-space: nowrap;" title="${localData.hPath}">${localData.hPath}</span>
<span class="fn__space"></span>
<button id="searchPathCheck" class="b3-button b3-button--small${notebookId ? "" : " b3-button--cancel"}">${window.siyuan.languages.specifyPath}</button>
<span class="fn__space"></span>
@@ -367,6 +370,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
onSearch(response.data, dialog);
loadingElement.classList.add("fn__none");
+ dialog.element.querySelector("#searchResult").innerHTML = "";
});
} else {
fetchPost("/api/search/fullTextSearchBlock", {
@@ -387,7 +391,8 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
},
path: !searchPathElement.classList.contains("b3-button--cancel") ? localData.idPath : ""
}, (response) => {
- onSearch(response.data, dialog);
+ onSearch(response.data.blocks, dialog);
+ dialog.element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);
loadingElement.classList.add("fn__none");
});
}
@@ -637,7 +642,7 @@ const getArticle = (options: {
k: string,
dialog: Dialog
}) => {
- fetchPost("/api/block/checkBlockFold", {id:options.id}, (foldResponse) => {
+ fetchPost("/api/block/checkBlockFold", {id: options.id}, (foldResponse) => {
if (!protyle) {
protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, {
blockId: options.id,