Skip to content

Commit

Permalink
wip: plugin config
Browse files Browse the repository at this point in the history
  • Loading branch information
cole committed Aug 1, 2024
1 parent 1fa7e28 commit cac7703
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
30 changes: 23 additions & 7 deletions packages/install-site.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { inject } from 'vue'
import { Fullscreen, Screen } from './plugins'
import { omit } from 'lodash-es'

const BaseKey = Symbol('Site')

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

function install (app, options) {
const { config: pluginConfig } = options

function install (app, options = {}) {
const $site = {
version: __SITE_VERSION__,
config: options.config || {}
config: pluginConfig
}

app.config.globalProperties.$site = $site
app.provide(BaseKey, $site)

defaultPlugins.forEach((plugin) => {
plugin.install(app, options, $site)
defaultPlugins.forEach(({ name, plugin }) => {
const pluginOptions = { ...options, ...pluginConfig[name] }
plugin.install(app, omit(pluginOptions, ['config']), $site)
plugin.__installed = true
})
}
Expand All @@ -24,6 +37,9 @@ export function useSite () {
return inject(BaseKey, {})
}

export function createSite (config) {
return { name: 'Site', install: install }
export function createSite (config = {}) {
const installExtend = (app, options) => {
install(app, { ...options, config })
}
return { name: 'Site', install: installExtend }
}
2 changes: 1 addition & 1 deletion packages/plugins/screen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default createReactivePlugin({
xxl: false
}, {
install (app, options, $site) {
const { sizes = {}, delay = 16, classes } = options
const { sizes = {}, delay = 16, classes } = options || {}

$site && ($site.screen = this)

Expand Down
6 changes: 5 additions & 1 deletion src/boot/site-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { createSite } from '@site'

export default ({ app }) => {
const site = createSite()
const site = createSite({
screen: {
classes: true
}
})
// 注入
app.use(site)
}
12 changes: 7 additions & 5 deletions src/layout/components/breadcrumb/style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ function genBaseStyle (token) {
return {
[componentCls]: {
paddingInline: token.sizeMD,
[`ol`]: {
flexWrap: 'nowrap'
},
[`${antCls}-breadcrumb-link`]: {
whiteSpace: 'nowrap'
[`${antCls}-breadcrumb`]: {
[`ol`]: {
flexWrap: 'nowrap'
},
[`${antCls}-breadcrumb-link`]: {
whiteSpace: 'nowrap'
}
}
}
}
Expand Down

0 comments on commit cac7703

Please sign in to comment.