fix: preferred-editor annotation is not set when editing old posts (#806)

#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

修复编辑旧文章时,没有为文章设置 `content.halo.run/preferred-editor` 的元数据的问题。

#### Which issue(s) this PR fixes:

Ref https://github.com/halo-dev/halo/issues/3080

#### Special notes for your reviewer:

测试方式:

1. 在有旧数据的情况下切换到此 PR。
2. 编辑一篇旧的文章后保存。
3. 打开文章设置,检查元数据中是否包含了 `content.halo.run/preferred-editor`

#### Does this PR introduce a user-facing change?


```release-note
None
```
pull/811/head
Ryan Wang 2022-12-29 21:42:34 +08:00 committed by GitHub
parent 4cb3a72f51
commit 89ee700f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -213,6 +213,16 @@ const handleFetchContent = async () => {
...formState.value.page.metadata.annotations,
"content.halo.run/preferred-editor": provider.name,
};
const { data } =
await apiClient.extension.singlePage.updatecontentHaloRunV1alpha1SinglePage(
{
name: formState.value.page.metadata.name,
singlePage: formState.value.page,
}
);
formState.value.page = data;
} else {
Dialog.warning({
title: "警告",

View File

@ -221,6 +221,14 @@ const handleFetchContent = async () => {
...formState.value.post.metadata.annotations,
"content.halo.run/preferred-editor": provider.name,
};
const { data } =
await apiClient.extension.post.updatecontentHaloRunV1alpha1Post({
name: formState.value.post.metadata.name,
post: formState.value.post,
});
formState.value.post = data;
} else {
Dialog.warning({
title: "警告",