diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index b834c3993..0a9646456 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -612,6 +612,7 @@ "md38": "The maximum length of the anchor text that is automatically rendered when the block ref anchor text is not customized, the default is 96 characters", "md39": "PlantUML Serve Address", "md40": "Leave blank to restore default https://www.plantuml.com/plantuml/svg/~1", + "md41": "Support using / to wrap regular expressions, for example foo,/[0-9]+/ means to exclude foo and numbers", "fileTree2": "The doc tree will automatically select the current document when the editor tab is switched", "fileTree3": "No confirmation required when deleting documents", "fileTree4": "If not enabled, a confirmation box will pop up every time you delete a document", @@ -723,7 +724,7 @@ "about12": "After enabling, other devices in the same LAN will be allowed to access. The application will be closed automatically after modification, please restart manually", "about13": "API token", "about14": "The token needs to be authenticated when calling the API", - "about17": "Do not enable proxy when set to Direct connection. The application will be closed automatically after modification, please restart manually", + "about17": "Do not enable proxy when set to Direct connection", "checkUpdate": "Check update", "currentVer": "Current version", "visitAnnouncements": "View system announcements", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index d3a3b2530..9b1ceb85c 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -612,6 +612,7 @@ "md38": "La longitud máxima del texto de anclaje que se renderiza automáticamente cuando el texto de anclaje del bloque ref no está personalizado, el valor por defecto es 96 caracteres", "md39": "Dirección de PlantUML Serve", "md40": "Dejar en blanco para restablecer el valor por defecto https://www.plantuml.com/plantuml/svg/~1", + "md41": "Se admite el uso de / para ajustar expresiones regulares, por ejemplo foo,/[0-9]+/ significa excluir foo y números", "fileTree2": "El árbol de documentos seleccionará automáticamente el documento actual cuando se cambie la pestaña del editor", "fileTree3": "No se requiere confirmación al borrar documentos", "fileTree4": "Si no se activa, aparecerá un cuadro de confirmación cada vez que se elimine un documento", @@ -723,7 +724,7 @@ "about12": "Después de habilitarla, se permitirá el acceso a otros dispositivos de la misma LAN. La aplicación se cerrará automáticamente después de la modificación, por favor reinicie manualmente", "about13": "Token API", "about14": "El token debe ser autentificado al llamar a la API", - "about17": "No habilite el proxy cuando esté configurado como Conexión directa. La aplicación se cerrará automáticamente después de la modificación, por favor reinicie manualmente", + "about17": "No habilite el proxy cuando esté configurado como Conexión directa", "checkUpdate": "Comprobar actualización", "currentVer": "Versión actual", "visitAnnouncements": "Ver los anuncios del sistema", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 65666e91c..ab69cbd86 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -612,6 +612,7 @@ "md38": "La longueur maximale du texte d'ancrage qui est automatiquement rendu lorsque le texte d'ancrage de la référence de bloc n'est pas personnalisé, la valeur par défaut est de 96 caractères", "md39": "Adresse Servo PlantUML", "md40": "Laissez vide pour restaurer https://www.plantuml.com/plantuml/svg/~1/ par défaut", + "md41": "Prend en charge l'utilisation de / pour envelopper les expressions régulières, par exemple foo,/[0-9]+/ signifie exclure foo et les nombres", "fileTree2": "L'arbre des Docs sélectionne automatiquement le document en cours lorsque l'on change d'onglet d'édition", "fileTree3": "Aucune confirmation requise lors de la suppression de documents", "fileTree4": "Si non activé, une boîte de confirmation apparaîtra à chaque fois que vous supprimerez un document", @@ -723,7 +724,7 @@ "about12": "Après l'activation, les autres appareils du même réseau local seront autorisés à accéder. L'application sera fermée automatiquement après modification, veuillez la redémarrer manuellement.", "about13": "API token", "about14": "Le token doit être authentifié lors de l'appel de l'API.", - "about17": "N'activez pas le proxy lorsqu'il est défini sur Connexion directe. L'application se fermera automatiquement après modification, merci de redémarrer manuellement", + "about17": "N'activez pas le proxy lorsqu'il est défini sur Connexion directe.", "checkUpdate": "Vérifier la mise à jour", "currentVer": "Version actuelle", "visitAnnouncements": "Voir les annonces du système", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 6240855a2..a18000638 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -612,6 +612,7 @@ "md38": "不自訂塊引錨文本時自動渲染錨文本的最大長度,預設為 96 個字元", "md39": "PlantUML 伺服地址", "md40": "留空將恢復默認值 https://www.plantuml.com/plantuml/svg/~1", + "md41": "支持使用 / 包裹正則表達式,例如 foo,/[0-9]+/ 表示排除 foo 和數字", "fileTree2": "在編輯器切換分頁時文檔樹會自動選中當前的文檔", "fileTree3": "刪除文檔時不需要確認", "fileTree4": "不啟用時每次刪除文檔都會彈出確認框", @@ -723,7 +724,7 @@ "about12": "啟用後將允許同一區域網內的其他設備進行存取。修改後會自動關閉應用,請手動重啟", "about13": "API token", "about14": "調用 API 時需要通過該 token 進行鑒權", - "about17": "設置為 直接連接 時不啟用代理。修改後會自動關閉應用,請手動重啟", + "about17": "設置為 直接連接 時不啟用代理", "checkUpdate": "檢查更新", "currentVer": "當前版本", "visitAnnouncements": "瀏覽系統公告", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 291868bb7..6bf7404d2 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -612,6 +612,7 @@ "md38": "不自定义块引锚文本时自动渲染锚文本的最大长度,默认为 96 个字符", "md39": "PlantUML 伺服地址", "md40": "留空将恢复默认值 https://www.plantuml.com/plantuml/svg/~1", + "md41": "支持使用 / 包裹正则表达式,例如 foo,/[0-9]+/ 表示排除 foo 和数字", "fileTree2": "在编辑器页签切换时文档树会自动选中当前的文档", "fileTree3": "删除文档时不需要确认", "fileTree4": "不启用时每次删除文档都会弹出确认框", @@ -723,7 +724,7 @@ "about12": "启用后将允许同一局域网内的其他设备进行访问。修改后会自动关闭应用,请手动重启", "about13": "API token", "about14": "调用 API 时需要通过该 token 进行鉴权", - "about17": "设置为 直接连接 时不启用代理。修改后会自动关闭应用,请手动重启", + "about17": "设置为 直接连接 时不启用代理", "checkUpdate": "检查更新", "currentVer": "当前版本", "visitAnnouncements": "浏览系统公告", diff --git a/app/src/config/about.ts b/app/src/config/about.ts index 7f1371c8b..557b281fd 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -12,6 +12,7 @@ import {openByMobile, writeText} from "../protyle/util/compatibility"; import {showMessage} from "../dialog/message"; import {Dialog} from "../dialog"; import {confirmDialog} from "../dialog/confirmDialog"; +import {setProxy} from "../util/onGetConfig"; export const about = { element: undefined as Element, @@ -170,7 +171,7 @@ export const about = { - +
@@ -388,15 +389,15 @@ export const about = { window.siyuan.config.system.downloadInstallPkg = downloadInstallPkgElement.checked; }); }); - about.element.querySelector("#aboutConfim").addEventListener("click", () => { - fetchPost("/api/system/setNetworkProxy", { - scheme: (about.element.querySelector("#aboutScheme") as HTMLInputElement).value, - host: (about.element.querySelector("#aboutHost") as HTMLInputElement).value, - port: (about.element.querySelector("#aboutPort") as HTMLInputElement).value - }, () => { - exportLayout(false, () => { - exitSiYuan(); - }); + about.element.querySelector("#aboutConfirm").addEventListener("click", () => { + const scheme = (about.element.querySelector("#aboutScheme") as HTMLInputElement).value; + const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value + const port = (about.element.querySelector("#aboutPort") as HTMLInputElement).value; + fetchPost("/api/system/setNetworkProxy", {scheme, host, port}, () => { + window.siyuan.config.system.networkProxy.scheme = scheme + window.siyuan.config.system.networkProxy.host = host + window.siyuan.config.system.networkProxy.port = port + setProxy() }); }); } diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 6b73d46ed..854457ad1 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -177,6 +177,7 @@ export const editor = {
${window.siyuan.languages.md35}
${window.siyuan.languages.md36}
+
${window.siyuan.languages.md41}
diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 32f8f6d1c..2bb638644 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -90,12 +90,18 @@ const hasKeymap = (keymap: Record, key1: "general" | "edito export const setProxy = () => { /// #if !BROWSER - const session = getCurrentWindow().webContents.session; - if (window.siyuan.config.system.networkProxy.scheme) { - session.closeAllConnections().then(() => { - session.setProxy({proxyRules: `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`}).then(); - }); + if ("" === window.siyuan.config.system.networkProxy.scheme) { + console.log("network proxy [system]"); + return } + + const session = getCurrentWindow().webContents.session; + session.closeAllConnections().then(() => { + const proxyURL = `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}` + session.setProxy({proxyRules: proxyURL}).then( + () => console.log("network proxy [" + proxyURL + "]"), + ); + }); /// #endif }; diff --git a/kernel/api/system.go b/kernel/api/system.go index 1c9c59ce9..a6ca40167 100644 --- a/kernel/api/system.go +++ b/kernel/api/system.go @@ -366,8 +366,8 @@ func setNetworkProxy(c *gin.Context) { } model.Conf.Save() - util.PushMsg(model.Conf.Language(42), 1000*15) - time.Sleep(time.Second * 3) + proxyURL := model.Conf.System.NetworkProxy.String() + util.SetNetworkProxy(proxyURL) } func addUIProcess(c *gin.Context) { diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index cc5950e01..0e69a7273 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -17,6 +17,7 @@ package model import ( + "regexp" "sort" "strings" @@ -97,13 +98,29 @@ func getVirtualRefKeywords(docName string) (ret []string) { if "" != strings.TrimSpace(Conf.Editor.VirtualBlockRefExclude) { exclude := strings.ReplaceAll(Conf.Editor.VirtualBlockRefExclude, "\\,", "__comma@sep__") excludes := strings.Split(exclude, ",") - var tmp []string + var tmp, regexps []string for _, e := range excludes { e = strings.ReplaceAll(e, "__comma@sep__", ",") - tmp = append(tmp, e) + if strings.HasPrefix(e, "/") && strings.HasSuffix(e, "/") { + regexps = append(regexps, e[1:len(e)-1]) + } else { + tmp = append(tmp, e) + } } excludes = tmp ret = gulu.Str.ExcludeElem(ret, excludes) + if 0 < len(regexps) { + tmp = nil + for _, re := range regexps { + for _, str := range ret { + if ok, regErr := regexp.MatchString(re, str); !ok && nil == regErr { + tmp = append(tmp, str) + break + } + } + } + ret = tmp + } } // 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537 diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go index 412bc0ff6..eb007b607 100644 --- a/kernel/util/runtime.go +++ b/kernel/util/runtime.go @@ -84,6 +84,8 @@ func SetNetworkProxy(proxyURL string) { if "" != proxyURL { logging.LogInfof("use network proxy [%s]", proxyURL) + } else { + logging.LogInfof("use network proxy [system]") } }