diff --git a/app/electron-builder-arm64.yml b/app/electron-builder-arm64.yml new file mode 100644 index 000000000..65e6d28aa --- /dev/null +++ b/app/electron-builder-arm64.yml @@ -0,0 +1,75 @@ +productName: "SiYuan" +appId: "org.b3log.siyuan" +asar: false +compression: "store" +copyright: "© 2024 Yunnan Liandi Technology Co., Ltd." +artifactName: "siyuan-${version}-${os}-arm64.${ext}" +extraMetadata: + main: "electron/main.js" +directories: + output: "build" +files: + - "electron" +extraFiles: + - from: "../LICENSE" + to: "LICENSE" +win: + icon: "src/assets/icon.ico" + extraResources: + - from: "kernel-arm64" + to: "kernel" + requestedExecutionLevel: "asInvoker" + # certificateSubjectName: "Yunnan Liandi Technology Co., Ltd." + signingHashAlgorithms: [ 'sha256' ] + #rfc3161TimeStampServer: "http://sha256timestamp.ws.symantec.com/sha256/timestamp" + #rfc3161TimeStampServer: "http://time.certum.pl" + rfc3161TimeStampServer: "http://timestamp.entrust.net/TSS/RFC3161sha2TS" + target: + - target: "nsis" + arch: "arm64" +nsis: + oneClick: false + perMachine: false + allowToChangeInstallationDirectory: true + allowElevation: true + deleteAppDataOnUninstall: true + createDesktopShortcut: true + createStartMenuShortcut: true + shortcutName: "SiYuan" + license: "../LICENSE" + include: "nsis/installer.nsh" + warningsAsErrors: false + installerSidebar: "nsis/installerSidebar.bmp" + uninstallerSidebar: "nsis/uninstallerSidebar.bmp" + +extraResources: + - from: "changelogs" + to: "changelogs" + - from: "stage" + to: "stage" + - from: "guide" + to: "guide" + filter: "!**/{.DS_Store,.git,.gitignore,.idea}" + - from: "appearance/boot" + to: "appearance/boot" + filter: "!**/{.DS_Store}" + - from: "appearance/icons" + to: "appearance/icons" + filter: "!**/{.DS_Store}" + - from: "appearance/langs" + to: "appearance/langs" + filter: "!**/{.DS_Store}" + - from: "appearance/emojis" + to: "appearance/emojis" + filter: "!**/{.DS_Store}" + - from: "appearance/themes/midnight" + to: "appearance/themes/midnight" + filter: "!**/{.DS_Store,custom.css}" + - from: "appearance/themes/daylight" + to: "appearance/themes/daylight" + filter: "!**/{.DS_Store,custom.css}" + - from: "src/assets/fonts" + to: "appearance/fonts" + filter: "!**/{.DS_Store}" + - from: "pandoc/pandoc-windows-amd64.zip" + to: "pandoc.zip" \ No newline at end of file diff --git a/app/electron-builder-linux-arm64.yml b/app/electron-builder-linux-arm64.yml new file mode 100644 index 000000000..3a16a14be --- /dev/null +++ b/app/electron-builder-linux-arm64.yml @@ -0,0 +1,59 @@ +productName: "SiYuan" +appId: "org.b3log.siyuan" +asar: false +compression: "store" +copyright: "© 2024 Yunnan Liandi Technology Co., Ltd." +artifactName: "siyuan-${version}-${os}-arm64.${ext}" +extraMetadata: + main: "electron/main.js" +directories: + output: "build" +files: + - "electron" +extraFiles: + - from: "../LICENSE" + to: "LICENSE" + +linux: + icon: "src/assets/icon.png" + category: "Utility" + extraResources: + - from: "kernel-linux-arm64" + to: "kernel" + target: + - target: "tar.gz" + arch: "arm64" + - target: "AppImage" + arch: "arm64" + +extraResources: + - from: "changelogs" + to: "changelogs" + - from: "stage" + to: "stage" + - from: "guide" + to: "guide" + filter: "!**/{.DS_Store,.git,.gitignore,.idea}" + - from: "appearance/boot" + to: "appearance/boot" + filter: "!**/{.DS_Store}" + - from: "appearance/icons" + to: "appearance/icons" + filter: "!**/{.DS_Store}" + - from: "appearance/langs" + to: "appearance/langs" + filter: "!**/{.DS_Store}" + - from: "appearance/emojis" + to: "appearance/emojis" + filter: "!**/{.DS_Store}" + - from: "appearance/themes/midnight" + to: "appearance/themes/midnight" + filter: "!**/{.DS_Store,custom.css}" + - from: "appearance/themes/daylight" + to: "appearance/themes/daylight" + filter: "!**/{.DS_Store,custom.css}" + - from: "src/assets/fonts" + to: "appearance/fonts" + filter: "!**/{.DS_Store}" + - from: "pandoc/pandoc-linux-amd64.zip" + to: "pandoc.zip" \ No newline at end of file diff --git a/app/electron-builder-linux.yml b/app/electron-builder-linux.yml index 342bb7605..e7bc7378c 100644 --- a/app/electron-builder-linux.yml +++ b/app/electron-builder-linux.yml @@ -1,7 +1,7 @@ productName: "SiYuan" appId: "org.b3log.siyuan" asar: false -compression: "normal" +compression: "store" copyright: "© 2024 Yunnan Liandi Technology Co., Ltd." artifactName: "siyuan-${version}-${os}.${ext}" extraMetadata: diff --git a/app/electron-builder.yml b/app/electron-builder.yml index 76fcfad4b..6722b2531 100644 --- a/app/electron-builder.yml +++ b/app/electron-builder.yml @@ -1,7 +1,7 @@ productName: "SiYuan" appId: "org.b3log.siyuan" asar: false -compression: "normal" +compression: "store" copyright: "© 2024 Yunnan Liandi Technology Co., Ltd." artifactName: "siyuan-${version}-${os}.${ext}" extraMetadata: diff --git a/app/package.json b/app/package.json index 7a2ed9e5a..9f7d615aa 100644 --- a/app/package.json +++ b/app/package.json @@ -19,9 +19,11 @@ "start": "NODE_ENV=development electron ./electron/main.js", "dist-appx": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --config electron-appx-builder.yml", "dist": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --config electron-builder.yml --publish=never", + "dist-arm64": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --arm64 --config electron-builder-arm64.yml --publish=never", "dist-darwin": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --mac --config electron-builder-darwin.yml --publish=never", "dist-darwin-arm64": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --arm64 --mac --config electron-builder-darwin-arm64.yml --publish=never", - "dist-linux": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --linux --config electron-builder-linux.yml --publish=never" + "dist-linux": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --linux --config electron-builder-linux.yml --publish=never", + "dist-linux-arm64": "ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ electron-builder --arm64 --linux --config electron-builder-linux-arm64.yml --publish=never" }, "keywords": [ "markdown", diff --git a/kernel/api/block.go b/kernel/api/block.go index addafe6cd..e6e2a62a4 100644 --- a/kernel/api/block.go +++ b/kernel/api/block.go @@ -233,7 +233,11 @@ func checkBlockFold(c *gin.Context) { } id := arg["id"].(string) - ret.Data = model.IsBlockFolded(id) + isFolded, isRoot := model.IsBlockFolded(id) + ret.Data = map[string]interface{}{ + "isFolded": isFolded, + "isRoot": isRoot, + } } func checkBlockExist(c *gin.Context) { diff --git a/kernel/model/block.go b/kernel/model/block.go index 4f551bda4..defd002ad 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -268,20 +268,31 @@ func GetBlockSiblingID(id string) (parent, previous, next string) { return } -func IsBlockFolded(id string) bool { +func IsBlockFolded(id string) (isFolded, isRoot bool) { + tree, _ := LoadTreeByBlockID(id) + if nil == tree { + return + } + + if tree.Root.ID == id { + isRoot = true + } + for i := 0; i < 32; i++ { b, _ := getBlock(id, nil) if nil == b { - return false + return } if "1" == b.IAL["fold"] { - return true + isFolded = true + return } id = b.ParentID + } - return false + return } func RecentUpdatedBlocks() (ret []*Block) { diff --git a/scripts/darwin-build.sh b/scripts/darwin-build.sh index d6dea75a9..8fe5bc1f1 100755 --- a/scripts/darwin-build.sh +++ b/scripts/darwin-build.sh @@ -18,10 +18,12 @@ export GO111MODULE=on export GOPROXY=https://goproxy.io export CGO_ENABLED=1 +echo 'Building Kernel amd64' export GOOS=darwin export GOARCH=amd64 go build --tags fts5 -v -o "../app/kernel-darwin/SiYuan-Kernel" -ldflags "-s -w" . +echo 'Building Kernel arm64' export GOOS=darwin export GOARCH=arm64 go build --tags fts5 -v -o "../app/kernel-darwin-arm64/SiYuan-Kernel" -ldflags "-s -w" . diff --git a/scripts/linux-build.sh b/scripts/linux-build.sh index 307208ba2..91b832559 100755 --- a/scripts/linux-build.sh +++ b/scripts/linux-build.sh @@ -8,6 +8,7 @@ cd .. echo 'Cleaning Builds' rm -rf app/build rm -rf app/kernel-linux +rm -rf app/kernel-linux-arm64 echo 'Building Kernel' @@ -17,12 +18,20 @@ export GO111MODULE=on export GOPROXY=https://goproxy.io export CGO_ENABLED=1 +echo 'Building Kernel amd64' export GOOS=linux export GOARCH=amd64 go build --tags fts5 -v -o "../app/kernel-linux/SiYuan-Kernel" -ldflags "-s -w" . + +echo 'Building Kernel arm64' +export GOARCH=arm64 +export CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc +go build --tags fts5 -v -o "../app/kernel-linux-arm64/SiYuan-Kernel" -ldflags "-s -w" . cd .. -echo 'Building Electron App' +echo 'Building Electron App amd64' cd app pnpm run dist-linux +echo 'Building Electron App arm64' +pnpm run dist-linux-arm64 cd .. diff --git a/scripts/win-build.bat b/scripts/win-build.bat index da942c6fd..e12148e5c 100644 --- a/scripts/win-build.bat +++ b/scripts/win-build.bat @@ -13,6 +13,7 @@ cd .. echo 'Cleaning Builds' del /S /Q /F app\build 1>nul del /S /Q /F app\kernel 1>nul +del /S /Q /F app\kernel-arm64 1>nul echo 'Building Kernel' @REM the C compiler "gcc" is necessary https://sourceforge.net/projects/mingw-w64/files/mingw-w64/ @@ -22,25 +23,39 @@ set GOPROXY=https://goproxy.io set CGO_ENABLED=1 cd kernel -@REM you can use `go generate` instead (nead add something in main.go) +@REM you can use `go mod tidy` to update kernel dependency before build +@REM you can use `go generate` instead (need add something in main.go) goversioninfo -platform-specific=true -icon=resource/icon.ico -manifest=resource/goversioninfo.exe.manifest +echo 'Building Kernel amd64' set GOOS=windows set GOARCH=amd64 -@REM you can use `go mod tidy` to update kernel dependency before build go build --tags fts5 -v -o "../app/kernel/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" . if errorlevel 1 ( exit /b %errorlevel% ) +echo 'Building Kernel arm64' +set GOARCH=arm64 +@REM if you want to build arm64, you need to install aarch64-w64-mingw32-gcc +set CC="D:/Program Files/llvm-mingw-20240518-ucrt-x86_64/bin/aarch64-w64-mingw32-gcc.exe" +go build --tags fts5 -v -o "../app/kernel-arm64/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" . +if errorlevel 1 ( + exit /b %errorlevel% +) cd .. -echo 'Building Electron App' +echo 'Building Electron App amd64' cd app call pnpm run dist if errorlevel 1 ( exit /b %errorlevel% ) +echo 'Building Electron App arm64' +call pnpm run dist-arm64 +if errorlevel 1 ( + exit /b %errorlevel% +) cd .. echo 'Building Appx'