66 extractGeekDailyBodyNote ,
77 type AdminGeekDailyListItem ,
88 type AdminGeekDailyRecord ,
9+ type AdminGeekDailyWechatDraftRecord ,
910 type AdminMePayload ,
1011} from ' @rebase/shared' ;
1112
@@ -54,9 +55,11 @@ const record = ref<AdminGeekDailyRecord | null>(null);
5455const loading = ref (true );
5556const saving = ref (false );
5657const actioning = ref (false );
58+ const wechatDrafting = ref (false );
5759const errorMessage = ref (' ' );
5860const successMessage = ref (' ' );
5961const fieldIssues = ref <Record <string , string >>({});
62+ const wechatDraftResult = ref <AdminGeekDailyWechatDraftRecord | null >(null );
6063const suggestedEpisodeNumber = ref (1 );
6164const currentStaffName = ref (' ' );
6265const activeWechatTab = ref <' preview' | ' source' >(' preview' );
@@ -75,13 +78,14 @@ const saveButtonLabel = computed(() => ((isNew.value || form.status === 'draft')
7578const saveButtonClass = computed (() => [' button-link' , ! canPublish .value && ' button-primary' ].filter (Boolean ).join (' ' ));
7679const canPublish = computed (() => form .status !== ' published' );
7780const canArchive = computed (() => Boolean (record .value ) && form .status !== ' archived' );
81+ const canCreateWechatDraft = computed (() => Boolean (record .value ) && form .status === ' published' && ! wechatGenerationIssue .value );
7882const workflowHint = computed (() => {
7983 if (isNew .value ) {
8084 return ' 可先保存草稿,也可直接发布;右侧可继续复制微信公众号内容。' ;
8185 }
8286
8387 if (form .status === ' published' ) {
84- return ' 已发布内容保存后会直接更新前台;右侧微信稿会同步更新 。' ;
88+ return ' 已发布内容保存后会直接更新前台;可继续复制微信稿,也可直接创建公众号草稿 。' ;
8589 }
8690
8791 if (form .status === ' archived' ) {
@@ -164,6 +168,7 @@ const resetFeedback = () => {
164168 errorMessage .value = ' ' ;
165169 successMessage .value = ' ' ;
166170 fieldIssues .value = {};
171+ wechatDraftResult .value = null ;
167172};
168173
169174const setCopyFeedback = (message : string ) => {
@@ -309,6 +314,26 @@ const persist = async (nextStatus: GeekDailyFormState['status'], mode: 'save' |
309314const save = async () => persist (form .status === ' published' ? ' published' : form .status === ' archived' ? ' archived' : ' draft' , ' save' );
310315const publish = async () => persist (' published' , ' publish' );
311316
317+ const createWechatDraft = async () => {
318+ if (! record .value ) {
319+ return ;
320+ }
321+
322+ wechatDrafting .value = true ;
323+ resetFeedback ();
324+ try {
325+ const result = await adminRequest <AdminGeekDailyWechatDraftRecord >(` /api/admin/v1/geekdaily/${record .value .id }/wechat-draft ` , {
326+ method: ' POST' ,
327+ });
328+ wechatDraftResult .value = result ;
329+ successMessage .value = ' 已创建公众号草稿。' ;
330+ } catch (error ) {
331+ errorMessage .value = error instanceof Error ? error .message : ' 无法创建公众号草稿。' ;
332+ } finally {
333+ wechatDrafting .value = false ;
334+ }
335+ };
336+
312337const runAction = async (action : ' archive' ) => {
313338 if (! record .value ) {
314339 return ;
@@ -355,6 +380,15 @@ onBeforeUnmount(() => {
355380 <button :class =" saveButtonClass" type =" button" :disabled =" loading || saving || actioning" @click =" save" >
356381 {{ saving ? '保存中…' : saveButtonLabel }}
357382 </button >
383+ <button
384+ v-if =" canCreateWechatDraft"
385+ class =" button-link"
386+ type =" button"
387+ :disabled =" loading || saving || actioning || wechatDrafting"
388+ @click =" createWechatDraft"
389+ >
390+ {{ wechatDrafting ? '创建中…' : '创建公众号草稿' }}
391+ </button >
358392 <button v-if =" canPublish" class =" button-link button-primary" type =" button" :disabled =" loading || saving || actioning" @click =" publish" >
359393 {{ actioning ? '发布中…' : '发布' }}
360394 </button >
@@ -364,6 +398,10 @@ onBeforeUnmount(() => {
364398
365399 <div v-if =" errorMessage" class =" panel panel-danger" ><p >{{ errorMessage }}</p ></div >
366400 <div v-if =" successMessage" class =" panel panel-success" ><p >{{ successMessage }}</p ></div >
401+ <div v-if =" wechatDraftResult" class =" panel panel-success stacked-gap-tight" >
402+ <p >公众号草稿已创建。</p >
403+ <p ><strong >mediaId:</strong ><code >{{ wechatDraftResult.mediaId }}</code ></p >
404+ </div >
367405 <div v-if =" loading" class =" panel" ><p >正在准备极客日报编辑器…</p ></div >
368406
369407 <div v-else class =" geekdaily-workspace" >
0 commit comments