@@ -94,7 +94,7 @@ function publishArticleToCnBlogFact(title, content, resolve,
9494 "inSiteHome" : false ,
9595 "siteCategoryId" : null ,
9696 "blogTeamIds" : null ,
97- "isPublished" : true ,
97+ "isPublished" : isPublish ,
9898 "displayOnHomePage" : true ,
9999 "isAllowComments" : true ,
100100 "includeInMainSyndication" : true ,
@@ -133,26 +133,29 @@ function publishArticleToCnBlogFact(title, content, resolve,
133133 'cookie' : dataStore . getCnBlogCookies ( ) ,
134134 'x-xsrf-token' : dataStore . GetCnblogsToken ( )
135135 }
136- } ) . then ( res => {
137- if ( res . status === 200 ) {
138- resolve ( res . data . url )
136+ } ) . then ( response => {
137+ // console.log(response)
138+ // console.log("data: " + JSON.stringify(response.data))
139+ // console.log("status: " + response.status)
140+ if ( response . status === 200 ) {
141+ let openUrl = response . data . url ;
142+ if ( openUrl . indexOf ( '//' ) === 0 ) {
143+ openUrl = "https:" + openUrl
144+ }
145+ resolve ( openUrl )
146+ }
147+ } ) . catch ( error => {
148+ // console.log("cookie: " + dataStore.getCnBlogCookies())
149+ // console.log('x-xsrf-token: ' + dataStore.GetCnblogsToken())
150+ if ( error . response && error . response . data ) {
151+ reject ( '发布失败!\n' + JSON . stringify ( error . response . data ) )
152+ } else if ( error . response ) {
153+ reject ( '发布失败!\n' + JSON . stringify ( error . response ) )
154+ } else {
155+ reject ( '发布失败!\n' + error . message )
139156 }
140- // console.log(res)
141- } ) . catch ( reason => {
142- reject ( '发布失败!\n' + JSON . stringify ( reason . response . data ) )
143- console . log ( "cookie: " + dataStore . getCnBlogCookies ( ) )
144- console . log ( 'x-xsrf-token: ' + dataStore . GetCnblogsToken ( ) )
145- console . log ( reason . response . data )
146157 } )
147158
148-
149- // const dom = new jsdom.JSDOM(str);
150- // const a = dom.window.document.body.getElementsByTagName('a')[0];
151- // let url = 'https://i.cnblogs.com' + a.href;
152-
153-
154- // //发布失败
155-
156159}
157160
158161exports . uploadPictureToCnBlogs = uploadPictureToCnBlogs ;
0 commit comments