From 3cc4ad6bffcda0178c9d605353b5ed3da117814c Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 23 Nov 2022 17:00:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?:bug:=20=E6=96=87=E6=A1=A3=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E4=BB=A5=E7=A9=BA=E6=A0=BC=E7=BB=93=E5=B0=BE=E6=97=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=20HTML=20=E6=8A=A5=E9=94=99=20Fix=20https://?= =?UTF-8?q?github.com/siyuan-note/siyuan/issues/6686?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/export/index.ts | 3 ++- kernel/model/export.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index c40f2f919..edbff9b9b 100644 --- a/app/src/protyle/export/index.ts +++ b/app/src/protyle/export/index.ts @@ -447,7 +447,8 @@ const getExportPath = (option: { type: string, id: string }, removeAssets?: bool } else if (option.type === "word") { url = "/api/export/exportDocx"; } - const savePath = result.filePaths[0].endsWith(response.data.rootTitle) ? result.filePaths[0] : path.join(result.filePaths[0], replaceLocalPath(response.data.rootTitle)); + let savePath = result.filePaths[0].endsWith(response.data.rootTitle) ? result.filePaths[0] : path.join(result.filePaths[0], replaceLocalPath(response.data.rootTitle)); + savePath = savePath.trim(); fetchPost(url, { id: option.id, pdf: option.type === "pdf", diff --git a/kernel/model/export.go b/kernel/model/export.go index de3e154fc..615531d70 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -244,6 +244,7 @@ func ExportMarkdownHTML(id, savePath string, docx bool) (name, dom string) { tree = exportTree(tree, true, true, false) name = path.Base(tree.HPath) name = util.FilterFileName(name) // 导出 PDF、HTML 和 Word 时未移除不支持的文件名符号 https://github.com/siyuan-note/siyuan/issues/5614 + savePath = strings.TrimSpace(savePath) if err := os.MkdirAll(savePath, 0755); nil != err { logging.LogErrorf("mkdir [%s] failed: %s", savePath, err) @@ -330,6 +331,7 @@ func ExportMarkdownHTML(id, savePath string, docx bool) (name, dom string) { } func ExportHTML(id, savePath string, pdf, keepFold bool) (name, dom string) { + savePath = strings.TrimSpace(savePath) tree, _ := loadTreeByBlockID(id) var headings []*ast.Node if pdf { // 导出 PDF 需要标记目录书签 From 2217f92df570fba3dcf4fd59ccaec9720e9256c8 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 23 Nov 2022 20:41:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BC=91=E7=9C=A0=E5=94=A4=E9=86=92=E5=90=8E?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=BD=91=E7=BB=9C=E8=BF=9E=E9=80=9A=E6=80=A7?= =?UTF-8?q?=E5=90=8E=E5=86=8D=E6=89=A7=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?6687?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 39 ++++++++++++++++++++++++++++++++------- app/pnpm-lock.yaml | 4 ++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index fb27463d8..c154859ed 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -583,10 +583,6 @@ const initKernel = (initData) => { }) } - const sleep = (ms) => { - return new Promise(resolve => setTimeout(resolve, ms)) - } - const getKernelPort = async () => { if (isDevEnv) { return kernelPort @@ -797,15 +793,31 @@ app.on('before-quit', (event) => { }) const {powerMonitor} = require('electron') -const cp = require("child_process"); powerMonitor.on('suspend', () => { writeLog('system suspend') - fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) }) -powerMonitor.on('resume', () => { +powerMonitor.on('resume', async () => { writeLog('system resume') + let online = false + for (let i = 0; i < 7; i++) { + if (await isOnline()) { + online = true + break; + } + + writeLog("network is offline") + await sleep(1000) + } + + if (!online) { + writeLog("network is offline, do not sync after system resume") + return; + } + + writeLog("sync after system resume") + // 桌面端系统休眠唤醒后同步延时 7s 后再执行 https://github.com/siyuan-note/siyuan/issues/6687 fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) }) @@ -813,3 +825,16 @@ powerMonitor.on('shutdown', () => { writeLog('system shutdown') fetch(getServer() + '/api/system/exit', {method: 'POST'}) }) + +const sleep = (ms) => { + return new Promise(resolve => setTimeout(resolve, ms)) +} + +const isOnline = async () => { + try { + const result = await fetch("https://icanhazip.com", {timeout: 1000}) + return 200 === result.status + } catch (e) { + return false; + } +} diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml index 1223b8de6..719239048 100644 --- a/app/pnpm-lock.yaml +++ b/app/pnpm-lock.yaml @@ -1906,10 +1906,10 @@ packages: resolution: {integrity: sha512-m0+M53+HYMzqKxwNQZT143K7WwXEGUy9LY31l8dJphXx2P/FQod615mVbxHyqbDCG4J5bHdWm21qZ0e2DVY6CQ==} engines: {node: '>=14.0.0'} dependencies: + 7zip-bin: 5.1.1 '@develar/schema-utils': 2.6.5 '@electron/universal': 1.2.1 '@malept/flatpak-bundler': 0.4.0 - 7zip-bin: 5.1.1 async-exit-hook: 2.0.1 bluebird-lst: 1.0.9 builder-util: 23.3.3 @@ -2193,9 +2193,9 @@ packages: /builder-util/23.3.3: resolution: {integrity: sha512-MJZlUiq2PY5hjYv9+XNaoYdsITqvLgRDoHSFg/4nzpInbNxNjLQOolL04Zsyp+hgfcbFvMC4h0KkR1CMPHLWbA==} dependencies: + 7zip-bin: 5.1.1 '@types/debug': 4.1.7 '@types/fs-extra': 9.0.13 - 7zip-bin: 5.1.1 app-builder-bin: 4.0.0 bluebird-lst: 1.0.9 builder-util-runtime: 9.0.3 From e7d1312914b9daf2bc38b4cc046804bcab83ed71 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 23 Nov 2022 20:43:37 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BC=91=E7=9C=A0=E5=94=A4=E9=86=92=E5=90=8E?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=BD=91=E7=BB=9C=E8=BF=9E=E9=80=9A=E6=80=A7?= =?UTF-8?q?=E5=90=8E=E5=86=8D=E6=89=A7=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?6687?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index c154859ed..d71e45a93 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -835,6 +835,11 @@ const isOnline = async () => { const result = await fetch("https://icanhazip.com", {timeout: 1000}) return 200 === result.status } catch (e) { - return false; + try { + const result = await fetch("https://www.baidu.com", {timeout: 1000}) + return 200 === result.status + } catch (e) { + return false; + } } } From 698a3e5421f39544128f294b7855debe6b7e97f2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 23 Nov 2022 20:54:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?:memo:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 13535995a..6240855a2 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -330,7 +330,7 @@ "moveToLeft": "向左移", "moveToRight": "向右移", "copyProtocol": "複製塊超連結", - "uploadAssets2CDN": "上傳資料檔到雲端", + "uploadAssets2CDN": "上傳資料檔到圖床", "notSupport1": "不支援跨筆記本進行拖拽", "keymapTip": "部分快捷鍵修改後需點擊刷新按鈕後才能生效", "keymapTip2": "使用默認快捷鍵", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 5083e802d..291868bb7 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -330,7 +330,7 @@ "moveToLeft": "向左移", "moveToRight": "向右移", "copyProtocol": "复制块超链接", - "uploadAssets2CDN": "上传资源文件到云端", + "uploadAssets2CDN": "上传资源文件到图床", "notSupport1": "不支持跨笔记本进行拖拽", "keymapTip": "部分快捷键修改后需点击刷新按钮后才能生效", "keymapTip2": "使用默认快捷键",