为每个ajax请求添加一个进度条
This commit is contained in:
parent
8b739366c0
commit
d7fb3356e8
|
@ -13,6 +13,7 @@
|
||||||
"echarts": "^4.8.0",
|
"echarts": "^4.8.0",
|
||||||
"element-ui": "^2.13.2",
|
"element-ui": "^2.13.2",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
|
"nprogress": "^0.2.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-quill-editor": "^3.0.6",
|
"vue-quill-editor": "^3.0.6",
|
||||||
"vue-router": "^3.2.0",
|
"vue-router": "^3.2.0",
|
||||||
|
|
10
src/main.js
10
src/main.js
|
@ -14,17 +14,25 @@ import 'quill/dist/quill.snow.css' // for snow theme
|
||||||
import 'quill/dist/quill.bubble.css' // for bubble theme
|
import 'quill/dist/quill.bubble.css' // for bubble theme
|
||||||
import timeline from 'element-ui/lib/timeline'
|
import timeline from 'element-ui/lib/timeline'
|
||||||
import timelineItem from 'element-ui/lib/timeline-item'
|
import timelineItem from 'element-ui/lib/timeline-item'
|
||||||
|
// 进度条
|
||||||
|
import NProgres from 'nprogress'
|
||||||
|
import 'nprogress/nprogress.css'
|
||||||
|
|
||||||
Vue.use(timeline)
|
Vue.use(timeline)
|
||||||
Vue.use(timelineItem)
|
Vue.use(timelineItem)
|
||||||
Vue.use(vueQuillEditor)
|
Vue.use(vueQuillEditor)
|
||||||
Vue.component('table-tree', tableTree)
|
Vue.component('table-tree', tableTree)
|
||||||
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
|
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
|
||||||
// 为每个请求头挂一个 token
|
// 为每个ajax请求头挂一个 token 并加载进度条
|
||||||
axios.interceptors.request.use(config => {
|
axios.interceptors.request.use(config => {
|
||||||
|
NProgres.start()
|
||||||
config.headers.Authorization = sessionStorage.getItem('token')
|
config.headers.Authorization = sessionStorage.getItem('token')
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
axios.interceptors.response.use(response => {
|
||||||
|
NProgres.done()
|
||||||
|
return response
|
||||||
|
})
|
||||||
|
|
||||||
Vue.filter('dataFormat', (time) => {
|
Vue.filter('dataFormat', (time) => {
|
||||||
const dt = (new Date(time))
|
const dt = (new Date(time))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user