Browse Source

版本检测更新功能

dev_web_online
陈薪名 2 years ago
parent
commit
bddfc3489d
  1. 2
      fe/PC/package.json
  2. 2
      fe/PC/src/components/currenButton/innerButton.vue
  3. 4
      fe/PC/src/utils/request.js
  4. 24
      fe/PC/src/utils/upDateVersion.js
  5. 6
      fe/PC/vue.config.js

2
fe/PC/package.json

@ -1,6 +1,6 @@
{ {
"name": "vue-element-admin", "name": "vue-element-admin",
"version": "4.4.0", "version": "4.4.1",
"description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features", "description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features",
"author": "Pan <panfree23@gmail.com>", "author": "Pan <panfree23@gmail.com>",
"scripts": { "scripts": {

2
fe/PC/src/components/currenButton/innerButton.vue

@ -33,7 +33,9 @@ export default {
}, },
mounted(){ mounted(){
window.addEventListener('setItemEvent', (item) => { window.addEventListener('setItemEvent', (item) => {
if (item.key.indexOf('tableColumns') > -1) {
this.initButtonType(item) this.initButtonType(item)
}
}) })
}, },
methods:{ methods:{

4
fe/PC/src/utils/request.js

@ -7,6 +7,7 @@ import store from '@/store'
import { import {
getToken getToken
} from '@/utils/auth' } from '@/utils/auth'
import { updateVersion } from '@/utils/upDateVersion'
// create an axios instance // create an axios instance
const service = axios.create({ const service = axios.create({
@ -21,6 +22,8 @@ service.interceptors.request.use(
// do something before request is sent // do something before request is sent
if (store.getters.token) { if (store.getters.token) {
// 检测版本是否有更新
updateVersion()
// let each request carry token // let each request carry token
// ['X-Token'] is a custom headers key // ['X-Token'] is a custom headers key
// please modify it according to the actual situation // please modify it according to the actual situation
@ -56,6 +59,7 @@ service.interceptors.response.use(
* You can also judge the status by HTTP Status Code * You can also judge the status by HTTP Status Code
*/ */
response => { response => {
const res = response.data const res = response.data
if(response.headers['content-disposition']){ if(response.headers['content-disposition']){
res.disposition = response.headers['content-disposition'] res.disposition = response.headers['content-disposition']

24
fe/PC/src/utils/upDateVersion.js

@ -0,0 +1,24 @@
/**
* 检测版本更新
*/
import Vue from 'vue'
export function updateVersion () {
const versionConfig = process.env.VUE_APP_INFO
let version = localStorage.getItem('upDateVersion')
if (version != versionConfig) {
localStorage.setItem('upDateVersion', versionConfig)
setTimeout(() => {
save()
}, 1000 * 3)
}
}
function save () {
var vm = new Vue()
vm.$message.success('正在更新, 预计5秒后更新完成')
setTimeout(() => {
vm.$message.success('更新完成')
}, 1000 * 3)
setTimeout(() => {
location.reload()
}, 1000 * 5)
}

6
fe/PC/vue.config.js

@ -8,6 +8,12 @@ function resolve(dir) {
const name = defaultSettings.title || '基础数据管理网站' // page title const name = defaultSettings.title || '基础数据管理网站' // page title
const pkg = require('./package.json')
const info = {
...pkg
}
process.env.VUE_APP_INFO = info.version
// If your port is set to 80, // If your port is set to 80,
// use administrator privileges to execute the command line. // use administrator privileges to execute the command line.
// For example, Mac: sudo npm run // For example, Mac: sudo npm run

Loading…
Cancel
Save