@@ -11,6 +11,7 @@ import { inputPostSettings } from '../../utils/input-post-settings';
1111import { searchPostsByTitle } from '../../services/search-post-by-title' ;
1212import * as path from 'path' ;
1313import { refreshPostsList } from './refresh-posts-list' ;
14+ import { PostEditDto } from '../../models/post-edit-dto' ;
1415
1516export const savePostFileToCnblogs = async ( fileUri : Uri ) => {
1617 if ( ! fileUri || fileUri . scheme !== 'file' ) {
@@ -21,7 +22,7 @@ export const savePostFileToCnblogs = async (fileUri: Uri) => {
2122 // const fileNameWithoutExt = path.basename(fileName, path.extname(fileName));
2223 const postId = PostFileMapManager . getPostId ( filePath ) ;
2324 if ( postId && postId >= 0 ) {
24- await savePostToCnblogs ( ( await postService . fetchPostEditDto ( postId ) ) . post ) ;
25+ await savePostToCnblogs ( await postService . fetchPostEditDto ( postId ) ) ;
2526 } else {
2627 const options = [ `新建博文` , `关联已有博文` ] ;
2728 const selected = await window . showInformationMessage (
@@ -84,15 +85,16 @@ export const saveLocalDraftToCnblogs = async (localDraft: LocalDraftFile) => {
8485 }
8586 Object . assign ( post , userInputPostConfig ) ;
8687
87- if ( ! ( await savePostToCnblogs ( post , true ) ) ) {
88+ if ( ! ( await savePostToCnblogs ( editDto , true ) ) ) {
8889 return ;
8990 }
9091 await PostFileMapManager . updateOrCreate ( post . id , localDraft . filePath ) ;
9192 postsDataProvider . fireTreeDataChangedEvent ( undefined ) ;
9293 await openPostFile ( localDraft ) ;
9394} ;
9495
95- export const savePostToCnblogs = async ( post : Post , isNewPost = false ) => {
96+ export const savePostToCnblogs = async ( input : Post | PostEditDto , isNewPost = false ) => {
97+ const post = input instanceof PostEditDto ? input . post : ( await postService . fetchPostEditDto ( input . id ) ) . post ;
9698 if ( ! post ) {
9799 return ;
98100 }
0 commit comments