@@ -163,13 +163,15 @@ func (cli *Client) PageFindOrCreateBySpaceAndTitle(space, parentId, title, wikiD
163163 //因此前先去掉,以避免对比内容变化时受到影响
164164 data = strings .TrimSuffix (strings .TrimPrefix (data , "\n " ), "\n " )
165165
166+ //获取当前页面的内容
166167 content , err := cli .ContentBySpaceAndTitle (space , title )
167168 if err != nil {
168169 return Content {}, fmt .Errorf ("查找%s出错: %s" , title , err )
169170 }
170171
171172 // 不存在则创建
172173 if content .Id == "" {
174+ data += fmt .Sprintf (ConfluenceNoteMacro , extraInfo )
173175 return cli .PageCreateInSpace (space , parentId , title , data )
174176 }
175177
@@ -192,18 +194,22 @@ func (cli *Client) PageFindOrCreateBySpaceAndTitle(space, parentId, title, wikiD
192194 return Content {}, fmt .Errorf ("转换新内容失败: %s" , err )
193195 }
194196
197+ // 去除原文件的备注宏
198+ if content .Body .Storage .Value != "" {
199+ content .Body .Storage .Value = strings .Split (content .Body .Storage .Value , ConfluenceNoteSplite )[0 ]
200+ }
195201 oldValue , err := cli .ContentBodyConvertTo (content .Body .Storage .Value , "storage" , "view" )
196202 if err != nil {
197203 return Content {}, fmt .Errorf ("转换旧内容失败: %s" , err )
198204 }
199205
200206 if newValue == oldValue && lastAncestorId == parentId {
201207 return content , nil
208+ } else {
209+ // 如果确定要更新confluence页面,那么这里添加一个备注宏
210+ data += fmt .Sprintf (ConfluenceNoteMacro , extraInfo )
202211 }
203212
204- // 如果确定要更新confluence页面,那么这里添加一个备注宏
205- data += fmt .Sprintf (ConfluenceNoteMacro , extraInfo )
206-
207213 // 存在则否则更新
208214 content .Space .Key = space
209215 content .Version .Number += 1
0 commit comments