Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
ed7b7039
Z
zendata
项目概览
易企天创
/
zendata
10 个月 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ed7b7039
编写于
3月 01, 2023
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issues
上级
d3e7e32a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
45 deletion
+69
-45
client/src/app/app.js
client/src/app/app.js
+8
-3
client/src/app/utils/comm.js
client/src/app/utils/comm.js
+1
-8
client/src/app/utils/consts.js
client/src/app/utils/consts.js
+3
-0
client/src/app/utils/hot-update.js
client/src/app/utils/hot-update.js
+32
-29
ui/src/config/settings.js
ui/src/config/settings.js
+3
-1
ui/src/layout/Update.vue
ui/src/layout/Update.vue
+22
-4
未找到文件。
client/src/app/app.js
浏览文件 @
ed7b7039
...
...
@@ -2,7 +2,7 @@ import {app, BrowserWindow, ipcMain, Menu, shell, dialog, globalShortcut} from '
import
{
DEBUG
,
electronMsg
,
electronMsg
,
electronMsgReboot
,
electronMsgReplay
,
electronMsgUpdate
,
minimumSizeHeight
,
...
...
@@ -15,7 +15,7 @@ import Lang, {initLang} from './core/lang';
import
{
startUIService
}
from
"
./core/ui
"
;
import
{
startZdServer
,
killZdServer
}
from
"
./core/zd
"
;
import
{
getCurrVersion
}
from
"
./utils/comm
"
;
import
{
checkUpdate
,
updateApp
}
from
"
./utils/hot-update
"
;
import
{
checkUpdate
,
downLoadAndUpdateApp
,
reboot
}
from
"
./utils/hot-update
"
;
const
cp
=
require
(
'
child_process
'
);
const
fs
=
require
(
'
fs
'
);
...
...
@@ -160,7 +160,12 @@ export class ZdApp {
logInfo
(
'
update confirm from renderer
'
,
arg
)
const
mainWin
=
this
.
_windows
.
get
(
'
main
'
);
updateApp
(
arg
.
newVersion
,
mainWin
)
downLoadAndUpdateApp
(
arg
.
newVersion
,
mainWin
)
});
ipcMain
.
on
(
electronMsgReboot
,
(
event
,
arg
)
=>
{
logInfo
(
'
reboot from renderer
'
,
arg
)
reboot
()
});
setInterval
(
async
()
=>
{
...
...
client/src/app/utils/comm.js
浏览文件 @
ed7b7039
...
...
@@ -67,7 +67,7 @@ export function changeVersion(newVersion) {
let
json
=
{}
if
(
fs
.
existsSync
(
pth
))
{
const
content
=
fs
.
readFileSync
(
pth
)
const
content
=
fs
.
readFileSync
(
pth
)
.
toString
()
json
=
JSON
.
parse
(
content
);
}
...
...
@@ -75,13 +75,6 @@ export function changeVersion(newVersion) {
fs
.
writeFileSync
(
pth
,
JSON
.
stringify
(
json
));
}
export
function
restart
()
{
app
.
relaunch
({
args
:
process
.
argv
.
slice
(
1
)
});
app
.
exit
(
0
);
}
export
function
getResPath
()
{
const
versionPath
=
path
.
resolve
(
ResDir
,
'
version.json
'
)
const
uiPath
=
path
.
resolve
(
ResDir
,
'
ui
'
);
...
...
client/src/app/utils/consts.js
浏览文件 @
ed7b7039
...
...
@@ -11,7 +11,10 @@ export const uuid = 'ZENDATA@1CF17A46-B136-4AEB-96B4-F21C8200EF5A~'
export
const
electronMsg
=
'
electronMsg
'
export
const
electronMsgReplay
=
'
electronMsgReplay
'
export
const
electronMsgUpdate
=
'
electronMsgUpdate
'
export
const
electronMsgReboot
=
'
electronMsgReboot
'
export
const
electronMsgDownloading
=
'
electronMsgDownloading
'
export
const
electronMsgDownloadSuccess
=
'
electronMsgDownloadSuccess
'
export
const
electronMsgUpdateFail
=
'
electronMsgUpdateFail
'
export
const
minimumSizeWidth
=
1024
export
const
minimumSizeHeight
=
640
...
...
client/src/app/utils/hot-update.js
浏览文件 @
ed7b7039
...
...
@@ -7,13 +7,29 @@ import {
getResPath
,
mkdir
,
restart
}
from
"
./comm
"
;
import
{
electronMsgDownloading
,
electronMsgUpdate
,
WorkDir
}
from
"
./consts
"
;
import
{
electronMsgDownloading
,
electronMsgDownloadSuccess
,
electronMsgUpdate
,
electronMsgUpdateFail
,
}
from
"
./consts
"
;
import
path
from
"
path
"
;
import
{
execSync
}
from
'
child_process
'
;
import
{
IS_WINDOWS_OS
}
from
"
../utils/env
"
;
import
fse
from
'
fs-extra
'
import
{
logErr
,
logInfo
}
from
"
./log
"
;
const
admZip
=
require
(
'
adm-zip
'
);
import
{
promisify
}
from
'
node:util
'
;
import
stream
from
'
node:stream
'
;
import
fs
from
'
node:fs
'
;
import
got
from
'
got
'
;
import
os
from
"
os
"
;
import
{
killZdServer
}
from
"
../core/zd
"
;
const
pipeline
=
promisify
(
stream
.
pipeline
);
mkdir
(
path
.
join
(
'
tmp
'
,
'
download
'
))
export
async
function
checkUpdate
(
mainWin
)
{
logInfo
(
'
checkUpdate ...
'
)
...
...
@@ -33,31 +49,7 @@ export async function checkUpdate(mainWin) {
}
}
export
const
updateApp
=
(
version
,
mainWin
)
=>
{
downLoadApp
(
version
,
mainWin
,
doUpdate
)
}
const
doUpdate
=
async
(
downloadPath
,
version
)
=>
{
await
copyFiles
(
downloadPath
);
changeVersion
(
version
);
restart
();
}
const
admZip
=
require
(
'
adm-zip
'
);
import
{
promisify
}
from
'
node:util
'
;
import
stream
from
'
node:stream
'
;
import
fs
from
'
node:fs
'
;
import
got
from
'
got
'
;
import
{
cpSync
}
from
"
fs
"
;
import
os
from
"
os
"
;
import
{
killZdServer
}
from
"
../core/zd
"
;
const
pipeline
=
promisify
(
stream
.
pipeline
);
mkdir
(
path
.
join
(
'
tmp
'
,
'
download
'
))
const
downLoadApp
=
(
version
,
mainWin
,
cb
)
=>
{
export
const
downLoadAndUpdateApp
=
(
version
,
mainWin
)
=>
{
const
downloadUrl
=
getAppUrl
(
version
)
const
downloadPath
=
getDownloadPath
(
version
)
...
...
@@ -75,13 +67,17 @@ const downLoadApp = (version, mainWin, cb) => {
const
md5Pass
=
await
checkMd5
(
version
,
downloadPath
)
if
(
md5Pass
)
{
cb
(
downloadPath
,
version
)
await
copyFiles
(
downloadPath
);
changeVersion
(
version
);
mainWin
.
webContents
.
send
(
electronMsgDownloadSuccess
,
{})
}
else
{
logInfo
(
'
check md5 failed
'
)
throw
new
Error
(
'
check md5 failed
'
)
}
}).
catch
((
err
)
=>
{
logErr
(
`update failed:
${
err
}
`
)
logErr
(
`upgrade app failed:
${
err
}
`
)
mainWin
.
webContents
.
send
(
electronMsgUpdateFail
,
{
err
:
err
.
message
})
});
}
...
...
@@ -116,4 +112,11 @@ const copyFiles = async (downloadPath) => {
const
cmd
=
`chmod +x
${
serverDist
}
`
execSync
(
cmd
,
{
windowsHide
:
true
})
}
}
export
function
reboot
()
{
app
.
relaunch
({
args
:
process
.
argv
.
slice
(
1
)
});
app
.
exit
(
0
);
}
\ No newline at end of file
ui/src/config/settings.js
浏览文件 @
ed7b7039
export
const
electronMsg
=
'
electronMsg
'
export
const
electronMsgReplay
=
'
electronMsgReplay
'
export
const
electronMsgUpdate
=
'
electronMsgUpdate
'
export
const
electronMsgReboot
=
'
electronMsgReboot
'
export
const
electronMsgDownloading
=
'
electronMsgDownloading
'
export
const
electronMsgDownloadSuccess
=
'
electronMsgDownloadSuccess
'
export
const
electronMsgUpdateFail
=
'
electronMsgUpdateFail
'
export
const
skippedVersion
=
'
skippedVersion
'
export
const
ignoreUtil
=
'
ignoreUtil
'
\ No newline at end of file
ui/src/layout/Update.vue
浏览文件 @
ed7b7039
...
...
@@ -15,9 +15,15 @@
</div>
<template
#footer
>
<a-button
@
click=
"update"
type=
"primary"
>
立即升级
</a-button>
<a-button
@
click=
"defer"
>
明天提醒我
</a-button>
<a-button
@
click=
"skip"
>
跳过这个版本
</a-button>
<div
v-if=
"!updateSuccess"
>
<a-button
@
click=
"update"
type=
"primary"
>
立即升级
</a-button>
<a-button
@
click=
"defer"
>
明天提醒我
</a-button>
<a-button
@
click=
"skip"
>
跳过这个版本
</a-button>
</div>
<div
v-if=
"updateSuccess"
>
<a-button
@
click=
"reboot"
type=
"primary"
>
立即重启
</a-button>
</div>
</
template
>
</a-modal>
</div>
...
...
@@ -27,7 +33,7 @@
import
{
electronMsgUpdate
,
electronMsgDownloading
,
skippedVersion
,
ignoreUtil
,
skippedVersion
,
ignoreUtil
,
electronMsgDownloadSuccess
,
electronMsgUpdateFail
,
electronMsgReboot
,
}
from
"
../config/settings.js
"
;
import
{
getCache
,
setCache
}
from
"
../utils/localCache.js
"
;
...
...
@@ -44,6 +50,7 @@ export default {
let
isElectron
=
false
let
ipcRenderer
=
undefined
let
version
=
null
let
updateSuccess
=
false
return
{
isVisible
,
...
...
@@ -54,6 +61,7 @@ export default {
ipcRenderer
,
isElectron
,
version
,
updateSuccess
,
}
},
...
...
@@ -87,6 +95,12 @@ export default {
console
.
log
(
'
downloading msg from electron
'
,
data
);
this
.
downloadingPercent
=
Math
.
round
(
data
.
percent
*
100
);
})
this
.
ipcRenderer
.
on
(
electronMsgDownloadSuccess
,
async
(
event
,
data
)
=>
{
console
.
log
(
'
md5 checking success msg from electron
'
,
data
);
})
this
.
ipcRenderer
.
on
(
electronMsgUpdateFail
,
async
(
event
,
data
)
=>
{
console
.
log
(
'
downloading fail msg from electron
'
,
data
);
})
}
},
mounted
()
{
...
...
@@ -101,6 +115,10 @@ export default {
forceUpdate
:
this
.
forceUpdate
})
},
reboot
()
{
console
.
log
(
'
reboot
'
)
this
.
ipcRenderer
.
send
(
electronMsgReboot
,
{})
},
defer
()
{
console
.
log
(
'
defer
'
)
setCache
(
ignoreUtil
,
Date
.
now
()
+
24
*
3600
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录