clear
Former-commit-id: e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly 5793d72d458b7eeaf28a097d026168cebc9fc256 [formerly 9c8de3644bd40a55711e618742e29cce390e4c5f]]]]] Former-commit-id: 05ca3c8da65f8583c142720628aa6ea71d2dbf45 Former-commit-id: 7a4d2fba696e901db86071ea2810e9c932c976ad Former-commit-id: c18d3689200ca0e528fbf9bf171f6e1b50131bc3 [formerly 455e9952ca890cd8ad882250cfb9eabd944d44ee] Former-commit-id: 021fa8191681fe4f22e9a9f40389831a847e9066 Former-commit-id: 1022b7792417ce366901b9d5284762a015dd6d26 Former-commit-id: bed799410be508713cac76b7c8cf02d4457fe996 Former-commit-id: f6787cfaac3404132ad1011e2707e08484708ca9 Former-commit-id: 7a8a3baca9ef30393744fd56def6d608b51dcddd
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
// 插件
|
||||
import Cookies from 'js-cookie'
|
||||
import axios from 'axios'
|
||||
import semver from 'semver'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
// 获取项目信息
|
||||
import packJson from '../../package.json'
|
||||
|
||||
let util = {}
|
||||
|
||||
/**
|
||||
* @description 得到现在的用户
|
||||
*/
|
||||
util.uuid = function () {
|
||||
return Cookies.get('uuid')
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 更新标题
|
||||
* @param {string} title 标题
|
||||
*/
|
||||
util.title = function (title) {
|
||||
const prefix = 'D2Admin'
|
||||
window.document.title = `${prefix}${title ? ` | ${title}` : ''}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断是否在其内
|
||||
* @param {*} ele element
|
||||
* @param {array} targetArr array
|
||||
*/
|
||||
util.isOneOf = function (ele, targetArr) {
|
||||
if (targetArr.indexOf(ele) >= 0) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 检查版本更新
|
||||
* @param {object} vm vue
|
||||
*/
|
||||
util.checkUpdate = function (vm) {
|
||||
axios.get('https://api.github.com/repos/FairyEver/d2-admin/releases/latest')
|
||||
.then(res => {
|
||||
let version = res.tag_name
|
||||
const update = semver.lt(packJson.version, version)
|
||||
if (vm.$env === 'development' && update && vm.$store.state.d2admin.updateNotify) {
|
||||
vm.$nextTick(() => {
|
||||
vm.$notify({
|
||||
title: `D2Admin 新版本 ${res.name}`,
|
||||
duration: 0,
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: `
|
||||
<p>当前版本: ${packJson.version}</p>
|
||||
<p>${dayjs(res.created_at).format('YYYY年M月D日')}更新 版本号: ${res.tag_name}</p>
|
||||
<p style="color: #CCC;">此信息只在开发环境提示</p>
|
||||
<p>
|
||||
<a
|
||||
href="${res.html_url}"
|
||||
class="el-button el-button--primary el-button--mini"
|
||||
style="text-decoration: none; margin-top: 10px;"
|
||||
target="blank">
|
||||
<i class="fa fa-link" style="margin-right: 5px;"></i>
|
||||
详细信息
|
||||
</a>
|
||||
</p>
|
||||
`.trim()
|
||||
})
|
||||
})
|
||||
}
|
||||
vm.$store.commit('d2adminUpdateSet', update)
|
||||
vm.$store.commit('d2adminReleasesSet', res)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('checkUpdate error', err)
|
||||
})
|
||||
}
|
||||
|
||||
export default util
|
||||
Reference in New Issue
Block a user