Skip to content

Commit

Permalink
fix: screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cole committed Aug 1, 2024
1 parent cac7703 commit 591df69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
18 changes: 6 additions & 12 deletions packages/install-site.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { inject } from 'vue'
import { Fullscreen, Screen } from './plugins'
import { omit } from 'lodash-es'
import { forEach, omit } from 'lodash-es'

const BaseKey = Symbol('Site')

const defaultPlugins = [
{
name: 'fullscreen',
plugin: Fullscreen
},
{
name: 'screen',
plugin: Screen
}
]
const defaultPlugins = {
fullscreen: Fullscreen,
screen: Screen
}

function install (app, options) {
const { config: pluginConfig } = options
Expand All @@ -26,7 +20,7 @@ function install (app, options) {
app.config.globalProperties.$site = $site
app.provide(BaseKey, $site)

defaultPlugins.forEach(({ name, plugin }) => {
forEach(defaultPlugins, (plugin, name) => {
const pluginOptions = { ...options, ...pluginConfig[name] }
plugin.install(app, omit(pluginOptions, ['config']), $site)
plugin.__installed = true
Expand Down
11 changes: 5 additions & 6 deletions packages/plugins/screen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { addClass, getWindowSize, removeClass } from '../../utils/dom'
import { addEvt } from '../../utils/event'
import { debounce, pick } from 'lodash-es'

const SIZE_LIST = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
const SIZE_LIST = ['sm', 'md', 'lg', 'xl', 'xxl']

export default createReactivePlugin({
width: 0,
height: 0,
name: 'xs',
sizes: {
xs: 0,
sm: 576,
md: 768,
lg: 992,
Expand Down Expand Up @@ -65,10 +64,10 @@ export default createReactivePlugin({
this.gt.xl = width >= sizes.xxl

this.xs = this.lt.sm
this.sm = this.gt.xs === false && this.lt.md === true
this.md = this.gt.sm === false && this.lt.lg === true
this.lg = this.gt.md === false && this.lt.xl === true
this.xl = this.gt.lg === false && this.lt.xxl === true
this.sm = this.gt.xs === true && this.lt.md === true
this.md = this.gt.sm === true && this.lt.lg === true
this.lg = this.gt.md === true && this.lt.xl === true
this.xl = this.gt.lg === true && this.lt.xxl === true
this.xxl = this.gt.xl

const name = (this.xs === true && 'xs')
Expand Down

0 comments on commit 591df69

Please sign in to comment.