diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 0fb285591..7608568a0 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 307d69b06..ed6e6bc60 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 ed5d22b5f..81f267c2f 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 cca17b392..cb888b391 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 11b5ab70c..023cec710 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 d9001ca09..2820c66ab 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 = '
' + window.siyuan.languages.findInDoc.replace("${x}", matchedRootCount).replace("${y}", matchedBlockCount) + "
"; + } + data.forEach((item: IBlock) => { resultHTML += `
@@ -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 7f7d215c6..874c79a71 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -40,6 +40,7 @@ export class Search extends Model {
+
@@ -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 d2dd5fa0e..6a90e91c7 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
- ${localData.hPath} + + + + ${localData.hPath} @@ -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,