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

This commit is contained in:
Liang Ding 2022-11-16 17:41:45 +08:00
parent 87fde9a1e8
commit deba07c4ad
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
11 changed files with 48 additions and 28 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -1,4 +1,5 @@
{
"keywordsLimit": "關鍵字數量限制",
"exportAsImage": "導出為圖片",
"exportBySiYuan": "由思源筆記導出",
"featureBetaStage": "該特性支持目前處於免費公測階段,目前尚未有明確的收費計劃,請悉知",

View file

@ -1,4 +1,5 @@
{
"keywordsLimit": "关键字数量限制",
"exportAsImage": "导出为图片",
"exportBySiYuan": "由思源笔记导出",
"featureBetaStage": "该特性支持目前处于免费公测阶段,目前尚未有明确的收费计划,请悉知",

View file

@ -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;
});

View file

@ -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

View file

@ -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"`
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"`
VirtualRefLimit int `json:"virtualRefLimit"`
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,
BacklinkMentionName: true,
BacklinkMentionAlias: false,
BacklinkMentionAnchor: true,
BacklinkMentionDoc: true,
BacklinkMentionKeywordsLimit: 512,
VirtualRefName: true,
VirtualRefAlias: false,
VirtualRefAnchor: true,
VirtualRefDoc: true,
VirtualRefLimit: 512,
VirtualRefName: true,
VirtualRefAlias: false,
VirtualRefAnchor: true,
VirtualRefDoc: true,
VirtualRefKeywordsLimit: 512,
}
}

View file

@ -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 + "\"")

View file

@ -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 {

View file

@ -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
}