mirror of https://github.com/halo-dev/halo-admin
Support check update method.
parent
06294f231f
commit
c8b2c41382
|
@ -29,7 +29,7 @@
|
||||||
showTime
|
showTime
|
||||||
:defaultValue="pickerDefaultValue"
|
:defaultValue="pickerDefaultValue"
|
||||||
format="YYYY-MM-DD HH:mm:ss"
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
placeholder="Select Publish Time"
|
placeholder="选择页面发表时间"
|
||||||
@change="onSheetDateChange"
|
@change="onSheetDateChange"
|
||||||
@ok="onSheetDateOk"
|
@ok="onSheetDateOk"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
|
|
||||||
<ul>
|
<ul style="margin: 0;padding: 0;list-style: none;">
|
||||||
<li>Server 版本:{{ environments.version }}</li>
|
<li>Server 版本:{{ environments.version }}</li>
|
||||||
<li>Admin 版本:{{ adminVersion }}</li>
|
<li>Admin 版本:{{ adminVersion }}</li>
|
||||||
<li>数据库:{{ environments.database }}</li>
|
<li>数据库:{{ environments.database }}</li>
|
||||||
|
@ -50,16 +50,19 @@
|
||||||
<a
|
<a
|
||||||
href="https://github.com/halo-dev"
|
href="https://github.com/halo-dev"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
style="margin-right: 10px;"
|
||||||
>开源地址
|
>开源地址
|
||||||
<a-icon type="link" /></a>
|
<a-icon type="link" /></a>
|
||||||
<a
|
<a
|
||||||
href="https://halo.run/guide"
|
href="https://halo.run/guide"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
style="margin-right: 10px;"
|
||||||
>用户文档
|
>用户文档
|
||||||
<a-icon type="link" /></a>
|
<a-icon type="link" /></a>
|
||||||
<a
|
<a
|
||||||
href="https://bbs.halo.run"
|
href="https://bbs.halo.run"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
style="margin-right: 10px;"
|
||||||
>在线社区
|
>在线社区
|
||||||
<a-icon type="link" /></a>
|
<a-icon type="link" /></a>
|
||||||
</a-card>
|
</a-card>
|
||||||
|
@ -107,6 +110,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import adminApi from '@/api/admin'
|
import adminApi from '@/api/admin'
|
||||||
|
import axios from 'axios'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -199,6 +203,7 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getEnvironments()
|
this.getEnvironments()
|
||||||
|
this.checkUpdate()
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
updateText() {
|
updateText() {
|
||||||
|
@ -229,7 +234,8 @@ export default {
|
||||||
const text = `Server 版本:${this.environments.version}
|
const text = `Server 版本:${this.environments.version}
|
||||||
Admin 版本:${this.adminVersion}
|
Admin 版本:${this.adminVersion}
|
||||||
数据库:${this.environments.database}
|
数据库:${this.environments.database}
|
||||||
运行模式:${this.environments.mode}`
|
运行模式:${this.environments.mode}
|
||||||
|
UA 信息:${navigator.userAgent}`
|
||||||
this.$copyText(text)
|
this.$copyText(text)
|
||||||
.then(message => {
|
.then(message => {
|
||||||
console.log('copy', message)
|
console.log('copy', message)
|
||||||
|
@ -239,25 +245,66 @@ Admin 版本:${this.adminVersion}
|
||||||
console.log('copy.err', err)
|
console.log('copy.err', err)
|
||||||
this.$message.error('复制失败!')
|
this.$message.error('复制失败!')
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
async checkUpdate() {
|
||||||
|
const _this = this
|
||||||
|
|
||||||
|
axios
|
||||||
|
.get('https://api.github.com/repos/halo-dev/halo/releases/latest')
|
||||||
|
.then(response => {
|
||||||
|
const data = response.data
|
||||||
|
if (data.draft || data.prerelease) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const current = _this.calculateIntValue(_this.environments.version)
|
||||||
|
const latest = _this.calculateIntValue(data.name)
|
||||||
|
if (current >= latest) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const title = '新版本提醒'
|
||||||
|
const content = '检测到新版本:' + data.name + ',点击下方按钮下载最新版本。'
|
||||||
|
const url = data.html_url
|
||||||
|
this.$notification.open({
|
||||||
|
message: title,
|
||||||
|
description: content,
|
||||||
|
icon: <a-icon type="smile" style="color: #108ee9" />,
|
||||||
|
btn: h => {
|
||||||
|
return h(
|
||||||
|
'a-button',
|
||||||
|
{
|
||||||
|
props: {
|
||||||
|
type: 'primary',
|
||||||
|
size: 'small'
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => window.open(url, '_blank')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'去看看'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.error('Check update fail', error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
calculateIntValue(version) {
|
||||||
|
version = version.replace(/v/g, '')
|
||||||
|
const ss = version.split('.')
|
||||||
|
if (ss == null || ss.length !== 3) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
const major = parseInt(ss[0])
|
||||||
|
const minor = parseInt(ss[1])
|
||||||
|
const micro = parseInt(ss[2])
|
||||||
|
if (isNaN(major) || isNaN(minor) || isNaN(micro)) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return major * 1000000 + minor * 1000 + micro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scope>
|
<style lang="less">
|
||||||
ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.environment-info {
|
|
||||||
ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue