An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add Settings - Search - Index - Asset path Fix https://github.com/siyuan-note/siyuan/issues/8221
Liang Ding3790507ee295
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.jsonindex a670434e44..8b6bda1513 100644--- a/app/appearance/langs/en_US.json+++ b/app/appearance/langs/en_US.json@@ -268,8 +268,10 @@"cancelMerged": "Cancel cell merge","useDefaultWidth": "Use Default Column Width","type": "Type",- "searchType": "Type (searches in the enabled types below, the filter option in the global search overrides this setting)",- "searchAttr": "Attribute (search not only in the content, but also in the following enabled attributes)",+ "searchBlockType": "Block types (searches in the enabled types below, the filter option in the global search overrides this setting)",+ "searchBlockAttr": "Block attributes (search not only in the content, but also in the following enabled attributes)",+ "searchIndex": "Index",+ "indexAssetPath": "Asset path","searchBackmention": "Backlink mentions (backlink mentions search keywords are obtained from)","searchVirtualRef": "Virtual reference (virtual reference search keywords are obtained from)","netImg2LocalAsset": "Convert network images to local images",diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.jsonindex 3d12d26869..acfacd332c 100644--- a/app/appearance/langs/es_ES.json+++ b/app/appearance/langs/es_ES.json@@ -268,8 +268,10 @@"cancelMerged": "Cancelar fusión de celda","useDefaultWidth": "Usar el ancho de columna por defecto","type": "Tipo",- "searchType": "Tipos (busque en los tipos habilitados a continuación, la opción de filtro en la búsqueda global anula esta configuración)",- "searchAttr": "Atributo (busca no sólo en el contenido, sino también en los siguientes atributos habilitados)",+ "searchBlockType": "Tipos de bloque (busque en los tipos habilitados a continuación, la opción de filtro en la búsqueda global anula esta configuración)",+ "searchBlockAttr": "Atributos de bloque (busca no sólo en el contenido, sino también en los siguientes atributos habilitados)",+ "searchIndex": "Índice",+ "indexAssetPath": "Chemin de l'actif","searchBackmention": "Menciones de backlinks (las menciones de backlinks de las que se obtienen las palabras clave de la búsqueda)","searchVirtualRef": "Referencia virtual (las palabras clave de búsqueda de referencias virtuales se obtienen a partir de ellas)","netImg2LocalAsset": "Convertir imágenes de red en imágenes locales",diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.jsonindex 9fe5825127..cc990d0058 100644--- a/app/appearance/langs/fr_FR.json+++ b/app/appearance/langs/fr_FR.json@@ -268,8 +268,10 @@"cancelMerged": "Annuler la fusion de cellules","useDefaultWidth": "Utiliser la largeur de colonne par défaut","type": "Type",- "searchType": "Types (recherche dans les types activés ci-dessous, l'option de filtre dans la recherche globale remplace ce paramètre)",- "searchAttr": "Attribut (recherche non seulement dans le contenu, mais aussi dans les attributs activés suivants)",+ "searchBlockType": "Types de bloc (recherche dans les types activés ci-dessous, l'option de filtre dans la recherche globale remplace ce paramètre)",+ "searchBlockAttr": "Attributs de bloc (recherche non seulement dans le contenu, mais aussi dans les attributs activés suivants)",+ "searchIndex": "Index",+ "indexAssetPath": "Chemin de l'actif","searchBackmention": "Mentions de backlink (les mentions de backlink à partir desquelles les mots-clés de recherche sont obtenus)","searchVirtualRef": "Référence virtuelle (les mots-clés de recherche de référence virtuelle sont obtenus à partir de)","netImg2LocalAsset": "Convertir des images réseau en images locales",diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.jsonindex 20f932de53..88b2fe9857 100644--- a/app/appearance/langs/zh_CHT.json+++ b/app/appearance/langs/zh_CHT.json@@ -268,8 +268,10 @@"cancelMerged": "拆分單元格","useDefaultWidth": "使用預設列寬","type": "類型",- "searchType": "類型(在以下啟用的類型中進行搜索,全局搜索中的過濾選項會覆蓋該設置)",- "searchAttr": "屬性(不僅在內容中進行搜索,同時也會在以下啟用的屬性中搜索)",+ "searchBlockType": "塊級類型(在以下啟用的類型中進行搜索,全局搜索中的過濾選項會覆蓋該設置)",+ "searchBlockAttr": "塊級屬性(不僅在內容中進行搜索,同時也會在以下啟用的屬性中搜索)",+ "searchIndex": "索引",+ "indexAssetPath": "資源文件路徑","searchBackmention": "反鏈提及(反鏈提及搜索關鍵字從以下方式獲得)","searchVirtualRef": "虛擬引用(虛擬引用搜索關鍵字從以下方式獲得)","netImg2LocalAsset": "網絡圖片轉換為本地圖片",diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.jsonindex f7829b1130..7529c2ee85 100644--- a/app/appearance/langs/zh_CN.json+++ b/app/appearance/langs/zh_CN.json@@ -268,8 +268,10 @@"cancelMerged": "拆分单元格","useDefaultWidth": "使用默认列宽","type": "类型",- "searchType": "类型(在以下启用的类型中进行搜索,全局搜索中的过滤选项会覆盖该设置)",- "searchAttr": "属性(不仅在内容中进行搜索,同时也会在以下启用的属性中搜索)",+ "searchBlockType": "块级类型(在以下启用的类型中进行搜索,全局搜索中的过滤选项会覆盖该设置)",+ "searchBlockAttr": "块级属性(不仅在内容中进行搜索,同时也会在以下启用的属性中搜索)",+ "searchIndex": "索引",+ "indexAssetPath": "资源文件路径","searchBackmention": "反链提及(反链提及搜索关键字从以下方式获得)","searchVirtualRef": "虚拟引用(虚拟引用搜索关键字从以下方式获得)","netImg2LocalAsset": "网络图片转换为本地图片",diff --git a/app/src/config/query.ts b/app/src/config/query.tsindex 4f89afb61b..c82d2af62d 100644--- a/app/src/config/query.ts+++ b/app/src/config/query.ts@@ -4,7 +4,7 @@ export const query = {element: undefined as Element,genHTML: () => {return `<div class="b3-label">- ${window.siyuan.languages.searchType}+ ${window.siyuan.languages.searchBlockType}<div class="fn__flex config-query"><label class="fn__flex"><svg class="svg"><use xlink:href="#iconMath"></use></svg>@@ -117,7 +117,7 @@ export const query = {</div></div><div class="b3-label">- ${window.siyuan.languages.searchAttr}+ ${window.siyuan.languages.searchBlockAttr}<div class="config-query"><label class="fn__flex"><svg class="svg"><use xlink:href="#iconN"></use></svg>@@ -228,6 +228,18 @@ export const query = {</label></div></div>+<div class="b3-label">+ ${window.siyuan.languages.searchIndex}+ <div class="config-query">+ <label class="fn__flex">+ <div class="fn__flex-1">+ ${window.siyuan.languages.indexAssetPath}+ </div>+ <span class="fn__space"></span>+ <input class="b3-switch" id="indexAssetPath" type="checkbox"${window.siyuan.config.search.indexAssetPath ? " checked" : ""}/>+ </label>+ </div>+</div><label class="fn__flex b3-label config__item"><div class="fn__flex-1">${window.siyuan.languages.searchLimit}@@ -266,6 +278,7 @@ export const query = {alias: (query.element.querySelector("#alias") as HTMLInputElement).checked,memo: (query.element.querySelector("#memo") as HTMLInputElement).checked,ial: (query.element.querySelector("#ial") as HTMLInputElement).checked,+ indexAssetPath: (query.element.querySelector("#indexAssetPath") as HTMLInputElement).checked,limit: parseInt((query.element.querySelector("#limit") as HTMLInputElement).value),caseSensitive: (query.element.querySelector("#caseSensitive") as HTMLInputElement).checked,backlinkMentionName: (query.element.querySelector("#backlinkMentionName") as HTMLInputElement).checked,diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 90c08022f7..2a7f30ad1a 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -551,6 +551,7 @@ declare interface IConfig {name: booleanalias: booleanmemo: boolean+ indexAssetPath: booleanial: booleanlimit: numbercaseSensitive: booleandiff --git a/kernel/api/setting.go b/kernel/api/setting.goindex eaa22794e1..4fd26b6164 100644--- a/kernel/api/setting.go+++ b/kernel/api/setting.go@@ -310,6 +310,8 @@ func setSearch(c *gin.Context) {}oldCaseSensitive := model.Conf.Search.CaseSensitive+ oldIndexAssetPath := model.Conf.Search.IndexAssetPath+oldVirtualRefName := model.Conf.Search.VirtualRefNameoldVirtualRefAlias := model.Conf.Search.VirtualRefAliasoldVirtualRefAnchor := model.Conf.Search.VirtualRefAnchor@@ -317,8 +319,11 @@ func setSearch(c *gin.Context) {model.Conf.Search = smodel.Conf.Save()+sql.SetCaseSensitive(s.CaseSensitive)- if s.CaseSensitive != oldCaseSensitive {+ sql.SetIndexAssetPath(s.IndexAssetPath)++ if needFullReindex := s.CaseSensitive != oldCaseSensitive || s.IndexAssetPath != oldIndexAssetPath; needFullReindex {model.FullReindex()}diff --git a/kernel/conf/search.go b/kernel/conf/search.goindex a71c2b5675..985f2dbbeb 100644--- a/kernel/conf/search.go+++ b/kernel/conf/search.go@@ -46,6 +46,8 @@ type Search struct {Memo bool `json:"memo"`IAL bool `json:"ial"`+ IndexAssetPath bool `json:"indexAssetPath"`+BacklinkMentionName bool `json:"backlinkMentionName"`BacklinkMentionAlias bool `json:"backlinkMentionAlias"`BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"`diff --git a/kernel/main.go b/kernel/main.goindex 1cfcfd4689..69773aa9e6 100644--- a/kernel/main.go+++ b/kernel/main.go@@ -36,6 +36,7 @@ func main() {sql.InitDatabase(false)sql.InitHistoryDatabase(false)sql.SetCaseSensitive(model.Conf.Search.CaseSensitive)+ sql.SetIndexAssetPath(model.Conf.Search.IndexAssetPath)model.BootSyncData()model.InitBoxes()diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.goindex b308b5a683..ba38597832 100644--- a/kernel/mobile/kernel.go+++ b/kernel/mobile/kernel.go@@ -50,6 +50,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, langsql.InitDatabase(false)sql.InitHistoryDatabase(false)sql.SetCaseSensitive(model.Conf.Search.CaseSensitive)+ sql.SetIndexAssetPath(model.Conf.Search.IndexAssetPath)model.BootSyncData()model.InitBoxes()diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex 222d9be73d..8d0ee41745 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -64,7 +64,7 @@ func SetBlockReminder(id string, timed string) (err error) {if ast.NodeDocument != node.Type && node.IsContainerBlock() {node = treenode.FirstLeafBlock(node)}- content := treenode.NodeStaticContent(node, nil, false)+ content := treenode.NodeStaticContent(node, nil, false, false)content = gulu.Str.SubStr(content, 128)err = SetCloudBlockReminder(id, content, timedMills)if nil != err {diff --git a/kernel/model/render.go b/kernel/model/render.goindex d6e8a489dd..217cbc307f 100644--- a/kernel/model/render.go+++ b/kernel/model/render.go@@ -93,7 +93,7 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) {}func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {- ret = treenode.NodeStaticContent(node, excludeTypes, false)+ ret = treenode.NodeStaticContent(node, excludeTypes, false, false)ret = strings.TrimSpace(ret)ret = strings.ReplaceAll(ret, "\n", "")ret = util.EscapeHTML(ret)@@ -156,7 +156,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {buf := bytes.Buffer{}for _, n := range subNodes {- buf.WriteString(treenode.NodeStaticContent(n, nil, false))+ buf.WriteString(treenode.NodeStaticContent(n, nil, false, false))}return buf.String()}diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.goindex 29a893e527..fcd285da75 100644--- a/kernel/model/virutalref.go+++ b/kernel/model/virutalref.go@@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {return ast.WalkContinue}- content := treenode.NodeStaticContent(n, nil, false)+ content := treenode.NodeStaticContent(n, nil, false, false)buf.WriteString(content)return ast.WalkContinue})diff --git a/kernel/sql/database.go b/kernel/sql/database.goindex 88e9a417ff..bfdd818022 100644--- a/kernel/sql/database.go+++ b/kernel/sql/database.go@@ -267,7 +267,10 @@ func initDBConnection() {db.SetConnMaxLifetime(365 * 24 * time.Hour)}-var caseSensitive bool+var (+ caseSensitive bool+ indexAssetPath bool+)func SetCaseSensitive(b bool) {caseSensitive = b@@ -278,6 +281,10 @@ func SetCaseSensitive(b bool) {}}+func SetIndexAssetPath(b bool) {+ indexAssetPath = b+}+func refsFromTree(tree *parse.Tree) (refs []*Ref, fileAnnotationRefs []*FileAnnotationRef) {ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {if entering {@@ -701,9 +708,9 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributeslength = utf8.RuneCountInString(fcontent)} else if n.IsContainerBlock() {markdown = treenode.ExportNodeStdMd(n, luteEngine)- content = treenode.NodeStaticContent(n, nil, true)+ content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)fc := treenode.FirstLeafBlock(n)- fcontent = treenode.NodeStaticContent(fc, nil, false)+ fcontent = treenode.NodeStaticContent(fc, nil, false, false)parentID = n.Parent.ID// 将标题块作为父节点if h := heading(n); nil != h {@@ -712,7 +719,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributeslength = utf8.RuneCountInString(fcontent)} else {markdown = treenode.ExportNodeStdMd(n, luteEngine)- content = treenode.NodeStaticContent(n, nil, true)+ content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)parentID = n.Parent.ID// 将标题块作为父节点if h := heading(n); nil != h {diff --git a/kernel/treenode/node.go b/kernel/treenode/node.goindex 535445819e..766e4eef3b 100644--- a/kernel/treenode/node.go+++ b/kernel/treenode/node.go@@ -132,7 +132,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {return markdown}-func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL bool) string {+func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath bool) string {if nil == node {return ""}@@ -185,8 +185,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATibuf.WriteByte(' ')}if nil != linkDest {- if !bytes.HasPrefix(linkDest.Tokens, []byte("assets/")) {- // Assets hyperlinks are no longer included in the search index https://github.com/siyuan-note/siyuan/issues/8076+ if !bytes.HasPrefix(linkDest.Tokens, []byte("assets/")) || includeAssetPath {buf.Write(linkDest.Tokens)buf.WriteByte(' ')}@@ -232,8 +231,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATibuf.WriteString(" " + n.TextMarkATitle)}- if !strings.HasPrefix(n.TextMarkAHref, "assets/") {- // Assets hyperlinks are no longer included in the search index https://github.com/siyuan-note/siyuan/issues/8076+ if !strings.HasPrefix(n.TextMarkAHref, "assets/") || includeAssetPath {buf.WriteString(" " + n.TextMarkAHref)}}