diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index af6a9c1c3..f3f1a4bf6 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", @@ -864,7 +865,7 @@ "35": "Rebuilding index, please wait...", "36": "There is too much content in the historical document, in order not to affect performance, it has been switched to plain text display", "37": "Do not include spaces and special symbols in the name of the cloud sync directory", - "38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords", + "38": "Too many keywords mentioned [%d], adjust if necessary [Settings - Search - Backlink Mentions - Keyword Limit]", "39": "Deleting index %s", "40": "Inserting index %s", "41": "Upload completed", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index a4d82cfb7..58a2d1060 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", @@ -864,7 +865,7 @@ "35": "Reconstruyendo el índice, por favor espere...", "36": "Hay demasiado contenido en el documento historico, para no afectar el rendimiento, se ha cambiado a visualizacion de texto sin formato", "37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube", - "38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave", + "38": "Demasiadas palabras clave mencionadas [%d], ajústelas si es necesario [Configuración - Búsqueda - Menciones de backlinks - Límite de palabras clave]", "39": "Eliminando índice %s", "40": "Insertando índice %s", "41": "Carga completada", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 778429ea3..2ca003d39 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", @@ -864,7 +865,7 @@ "35": "Recréation de l'index, veuillez patienter...", "36": "Il y a trop de contenu dans le document historique, afin de ne pas affecter les performances, il a été basculé sur l'affichage en texte brut", "37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud", - "38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés", + "38": "Trop de mots-clés mentionnés [%d], ajustez si nécessaire [Paramètres - Recherche - Mentions de backlink - Limite de mots-clés]", "39": "Suppression de l'index %s", "40": "Insertion de l'index %s", "41": "Transfert complété", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 9f7961088..28c67c6b5 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "關鍵字數量限制", "exportAsImage": "導出為圖片", "exportBySiYuan": "由思源筆記導出", "featureBetaStage": "該特性支持目前處於免費公測階段,目前尚未有明確的收費計劃,請悉知", @@ -864,7 +865,7 @@ "35": "正在重建索引,請稍等...", "36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示", "37": "雲端同步目錄的名稱請勿包含空格和特殊符號", - "38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字", + "38": "提及關鍵字數量 [%d] 過多,如有需要可以調整 [設置 - 搜索 - 反鏈提及 - 關鍵字數量限制]", "39": "正在刪除索引 %s", "40": "正在插入索引 %s", "41": "上傳完畢", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 9f7e30bd1..cdf940fe2 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "关键字数量限制", "exportAsImage": "导出为图片", "exportBySiYuan": "由思源笔记导出", "featureBetaStage": "该特性支持目前处于免费公测阶段,目前尚未有明确的收费计划,请悉知", @@ -864,7 +865,7 @@ "35": "正在重建索引,请稍等...", "36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示", "37": "云端同步目录的名称请勿包含空格和特殊符号", - "38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字", + "38": "提及关键字数量 [%d] 过多,如有需要可以调整 [设置 - 搜索 - 反链提及 - 关键字数量限制]", "39": "正在删除索引 %s", "40": "正在插入索引 %s", "41": "上传完毕", diff --git a/app/src/config/query.ts b/app/src/config/query.ts index 15ad23069..31a196a2c 100644 --- a/app/src/config/query.ts +++ b/app/src/config/query.ts @@ -149,6 +149,10 @@ export const query = { + + ${window.siyuan.languages.keywordsLimit} + +
@@ -182,7 +186,10 @@ export const query = { -
+ + ${window.siyuan.languages.keywordsLimit} + + +`; } else if (provider === 3) { const tip = `
@@ -137,6 +153,14 @@ const renderProvider = (provider: number) => {
Password
+
+
+
TLS verify
+
+
`; } return `${tip} @@ -154,6 +178,14 @@ const renderProvider = (provider: number) => {
Password
+ +`; } return ""; @@ -222,6 +254,7 @@ const bindProviderEvent = () => { bucket: (providerPanelElement.querySelector("#bucket") as HTMLInputElement).value, pathStyle: (providerPanelElement.querySelector("#pathStyle") as HTMLInputElement).value === "true", region: (providerPanelElement.querySelector("#region") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#s3SkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderS3", {s3}, () => { window.siyuan.config.sync.s3 = s3; @@ -231,6 +264,7 @@ const bindProviderEvent = () => { endpoint: (providerPanelElement.querySelector("#endpoint") as HTMLInputElement).value, username: (providerPanelElement.querySelector("#username") as HTMLInputElement).value, password: (providerPanelElement.querySelector("#password") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#webdavSkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderWebDAV", {webdav}, () => { window.siyuan.config.sync.webdav = webdav; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 4e96fd740..554faa45e 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -340,11 +340,13 @@ declare interface IConfig { secretKey: string bucket: string region: string + skipTlsVerify: boolean } webdav: { endpoint: string username: string password: string + skipTlsVerify: boolean } }, lang: string @@ -414,10 +416,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 c85d368fa..80275d1b7 100644 --- a/kernel/conf/search.go +++ b/kernel/conf/search.go @@ -45,15 +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"` + 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"` + VirtualRefName bool `json:"virtualRefName"` + VirtualRefAlias bool `json:"virtualRefAlias"` + VirtualRefAnchor bool `json:"virtualRefAnchor"` + VirtualRefDoc bool `json:"virtualRefDoc"` + VirtualRefKeywordsLimit int `json:"virtualRefKeywordsLimit"` } func NewSearch() *Search { @@ -78,15 +80,17 @@ func NewSearch() *Search { Memo: true, Custom: false, - BacklinkMentionName: true, - BacklinkMentionAlias: false, - BacklinkMentionAnchor: true, - BacklinkMentionDoc: true, + BacklinkMentionName: true, + BacklinkMentionAlias: false, + BacklinkMentionAnchor: true, + BacklinkMentionDoc: true, + BacklinkMentionKeywordsLimit: 512, - VirtualRefName: true, - VirtualRefAlias: false, - VirtualRefAnchor: true, - VirtualRefDoc: true, + VirtualRefName: true, + VirtualRefAlias: false, + VirtualRefAnchor: true, + VirtualRefDoc: true, + VirtualRefKeywordsLimit: 512, } } diff --git a/kernel/conf/sync.go b/kernel/conf/sync.go index 1c9b7edad..752c18f4c 100644 --- a/kernel/conf/sync.go +++ b/kernel/conf/sync.go @@ -39,18 +39,20 @@ func NewSync() *Sync { } type S3 struct { - Endpoint string `json:"endpoint"` // 服务端点 - AccessKey string `json:"accessKey"` // Access Key - SecretKey string `json:"secretKey"` // Secret Key - Bucket string `json:"bucket"` // 存储空间 - Region string `json:"region"` // 存储区域 - PathStyle bool `json:"pathStyle"` // 是否使用路径风格 + Endpoint string `json:"endpoint"` // 服务端点 + AccessKey string `json:"accessKey"` // Access Key + SecretKey string `json:"secretKey"` // Secret Key + Bucket string `json:"bucket"` // 存储空间 + Region string `json:"region"` // 存储区域 + PathStyle bool `json:"pathStyle"` // 是否使用路径风格 + SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证 } type WebDAV struct { - Endpoint string `json:"endpoint"` // 服务端点 - Username string `json:"username"` // 用户名 - Password string `json:"password"` // 密码 + Endpoint string `json:"endpoint"` // 服务端点 + Username string `json:"username"` // 用户名 + Password string `json:"password"` // 密码 + SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证 } const ( diff --git a/kernel/go.mod b/kernel/go.mod index 8f8de19b3..a998cab6d 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -36,7 +36,7 @@ require ( github.com/panjf2000/ants/v2 v2.6.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/radovskyb/watcher v1.0.7 - github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 + github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef diff --git a/kernel/go.sum b/kernel/go.sum index 7fcc2e2e7..b9bdab187 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -359,8 +359,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 h1:m4+9OWYEKS832LJ9E1eAiUz0ATQAUo7gFs7E5S9JSho= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e h1:gwI3Zo+ce5GPZlau8kMcUipZwY1yJFjeG8ghwxB6YW4= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw= github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90= diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 66da9cc01..28f14f780 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 511 < i { // 提及搜索最大限制 https://github.com/siyuan-note/siyuan/issues/3715 + 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 52c5b9af1..f13377644 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -278,6 +278,12 @@ func InitConf() { if 1 > Conf.Search.Limit { Conf.Search.Limit = 64 } + if 1 > Conf.Search.BacklinkMentionKeywordsLimit { + Conf.Search.BacklinkMentionKeywordsLimit = 512 + } + if 1 > Conf.Search.VirtualRefKeywordsLimit { + Conf.Search.VirtualRefKeywordsLimit = 512 + } if nil == Conf.Stat { Conf.Stat = conf.NewStat() diff --git a/kernel/model/repository.go b/kernel/model/repository.go index 385ec5cb2..9ff57f12f 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -824,16 +824,17 @@ func newRepository() (ret *dejavu.Repo, err error) { case conf.ProviderSiYuan: cloudRepo = cloud.NewSiYuan(&cloud.BaseCloud{Conf: cloudConf}) case conf.ProviderS3: - cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}) + s3HTTPClient := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: cloudConf.S3.SkipTlsVerify}}} + s3HTTPClient.Timeout = 30 * time.Second + cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient) case conf.ProviderWebDAV: - webdavClient := gowebdav.NewClient(cloudConf.Endpoint, cloudConf.Username, cloudConf.Password) - a := cloudConf.Username + ":" + cloudConf.Password + webdavClient := gowebdav.NewClient(cloudConf.WebDAV.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password) + a := cloudConf.WebDAV.Username + ":" + cloudConf.WebDAV.Password auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a)) webdavClient.SetHeader("Authorization", auth) webdavClient.SetHeader("User-Agent", util.UserAgent) webdavClient.SetTimeout(30 * time.Second) - // WebDAV 数据同步跳过 HTTPS 证书校验 https://github.com/siyuan-note/siyuan/issues/6556 - webdavClient.SetTransport(&http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}) + webdavClient.SetTransport(&http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: cloudConf.WebDAV.SkipTlsVerify}}) cloudRepo = cloud.NewWebDAV(&cloud.BaseCloud{Conf: cloudConf}, webdavClient) default: err = fmt.Errorf("unknown cloud provider [%d]", Conf.Sync.Provider) @@ -1048,16 +1049,22 @@ func buildCloudConf() (ret *cloud.Conf, err error) { case conf.ProviderSiYuan: ret.Endpoint = "https://siyuan-data.b3logfile.com/" case conf.ProviderS3: - ret.Endpoint = Conf.Sync.S3.Endpoint - ret.AccessKey = Conf.Sync.S3.AccessKey - ret.SecretKey = Conf.Sync.S3.SecretKey - ret.Bucket = Conf.Sync.S3.Bucket - ret.Region = Conf.Sync.S3.Region - ret.PathStyle = Conf.Sync.S3.PathStyle + ret.S3 = &cloud.ConfS3{ + Endpoint: Conf.Sync.S3.Endpoint, + AccessKey: Conf.Sync.S3.AccessKey, + SecretKey: Conf.Sync.S3.SecretKey, + Bucket: Conf.Sync.S3.Bucket, + Region: Conf.Sync.S3.Region, + PathStyle: Conf.Sync.S3.PathStyle, + SkipTlsVerify: Conf.Sync.S3.SkipTlsVerify, + } case conf.ProviderWebDAV: - ret.Endpoint = Conf.Sync.WebDAV.Endpoint - ret.Username = Conf.Sync.WebDAV.Username - ret.Password = Conf.Sync.WebDAV.Password + ret.WebDAV = &cloud.ConfWebDAV{ + Endpoint: Conf.Sync.WebDAV.Endpoint, + Username: Conf.Sync.WebDAV.Username, + Password: Conf.Sync.WebDAV.Password, + SkipTlsVerify: Conf.Sync.WebDAV.SkipTlsVerify, + } default: err = fmt.Errorf("invalid provider [%d]", Conf.Sync.Provider) return diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index 0e7614955..cc5950e01 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -109,9 +109,9 @@ func getVirtualRefKeywords(docName string) (ret []string) { // 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537 ret = gulu.Str.ExcludeElem(ret, []string{docName}) ret = prepareMarkKeywords(ret) - // 虚拟引用搜索关键字最多支持 `搜索结果显示数` 的 8 倍 https://github.com/siyuan-note/siyuan/issues/6603 - if Conf.Search.Limit*8 < len(ret) { - ret = ret[:Conf.Search.Limit*8] + + if Conf.Search.VirtualRefKeywordsLimit < len(ret) { + ret = ret[:Conf.Search.VirtualRefKeywordsLimit] } return }