Skip to content

Commit

Permalink
fix(site): add smb design-config support (#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjunjian authored Dec 3, 2024
1 parent da4f7fa commit c504457
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/sites/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@opentiny/vue-common": "workspace:~",
"@opentiny/vue-design-aurora": "workspace:~",
"@opentiny/vue-design-saas": "workspace:~",
"@opentiny/vue-design-smb": "workspace:~",
"@opentiny/vue-directive": "workspace:~",
"@opentiny/vue-hooks": "workspace:~",
"@opentiny/vue-icon": "workspace:~",
Expand Down
7 changes: 6 additions & 1 deletion examples/sites/src/tools/useTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { watch, computed } from 'vue'
import { hooks } from '@opentiny/vue-common'
import designSaasConfig from '@opentiny/vue-design-saas'
import designSMBConfig from '@opentiny/vue-design-smb'
import { router } from '@/router'
import { appData } from './appData'
import { THEME_ROUTE_MAP, CURRENT_THEME_KEY, DEFAULT_THEME, AURORA_THEME, SMB_THEME, INFINITY_THEME } from '../const'
Expand Down Expand Up @@ -71,7 +72,11 @@ const designConfig = computed(() => {
if (import.meta.env.VITE_TINY_THEME === 'saas') {
return designSaasConfig
}
return designConfigMap[currentThemeKey.value]
if (router.currentRoute.value.params.theme === 'smb-theme') {
return designSMBConfig
}

return {}
})

const changeTheme = (themeKey) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/vue-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export const setup = ({ props, context, renderless, api, extendOptions = {}, mon
const render = typeof props.tiny_renderless === 'function' ? props.tiny_renderless : renderless

// 获取组件级配置和全局配置(inject需要带有默认值,否则控制台会报警告)
const globalDesignConfig: DesignConfig = customDesignConfig.designConfig || hooks.inject(design.configKey, {})
let globalDesignConfig: DesignConfig = customDesignConfig.designConfig || hooks.inject(design.configKey, {})
// globalDesignConfig 可能是响应式对象,比如 computed
globalDesignConfig = globalDesignConfig.value || globalDesignConfig
const designConfig = globalDesignConfig?.components?.[getComponentName().replace($prefix, '')]

const utils = {
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/config-provider/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default defineComponent({
})
},
setup(props, { slots }) {
const { direction } = hooks.toRefs(props)
provideDesignConfig(props.design)
const { direction, design } = hooks.toRefs(props)
provideDesignConfig(design)
const isRTL = hooks.computed(() => direction.value === 'rtl')
const cssVar = hooks.computed(() => {
return {
Expand Down

0 comments on commit c504457

Please sign in to comment.