Skip to content

Commit d4c1de4

Browse files
authored
fix(generator): when the theme is not set, the property configuration will not be displayed (#225)
1 parent 77eaaad commit d4c1de4

File tree

1 file changed

+13
-4
lines changed
  • packages/generator/src/store/unclassified

1 file changed

+13
-4
lines changed

packages/generator/src/store/unclassified/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,23 @@ export const curThemeAndTypeAtom = selector<string>({
117117
get: ({ get }) => {
118118
return get(themeAndTypeAtom)
119119
},
120-
set: ({ set }, newValue) => {
120+
set: ({ set, get }, newValue) => {
121121
if (newValue instanceof DefaultValue) {
122122
set(themeAndTypeAtom, newValue)
123123
} else {
124124
// 如果用户输入的theme::type中type是root、object、array。则默认设置为root、object、array。v0不建议用户使用object、array、root的类型。文档体现
125-
const [, type] = newValue.split('::')
126-
if (type && ['root', 'array', 'object'].includes(type)) {
127-
set(themeAndTypeAtom, type)
125+
const [theme, type] = newValue.split('::')
126+
if (type) {
127+
if (['root', 'array', 'object'].includes(type)) {
128+
// 选中全局、非对象容器、非数组容器
129+
set(themeAndTypeAtom, type)
130+
} else if (theme === 'undefined') {
131+
// 未设置theme,使用全局主题
132+
const globalTheme = get(globalThemeAtom)
133+
set(themeAndTypeAtom, `${globalTheme}::${type}`)
134+
} else {
135+
set(themeAndTypeAtom, newValue)
136+
}
128137
} else {
129138
set(themeAndTypeAtom, newValue)
130139
}

0 commit comments

Comments
 (0)