Skip to content

Commit 4c0056c

Browse files
committed
fix(site): add smb design-config support
1 parent 60e5402 commit 4c0056c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

examples/sites/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@opentiny/vue-common": "workspace:~",
2626
"@opentiny/vue-design-aurora": "workspace:~",
2727
"@opentiny/vue-design-saas": "workspace:~",
28+
"@opentiny/vue-design-smb": "workspace:~",
2829
"@opentiny/vue-directive": "workspace:~",
2930
"@opentiny/vue-hooks": "workspace:~",
3031
"@opentiny/vue-icon": "workspace:~",

examples/sites/src/tools/useTheme.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { watch, computed } from 'vue'
22
import { hooks } from '@opentiny/vue-common'
33
import designSaasConfig from '@opentiny/vue-design-saas'
4+
import designSMBConfig from '@opentiny/vue-design-smb'
45
import { router } from '@/router'
56
import { appData } from './appData'
67
import { THEME_ROUTE_MAP, CURRENT_THEME_KEY, DEFAULT_THEME, AURORA_THEME, SMB_THEME, INFINITY_THEME } from '../const'
@@ -71,7 +72,11 @@ const designConfig = computed(() => {
7172
if (import.meta.env.VITE_TINY_THEME === 'saas') {
7273
return designSaasConfig
7374
}
74-
return designConfigMap[currentThemeKey.value]
75+
if (router.currentRoute.value.params.theme === 'smb-theme') {
76+
return designSMBConfig
77+
}
78+
79+
return {}
7580
})
7681

7782
const changeTheme = (themeKey) => {

packages/vue-common/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export const setup = ({ props, context, renderless, api, extendOptions = {}, mon
174174
const render = typeof props.tiny_renderless === 'function' ? props.tiny_renderless : renderless
175175

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

180182
const utils = {

packages/vue/src/config-provider/src/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export default defineComponent({
5858
})
5959
},
6060
setup(props, { slots }) {
61-
const { direction } = hooks.toRefs(props)
62-
provideDesignConfig(props.design)
61+
const { direction, design } = hooks.toRefs(props)
62+
provideDesignConfig(design)
6363
const isRTL = hooks.computed(() => direction.value === 'rtl')
6464
const cssVar = hooks.computed(() => {
6565
return {

0 commit comments

Comments
 (0)