-
Notifications
You must be signed in to change notification settings - Fork 272
/
index.js
53 lines (43 loc) · 1.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import Vue from 'vue'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import VueProgressbar from 'vue-progressbar'
import { sync } from 'vuex-router-sync'
import App from './views/app'
import store from './vuex/index/store'
import router from './router/index'
import CovLocalDB from './util'
Vue.use(VueProgressbar)
Vue.use(VueResource)
Vue.use(VueRouter)
Vue.use(Vuex)
const IMG_MAP = new CovLocalDB('vue-zhihu-img')
Vue.prototype.$preImg = (uri) => {
if (IMG_MAP[uri]) {
}
}
Vue.prototype.$covImg = (self, uri, callback) => {
if (IMG_MAP.get(uri)) {
return callback(IMG_MAP.get(uri))
}
let data = window.btoa(uri.split('').reverse().join(''))
self.$http.get(window.location.origin + '/imagebox?type=rev-64&data=' + data)
.then(response => {
if (response.data.code === 200) {
IMG_MAP.set(uri, response.data.data.url)
callback(response.data.data.url)
} else {
console.log(response.data.message)
}
})
.catch(err => {
console.log(err)
})
}
Vue.prototype.$Api = (url) => {
return window.location.origin + '/readapi?uri=' + url
}
Vue.config.debug = process.env.NODE_ENV === 'dev'
sync(store, router)
router.start(App, 'cov-app')