blog-client/plugins/vue.js

92 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-02-07 16:26:17 +08:00
import Vue from 'vue'
import { library } from '@fortawesome/fontawesome-svg-core'
2020-07-08 18:13:20 +08:00
import {
faGithub,
faQq,
faWeixin,
faWeibo,
faTwitter,
faFacebook,
faGooglePlus,
faTelegram
} from '@fortawesome/free-brands-svg-icons'
import {
faEnvelope,
faSearch,
faThermometerEmpty,
faThermometerQuarter,
faThermometerHalf,
faThermometerThreeQuarters,
faThermometerFull,
faAngleDoubleUp,
faChevronLeft,
faChevronRight,
faRss
} from '@fortawesome/free-solid-svg-icons'
import {
faClock,
faCalendarAlt,
faBookmark
} from '@fortawesome/free-regular-svg-icons'
2019-02-07 16:26:17 +08:00
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import hljs from 'highlight.js'
2020-09-19 14:32:07 +08:00
import { Loading } from 'element-ui'
2019-02-07 16:26:17 +08:00
import Slide from '../components/Slide'
2020-07-08 18:13:20 +08:00
library.add(
faGithub,
faQq,
faWeixin,
faWeibo,
faTwitter,
faFacebook,
faGooglePlus,
faTelegram,
faEnvelope,
faRss,
faSearch,
faClock,
faCalendarAlt,
faBookmark,
faThermometerEmpty,
faThermometerQuarter,
faThermometerHalf,
faThermometerThreeQuarters,
faThermometerFull,
faAngleDoubleUp,
faChevronLeft,
faChevronRight
)
2019-02-07 16:26:17 +08:00
Vue.component('Icon', FontAwesomeIcon)
Vue.component('Slide', Vue.extend(Slide))
2020-09-19 14:32:07 +08:00
Vue.use(Loading.directive)
2019-02-07 16:26:17 +08:00
export default function (ctx, inject) {
inject('getHatValue', (count, hotConst = 1000) => {
const hotTmp = count / hotConst
if (hotTmp >= 1) {
return 'full'
} else if (hotTmp >= 0.75 && hotTmp < 1) {
2019-06-30 12:46:50 +08:00
return 'three-quarters'
2019-02-07 16:26:17 +08:00
} else if (hotTmp >= 0.5 && hotTmp < 0.75) {
return 'half'
} else if (hotTmp >= 0.25 && hotTmp < 0.5) {
return 'quarter'
} else if (hotTmp >= 0 && hotTmp < 0.25) {
return 'empty'
}
return 'empty'
})
inject('finishLoad', () => {
2020-07-08 18:13:20 +08:00
Array.prototype.forEach.call(
document.querySelectorAll('pre code'),
hljs.highlightBlock
) // 代码高亮
2019-02-07 16:26:17 +08:00
document.getElementById('loading').style.display = 'none' // 隐藏Loading
})
}