File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
packages/generator/src/store/unclassified Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -117,14 +117,23 @@ export const curThemeAndTypeAtom = selector<string>({
117
117
get : ( { get } ) => {
118
118
return get ( themeAndTypeAtom )
119
119
} ,
120
- set : ( { set } , newValue ) => {
120
+ set : ( { set, get } , newValue ) => {
121
121
if ( newValue instanceof DefaultValue ) {
122
122
set ( themeAndTypeAtom , newValue )
123
123
} else {
124
124
// 如果用户输入的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
+ }
128
137
} else {
129
138
set ( themeAndTypeAtom , newValue )
130
139
}
You can’t perform that action at this time.
0 commit comments