简化版本检查代码
Former-commit-id: 4f1bbdc34a208047aa26a37b3a15034f16463e9d [formerly 4f1bbdc34a208047aa26a37b3a15034f16463e9d [formerly 4f1bbdc34a208047aa26a37b3a15034f16463e9d [formerly 4f1bbdc34a208047aa26a37b3a15034f16463e9d [formerly f10219d0337fc94fcad4a395f634ff82da269a2e [formerly 3c58b53fea597ae0fe5418d44133a7e59ee1441e]]]]] Former-commit-id: 94e99a356571ebf8274954ca601c593e8ea93514 Former-commit-id: 1cab1aa58616e215d1a39f4d6a3a7c2453ca2153 Former-commit-id: ed071e422a123fb3094e88a936724e9c65d70888 [formerly 12d167b90bfde092d7521b4041cee7c656d944b7] Former-commit-id: 42a97fc37840b20ca517afabfa28a24bf557625d Former-commit-id: 764d8f4a94a499abbd2aaa9c3307600c13b78028 Former-commit-id: db598cfc092862c94b8bd859f9b941135c124069 Former-commit-id: 77f5ca3d799fe9d4a8bb9b08e5be79686369e361 Former-commit-id: 18c090ca7aaa651db442c4b41d39ba0543a89944
This commit is contained in:
@@ -5,12 +5,11 @@ import setting from '@/setting.js'
|
||||
const adapter = new LocalStorage(`d2admin-${setting.releases.version}`)
|
||||
const db = low(adapter)
|
||||
|
||||
// 初始化数据库
|
||||
db.defaults({
|
||||
// 系统
|
||||
sys: {},
|
||||
// 存储
|
||||
database: {}
|
||||
}).write()
|
||||
db
|
||||
.defaults({
|
||||
sys: {},
|
||||
database: {}
|
||||
})
|
||||
.write()
|
||||
|
||||
export default db
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Cookies from 'js-cookie'
|
||||
import { version } from '../../package.json'
|
||||
import setting from '@/setting.js'
|
||||
|
||||
const cookies = {}
|
||||
|
||||
@@ -9,12 +9,12 @@ const cookies = {}
|
||||
* @param {String} value cookie value
|
||||
* @param {Object} setting cookie setting
|
||||
*/
|
||||
cookies.set = function (name = 'default', value = '', setting = {}) {
|
||||
let cookieSetting = {
|
||||
cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
|
||||
let currentCookieSetting = {
|
||||
expires: 1
|
||||
}
|
||||
Object.assign(cookieSetting, setting)
|
||||
Cookies.set(`d2admin-${version}-${name}`, value, cookieSetting)
|
||||
Object.assign(currentCookieSetting, cookieSetting)
|
||||
Cookies.set(`d2admin-${setting.releases.version}-${name}`, value, currentCookieSetting)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +22,7 @@ cookies.set = function (name = 'default', value = '', setting = {}) {
|
||||
* @param {String} name cookie name
|
||||
*/
|
||||
cookies.get = function (name = 'default') {
|
||||
return Cookies.get(`d2admin-${version}-${name}`)
|
||||
return Cookies.get(`d2admin-${setting.releases.version}-${name}`)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ cookies.getAll = function () {
|
||||
* @param {String} name cookie name
|
||||
*/
|
||||
cookies.remove = function (name = 'default') {
|
||||
return Cookies.remove(`d2admin-${version}-${name}`)
|
||||
return Cookies.remove(`d2admin-${setting.releases.version}-${name}`)
|
||||
}
|
||||
|
||||
export default cookies
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import axios from 'axios'
|
||||
import semver from 'semver'
|
||||
import { version } from '../../package.json'
|
||||
import log from './util.log.js'
|
||||
import cookies from './util.cookies.js'
|
||||
|
||||
@@ -14,7 +11,8 @@ let util = {
|
||||
* @param {String} title 标题
|
||||
*/
|
||||
util.title = function (titleText) {
|
||||
window.document.title = `${process.env.VUE_APP_TITLE}${titleText ? ` | ${titleText}` : ''}`
|
||||
const processTitle = process.env.VUE_APP_TITLE || 'D2Admin'
|
||||
window.document.title = `${processTitle}${titleText ? ` | ${titleText}` : ''}`
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,50 +29,4 @@ util.open = function (url) {
|
||||
document.body.removeChild(document.getElementById('d2admin-menu-link'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
if (!process.env.VUE_APP_RELEASES_API) {
|
||||
return
|
||||
}
|
||||
axios.get(process.env.VUE_APP_RELEASES_API)
|
||||
.then(res => {
|
||||
let versionGet = res.tag_name
|
||||
const update = semver.lt(version, versionGet)
|
||||
if (update) {
|
||||
log.capsule('D2Admin', `New version ${res.name}`)
|
||||
console.log(`版本号: ${res.tag_name} | 详情${res.html_url}`)
|
||||
vm.$store.commit('d2admin/releases/updateSet', true)
|
||||
}
|
||||
vm.$store.commit('d2admin/releases/latestSet', res)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('checkUpdate error', err)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 显示版本信息
|
||||
*/
|
||||
util.showInfo = function showInfo () {
|
||||
log.capsule('D2Admin', `v${version}`)
|
||||
console.log('Github https://github.com/d2-projects/d2-admin')
|
||||
console.log('Doc http://d2admin.fairyever.com/zh/')
|
||||
}
|
||||
|
||||
export default util
|
||||
|
||||
Reference in New Issue
Block a user