Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lowcode-electron
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
electron
lowcode-electron
Commits
f15ece1f
Commit
f15ece1f
authored
Aug 04, 2023
by
韵晨龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改runtime启动方式
parent
94452185
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
18 deletions
+28
-18
runtime.js
src/command/runtime.js
+2
-5
shell.js
src/command/shell.js
+1
-1
enum.js
src/enum.js
+2
-1
main.js
src/main.js
+6
-4
onPlatform.js
src/sevice/mainApi/on/onPlatform.js
+2
-0
process.js
src/sevice/process.js
+15
-7
No files found.
src/command/runtime.js
View file @
f15ece1f
...
...
@@ -36,7 +36,6 @@ function javaServer(javaPath) {
// to do somethink
function
runtimeServer
()
{
const
javaPath
=
process
.
argv
[
process
.
argv
.
length
-
1
]
detect
(
port
)
.
then
(
_port
=>
{
if
(
port
==
_port
)
{
...
...
@@ -50,7 +49,5 @@ function runtimeServer() {
});
}
// runtimeServer()
module
.
exports
=
{
runtimeServer
}
runtimeServer
()
src/command/shell.js
View file @
f15ece1f
...
...
@@ -33,7 +33,7 @@ function javaServer() {
child
.
stdout
.
on
(
'data'
,
function
(
stdout
)
{
log
.
info
(
stdout
)
if
(
stdout
.
includes
(
'Started Application in'
)
&&
!
isStart
)
{
ipcRenderer
.
send
(
"close"
);
ipcRenderer
.
send
(
"close"
,
MESSAGE_TYPE
.
DESIGN
);
isStart
=
true
}
})
...
...
src/enum.js
View file @
f15ece1f
...
...
@@ -32,7 +32,8 @@ exports.MAIN = {
exports
.
MESSAGE_TYPE
=
{
RUNTIME
:
'RUNTIME'
,
DEVELOPMENT
:
'DEVELOPMENT'
,
SUCCESS
:
'SUCCESS'
SUCCESS
:
'SUCCESS'
,
DESIGN
:
"DESIGN"
}
exports
.
DATA_BASE_MAP
=
{
DATABASE
:
'database'
,
...
...
src/main.js
View file @
f15ece1f
...
...
@@ -3,7 +3,7 @@ const { app, BrowserWindow, ipcMain } = require('electron')
const
path
=
require
(
'path'
)
const
kill
=
require
(
'kill-port'
)
const
{
MainEvent
,
Process
}
=
require
(
'./sevice/index'
)
const
{
MAIN
,
IPC
}
=
require
(
'./enum'
)
const
{
MAIN
,
IPC
,
MESSAGE_TYPE
}
=
require
(
'./enum'
)
const
{
setStore
,
getContext
}
=
require
(
'./store'
)
const
utils
=
require
(
'./utils'
)
const
{
handleMounted
,
handleClose
}
=
require
(
'./hook'
)
...
...
@@ -97,10 +97,12 @@ class Main {
this
.
setWin
(
mainWindow
)
// todo 这里有优化空间
ipcMain
.
on
(
'close'
,
()
=>
{
ipcMain
.
on
(
'close'
,
(
event
,
arg
)
=>
{
// 向渲染进程发送消息,通知前端进行相应的操作
mainWindow
.
webContents
.
send
(
'close'
);
mainWindow
&&
mainWindow
.
loadURL
(
this
.
IDEPage
());
if
(
arg
==
MESSAGE_TYPE
.
DESIGN
){
mainWindow
.
webContents
.
send
(
'close'
);
mainWindow
&&
mainWindow
.
loadURL
(
this
.
IDEPage
());
}
});
}
return
mainWindow
...
...
src/sevice/mainApi/on/onPlatform.js
View file @
f15ece1f
...
...
@@ -7,6 +7,7 @@ const utils = require('../../../utils')
const
open
=
require
(
'open'
);
// I/O的异步性能比work_threads性能好,统一采用异步I/O
const
{
getContext
}
=
require
(
'../../../store'
)
const
log
=
getContext
().
log
async
function
previewMounted
(
childProcess
,
ctx
,
url
)
{
// const cmd = utils.openUrlCmd(url)
...
...
@@ -27,6 +28,7 @@ const onPlatform = {
const
platFormPath
=
path
.
resolve
(
utils
.
getPlatDir
(),
platform
)
let
runtimeRelativePath
=
'./deployment/bin/'
const
startSh
=
path
.
resolve
(
platFormPath
,
runtimeRelativePath
)
childProcess
.
batchCommand
(
runtimePath
,
[
startSh
],
()
=>
{
// 处理进程成功
// 'http://localhost:7018?platform=bigcode&previewTenantId=ADMIN_SYC&code=x0hRRhMc9Jqzw1jOyho4sg'
...
...
src/sevice/process.js
View file @
f15ece1f
...
...
@@ -18,24 +18,32 @@ class ProcessActivity {
this
.
index
=
null
this
.
pids
=
[]
this
.
batchCommand
(
shellPath
)
this
.
batchCommand
Form
(
shellPath
)
this
.
onKillProcess
()
}
batchCommandForm
(
shellPath
,
args
=
[],
cb
)
{
let
forkParam
=
[
shellPath
]
if
(
args
.
length
)
{
forkParam
=
[
shellPath
,
args
]
}
const
child
=
utilityProcess
.
fork
(...
forkParam
)
}
batchCommand
(
shellPath
,
args
=
[],
cb
)
{
let
forkParam
=
[
shellPath
]
if
(
args
.
length
)
{
forkParam
=
[
shellPath
,
args
]
}
const
child
=
utilityProcess
.
fork
(...
forkParam
)
child
.
on
(
'spawn'
,
(
data
)
=>
{
utils
.
time
(()
=>
{
const
{
mainEvent
,
win
,
log
}
=
getContext
(
)
mainEvent
.
sendApi
.
sendStart
.
startSucess
(
win
)
},
1500
)
child
.
on
(
'message'
,
(
data
)
=>
{
const
childParam
=
{
data
,
child
}
if
(
args
.
length
||
cb
)
{
return
this
.
watchGlobalMsg
(
childParam
,
cb
)
}
this
.
handleDefaultProcessEnd
(
childParam
)
})
}
/**
* 监听全局消息
* @param {Object} childParam
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment