first commit
This commit is contained in:
56
plugins/browser.js
Normal file
56
plugins/browser.js
Normal file
@ -0,0 +1,56 @@
|
||||
import '~/layouts/common.styl'
|
||||
|
||||
const $tags = document.getElementById('tags')
|
||||
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
|
||||
|
||||
function addEvent(obj, type, fn) {
|
||||
if (obj.attachEvent) {
|
||||
obj.attachEvent('on' + type, function () {
|
||||
fn.call(obj)
|
||||
})
|
||||
} else {
|
||||
obj.addEventListener(type, fn, false)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEvent = addEvent
|
||||
|
||||
window.onload = function () {
|
||||
if (navigator.appName === 'Microsoft Internet Explorer' && parseInt(navigator.appVersion.split(';')[1].replace(/[ ]/g, '').replace('MSIE', '')) <= 9) {
|
||||
alert('您的浏览器版本过低,继续访问将会出现问题,请升级浏览器版本!')
|
||||
}
|
||||
|
||||
// 底部返回顶部按钮
|
||||
const top = document.getElementById('gotop')
|
||||
// 滚动一屏幕时显示回到顶部
|
||||
addEvent(window, 'scroll', function () {
|
||||
const currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
||||
currentPosition > window.screen.availHeight ? top.style.display = 'block' : top.style.display = 'none'
|
||||
|
||||
// 左部导航自动浮动
|
||||
if (currentPosition > floatTop) {
|
||||
document.getElementById('navication').style.position = 'fixed'
|
||||
} else {
|
||||
document.getElementById('navication').style.position = 'static'
|
||||
}
|
||||
})
|
||||
|
||||
top.onclick = function () {
|
||||
var timer = setInterval(function () { // eslint-disable-line
|
||||
let currentPosition = document.documentElement.scrollTop || document.body.scrollTop
|
||||
currentPosition -= 100
|
||||
if (currentPosition > 0) {
|
||||
window.scrollTo(0, currentPosition)
|
||||
} else {
|
||||
window.scrollTo(0, 0)
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
|
||||
let _hmt = _hmt || [] // eslint-disable-line
|
||||
const hm = document.createElement('script')
|
||||
hm.src = 'https://hm.baidu.com/hm.js?4c563e5be89b05d4973bbfbb9b8a0aa3'
|
||||
const s = document.getElementsByTagName('script')[0]
|
||||
s.parentNode.insertBefore(hm, s)
|
||||
}
|
5
plugins/moment.js
Normal file
5
plugins/moment.js
Normal file
@ -0,0 +1,5 @@
|
||||
import moment from 'moment'
|
||||
|
||||
export default function (ctx, inject) {
|
||||
inject('moment', moment)
|
||||
}
|
40
plugins/vue.js
Normal file
40
plugins/vue.js
Normal file
@ -0,0 +1,40 @@
|
||||
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'
|
||||
import { faEnvelope, faSearch, faThermometerEmpty, faThermometerQuarter, faThermometerHalf, faThermometerThreeQuarters, faThermometerFull, faAngleDoubleUp, faChevronLeft, faChevronRight } from '@fortawesome/free-solid-svg-icons'
|
||||
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'
|
||||
|
||||
library.add(faGithub, faQq, faWeixin, faWeibo, faTwitter, faFacebook, faGooglePlus, faTelegram, faEnvelope, faSearch, faClock, faCalendarAlt, faBookmark, faThermometerEmpty, faThermometerQuarter, faThermometerHalf, faThermometerThreeQuarters, faThermometerFull, faAngleDoubleUp, faChevronLeft, faChevronRight)
|
||||
|
||||
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) {
|
||||
return 'threeQuarters'
|
||||
} 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
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user