mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
8487627a15
commit
8a6c1688b6
1 changed files with 6 additions and 8 deletions
|
|
@ -35,12 +35,9 @@ const isDevEnv = process.env.NODE_ENV === 'development'
|
||||||
const appVer = app.getVersion()
|
const appVer = app.getVersion()
|
||||||
const confDir = path.join(app.getPath('home'), '.config', 'siyuan')
|
const confDir = path.join(app.getPath('home'), '.config', 'siyuan')
|
||||||
const windowStatePath = path.join(confDir, 'windowState.json')
|
const windowStatePath = path.join(confDir, 'windowState.json')
|
||||||
let firstOpenWindow, bootWindow
|
let bootWindow
|
||||||
let siyuanOpenURL
|
|
||||||
let firstOpen = false
|
let firstOpen = false
|
||||||
let resetWindowStateOnRestart = false
|
|
||||||
let workspaces = [] // workspaceDir, id, browserWindow, tray
|
let workspaces = [] // workspaceDir, id, browserWindow, tray
|
||||||
const localhost = '127.0.0.1'
|
|
||||||
let kernelPort = 6806
|
let kernelPort = 6806
|
||||||
require('@electron/remote/main').initialize()
|
require('@electron/remote/main').initialize()
|
||||||
|
|
||||||
|
|
@ -62,7 +59,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getServer = () => {
|
const getServer = () => {
|
||||||
return 'http://' + localhost + ':' + kernelPort
|
return 'http://127.0.0.1:' + kernelPort
|
||||||
}
|
}
|
||||||
|
|
||||||
const sleep = (ms) => {
|
const sleep = (ms) => {
|
||||||
|
|
@ -240,6 +237,7 @@ const boot = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
currentWindow.webContents.on('did-finish-load', () => {
|
currentWindow.webContents.on('did-finish-load', () => {
|
||||||
|
let siyuanOpenURL
|
||||||
if ('win32' === process.platform || 'linux' === process.platform) {
|
if ('win32' === process.platform || 'linux' === process.platform) {
|
||||||
siyuanOpenURL = process.argv.find((arg) => arg.startsWith('siyuan://'))
|
siyuanOpenURL = process.argv.find((arg) => arg.startsWith('siyuan://'))
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +252,6 @@ const boot = () => {
|
||||||
setTimeout(() => { // 等待界面js执行完毕
|
setTimeout(() => { // 等待界面js执行完毕
|
||||||
writeLog(siyuanOpenURL)
|
writeLog(siyuanOpenURL)
|
||||||
currentWindow.webContents.send('siyuan-openurl', siyuanOpenURL)
|
currentWindow.webContents.send('siyuan-openurl', siyuanOpenURL)
|
||||||
siyuanOpenURL = null
|
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -570,6 +567,8 @@ app.commandLine.appendSwitch('enable-features', 'PlatformHEVCDecoderSupport')
|
||||||
app.setPath('userData', app.getPath('userData') + '-Electron') // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349
|
app.setPath('userData', app.getPath('userData') + '-Electron') // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
|
||||||
|
let resetWindowStateOnRestart = false
|
||||||
const resetTrayMenu = (tray, lang, mainWindow) => {
|
const resetTrayMenu = (tray, lang, mainWindow) => {
|
||||||
const trayMenuTemplate = [
|
const trayMenuTemplate = [
|
||||||
{
|
{
|
||||||
|
|
@ -782,7 +781,7 @@ app.whenReady().then(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (firstOpen) {
|
if (firstOpen) {
|
||||||
firstOpenWindow = new BrowserWindow({
|
const firstOpenWindow = new BrowserWindow({
|
||||||
width: screen.getPrimaryDisplay().size.width / 2,
|
width: screen.getPrimaryDisplay().size.width / 2,
|
||||||
height: screen.getPrimaryDisplay().workAreaSize.height / 2,
|
height: screen.getPrimaryDisplay().workAreaSize.height / 2,
|
||||||
frame: false,
|
frame: false,
|
||||||
|
|
@ -836,7 +835,6 @@ app.whenReady().then(() => {
|
||||||
|
|
||||||
app.on('open-url', (event, url) => { // for macOS
|
app.on('open-url', (event, url) => { // for macOS
|
||||||
if (url.startsWith('siyuan://')) {
|
if (url.startsWith('siyuan://')) {
|
||||||
siyuanOpenURL = url
|
|
||||||
workspaces.forEach(item => {
|
workspaces.forEach(item => {
|
||||||
if (item.browserWindow && !item.browserWindow.isDestroyed()) {
|
if (item.browserWindow && !item.browserWindow.isDestroyed()) {
|
||||||
item.browserWindow.webContents.send('siyuan-openurl', url)
|
item.browserWindow.webContents.send('siyuan-openurl', url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue