Skip to content

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

:art: 在 设置 - 搜索 中分别增加虚拟引用和反链提及 `关键字数量限制` https://github.com/siyuan-note/siyuan/issues/6603

Liang Dingdeba07c4ad01
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 2af5c263bf..f3f1a4bf65 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,5 @@
{
+ "keywordsLimit": "Keywords Limit",
"exportAsImage": "Export as image",
"exportBySiYuan": "Export by SiYuan",
"featureBetaStage": "This feature support is currently in the free public beta stage, and there is no clear charging plan yet, please know",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index f2c62fccc8..58a2d1060b 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,5 @@
{
+ "keywordsLimit": "Límite de palabras clave",
"exportAsImage": "Exportar como imagen",
"exportBySiYuan": "Exportar por SiYuan",
"featureBetaStage": "El soporte de esta función se encuentra actualmente en la etapa beta pública gratuita, y aún no hay un plan de carga claro, tenga en cuenta",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index ab4fad965f..2ca003d39e 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,5 @@
{
+ "keywordsLimit": "Limite de mots clés",
"exportAsImage": "Exporter en tant qu'image",
"exportBySiYuan": "Exporter par SiYuan",
"featureBetaStage": "La prise en charge de cette fonctionnalité est actuellement en phase de bêta publique gratuite et il n'y a pas encore de plan de facturation clair, veuillez savoir",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index eb234e307e..28c67c6b54 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,5 @@
{
+ "keywordsLimit": "關鍵字數量限制",
"exportAsImage": "導出為圖片",
"exportBySiYuan": "由思源筆記導出",
"featureBetaStage": "該特性支持目前處於免費公測階段,目前尚未有明確的收費計劃,請悉知",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index cd6e26e82f..cdf940fe20 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "keywordsLimit": "关键字数量限制",
"exportAsImage": "导出为图片",
"exportBySiYuan": "由思源笔记导出",
"featureBetaStage": "该特性支持目前处于免费公测阶段,目前尚未有明确的收费计划,请悉知",
diff --git a/app/src/config/query.ts b/app/src/config/query.ts
index 15ad230698..aadf80139d 100644
--- a/app/src/config/query.ts
+++ b/app/src/config/query.ts
@@ -149,6 +149,10 @@ export const query = {
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" id="backlinkMentionDoc" type="checkbox"${window.siyuan.config.search.backlinkMentionDoc ? " checked" : ""}/>
</label>
+
+ ${window.siyuan.languages.keywordsLimit}
+ <span class="fn__space"></span>
+ <input class="b3-text-field fn__flex-center fn__size200" id="backlinkMentionKeywordsLimit" type="number" min="1" max="10240" value="${window.siyuan.config.search.backlinkMentionKeywordsLimit}">
</div>
</div>
<div class="b3-label">
@@ -182,7 +186,14 @@ export const query = {
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" id="virtualRefDoc" type="checkbox"${window.siyuan.config.search.virtualRefDoc ? " checked" : ""}/>
</label>
- </div>
+
+ <label class="fn__flex">
+ <div class="fn__flex-1 b3-label__text">
+ ${window.siyuan.languages.keywordsLimit}
+ </div>
+ <span class="fn__space"></span>
+ <input class="b3-text-field fn__flex-center fn__size200" id="virtualRefKeywordsLimit" type="number" min="1" max="10240" value="${window.siyuan.config.search.virtualRefKeywordsLimit}">
+ </label>
</div>
<label class="fn__flex b3-label">
<div class="fn__flex-1">
@@ -226,10 +237,12 @@ export const query = {
backlinkMentionAlias: (query.element.querySelector("#backlinkMentionAlias") as HTMLInputElement).checked,
backlinkMentionAnchor: (query.element.querySelector("#backlinkMentionAnchor") as HTMLInputElement).checked,
backlinkMentionDoc: (query.element.querySelector("#backlinkMentionDoc") as HTMLInputElement).checked,
+ backlinkMentionKeywordsLimit: parseInt((query.element.querySelector("#backlinkMentionKeywordsLimit") as HTMLInputElement).value),
virtualRefName: (query.element.querySelector("#virtualRefName") as HTMLInputElement).checked,
virtualRefAlias: (query.element.querySelector("#virtualRefAlias") as HTMLInputElement).checked,
virtualRefAnchor: (query.element.querySelector("#virtualRefAnchor") as HTMLInputElement).checked,
virtualRefDoc: (query.element.querySelector("#virtualRefDoc") as HTMLInputElement).checked,
+ virtualRefKeywordsLimit: parseInt((query.element.querySelector("#virtualRefKeywordsLimit") as HTMLInputElement).value),
}, response => {
window.siyuan.config.search = response.data;
});
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 4e96fd740b..9f5c2ea150 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -414,10 +414,12 @@ declare interface IConfig {
backlinkMentionAlias: boolean
backlinkMentionAnchor: boolean
backlinkMentionDoc: boolean
+ backlinkMentionKeywordsLimit: boolean
virtualRefName: boolean
virtualRefAlias: boolean
virtualRefAnchor: boolean
virtualRefDoc: boolean
+ virtualRefKeywordsLimit: boolean
},
stat: {
treeCount: number
diff --git a/kernel/conf/search.go b/kernel/conf/search.go
index a9e1cf7406..80275d1b70 100644
--- a/kernel/conf/search.go
+++ b/kernel/conf/search.go
@@ -45,17 +45,17 @@ type Search struct {
Memo bool `json:"memo"`
Custom bool `json:"custom"`
- BacklinkMentionName bool `json:"backlinkMentionName"`
- BacklinkMentionAlias bool `json:"backlinkMentionAlias"`
- BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"`
- BacklinkMentionDoc bool `json:"backlinkMentionDoc"`
- BacklinkMentionLimit int `json:"backlinkMentionLimit"`
-
- VirtualRefName bool `json:"virtualRefName"`
- VirtualRefAlias bool `json:"virtualRefAlias"`
- VirtualRefAnchor bool `json:"virtualRefAnchor"`
- VirtualRefDoc bool `json:"virtualRefDoc"`
- VirtualRefLimit int `json:"virtualRefLimit"`
+ BacklinkMentionName bool `json:"backlinkMentionName"`
+ BacklinkMentionAlias bool `json:"backlinkMentionAlias"`
+ BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"`
+ BacklinkMentionDoc bool `json:"backlinkMentionDoc"`
+ BacklinkMentionKeywordsLimit int `json:"backlinkMentionKeywordsLimit"`
+
+ VirtualRefName bool `json:"virtualRefName"`
+ VirtualRefAlias bool `json:"virtualRefAlias"`
+ VirtualRefAnchor bool `json:"virtualRefAnchor"`
+ VirtualRefDoc bool `json:"virtualRefDoc"`
+ VirtualRefKeywordsLimit int `json:"virtualRefKeywordsLimit"`
}
func NewSearch() *Search {
@@ -80,17 +80,17 @@ func NewSearch() *Search {
Memo: true,
Custom: false,
- BacklinkMentionName: true,
- BacklinkMentionAlias: false,
- BacklinkMentionAnchor: true,
- BacklinkMentionDoc: true,
- BacklinkMentionLimit: 512,
-
- VirtualRefName: true,
- VirtualRefAlias: false,
- VirtualRefAnchor: true,
- VirtualRefDoc: true,
- VirtualRefLimit: 512,
+ BacklinkMentionName: true,
+ BacklinkMentionAlias: false,
+ BacklinkMentionAnchor: true,
+ BacklinkMentionDoc: true,
+ BacklinkMentionKeywordsLimit: 512,
+
+ VirtualRefName: true,
+ VirtualRefAlias: false,
+ VirtualRefAnchor: true,
+ VirtualRefDoc: true,
+ VirtualRefKeywordsLimit: 512,
}
}
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index 372c3d817c..28f14f7807 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -737,7 +737,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
buf := bytes.Buffer{}
buf.WriteString("SELECT * FROM " + table + " WHERE " + table + " MATCH '{content}:(")
for i, mentionKeyword := range mentionKeywords {
- if Conf.Search.BacklinkMentionLimit < i {
+ if Conf.Search.BacklinkMentionKeywordsLimit < i {
util.PushMsg(fmt.Sprintf(Conf.Language(38), len(mentionKeywords)), 5000)
mentionKeyword = strings.ReplaceAll(mentionKeyword, "\"", "\"\"")
buf.WriteString("\"" + mentionKeyword + "\"")
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index 2576ca6ca9..f133776448 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -278,11 +278,11 @@ func InitConf() {
if 1 > Conf.Search.Limit {
Conf.Search.Limit = 64
}
- if 1 > Conf.Search.BacklinkMentionLimit {
- Conf.Search.BacklinkMentionLimit = 512
+ if 1 > Conf.Search.BacklinkMentionKeywordsLimit {
+ Conf.Search.BacklinkMentionKeywordsLimit = 512
}
- if 1 > Conf.Search.VirtualRefLimit {
- Conf.Search.VirtualRefLimit = 512
+ if 1 > Conf.Search.VirtualRefKeywordsLimit {
+ Conf.Search.VirtualRefKeywordsLimit = 512
}
if nil == Conf.Stat {
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go
index 4fa5173d02..cc5950e013 100644
--- a/kernel/model/virutalref.go
+++ b/kernel/model/virutalref.go
@@ -110,8 +110,8 @@ func getVirtualRefKeywords(docName string) (ret []string) {
ret = gulu.Str.ExcludeElem(ret, []string{docName})
ret = prepareMarkKeywords(ret)
- if Conf.Search.VirtualRefLimit < len(ret) {
- ret = ret[:Conf.Search.VirtualRefLimit]
+ if Conf.Search.VirtualRefKeywordsLimit < len(ret) {
+ ret = ret[:Conf.Search.VirtualRefKeywordsLimit]
}
return
}