@@ -34,10 +34,17 @@ class AccessPermissionPickItem implements QuickPickItem {
34
34
constructor ( public id : AccessPermission , public label : string ) { }
35
35
}
36
36
37
- type PostSettingsType = 'categoryIds' | 'tags' | 'description' | 'password' | 'accessPermission' ;
37
+ type PostSettingsType = 'categoryIds' | 'tags' | 'description' | 'password' | 'accessPermission' | 'isPublished' ;
38
38
type PostSettingsDto = Pick < BlogPost , PostSettingsType > ;
39
39
40
- const defaultSteps : PostSettingsType [ ] = [ 'accessPermission' , 'description' , 'categoryIds' , 'tags' , 'password' ] ;
40
+ const defaultSteps : PostSettingsType [ ] = [
41
+ 'accessPermission' ,
42
+ 'description' ,
43
+ 'categoryIds' ,
44
+ 'tags' ,
45
+ 'password' ,
46
+ 'isPublished' ,
47
+ ] ;
41
48
42
49
const parseTagNames = ( value : string ) => {
43
50
return value . split ( / [ , , ] / ) . filter ( t => ! ! t ) ;
@@ -172,12 +179,34 @@ export const inputPostSettings = async (
172
179
configuredPost . password = value ?? '' ;
173
180
return calculateNextStep ( ) ;
174
181
} ;
182
+ // 是否发布
183
+ const inputIsPublished = async ( input : MultiStepInput ) => {
184
+ calculateStepNumber ( 'isPublished' ) ;
185
+ const items = [ { label : '是' } as QuickPickItem , { label : '否' } as QuickPickItem ] ;
186
+ const picked = await input . showQuickPick ( {
187
+ items : items ,
188
+ title : state . title ,
189
+ step : state . step ++ ,
190
+ totalSteps : state . totalSteps ,
191
+ placeholder : '<必选>是否发布' ,
192
+ activeItems : configuredPost . isPublished ? [ items [ 0 ] ] : [ items [ 1 ] ] ,
193
+ buttons : [ ] ,
194
+ canSelectMany : false ,
195
+ shouldResume : ( ) => Promise . resolve ( false ) ,
196
+ } ) ;
197
+ if ( picked ) {
198
+ configuredPost . isPublished = picked === items [ 0 ] ;
199
+ }
200
+
201
+ return calculateNextStep ( ) ;
202
+ } ;
175
203
map = [
176
204
[ 'accessPermission' , inputAccessPermission ] ,
177
205
[ 'categoryIds' , inputCategory ] ,
178
206
[ 'password' , inputPassword ] ,
179
207
[ 'description' , inputDescription ] ,
180
208
[ 'tags' , inputTags ] ,
209
+ [ 'isPublished' , inputIsPublished ] ,
181
210
] ;
182
211
183
212
await MultiStepInput . run ( calculateNextStep ( ) ! ) ;
0 commit comments