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) }