no message

This commit is contained in:
小陌 2023-09-09 15:51:08 +08:00
parent 70b9a2fb06
commit 19846ad425

View File

@ -1,24 +1,21 @@
<template> <template>
<x-page-header title="系统更新" description="你可以随时检查使用系统是否是最新版本,并进行一键升级" icon="el-icon-setting"></x-page-header> <x-page-header title="系统更新" description="你可以随时检查使用系统是否是最新版本,并进行一键升级" icon="el-icon-setting"></x-page-header>
<div class="x-update"> <div class="x-update">
<el-alert title="当前为更新系统核心架构; 更新前,您需要备份您的数据,防止数据丢失。" type="warning" style="padding: 10px 0;" /> <el-alert title="当前为更新系统核心架构; 更新前,您需要备份您的数据,防止数据丢失。" type="warning" style="padding: 10px 0;" />
<el-alert title="相关应用请单独更新, 框架更新可能导致部分应用报错。" type="error" style="padding: 10px 0;" /> <el-alert title="相关应用请单独更新, 框架更新可能导致部分应用报错。" type="error" style="padding: 10px 0;" />
<!-- 登录状态 --> <!-- 登录状态 -->
<div v-if="isLogin" class="login-box"> <div v-if="userData.uid" class="login-box">
<!-- 头像 --> <!-- 头像 -->
<div class="face"> <div class="face">
<img v-if="userData.img" :src="userData.img" alt=""> <img v-if="userData.avatar" :src="userData.avatar" alt="">
<span v-else>{{ userData.name }}</span> <span v-else style="text-transform: capitalize;">{{ userData.username }}</span>
</div> </div>
<!-- 信息 --> <!-- 信息 -->
<div class="info"> <div class="info">
<span class="name">{{ userData.name }}</span> <span class="name" style="text-transform: capitalize;">{{ userData.username }}</span>
<span class="title">{{ userData.title }}</span> <span class="title">授权 {{ name }}</span>
<p>{{ userData.companyName }}</p> <p>{{ authorizationtime }}</p>
<p> <p>
<i class="el-icon-mobile-phone"/> <i class="el-icon-mobile-phone"/>
{{ userData.mobile }} {{ userData.mobile }}
@ -30,11 +27,11 @@
</div> </div>
<!-- 按钮 --> <!-- 按钮 -->
<div> <div>
<el-button type="primary" plain @click="logoutHandle">注销</el-button> <el-button type="primary" plain @click="logoutHandle">退出</el-button>
</div> </div>
</div> </div>
<!-- 未登录X-PHP账号的提示 --> <!-- 未登录云平台账号的提示 -->
<div v-else class="login-box"> <div v-else class="login-box">
<!-- 头像 --> <!-- 头像 -->
<div class="face">登录</div> <div class="face">登录</div>
@ -42,7 +39,7 @@
<!-- 提示 --> <!-- 提示 -->
<div class="login-box-title"> <div class="login-box-title">
<span @click="dialogVisible = true">请点击登</span> <span @click="dialogVisible = true">请点击登</span>
<p>更新前需要先登录X-PHP账号</p> <p>更新前需要先登录云平台账号</p>
</div> </div>
</div> </div>
<!-- 按钮 --> <!-- 按钮 -->
@ -59,42 +56,66 @@
<div v-if="isNewest" class="version"> <div v-if="isNewest" class="version">
<p class="text">您当前是最新版本</p> <p class="text">您当前是最新版本</p>
当前版本{{ version }} 当前版本{{ version }} ({{ release }})
</div> </div>
<!-- 有新版本 --> <div v-else v-loading="updateLoading" class="version">
<div v-loading="updateLoading" v-else :element-loading-text="progressTooltip" class="version" element-loading-background="#fff">
<p class="text">有新的版本可升级</p> <p class="text">有新的版本可升级</p>
当前版本{{ serverVersion }}您可以升级到 当前版本{{ version }} ({{ release }})
<span>{{ version }}</span>
<div class="update-wrap"> <div class="update-wrap">
<el-badge :value="1" class="update-badge">
<el-button :type="isCanUpdate ? 'primary' : 'info'" @click="updateHandle">现在更新</el-button> <el-table :data="upgradelist" border style="width:100%">
</el-badge>
<el-table-column label="版本" width="160">
<template #default="scope">
<span>{{ scope.row.version }} ({{ scope.row.release }})</span>
</template>
</el-table-column>
<el-table-column label="更新内容">
<template #default="scope">
<input style="cursor: pointer; " class="el-input__inner" type="text" readonly :value="scope.row.message">
</template>
</el-table-column>
<el-table-column label="发布时间" width="160">
<template #default="scope">
<span v-time="scope.row.timestamp"></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="145" fixed="right">
<template #default="scope">
<el-button :type="isCanUpdate ? 'default' : 'info'" @click="updateHandle(scope.row)">更新到此版本</el-button>
</template>
</el-table-column>
</el-table>
</div> </div>
</div> </div>
</div> </div>
<!-- 登录X-PHP弹窗 --> <!-- 登录云平台弹窗 -->
<el-dialog v-model="dialogVisible" class=“ title="" width="500px"> <el-dialog v-model="dialogVisible" class="xlogin" title="" width="500px">
<template #header="{}"> <template #header="{}">
<div class="el-dialog__title"> <div class="el-dialog__title">
登录X-PHP账号 登录云平台账号
<p class="description">您可以登录X-PHP账号来进行一键升级</p> <p class="description">您可以登录云平台账号来进行一键升级,如没有请<a target="_blank" :href="cloudregister">注册</a></p>
</div> </div>
</template> </template>
<!-- 登录表单 --> <!-- 登录表单 -->
<el-form ref="loginRef" :model="loginForm" :rules="loginRules" label-width="80px" label-position="top" class="login-form"> <el-form ref="loginRef" :model="loginForm" :rules="loginRules" label-width="80px" label-position="top" class="login-form">
<div class="form-item"> <div class="form-item">
<el-form-item prop="username"> <el-form-item prop="account">
<i class="wk wk-mobile"/>账号 账号
<el-input v-model="loginForm.username" placeholder="请输入您的X-PHP账号"/> <el-input v-model="loginForm.account" autocomplete="off" placeholder="请输入您的云平台账号"/>
</el-form-item> </el-form-item>
</div> </div>
<div class="form-item password"> <div class="form-item password">
<el-form-item prop="password"> <el-form-item prop="password">
<i class="wk wk-lock"/>密码 密码
<el-input v-model="loginForm.password" type="password" placeholder="请输入您的X-PHP账号的密码"/> <el-input v-model="loginForm.password" autocomplete="off" type="password" placeholder="请输入您的云平台账号的密码"/>
</el-form-item> </el-form-item>
</div> </div>
<el-button type="primary" @click="loginHandle('loginRef')">确认登录</el-button> <el-button type="primary" @click="loginHandle('loginRef')">确认登录</el-button>
@ -104,327 +125,193 @@
</template> </template>
<script> <script>
import { ElMessageBox } from 'element-plus';
export default { export default {
/** 系统升级 */ /** 系统升级 */
name: 'Update', name: 'Update',
components: { components: {
}, },
data() { data() {
var checkPort = (rule, value, callback) => {
if (!value) {
return callback(new Error('请输入数据库端口号'))
}
setTimeout(() => {
if (!Number.isInteger(value)) {
callback(new Error('请输入数字值'))
} else {
if (value > 65535 || value <= 0) {
callback(new Error('请输入0~65535之间的端口号'))
} else {
callback()
}
}
}, 1000)
}
return { return {
isClick: false, isClick: false,
isCanUpdate: true, isCanUpdate: true,
isLogin: false, // X-PHP
dialogVisible: false, // dialogVisible: false, //
dialogVisibleH: false, //
loginForm: { loginForm: {
username: '', account: '',
password: '' password: ''
}, },
loginRules: { loginRules: {
username: [ account: [{ required: true, message: '请输入云平台账号', trigger: 'blur' }],
{ required: true, message: '请输入X-PHP账号', trigger: 'blur' }
],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }] password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
}, },
userData: {}, userData: {
isCheckUpdate: true, // uid:0
},
name:null,
authorizationtime:null,
cloudregister: null,
isCheckUpdate: false, //
isNewest: false, // isNewest: false, //
checkLoading: false, // loading checkLoading: false, // loading
version: '', // version: '', //
serverVersion: '', // release: '', //
isCustom: -1, // 0: 1: serverVersion: {}, //
backupType: 1, // 1: 2: upgradelist: [], //
databaseList: [], //
database: '', //
databaseRules: {
host: [
{ required: true, message: '请输入数据库地址', trigger: 'blur' }
],
port: [{ validator: checkPort, trigger: 'blur' }],
databaseName: [
{ required: true, message: '请输入数据库名称', trigger: 'blur' }
],
DBUsername: [
{ required: true, message: '请输入数据库账号', trigger: 'blur' }
],
DBPassword: [
{ required: true, message: '请输入数据库密码', trigger: 'blur' }
]
},
customDatabase: {
//
host: '', //
port: '', //
databaseName: '', //
DBUsername: '', //
DBPassword: '' //
},
backLoading: false, // loading
isBackSuccess: false,
sql: '', //
backType: 1, // 1: 2:
updateLoading: false, updateLoading: false,
progressTooltip: '',
progress: 0 // progress: 0 //
} }
}, },
created() { created() {
// const _this = this this.loaddata();
// async function decorator() {
// var { data } = await xCheckVersionAPI()
// _this.checkIsNewest(data.version, data.serverVersion)
// _this.checkLoading = false
// _this.version = data.version
// _this.serverVersion = data.serverVersion
// _this.isCheckUpdate = true
// }
// decorator()
}, },
methods: { methods: {
loaddata(){
this.loading = true;
this.$http.get('admin/upgrade/get').then((res) => {
this.loading = false;
if (res.code == 200) {
this.userData = res.data.user;
this.cloudregister = res.data.cloudregister;
this.name = res.data.name;
this.authorizationtime = res.data.authorizationtime;
return ;
}
this.$alert(res.message, "提示", {type: 'error'});
});
},
loginHandle(formName) { loginHandle(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
// var param = { this.$http.post('admin/upgrade/login', this.loginForm).then((res) => {
// username: this.loginForm.username, if (res.code == 200) {
// password: this.loginForm.password this.dialogVisible = false;
// } this.$message.success(res.message || "操作成功");
// loginWKAPI(param).then(res => { this.userData = res.data;
// var { data } = res return true;
// if (res.code === 0) { }
// this.userData = data this.$alert(res.message, "提示", {type: 'error'});
// this.dialogVisible = false });
// this.isLogin = true
// Object.assign(this.userData, this.loginForm)
// }
// }).catch(() => {
// })
} else { } else {
return false return false
} }
}) })
}, },
logoutHandle() { logoutHandle() {
this.isLogin = false ElMessageBox.confirm('退出后无法在线升级系统框架和下载应用.', '正在退出云账号', {
this.loginForm.username = '' type: 'error',
this.loginForm.password = '' closeOnClickModal: false,
confirmButtonText: '确认退出',
}).then(() => {
this.$http.post('admin/upgrade/quit', {}).then((res) => {
if (res.code == 200) {
this.userData = {uid:0}
this.loginForm.account = ''
this.loginForm.password = ''
this.$message.success(res.message || "操作成功")
return true;
}
this.$alert(res.message, "提示", {type: 'error'});
});
}).catch(() => {})
}, },
async checkHandle() { async checkHandle() {
// this.checkLoading = true this.checkLoading = true
// var { data } = await xCheckVersionAPI() var { code, data, message } = await this.$http.post('admin/upgrade/check', {})
this.checkLoading = false
// this.isNewest = this.checkIsNewest(data.version, data.serverVersion) if (code==200) {
// this.checkLoading = false //
this.isNewest = !data.upgrade ? true : false;
// this.version = data.version //
// this.serverVersion = data.serverVersion this.version = data.version
this.release = data.release
// this.isCheckUpdate = true //
// this.isClick = true this.serverVersion = data.serverVersion
}, //
this.upgradelist = data.upgradelist
checkIsNewest(a, b) { //
// var a = toNum(a) this.isCheckUpdate = true
// var b = toNum(b) //
this.isClick = true
if (a > b) { return true;
return false
} else {
return true
} }
// function toNum(a) { if (code==205) {
// var a = a.toString() this.$message.info(message || "请先登录云平台")
// var c = a.split('.') this.dialogVisible = true;
// var num_place = ['', '0', '00', '000', '0000'] return ;
// var r = num_place.reverse() }
// for (var i = 0; i < c.length; i++) {
// var len = c[i].length this.$alert(message || '操作失败', "提示", {type: 'error'});
// c[i] = r[len] + c[i]
// }
// var res = c.join('')
// return res
// }
}, },
async queryDatabaseHandle() { async updateHandle(row) {
this.isCustom = 1 if (!this.userData.uid) {
// var res = await xQueryDatabaseAPI() this.$message.info("请先登录云平台")
this.dialogVisible = true;
var res = {
data:[
[]
],
code:0
};
this.databaseList = res.data
this.isShowDatabase = res.code === 0
},
submitForm() {
this.$refs.databaseForm.validate((valid) => {
if (valid) {
this.dataBackHandle()
} else {
return false
}
})
},
async dataBackHandle() {
if (!this.isLogin) {
this.$message({
showClose: true,
message: '请登陆X-PHP账号',
type: 'warning'
})
return return
} }
this.updateLoading = { visible:true, text:'获取更新信息中' }
var res = await this.$http.post('admin/upgrade/update', {version:row.version, release:row.release, xphphash:row.xphphash})
if (res.code == 200) {
if (this.isCustom && !this.database) { this.updateLoading = { visible:true, text:res.message || "文件下载成功" }
this.$message({ this.$message.success(res.message || "文件下载成功");
showClose: true,
message: '请选择要备份的数据库',
type: 'warning'
})
return
}
var _this = this;
this.backLoading = true setTimeout(async ()=>{
// var data = this.isCustom var install = await _this.$http.post('admin/upgrade/install', {token:res.data.token});
// ? { if (install.code==200) {
// backupType: this.backupType, _this.updateLoading = false
// databaseName: this.database, _this.$message.success(install.message || "更新成功")
// username: this.loginForm.username, //
// password: this.loginForm.password, _this.checkHandle();
// isCustom: this.isCustom return ;
// }
// : Object.assign(this.customDatabase, this.loginForm)
// var res = await xBackupDatabaseAPI(data)
var res = {
code:0
}
this.backLoading = false
if (res.code === 0) {
this.isBackSuccess = true
this.sql = res.data
this.isCanUpdate = true
}
},
async updateHandle() {
if (!this.isLogin) {
this.$message({
message: '未进行登陆',
type: 'warning'
})
// return
}
this.updateLoading = true
// var data = this.isCustom
// ? {
// backupType: this.backupType,
// databaseName: this.database,
// username: this.loginForm.username,
// password: this.loginForm.password,
// isCustom: this.isCustom
// }
// : Object.assign(this.customDatabase, this.loginForm)
// var res = await xUpdateAPI(data)
var res = {code:0}
if (res.code === 0) {
this.progressTooltip = '更新准备中'
var _this = this
var timer = setInterval(function() {
fn()
async function fn() {
// var res = await updateProgressAPI()
var res = {code:0, data:100}
switch (res.data) {
case 5:
_this.progressTooltip = '获取更新信息中'
break
case 15:
_this.progressTooltip = '备份数据库中'
break
case 25:
_this.progressTooltip = '备份文件中'
break
case 50:
_this.progressTooltip = '停止受影响的服务中'
break
case 70:
_this.progressTooltip = '执行升级中'
break
case 100:
_this.progressTooltip = '升级已完成'
setTimeout(function() {
_this.updateLoading = false
_this.isNewest = true
}, 500)
clearInterval(timer)
break
default:
_this.progressTooltip = '升级已完成'
setTimeout(function() {
_this.updateLoading = false
_this.isNewest = true
}, 500)
clearInterval(timer)
break
} }
} this.updateLoading = false
}, 3000) this.$alert(install.message || '操作失败', "提示", {type: 'error'});
}, 1000)
return ;
} }
else if (res.code==205) {
this.$message.info(res.message || "请先登录云平台")
this.dialogVisible = true;
return ;
}
this.updateLoading = false
this.$alert(res.message || '操作失败', "提示", {type: 'error'});
}, },
//
handleSizeChange(val) {
// Lockr.set('xPageSizes', val)
this.pageSize = val
},
//
handleCurrentChange(val) {
this.currentPage = val
}
} }
} }
</script> </script>
<style>
.xlogin .el-input__wrapper{
padding: 1px 1px;
}
.xlogin .el-input__inner{
--el-input-inner-height: auto;
padding: 4px 10px;
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
code {
padding: 2px 4px;
font-size: 90%;
color: #c7254e;
background-color: #f9f2f4;
border-radius: 4px;
clear: both;
display: initial;
cursor: pointer;
}
.el-alert { .el-alert {
margin: 10px 0 10px; margin: 10px 0 10px;
} }
@ -450,8 +337,7 @@ $linkColor: #3b6ff1;
.x-update { .x-update {
width: 100%; width: 100%;
min-width: 1200px; height: calc(100% - 102px);
height: 100%;
padding: 15px 20px 20px; padding: 15px 20px 20px;
background: #fff; background: #fff;
overflow: auto; overflow: auto;
@ -515,7 +401,7 @@ $linkColor: #3b6ff1;
// //
.login-box { .login-box {
width: 600px; max-width: 800px;
background: #f8f8f8; background: #f8f8f8;
padding: 22px; padding: 22px;
display: flex; display: flex;
@ -575,7 +461,7 @@ $linkColor: #3b6ff1;
// //
.last-time { .last-time {
margin: 16px 0; margin: 16px 0;
padding: 16px 0; padding: 16px 0 0;
} }
.version { .version {