UNPKG

lixin-web

Version:

vue and bootstrap

103 lines (87 loc) 3.44 kB
import { isDesktopScreen, isMobileScreen, hasWebP, preloadImage, async$VM, getPath, each,store,ajax } from './util/Will' import { EVENTS, util } from './vuex' // const tabletBreakpoint = 768 // const $nav = $('.navbar-top') // //todo rewrite https://vuematerial.github.io/#/components/sidenav // const requireOffcanvas = () => { // import ('../module/ref/bootstrap.offcanvas') // .then(Offcanvas => { // const offcanvas = new Offcanvas($('.offcanvas-toggle')) // $nav.find('.backdrop').click(offcanvas._close) // }) // } // // isMobileScreen && requireOffcanvas() const pathname = getPath() pathname && $(`[href="${pathname}"]`).parent().addClass('active') if (pathname.includes('index')) { if (localStorage.indexBannerBg) { preloadImage('index/index_bg', true, { bg: '.index-banner' }, util.checkWebP) .then(() => { import ('./indexPage') async$VM('util/DomainValidation', '#domain-validation') }) } else { isDesktopScreen && import ('./indexPage') async$VM('util/DomainValidation', '#domain-validation') } } if (pathname.includes('game-regist')) { // require.ensure([], require => new Vue({el:'.signup-form',render: h => h(require('../component/SignUp'))})) async$VM('login/SignUp', '.signup-form') } if (pathname == '/') { if (isDevEnv) { !sessionStorage.isDevLogin && ajax('login',{ username: 'sundy03', password: 'a123456' }, () => { location.reload() sessionStorage.modalNotice = true }) && sessionStorage.setItem('isDevLogin', true) } async$VM('login/index', '.lx-login-form') } if (pathname.includes('game-events')) { const bg = document.body if (isDevEnv) { const date = +new Date Object.keys(EVENTS.configs).forEach(i => { const event = EVENTS.configs[i] if (date > event.endTime) return event.show = true }) hasWebP() .then(() => { util.checkWebP = true preloadImage('event_banner', !isMobileScreen, { isWebP: true, bg }) async$VM('events/index', '#game-event') }) .catch(() => { preloadImage('event_banner', !isMobileScreen, { isWebP: false, bg }) async$VM('events/index', '#game-event') }) } else { Will.ajax({}, '/api/activity/get-access-info') .done(res => { EVENTS.filter(res.data) hasWebP() .then(() => { util.checkWebP = true preloadImage('event_banner', !isMobileScreen, { isWebP: true, bg }) async$VM('events/index', '#game-event') }) .catch(() => { preloadImage('event_banner', !isMobileScreen, { isWebP: false, bg }) async$VM('events/index', '#game-event') }) }) .fail(() => Will.error('网络异常,请刷新页面重新加载数据')) } } if (isDesktopScreen && pathname.includes('lottery')) { import ('./webqq') } if (pathname.includes('aboutus')) { import ('./about') }