blog-client/plugins/vue.js

41 lines
1.8 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'
import { faGithub, faQq, faWeixin, faWeibo, faTwitter, faFacebook, faGooglePlus, faTelegram } from '@fortawesome/free-brands-svg-icons'
2020-06-10 21:28:34 +08:00
import { faEnvelope, faSearch, faThermometerEmpty, faThermometerQuarter, faThermometerHalf, faThermometerThreeQuarters, faThermometerFull, faAngleDoubleUp, faChevronLeft, faChevronRight, faRss } from '@fortawesome/free-solid-svg-icons'
2019-02-07 16:26:17 +08:00
import { faClock, faCalendarAlt, faBookmark } from '@fortawesome/free-regular-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import hljs from 'highlight.js'
import Swiper from '../components/Swiper'
import Slide from '../components/Slide'
2020-06-10 21:28:34 +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('Swiper', Vue.extend(Swiper))
Vue.component('Slide', Vue.extend(Slide))
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', () => {
Array.prototype.forEach.call(document.querySelectorAll('pre code'), hljs.highlightBlock) // 代码高亮
document.getElementById('loading').style.display = 'none' // 隐藏Loading
})
}