Skip to content

Commit

Permalink
fix(generator): when the theme is not set, the property configuration…
Browse files Browse the repository at this point in the history
… will not be displayed (#225)
  • Loading branch information
mengshang918 committed Jun 30, 2022
1 parent 77eaaad commit d4c1de4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/generator/src/store/unclassified/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,23 @@ export const curThemeAndTypeAtom = selector<string>({
get: ({ get }) => {
return get(themeAndTypeAtom)
},
set: ({ set }, newValue) => {
set: ({ set, get }, newValue) => {
if (newValue instanceof DefaultValue) {
set(themeAndTypeAtom, newValue)
} else {
// 如果用户输入的theme::type中type是root、object、array。则默认设置为root、object、array。v0不建议用户使用object、array、root的类型。文档体现
const [, type] = newValue.split('::')
if (type && ['root', 'array', 'object'].includes(type)) {
set(themeAndTypeAtom, type)
const [theme, type] = newValue.split('::')
if (type) {
if (['root', 'array', 'object'].includes(type)) {
// 选中全局、非对象容器、非数组容器
set(themeAndTypeAtom, type)
} else if (theme === 'undefined') {
// 未设置theme,使用全局主题
const globalTheme = get(globalThemeAtom)
set(themeAndTypeAtom, `${globalTheme}::${type}`)
} else {
set(themeAndTypeAtom, newValue)
}
} else {
set(themeAndTypeAtom, newValue)
}
Expand Down

0 comments on commit d4c1de4

Please sign in to comment.