Skip to content

Commit 25225f7

Browse files
author
shyling
committed
Add progressbar
1 parent 0366ab0 commit 25225f7

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"request-promise": "^4.2.0",
3838
"roboto-fontface": "^0.7.0",
3939
"vue": "^2.2.5",
40+
"vue-progressbar": "^0.7.1",
4041
"vue-resource": "^1.2.1",
4142
"vue-router": "^2.1.1",
4243
"vuex": "^2.2.1"

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template lang="pug">
22
div#app
3+
vue-progress-bar
34
app-header
45
router-view
56
app-footer

src/components/list.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export default {
9292
}),
9393
async created() {
9494
try {
95+
this.$Progress.start();
9596
await this.$store.dispatch('fetchList');
97+
this.$Progress.finish();
9698
} catch (e) {
99+
this.$Progress.fail();
97100
this.message = '加载出错,你可以尝试登陆后重试';
98101
this.snackbar = true;
99102
}

src/components/post.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ export default {
111111
},
112112
async created() {
113113
try {
114+
this.$Progress.start();
114115
await Promise.all([
115116
this.$store.dispatch('fetchPost', this.id),
116117
this.$store.dispatch('fetchComments', this.id)
117118
]);
119+
this.$Progress.finish();
118120
} catch (e) {
121+
this.$Progress.fail();
119122
this.message = '加载出错,你可以尝试登陆后重试';
120123
this.snackbar = true;
121124
}

src/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Vue from 'vue'
33
import Vuex from 'vuex'
44
import VueRouter from 'vue-router'
55
import VueResource from 'vue-resource'
6+
import VueProgressBar from 'vue-progressbar'
67

78
import MuseUI from 'muse-ui'
89

@@ -19,6 +20,11 @@ Vue.use(VueResource);
1920
Vue.use(VueRouter);
2021
Vue.use(MuseUI);
2122
Vue.use(Vuex);
23+
Vue.use(VueProgressBar, {
24+
color: '#42a5f5',
25+
failedColor: '#f44336',
26+
thickness: '2px'
27+
});
2228

2329
Vue.http.options.root = '/api';
2430
const token = window.localStorage && window.localStorage.getItem('GITHUB_TOKEN');

0 commit comments

Comments
 (0)