mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 06:46:09 +08:00
修复检查更新
This commit is contained in:
parent
2546cebdea
commit
83255280b9
|
@ -414,7 +414,7 @@ export default class UserService {
|
||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: {
|
data: {
|
||||||
hasNewVersion: currentVersion !== lastVersion,
|
hasNewVersion: this.checkHasNewVersion(currentVersion, lastVersion),
|
||||||
lastVersion,
|
lastVersion,
|
||||||
lastLog,
|
lastLog,
|
||||||
},
|
},
|
||||||
|
@ -427,6 +427,25 @@ export default class UserService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkHasNewVersion(curVersion: string, lastVersion: string) {
|
||||||
|
const curArr = curVersion.split('.').map((x) => parseInt(x, 10));
|
||||||
|
const lastArr = lastVersion.split('.').map((x) => parseInt(x, 10));
|
||||||
|
if (curArr[0] < lastArr[0]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (curArr[0] === lastArr[0] && curArr[1] < lastArr[1]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
curArr[0] === lastArr[0] &&
|
||||||
|
curArr[1] === lastArr[1] &&
|
||||||
|
curArr[2] < lastArr[2]
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public async updateSystem() {
|
public async updateSystem() {
|
||||||
const cp = spawn('ql -l update', { shell: '/bin/bash' });
|
const cp = spawn('ql -l update', { shell: '/bin/bash' });
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ const CheckUpdate = ({ socketMessage }: any) => {
|
||||||
const checkUpgrade = () => {
|
const checkUpgrade = () => {
|
||||||
if (updateLoading) return;
|
if (updateLoading) return;
|
||||||
setUpdateLoading(true);
|
setUpdateLoading(true);
|
||||||
const hide = message.loading('检查更新中...', 0);
|
message.loading('检查更新中...', 0);
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}system/update-check`)
|
.put(`${config.apiPrefix}system/update-check`)
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
|
@ -107,13 +107,13 @@ const CheckUpdate = ({ socketMessage }: any) => {
|
||||||
if (!modalRef.current || !socketMessage) {
|
if (!modalRef.current || !socketMessage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { type, message, references } = socketMessage;
|
const { type, message: _message, references } = socketMessage;
|
||||||
|
|
||||||
if (type !== 'updateSystemVersion') {
|
if (type !== 'updateSystemVersion') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newMessage = `${value} \n ${message}`;
|
const newMessage = `${value}\n${_message}`;
|
||||||
modalRef.current.update({
|
modalRef.current.update({
|
||||||
content: (
|
content: (
|
||||||
<div style={{ height: '60vh', overflowY: 'auto' }}>
|
<div style={{ height: '60vh', overflowY: 'auto' }}>
|
||||||
|
@ -138,7 +138,7 @@ const CheckUpdate = ({ socketMessage }: any) => {
|
||||||
.getElementById('log-identifier')!
|
.getElementById('log-identifier')!
|
||||||
.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||||
|
|
||||||
if (newMessage.includes('重启面板')) {
|
if (_message.includes('重启面板')) {
|
||||||
message.warning({
|
message.warning({
|
||||||
content: (
|
content: (
|
||||||
<span>
|
<span>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user