mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
550195b603
4 changed files with 81 additions and 36 deletions
|
|
@ -364,7 +364,7 @@ const showWindow = (wnd) => {
|
|||
wnd.focus()
|
||||
}
|
||||
|
||||
const initKernel = (workspace, lang) => {
|
||||
const initKernel = (workspace, port, lang) => {
|
||||
return new Promise(async (resolve) => {
|
||||
bootWindow = new BrowserWindow({
|
||||
width: screen.getPrimaryDisplay().size.width / 2,
|
||||
|
|
@ -390,22 +390,26 @@ const initKernel = (workspace, lang) => {
|
|||
}
|
||||
|
||||
if (!isDevEnv || workspaces.length > 0) {
|
||||
const getAvailablePort = () => {
|
||||
// https://gist.github.com/mikeal/1840641
|
||||
return new Promise((portResolve, portReject) => {
|
||||
const server = net.createServer()
|
||||
server.on('error', error => {
|
||||
writeLog(error)
|
||||
kernelPort = ''
|
||||
portReject()
|
||||
if (port && "" !== port) {
|
||||
kernelPort = port
|
||||
} else {
|
||||
const getAvailablePort = () => {
|
||||
// https://gist.github.com/mikeal/1840641
|
||||
return new Promise((portResolve, portReject) => {
|
||||
const server = net.createServer()
|
||||
server.on('error', error => {
|
||||
writeLog(error)
|
||||
kernelPort = ''
|
||||
portReject()
|
||||
})
|
||||
server.listen(0, () => {
|
||||
kernelPort = server.address().port
|
||||
server.close(() => portResolve(kernelPort))
|
||||
})
|
||||
})
|
||||
server.listen(0, () => {
|
||||
kernelPort = server.address().port
|
||||
server.close(() => portResolve(kernelPort))
|
||||
})
|
||||
})
|
||||
}
|
||||
await getAvailablePort()
|
||||
}
|
||||
await getAvailablePort()
|
||||
}
|
||||
writeLog('got kernel port [' + kernelPort + ']')
|
||||
if (!kernelPort) {
|
||||
|
|
@ -417,10 +421,13 @@ const initKernel = (workspace, lang) => {
|
|||
if (isDevEnv && workspaces.length === 0) {
|
||||
cmds.push('--mode', 'dev')
|
||||
}
|
||||
if (workspace) {
|
||||
if (workspace && "" !== workspace) {
|
||||
cmds.push('--workspace', workspace)
|
||||
}
|
||||
if (lang) {
|
||||
if (port && "" !== port) {
|
||||
cmds.push('--port', port)
|
||||
}
|
||||
if (lang && "" !== lang) {
|
||||
cmds.push('--lang', lang)
|
||||
}
|
||||
let cmd = `ui version [${appVer}], booting kernel [${kernelPath} ${cmds.join(
|
||||
|
|
@ -728,7 +735,7 @@ app.whenReady().then(() => {
|
|||
}
|
||||
})
|
||||
if (!foundWorkspace) {
|
||||
initKernel(data.workspace, data.lang).then((isSucc) => {
|
||||
initKernel(data.workspace, "", data.lang).then((isSucc) => {
|
||||
if (isSucc) {
|
||||
boot()
|
||||
}
|
||||
|
|
@ -835,7 +842,7 @@ app.whenReady().then(() => {
|
|||
firstOpenWindow.show()
|
||||
// 初始化启动
|
||||
ipcMain.on('siyuan-first-init', (event, data) => {
|
||||
initKernel(data.workspace, data.lang).then((isSucc) => {
|
||||
initKernel(data.workspace, "", data.lang).then((isSucc) => {
|
||||
if (isSucc) {
|
||||
boot()
|
||||
}
|
||||
|
|
@ -855,7 +862,11 @@ app.whenReady().then(() => {
|
|||
if (workspace) {
|
||||
writeLog('got arg [--workspace=' + workspace + ']')
|
||||
}
|
||||
initKernel(workspace).then((isSucc) => {
|
||||
const port = getArg('--port')
|
||||
if (port) {
|
||||
writeLog('got arg [--port=' + port + ']')
|
||||
}
|
||||
initKernel(workspace, port, "").then((isSucc) => {
|
||||
if (isSucc) {
|
||||
boot()
|
||||
}
|
||||
|
|
@ -880,6 +891,13 @@ app.on('second-instance', (event, argv) => {
|
|||
workspace = workspace.split('=')[1]
|
||||
writeLog('got second-instance arg [--workspace=' + workspace + ']')
|
||||
}
|
||||
let port = argv.find((arg) => arg.startsWith('--port='))
|
||||
if (port) {
|
||||
port = port.split('=')[1]
|
||||
writeLog('got second-instance arg [--port=' + port + ']')
|
||||
} else {
|
||||
port = 0
|
||||
}
|
||||
const foundWorkspace = workspaces.find(item => {
|
||||
if (item.browserWindow && !item.browserWindow.isDestroyed()) {
|
||||
if (workspace && workspace === item.workspaceDir) {
|
||||
|
|
@ -892,7 +910,7 @@ app.on('second-instance', (event, argv) => {
|
|||
return
|
||||
}
|
||||
if (workspace) {
|
||||
initKernel(workspace).then((isSucc) => {
|
||||
initKernel(workspace, port, "").then((isSucc) => {
|
||||
if (isSucc) {
|
||||
boot()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"Properties": {
|
||||
"id": "20230106104821-9nfphwm",
|
||||
"title": "Workspace",
|
||||
"updated": "20230113231033"
|
||||
"updated": "20230117000549"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20230109113955-471odxk",
|
||||
"updated": "20230113231033"
|
||||
"updated": "20230117000549"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@
|
|||
},
|
||||
"Properties": {
|
||||
"id": "20230109113955-4p8sitz",
|
||||
"updated": "20230113231033"
|
||||
"updated": "20230117000549"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20230109113955-f2iskk4",
|
||||
"updated": "20230113231033"
|
||||
"updated": "20230117000549"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -182,7 +182,16 @@
|
|||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": "."
|
||||
"Data": ". In addition, you can also pass "
|
||||
},
|
||||
{
|
||||
"Type": "NodeTextMark",
|
||||
"TextMarkType": "code",
|
||||
"TextMarkTextContent": "--port=12345"
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " to specify the port that the kernel listens to."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"Properties": {
|
||||
"id": "20230106101434-e6g4av3",
|
||||
"title": "工作空间",
|
||||
"updated": "20230113230911"
|
||||
"updated": "20230117000600"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20230106104300-j6nj9t2",
|
||||
"updated": "20230113230911"
|
||||
"updated": "20230117000600"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
},
|
||||
"Properties": {
|
||||
"id": "20230109113554-izjti9n",
|
||||
"updated": "20230113230911"
|
||||
"updated": "20230117000600"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20230109113909-5dp3vml",
|
||||
"updated": "20230113230911"
|
||||
"updated": "20230117000600"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -181,7 +181,16 @@
|
|||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": "。"
|
||||
"Data": "。除此以外,还可以通过 "
|
||||
},
|
||||
{
|
||||
"Type": "NodeTextMark",
|
||||
"TextMarkType": "code",
|
||||
"TextMarkTextContent": "--port=12345"
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " 来指定内核监听的端口。"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"Properties": {
|
||||
"id": "20230106104645-o838uew",
|
||||
"title": "工作空間",
|
||||
"updated": "20230113230938"
|
||||
"updated": "20230117000552"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20230109113932-3g0ywic",
|
||||
"updated": "20230113230938"
|
||||
"updated": "20230117000552"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@
|
|||
},
|
||||
"Properties": {
|
||||
"id": "20230109113932-w8e5hz3",
|
||||
"updated": "20230113230938"
|
||||
"updated": "20230117000552"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20230109113932-8g1zoun",
|
||||
"updated": "20230113230938"
|
||||
"updated": "20230117000552"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
|
@ -182,7 +182,16 @@
|
|||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": "。"
|
||||
"Data": "。除此以外,還可以通過 "
|
||||
},
|
||||
{
|
||||
"Type": "NodeTextMark",
|
||||
"TextMarkType": "code",
|
||||
"TextMarkTextContent": "--port=12345"
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " 來指定內核監聽的端口。"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue