refactor: about page.

pull/62/head
ruibaby 2020-02-16 15:39:47 +08:00
parent 60fb720f74
commit d50da4de98
2 changed files with 60 additions and 67 deletions

View File

@ -497,7 +497,7 @@ const internalColumns = [
dataIndex: 'title' dataIndex: 'title'
}, },
{ {
title: '访问路径', title: '访问地址',
dataIndex: 'url' dataIndex: 'url'
}, },
{ {

View File

@ -20,7 +20,7 @@
<a-icon type="copy" /> <a-icon type="copy" />
</a> </a>
</template> </template>
<a-popconfirm <!-- <a-popconfirm
slot="extra" slot="extra"
placement="left" placement="left"
okText="确定" okText="确定"
@ -41,7 +41,7 @@
icon="cloud-download" icon="cloud-download"
> >
</a-button> </a-button>
</a-popconfirm> </a-popconfirm> -->
<ul style="margin: 0;padding: 0;list-style: none;"> <ul style="margin: 0;padding: 0;list-style: none;">
<li>Server 版本{{ environments.version }}</li> <li>Server 版本{{ environments.version }}</li>
@ -132,20 +132,14 @@ export default {
contributions: 0 contributions: 0
} }
], ],
contributorsLoading: true, contributorsLoading: true
updating: false
} }
}, },
created() { created() {
this.getEnvironments() this.getEnvironments()
this.fetchContributors() this.fetchContributors()
this.checkServerUpdate() this.checkServerUpdate()
this.checkAdminUpdate() // this.checkAdminUpdate()
},
computed: {
updateText() {
return this.updating ? '更新中...' : '更新'
}
}, },
methods: { methods: {
getEnvironments() { getEnvironments() {
@ -153,20 +147,20 @@ export default {
this.environments = response.data.data this.environments = response.data.data
}) })
}, },
confirmUpdate() { // confirmUpdate() {
this.updating = true // this.updating = true
adminApi // adminApi
.updateAdminAssets() // .updateAdminAssets()
.then(response => { // .then(response => {
this.$notification.success({ // this.$notification.success({
message: '更新成功', // message: '',
description: '请刷新后体验最新版本!' // description: ''
}) // })
}) // })
.finally(() => { // .finally(() => {
this.updating = false // this.updating = false
}) // })
}, // },
handleCopyEnvironments() { handleCopyEnvironments() {
const text = `Server 版本:${this.environments.version} const text = `Server 版本:${this.environments.version}
Admin 版本${this.adminVersion} Admin 版本${this.adminVersion}
@ -189,7 +183,6 @@ User Agent${navigator.userAgent}`
axios axios
.get('https://api.github.com/repos/halo-dev/halo/contributors') .get('https://api.github.com/repos/halo-dev/halo/contributors')
.then(response => { .then(response => {
console.log(response.data)
_this.contributors = response.data _this.contributors = response.data
this.contributorsLoading = false this.contributorsLoading = false
}) })
@ -240,48 +233,48 @@ User Agent${navigator.userAgent}`
console.error('Check update fail', error) console.error('Check update fail', error)
}) })
}, },
async checkAdminUpdate() { // async checkAdminUpdate() {
const _this = this // const _this = this
axios // axios
.get('https://api.github.com/repos/halo-dev/halo-admin/releases/latest') // .get('https://api.github.com/repos/halo-dev/halo-admin/releases/latest')
.then(response => { // .then(response => {
const data = response.data // const data = response.data
if (data.draft || data.prerelease) { // if (data.draft || data.prerelease) {
return // return
} // }
const current = _this.calculateIntValue(_this.adminVersion) // const current = _this.calculateIntValue(_this.adminVersion)
const latest = _this.calculateIntValue(data.name) // const latest = _this.calculateIntValue(data.name)
if (current >= latest) { // if (current >= latest) {
return // return
} // }
const title = '新版本提醒' // const title = ''
const content = '检测到 Admin 新版本:' + data.name + ',点击下方按钮可直接更新为最新版本。' // const content = ' Admin ' + data.name + ''
this.$notification.open({ // this.$notification.open({
message: title, // message: title,
description: content, // description: content,
icon: <a-icon type="smile" style="color: #108ee9" />, // icon: <a-icon type="smile" style="color: #108ee9" />,
btn: h => { // btn: h => {
return h( // return h(
'a-button', // 'a-button',
{ // {
props: { // props: {
type: 'primary', // type: 'primary',
size: 'small' // size: 'small'
}, // },
on: { // on: {
click: () => _this.confirmUpdate() // click: () => _this.confirmUpdate()
} // }
}, // },
'点击更新' // ''
) // )
} // }
}) // })
}) // })
.catch(function(error) { // .catch(function(error) {
console.error('Check update fail', error) // console.error('Check update fail', error)
}) // })
}, // },
calculateIntValue(version) { calculateIntValue(version) {
version = version.replace(/v/g, '') version = version.replace(/v/g, '')
const ss = version.split('.') const ss = version.split('.')