From b72b312aa084fc8d6f3ac7b7012677f4a65a5b9b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 14:26:49 +0800 Subject: [PATCH 1/8] :recycle: Upgrade to Electron v41.5.0 https://github.com/siyuan-note/siyuan/issues/17617 Signed-off-by: Daniel <845765@qq.com> --- .github/CONTRIBUTING.md | 8 ++++---- .github/CONTRIBUTING_zh_CN.md | 8 ++++---- app/package.json | 4 ++-- app/pnpm-lock.yaml | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f05c349f1..9051b5b81 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,17 +8,17 @@ ## NPM dependencies -Install pnpm: `npm install -g pnpm@10.33.0` +Install pnpm: `npm install -g pnpm@10.33.3`
For China mainland Set the Electron mirror environment variable and install Electron: -* macOS/Linux: `ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ pnpm install electron@40.9.3 -D` +* macOS/Linux: `ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ pnpm install electron@41.5.0 -D` * Windows: * `SET ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/` - * `pnpm install electron@40.9.3 -D` + * `pnpm install electron@41.5.0 -D` NPM mirror: @@ -28,7 +28,7 @@ NPM mirror: Enter the app folder and execute: -* `pnpm install electron@40.9.3 -D` +* `pnpm install electron@41.5.0 -D` * `pnpm run dev` * `pnpm run start` diff --git a/.github/CONTRIBUTING_zh_CN.md b/.github/CONTRIBUTING_zh_CN.md index f8504aad8..fd8c15fe8 100644 --- a/.github/CONTRIBUTING_zh_CN.md +++ b/.github/CONTRIBUTING_zh_CN.md @@ -8,17 +8,17 @@ ## NPM 依赖 -安装 pnpm:`npm install -g pnpm@10.33.0` +安装 pnpm:`npm install -g pnpm@10.33.3`
适用于中国大陆 设置 Electron 镜像环境变量并安装 Electron: -* macOS/Linux:`ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ pnpm install electron@40.9.3 -D` +* macOS/Linux:`ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ pnpm install electron@41.5.0 -D` * Windows: * `SET ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/` - * `pnpm install electron@40.9.3 -D` + * `pnpm install electron@41.5.0 -D` NPM 镜像: @@ -28,7 +28,7 @@ NPM 镜像: 进入 app 文件夹执行: -* `pnpm install electron@40.9.3 -D` +* `pnpm install electron@41.5.0 -D` * `pnpm run dev` * `pnpm run start` diff --git a/app/package.json b/app/package.json index 6fba22ee9..9ff20fd34 100644 --- a/app/package.json +++ b/app/package.json @@ -4,7 +4,7 @@ "description": "Refactor your thinking", "homepage": "https://b3log.org/siyuan", "main": "./electron/main.js", - "packageManager": "pnpm@10.33.0", + "packageManager": "pnpm@10.33.3", "scripts": { "lint": "eslint . --fix --cache", "dev": "webpack --mode development", @@ -57,7 +57,7 @@ "clean-webpack-plugin": "^4.0.0", "css-loader": "^7.1.2", "dayjs": "^1.11.5", - "electron": "40.9.3", + "electron": "41.5.0", "electron-builder": "26.0.12", "encoding": "^0.1.13", "esbuild-loader": "^3.0.1", diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml index 1a390a377..aac1c7456 100644 --- a/app/pnpm-lock.yaml +++ b/app/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: '@electron/remote': specifier: ^2.1.3 - version: 2.1.3(electron@40.9.3) + version: 2.1.3(electron@41.5.0) devDependencies: '@eslint/eslintrc': specifier: ^3.3.1 @@ -40,8 +40,8 @@ importers: specifier: ^1.11.5 version: 1.11.19 electron: - specifier: 40.9.3 - version: 40.9.3 + specifier: 41.5.0 + version: 41.5.0 electron-builder: specifier: 26.0.12 version: 26.0.12(electron-builder-squirrel-windows@26.0.12) @@ -1186,8 +1186,8 @@ packages: resolution: {integrity: sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==} engines: {node: '>=8.0.0'} - electron@40.9.3: - resolution: {integrity: sha512-rDcJOT6BBE689Ada+4jD3rVr05pMv9MZOgT0x/rIMVDF9c4ttx4RTb6lVARTyxZC7uqpirttCtcli1eg1DX5qg==} + electron@41.5.0: + resolution: {integrity: sha512-x9j9//PubUA4EjDtQbZhtk3prolandqCKgit0uCIqc1jb8FTskPbnJtxcDFB1aejczJcuERgjPixBUaMwoWyJg==} engines: {node: '>= 12.20.55'} hasBin: true @@ -2835,9 +2835,9 @@ snapshots: - bluebird - supports-color - '@electron/remote@2.1.3(electron@40.9.3)': + '@electron/remote@2.1.3(electron@41.5.0)': dependencies: - electron: 40.9.3 + electron: 41.5.0 '@electron/universal@2.0.1': dependencies: @@ -3964,7 +3964,7 @@ snapshots: transitivePeerDependencies: - supports-color - electron@40.9.3: + electron@41.5.0: dependencies: '@electron/get': 2.0.3 '@types/node': 24.12.0 From 9d4c65c96b96ee0de12af412e0e11f5f2d95946a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 14:36:55 +0800 Subject: [PATCH 2/8] :technologist: Remove the `notebook` parameter from the API `/api/history/rollbackDocHistory` endpoint https://github.com/siyuan-note/siyuan/issues/17411 Signed-off-by: Daniel <845765@qq.com> --- app/src/history/doc.ts | 1 - app/src/history/history.ts | 1 - kernel/api/history.go | 9 ++------- kernel/model/history.go | 18 ++++++++++++------ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/history/doc.ts b/app/src/history/doc.ts index bb0561936..f3a6e80e8 100644 --- a/app/src/history/doc.ts +++ b/app/src/history/doc.ts @@ -150,7 +150,6 @@ export const openDocHistory = (options: { .replace("${time}", target.previousElementSibling.previousElementSibling.textContent.trim()); confirmDialog("⚠️ " + window.siyuan.languages.rollback, confirmTip, () => { fetchPost("/api/history/rollbackDocHistory", { - notebook: options.notebookId, historyPath: dataPath }); }); diff --git a/app/src/history/history.ts b/app/src/history/history.ts index e0e49615a..23e69d240 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -581,7 +581,6 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => { }); } else if (dataType === "doc") { fetchPost("/api/history/rollbackDocHistory", { - notebook: target.parentElement.getAttribute("data-notebook-id"), historyPath: target.parentElement.getAttribute("data-path") }); } else if (dataType === "av") { diff --git a/kernel/api/history.go b/kernel/api/history.go index 2109efb7c..6f3aadbdb 100644 --- a/kernel/api/history.go +++ b/kernel/api/history.go @@ -185,23 +185,18 @@ func rollbackDocHistory(c *gin.Context) { return } - var notebook, historyPath string + var historyPath string if !util.ParseJsonArgs(arg, ret, - util.BindJsonArg("notebook", ¬ebook, true, true), util.BindJsonArg("historyPath", &historyPath, true, true), ) { return } - err := model.RollbackDocHistory(notebook, historyPath) + err := model.RollbackDocHistory(historyPath) if err != nil { ret.Code = -1 ret.Msg = err.Error() return } - - ret.Data = map[string]any{ - "box": notebook, - } } func rollbackAssetsHistory(c *gin.Context) { diff --git a/kernel/model/history.go b/kernel/model/history.go index 2767383f8..6906febea 100644 --- a/kernel/model/history.go +++ b/kernel/model/history.go @@ -227,7 +227,7 @@ func GetDocHistoryContent(historyPath, keyword string, highlight bool) (id, root return } -func RollbackDocHistory(boxID, historyPath string) (err error) { +func RollbackDocHistory(historyPath string) (err error) { if !gulu.File.IsExist(historyPath) { logging.LogWarnf("doc history [%s] not exist", historyPath) return @@ -235,6 +235,16 @@ func RollbackDocHistory(boxID, historyPath string) (err error) { FlushTxQueue() + relPath := strings.TrimPrefix(historyPath, util.HistoryDir) + relPath = strings.TrimPrefix(relPath, string(os.PathSeparator)) + relPath = filepath.ToSlash(relPath) + parts := strings.SplitN(relPath, "/", 3) + if len(parts) < 3 { + logging.LogWarnf("invalid history path [%s]", historyPath) + return + } + boxID := parts[1] + box, needResetTree, err := getRollbackBox(boxID) if err != nil { logging.LogErrorf("get rollback box [%s] failed: %s", boxID, err) @@ -258,11 +268,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) { var avIDs []string tree, _ := loadTree(srcPath, util.NewLute()) if nil != tree { - historyDir := strings.TrimPrefix(historyPath, util.HistoryDir+string(os.PathSeparator)) - if strings.Contains(historyDir, string(os.PathSeparator)) { - historyDir = historyDir[:strings.Index(historyDir, string(os.PathSeparator))] - } - historyDir = filepath.Join(util.HistoryDir, historyDir) + historyDir := filepath.Join(util.HistoryDir, parts[0]) avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView) for _, avNode := range avNodes { From ab4609467230fc63ed50d38f1bbb80e7ea28ffe5 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 16:18:40 +0800 Subject: [PATCH 3/8] :art: Improve export of heading levels in embedded blocks https://github.com/siyuan-note/siyuan/issues/17629 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/render.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kernel/model/render.go b/kernel/model/render.go index 0da067c5a..c2af2d716 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -283,19 +283,25 @@ func resolveEmbedR(n *ast.Node, blockEmbedMode int, luteEngine *lute.Lute, resol if "d" == sqlBlock.Type { if 0 == blockEmbedMode { // 嵌入块中出现了大于等于上方非嵌入块的标题时需要降低嵌入块中的标题级别 - // Improve export of heading levels in embedded blocks https://github.com/siyuan-note/siyuan/issues/12233 https://github.com/siyuan-note/siyuan/issues/12741 + // Improve export of heading levels in embedded blocks + // https://github.com/siyuan-note/siyuan/issues/12233 + // https://github.com/siyuan-note/siyuan/issues/12741 + // https://github.com/siyuan-note/siyuan/issues/17629 embedTopLevel := 0 + embedFirstHeading := subTree.Root.ChildByType(ast.NodeHeading) + if nil != embedFirstHeading { + embedTopLevel = embedFirstHeading.HeadingLevel + } ast.Walk(subTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering || ast.NodeHeading != n.Type { return ast.WalkContinue } - embedTopLevel = n.HeadingLevel - if parentHeadingLevel >= embedTopLevel { - n.HeadingLevel += parentHeadingLevel - embedTopLevel + 1 - if 6 < n.HeadingLevel { - n.HeadingLevel = 6 - } + n.HeadingLevel += parentHeadingLevel - embedTopLevel + 1 + if 1 > n.HeadingLevel { + n.HeadingLevel = 1 + } else if 6 < n.HeadingLevel { + n.HeadingLevel = 6 } return ast.WalkContinue }) From 7522d9040b94d839fddf5434973c1ddc51566934 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 16:33:56 +0800 Subject: [PATCH 4/8] :art: Improve export of heading levels in embedded blocks https://github.com/siyuan-note/siyuan/issues/17629 https://github.com/siyuan-note/siyuan/issues/17630 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/render.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/model/render.go b/kernel/model/render.go index c2af2d716..b7bdafd72 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -243,7 +243,7 @@ func resolveEmbedR(n *ast.Node, blockEmbedMode int, luteEngine *lute.Lute, resol for _, child := range children { var unlinks []*ast.Node - parentHeadingLevel := 0 + parentHeadingLevel := 1 for prev := child; nil != prev; prev = prev.Previous { if ast.NodeHeading == prev.Type { parentHeadingLevel = prev.HeadingLevel @@ -298,8 +298,8 @@ func resolveEmbedR(n *ast.Node, blockEmbedMode int, luteEngine *lute.Lute, resol } n.HeadingLevel += parentHeadingLevel - embedTopLevel + 1 - if 1 > n.HeadingLevel { - n.HeadingLevel = 1 + if 2 > n.HeadingLevel { + n.HeadingLevel = 2 } else if 6 < n.HeadingLevel { n.HeadingLevel = 6 } @@ -350,13 +350,14 @@ func resolveEmbedR(n *ast.Node, blockEmbedMode int, luteEngine *lute.Lute, resol break } } - if parentHeadingLevel >= embedTopLevel { - for _, hChild := range hChildren { - if ast.NodeHeading == hChild.Type { - hChild.HeadingLevel += parentHeadingLevel - embedTopLevel + 1 - if 6 < hChild.HeadingLevel { - hChild.HeadingLevel = 6 - } + + for _, hChild := range hChildren { + if ast.NodeHeading == hChild.Type { + hChild.HeadingLevel += parentHeadingLevel - embedTopLevel + 1 + if 2 > hChild.HeadingLevel { + hChild.HeadingLevel = 2 + } else if 6 < hChild.HeadingLevel { + hChild.HeadingLevel = 6 } } } From a7dd99019394f713c853149f4225fb7520bf1444 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 16:42:39 +0800 Subject: [PATCH 5/8] :art: https://github.com/siyuan-note/siyuan/issues/17087 Signed-off-by: Daniel <845765@qq.com> --- app/electron/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index eb4f4fa49..dbe5b0b51 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -303,7 +303,6 @@ const showErrorWindow = (titleZh, titleEn, content, emoji = "⚠️") => { titleBarStyle: "hidden", fullscreenable: false, icon: path.join(appDir, "stage", "icon-large.png"), - transparent: "darwin" === process.platform, // 避免深色模式关闭窗口时闪现白色背景 webPreferences: { nodeIntegration: true, webviewTag: true, webSecurity: false, contextIsolation: false, }, From 40c148b56e4d4783afbf0a9cdd604fe537aecc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AA=E6=9D=A5=E6=96=B9=E8=88=9F?= Date: Wed, 6 May 2026 17:02:56 +0800 Subject: [PATCH 6/8] :hammer: Improve Linux build scripts (#17632) --- .gitignore | 3 +++ scripts/linux-build.sh | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b4718a8ca..53a3ea8d0 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,8 @@ logs package-lock.json yarn.lock +# musl toolchain +muslbin/ + # Workflows **/__pycache__ diff --git a/scripts/linux-build.sh b/scripts/linux-build.sh index 6f514a4ee..4ea89bb9b 100755 --- a/scripts/linux-build.sh +++ b/scripts/linux-build.sh @@ -66,18 +66,52 @@ export GOPROXY=https://mirrors.aliyun.com/goproxy/ export CGO_ENABLED=1 export GOOS=linux +setup_cc() { + local arch=$1 + local target_prefix + if [[ "$arch" == "amd64" ]]; then + target_prefix="x86_64-linux-musl" + elif [[ "$arch" == "arm64" ]]; then + target_prefix="aarch64-linux-musl" + fi + + local original_cc=~/${target_prefix}-cross/bin/${target_prefix}-gcc + + if [ -x "$original_cc" ]; then + export CC="$original_cc" + elif command -v ${target_prefix}-gcc >/dev/null 2>&1; then + export CC=$(command -v ${target_prefix}-gcc) + elif [[ "$arch" == "amd64" && "$(uname -m)" == "x86_64" ]] && command -v musl-gcc >/dev/null 2>&1; then + export CC=$(command -v musl-gcc) + elif [[ "$arch" == "arm64" && "$(uname -m)" == "aarch64" ]] && command -v musl-gcc >/dev/null 2>&1; then + export CC=$(command -v musl-gcc) + else + local muslbin_dir="$PROJECT_ROOT/muslbin" + local toolchain_dir="$muslbin_dir/${target_prefix}-cross" + local downloaded_cc="$toolchain_dir/bin/${target_prefix}-gcc" + + if [ ! -x "$downloaded_cc" ]; then + echo "CC not found, downloading ${target_prefix}-cross..." + mkdir -p "$muslbin_dir" + curl -L "https://musl.cc/${target_prefix}-cross.tgz" | tar -xz -C "$muslbin_dir" + fi + export CC="$downloaded_cc" + fi + echo "Using CC=$CC" +} + if [[ "$TARGET" == 'amd64' || "$TARGET" == 'all' ]]; then echo echo 'Building Kernel amd64' export GOARCH=amd64 - export CC=~/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc + setup_cc amd64 go build -buildmode=pie -tags fts5 -v -o "../app/kernel-linux/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" . fi if [[ "$TARGET" == 'arm64' || "$TARGET" == 'all' ]]; then echo echo 'Building Kernel arm64' export GOARCH=arm64 - export CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc + setup_cc arm64 go build -buildmode=pie -tags fts5 -v -o "../app/kernel-linux-arm64/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" . fi From 479aa3a68b4d2ee419424c5603950212021f6231 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 17:55:41 +0800 Subject: [PATCH 7/8] :hammer: Improve CD scripts Signed-off-by: Daniel <845765@qq.com> --- .github/workflows/cd.yml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 242b0634b..eb230b41c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -90,23 +90,14 @@ jobs: matrix: config: - os: ubuntu-24.04 - name: ubuntu build linux.AppImage + name: ubuntu build linux kernel_path: "../app/kernel-linux/SiYuan-Kernel" build_args_prefix: "-s -w -X" build_args_suffix: "Mode=prod" electron_args: "dist-linux" goos: "linux" goarch: "amd64" - suffix: "linux.AppImage" - - os: ubuntu-24.04 - name: ubuntu build linux.tar.gz - kernel_path: "../app/kernel-linux/SiYuan-Kernel" - build_args_prefix: "-s -w -X" - build_args_suffix: "Mode=prod" - electron_args: "dist-linux" - goos: "linux" - goarch: "amd64" - suffix: "linux.tar.gz" + suffix: "linux" - os: macos-latest name: macos build mac.dmg kernel_path: "../app/kernel-darwin/SiYuan-Kernel" @@ -222,11 +213,16 @@ jobs: GOPATH: ${{ github.workspace }}/go GOARCH: ${{ matrix.config.goarch }} + - name: Install RPM build tools + if: matrix.config.goos == 'linux' + run: sudo apt-get install -y rpm + - name: Building Electron App run: pnpm run ${{ matrix.config.electron_args }} working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app - name: Upload Release + if: matrix.config.goos != 'linux' uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -235,3 +231,16 @@ jobs: asset_name: siyuan-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }} asset_path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }} asset_content_type: application/octet-stream + + - name: Upload Linux Release Assets + if: matrix.config.goos == 'linux' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION="${{ needs.create_release.outputs.version }}" + BUILD_DIR="${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build" + for ext in AppImage tar.gz deb rpm; do + asset="${BUILD_DIR}/siyuan-${VERSION}-linux.${ext}" + echo "Uploading linux.${ext}..." + gh release upload "${{ github.ref_name }}" "${asset}" --clobber + done From 5eebb29831b264d9a5b9323a58c21fde4b779f35 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 6 May 2026 18:01:40 +0800 Subject: [PATCH 8/8] :art: https://github.com/siyuan-note/siyuan/issues/17087 Signed-off-by: Daniel <845765@qq.com> --- app/electron/main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index dbe5b0b51..014f3ce95 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -303,6 +303,7 @@ const showErrorWindow = (titleZh, titleEn, content, emoji = "⚠️") => { titleBarStyle: "hidden", fullscreenable: false, icon: path.join(appDir, "stage", "icon-large.png"), + transparent: "darwin" === process.platform, // 避免深色模式关闭窗口时闪现白色背景 webPreferences: { nodeIntegration: true, webviewTag: true, webSecurity: false, contextIsolation: false, }, @@ -403,7 +404,6 @@ const initMainWindow = () => { fullscreenable: true, fullscreen: windowState.fullscreen, trafficLightPosition: {x: 8, y: 8}, - transparent: "darwin" === process.platform, // 避免缩放窗口时出现边框 webPreferences: { nodeIntegration: true, webviewTag: true, @@ -1146,7 +1146,6 @@ app.whenReady().then(() => { minWidth: 493, minHeight: 376, fullscreenable: true, - transparent: "darwin" === process.platform, // 避免缩放窗口时出现边框 frame: "darwin" === process.platform, icon: path.join(appDir, "stage", "icon-large.png"), titleBarStyle: "hidden",