src/App.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/utils/device.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/utils/util.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/App.vue
@@ -5,8 +5,8 @@ </template> <script> import enquireScreen from './utils/device' import {mapState} from 'vuex' import {enquireScreen} from './utils/util' import {mapState, mapMutations} from 'vuex' import themeUtil from '@/utils/themeUtil'; import {getI18nKey} from '@/utils/routerUtil' @@ -20,9 +20,7 @@ created () { this.setHtmlTitle() this.setLanguage(this.lang) enquireScreen(isMobile => { this.$store.commit('setting/setDevice', isMobile) }) enquireScreen(isMobile => this.setDevice(isMobile)) }, mounted() { this.setWeekModeTheme(this.weekMode) @@ -54,6 +52,7 @@ ...mapState('setting', ['theme', 'weekMode', 'lang']) }, methods: { ...mapMutations('setting', ['setDevice']), setWeekModeTheme(weekMode) { if (weekMode) { document.body.classList.add('week-mode') src/utils/device.js
File was deleted src/utils/util.js
@@ -1,3 +1,5 @@ import enquireJs from 'enquire.js' export function isDef (v){ return v !== undefined && v !== null } @@ -18,4 +20,16 @@ return _toString.call(v) === '[object RegExp]' } export function enquireScreen(call) { const handler = { match: function () { call && call(true) }, unmatch: function () { call && call(false) } } enquireJs.register('only screen and (max-width: 767.99px)', handler) } const _toString = Object.prototype.toString