Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-12-20 20:14:40 +08:00
commit 4868392491
18 changed files with 88 additions and 111 deletions

View file

@ -33,4 +33,4 @@ jobs:
- name: Build the Docker image
run: |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v2.5.4 .
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v2.5.5 .

View file

@ -1,3 +1,27 @@
## v2.5.5 / 2022-12-20
### 改进功能
* [搜索上下及左右布局可进行大小调整](https://github.com/siyuan-note/siyuan/issues/6762)
* [屏蔽列表项拖拽到列表项第一个块上方和列表前一个块的下方](https://github.com/siyuan-note/siyuan/issues/6843)
* [支持数据快照对比](https://github.com/siyuan-note/siyuan/issues/6858)
* [导出 Markdown zip 包内不带文件夹](https://github.com/siyuan-note/siyuan/issues/6869)
* [显示本地数据快照文件类型计数](https://github.com/siyuan-note/siyuan/issues/6870)
* [改进数据快照加载性能](https://github.com/siyuan-note/siyuan/issues/6872)
* [桌面端检查磁盘可用空间](https://github.com/siyuan-note/siyuan/issues/6873)
* [导出 Markdown 文件时开头附上一些元数据](https://github.com/siyuan-note/siyuan/issues/6880)
* [支持去掉 PDF 导出页脚处 `由思源笔记导出`](https://github.com/siyuan-note/siyuan/issues/6881)
* [改进部分繁体中文为习惯性用语](https://github.com/siyuan-note/siyuan/pull/6882)
* [托盘菜单支持多语言](https://github.com/siyuan-note/siyuan/issues/6883)
* [改进桌面端拉起内核](https://github.com/siyuan-note/siyuan/issues/6894)
### 修复缺陷
* [复制超链接嵌套行级代码丢失链接地址](https://github.com/siyuan-note/siyuan/issues/6868)
* [HTML 块渲染可能触发状态异常](https://github.com/siyuan-note/siyuan/issues/6884)
* [数据同步报错 `file exists`](https://github.com/siyuan-note/siyuan/issues/6888)
* [建立索引时无法解析 `v2.2.0-` 版本的块引用](https://github.com/siyuan-note/siyuan/issues/6889)
## v2.5.4 / 2022-12-13
### 改进功能

View file

@ -38,8 +38,6 @@
"floatWindowMode": "Hover to display a floating window",
"floatWindowModeTip": "After enabling, a floating window will appear when the mouse hovers over the block reference, breadcrumb block icon, etc. After disabling, you need to hold down the <code class='fn__code'>${hotkey}</code> key to appear the floating window",
"codeSnippet": "Code Snippet",
"useFixedPort": "Use Fixed Port",
"useFixedPortTip": "After enabling, only the port <code class='fn__code'>6806</code> will be used. When disabled, both random ports and <code class='fn__code'>6806</code> will be used. The application will be closed automatically after modification, please restart manually",
"expandDown": "Expand Down",
"expandUp": "Expand Up",
"goForward": "Go forward",

View file

@ -38,8 +38,6 @@
"floatWindowMode": "Pase el cursor para mostrar una ventana flotante",
"floatWindowModeTip": "Después de habilitar, aparecerá una ventana flotante cuando el mouse se desplace sobre la referencia del bloque, el ícono del bloque de navegación, etc. Después de deshabilitar, debe mantener presionada la tecla <code class='fn__code'>${hotkey}</code> para aparece la ventana flotante",
"codeSnippet": "Fragmento de código",
"useFixedPort": "Usar puerto fijo",
"useFixedPortTip": "Después de habilitarlo, solo se usará el puerto <code class='fn__code'>6806</code>. Cuando está deshabilitado, se utilizarán tanto los puertos aleatorios como <code class='fn__code'>6806</code>. La aplicación se cerrará automáticamente después de la modificación, por favor reinicie manualmente",
"expandDown": "Expandir hacia abajo",
"expandUp": "Expandir hacia arriba",
"goForward": "Ir hacia adelante",

View file

@ -38,8 +38,6 @@
"floatWindowMode": "Survolez pour afficher une fenêtre flottante",
"floatWindowModeTip": "Après l'activation, une fenêtre flottante apparaît lorsque la souris survole la référence du bloc, l'icône du fil d'Ariane, etc. Après la désactivation, vous devez maintenir enfoncée la touche <code class='fn__code'>${hotkey}</code> pour apparaît la fenêtre flottante",
"codeSnippet": "Extrait de code",
"useFixedPort": "Utiliser un port fixe",
"useFixedPortTip": "Après activation, seul le port <code class='fn__code'>6806</code> sera utilisé. Lorsqu'il est désactivé, les ports aléatoires et <code class='fn__code'>6806</code> seront utilisés. L'application sera fermée automatiquement après modification, veuillez la redémarrer manuellement.",
"expandDown": "Développer vers le bas",
"expandUp": "Développer vers le haut",
"goForward": "Suivant",

View file

@ -38,8 +38,6 @@
"floatWindowMode": "懸停出現浮窗",
"floatWindowModeTip": "啟用後鼠標懸停塊引、導覽路徑塊標等位置會出現浮窗,關閉後需按住 <code class='fn__code'>${hotkey}</code> 鍵才會出現浮窗",
"codeSnippet": "代碼片段",
"useFixedPort": "使用固定端口",
"useFixedPortTip": "啟用後將僅使用固定端口 <code class='fn__code'>6806</code>,關閉時同時使用隨機端口和 <code class='fn__code'>6806</code>。修改後會自動關閉應用,請手動重啟",
"expandDown": "向下擴選",
"expandUp": "向上擴選",
"goForward": "前進",

View file

@ -38,8 +38,6 @@
"floatWindowMode": "悬停出现浮窗",
"floatWindowModeTip": "启用后鼠标悬停块引、面包屑块标等位置会出现浮窗,关闭后需按住 <code class='fn__code'>${hotkey}</code> 键才会出现浮窗",
"codeSnippet": "代码片段",
"useFixedPort": "使用固定端口",
"useFixedPortTip": "启用后将仅使用固定端口 <code class='fn__code'>6806</code>,关闭时同时使用随机端口和 <code class='fn__code'>6806</code>。修改后会自动关闭应用,请手动重启",
"expandDown": "向下扩选",
"expandUp": "向上扩选",
"goForward": "前进",

View file

@ -9,7 +9,7 @@
<Identity Name="89C2A984.SiYuan"
ProcessorArchitecture="x64"
Publisher='CN=087C656E-C1D9-42D8-8807-CED45A74FC0F'
Version="2.5.4.0"/>
Version="2.5.5.0"/>
<Properties>
<DisplayName>SiYuan</DisplayName>
<PublisherDisplayName>云南链滴科技有限公司</PublisherDisplayName>

View file

@ -27,6 +27,7 @@ const {
} = require('electron')
const path = require('path')
const fs = require('fs')
const net = require("net");
const fetch = require('electron-fetch').default
process.noAsar = true
const appDir = path.dirname(app.getAppPath())
@ -34,7 +35,6 @@ const isDevEnv = process.env.NODE_ENV === 'development'
const appVer = app.getVersion()
const confDir = path.join(app.getPath('home'), '.config', 'siyuan')
const windowStatePath = path.join(confDir, 'windowState.json')
const portJSONPath = path.join(confDir, 'port.json')
let tray // 托盘必须使用全局变量,以防止被垃圾回收 https://www.electronjs.org/docs/faq#my-apps-windowtray-disappeared-after-a-few-minutes
let mainWindow // 从托盘处激活报错 https://github.com/siyuan-note/siyuan/issues/769
let firstOpenWindow, bootWindow
@ -42,7 +42,6 @@ let closeButtonBehavior = 0
let siyuanOpenURL
let firstOpen = false
let resetWindowStateOnRestart = false
let kernelPort = "6806"
const localhost = "127.0.0.1"
require('@electron/remote/main').initialize()
@ -51,10 +50,6 @@ if (!app.requestSingleInstanceLock()) {
return
}
const getServer = () => {
return "http://" + localhost + ":" + kernelPort
}
const showErrorWindow = (title, content) => {
let errorHTMLPath = path.join(appDir, 'app', 'electron', 'error.html')
if (isDevEnv) {
@ -567,9 +562,7 @@ const initKernel = (initData) => {
},
})
const kernelName = 'win32' === process.platform
? 'SiYuan-Kernel.exe'
: 'SiYuan-Kernel'
const kernelName = 'win32' === process.platform ? 'SiYuan-Kernel.exe' : 'SiYuan-Kernel'
const kernelPath = path.join(appDir, 'kernel', kernelName)
if (!fs.existsSync(kernelPath)) {
showErrorWindow('⚠️ 内核文件丢失 Kernel is missing',
@ -579,7 +572,8 @@ const initKernel = (initData) => {
return
}
const cmds = ['--wd', appDir]
const availablePort = await getKernelPort()
const cmds = ['--port', availablePort, '--wd', appDir]
if (isDevEnv) {
cmds.push('--mode', 'dev')
}
@ -641,44 +635,6 @@ const initKernel = (initData) => {
})
}
const getKernelPort = async () => {
if (isDevEnv) {
return kernelPort
}
await sleep(200)
let gotPort = false
let count = 0
while (!gotPort) {
try {
const portJSON = JSON.parse(fs.readFileSync(portJSONPath, 'utf8'))
const ret = portJSON[kernelProcessPid]
if (ret) {
gotPort = true
return ret
}
await sleep(100)
} catch (e) {
await sleep(100)
} finally {
count++
if (64 < count) {
writeLog('get kernel port failed [pid=' + kernelProcessPid + '], try to use 6806')
return
}
}
}
}
kernelPort = await getKernelPort()
if (!kernelPort) {
showErrorWindow('⚠️ 获取内核服务端口失败 Failed to get kernel serve port',
'<div>获取内核服务端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to get kernel serve port, please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>')
bootWindow.destroy()
resolve(false)
}
writeLog("got kernel port [" + kernelPort + "]")
let gotVersion = false
let apiData
let count = 0
@ -698,8 +654,12 @@ const initKernel = (initData) => {
count++
if (14 < count) {
writeLog('get kernel ver failed')
showErrorWindow('⚠️ 获取内核服务端口失败 Failed to get kernel serve port',
'<div>获取内核服务端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to get kernel serve port, please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>')
bootWindow.destroy()
resolve(false)
return
}
}
}
@ -861,7 +821,6 @@ app.on('before-quit', (event) => {
})
const {powerMonitor} = require('electron')
const {build} = require("electron-builder");
powerMonitor.on('suspend', () => {
writeLog('system suspend')
@ -912,3 +871,43 @@ const isOnline = async () => {
}
}
}
let kernelPort = 6806
const getKernelPort = async () => {
if (isDevEnv) {
writeLog("got kernel port [" + kernelPort + "]")
return kernelPort
}
// 改进桌面端拉起内核 https://github.com/siyuan-note/siyuan/issues/6894
kernelPort = await getAvailablePort()
writeLog("got kernel available port [" + kernelPort + "]")
return kernelPort
}
let tryGetPortCount = 0
const getAvailablePort = (port = kernelPort) => {
// https://gist.github.com/mikeal/1840641
const server = net.createServer()
return new Promise((resolve, reject) => server
.on('error', error => {
writeLog(error)
if (2048 < ++tryGetPortCount) {
writeLog('failed to get available port [tryCount=' + tryGetPortCount + ', port=' + port + ']')
reject(error)
return
}
server.listen(++port)
})
.on('listening', () => {
writeLog('found an available port [' + port + ']')
server.close(() => resolve(port))
})
.listen(port, '127.0.0.1'))
}
const getServer = () => {
return "http://" + localhost + ":" + kernelPort
}

View file

@ -1,6 +1,6 @@
{
"name": "SiYuan",
"version": "2.5.4",
"version": "2.5.5",
"description": "Build Your Eternal Digital Garden",
"homepage": "https://b3log.org/siyuan",
"main": "./electron/main.js",

4
app/pnpm-lock.yaml generated
View file

@ -1928,10 +1928,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
@ -2215,9 +2215,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

View file

@ -57,14 +57,6 @@ export const about = {
<div class="fn__space"></div>
<input class="b3-switch fn__flex-center" id="networkServe" type="checkbox"${window.siyuan.config.system.networkServe ? " checked" : ""}>
</label>
<label class="b3-label fn__flex">
<div class="fn__flex-1">
${window.siyuan.languages.useFixedPort}
<div class="b3-label__text">${window.siyuan.languages.useFixedPortTip}</div>
</div>
<div class="fn__space"></div>
<input class="b3-switch fn__flex-center" id="fixedPort" type="checkbox"${window.siyuan.config.system.fixedPort ? " checked" : ""}>
</label>
<label class="b3-label${isBrowser() ? " fn__none" : " fn__flex"}">
<div class="fn__flex-1">
${window.siyuan.languages.about2}
@ -369,14 +361,6 @@ export const about = {
});
});
});
const fixedPortElement = about.element.querySelector("#fixedPort") as HTMLInputElement;
fixedPortElement.addEventListener("change", () => {
fetchPost("/api/system/setFixedPort", {fixedPort: fixedPortElement.checked}, () => {
exportLayout(false, () => {
exitSiYuan();
});
});
});
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
googleAnalyticsElement.addEventListener("change", () => {
fetchPost("/api/system/setGoogleAnalytics", {googleAnalytics: googleAnalyticsElement.checked}, () => {

View file

@ -74,7 +74,7 @@ export const initConfigSearch = (element: HTMLElement) => {
"importKey", "genKey", "genKeyByPW", "copyKey", "resetRepo", "systemLogTip", "export", "visitAnnouncements",
"safeQuit", "directConnection", "siyuanNote", "key", "password", "copied", "resetRepoTip",
"autoDownloadUpdatePkg", "autoDownloadUpdatePkgTip", "networkProxy", "keyPlaceholder", "initRepoKeyTip",
"useFixedPort", "useFixedPortTip", "googleAnalytics", "googleAnalyticsTip"]),
"googleAnalytics", "googleAnalyticsTip"]),
];
const inputElement = element.querySelector(".b3-form__icon input") as HTMLInputElement;
/// #if !BROWSER

View file

@ -39,7 +39,6 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/system/getEmojiConf", model.CheckAuth, getEmojiConf)
ginServer.Handle("POST", "/api/system/setAccessAuthCode", model.CheckAuth, setAccessAuthCode)
ginServer.Handle("POST", "/api/system/setNetworkServe", model.CheckAuth, setNetworkServe)
ginServer.Handle("POST", "/api/system/setFixedPort", model.CheckAuth, setFixedPort)
ginServer.Handle("POST", "/api/system/setUploadErrLog", model.CheckAuth, setUploadErrLog)
ginServer.Handle("POST", "/api/system/setGoogleAnalytics", model.CheckAuth, setGoogleAnalytics)
ginServer.Handle("POST", "/api/system/setDownloadInstallPkg", model.CheckAuth, setDownloadInstallPkg)

View file

@ -285,23 +285,6 @@ func setNetworkServe(c *gin.Context) {
time.Sleep(time.Second * 3)
}
func setFixedPort(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
fixedPort := arg["fixedPort"].(bool)
model.Conf.System.FixedPort = fixedPort
model.Conf.Save()
util.PushMsg(model.Conf.Language(42), 1000*15)
time.Sleep(time.Second * 3)
}
func setGoogleAnalytics(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -35,7 +35,6 @@ type System struct {
DataDir string `json:"dataDir"`
NetworkServe bool `json:"networkServe"` // 是否开启网络伺服
FixedPort bool `json:"fixedPort"` // 是否使用固定端口 6806
NetworkProxy *NetworkProxy `json:"networkProxy"`
UploadErrLog bool `json:"uploadErrLog"`

View file

@ -296,13 +296,6 @@ func InitConf() {
Conf.AccessAuthCode = util.AccessAuthCode
}
if util.ContainerStd != util.Container {
Conf.System.FixedPort = true
}
if Conf.System.FixedPort {
util.ServerPort = util.FixedPort
}
Conf.LocalIPs = util.GetLocalIPs()
Conf.Save()

View file

@ -41,7 +41,7 @@ import (
var Mode = "prod"
const (
Ver = "2.5.4"
Ver = "2.5.5"
IsInsider = false
)
@ -446,10 +446,16 @@ func GetDataAssetsAbsPath() (ret string) {
func tryLockWorkspace() {
WorkspaceLock = flock.New(filepath.Join(WorkspaceDir, ".lock"))
if err := WorkspaceLock.Lock(); nil != err {
logging.LogErrorf("lock workspace [%s] failed: %s", WorkspaceDir, err)
os.Exit(ExitCodeWorkspaceLocked)
ok, err := WorkspaceLock.TryLock()
if ok {
return
}
if nil != err {
logging.LogErrorf("lock workspace [%s] failed: %s", WorkspaceDir, err)
} else {
logging.LogErrorf("lock workspace [%s] failed", WorkspaceDir)
}
os.Exit(ExitCodeWorkspaceLocked)
}
func UnlockWorkspace() {