mirror of https://github.com/halo-dev/halo
perf: refine setup data and logic of post publish (halo-dev/console#739)
#### What type of PR is this? /kind improvement /milestone 2.0 #### What this PR does / why we need it: 更新系统初始化数据的资源,主要为了适配 https://github.com/halo-dev/console/pull/730 的修改。 #### Special notes for your reviewer: 测试方式: 1. 准备全新的环境。 2. 启动之后初始化,检查初始数据是否正常。 #### Does this PR introduce a user-facing change? ```release-note None ```pull/3445/head
parent
06030165f5
commit
d6b22860a9
|
@ -48,12 +48,30 @@ const handleSubmit = async () => {
|
||||||
await apiClient.extension.tag.createcontentHaloRunV1alpha1Tag({
|
await apiClient.extension.tag.createcontentHaloRunV1alpha1Tag({
|
||||||
tag: tag as Tag,
|
tag: tag as Tag,
|
||||||
});
|
});
|
||||||
await apiClient.post.draftPost({ postRequest: post as PostRequest });
|
const { data: postData } = await apiClient.post.draftPost({
|
||||||
|
postRequest: post as PostRequest,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await apiClient.post.publishPost({ name: postData.metadata.name });
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Publish post failed", e);
|
||||||
|
}
|
||||||
|
|
||||||
// Create singlePage
|
// Create singlePage
|
||||||
await apiClient.singlePage.draftSinglePage({
|
const { data: singlePageData } = await apiClient.singlePage.draftSinglePage(
|
||||||
singlePageRequest: singlePage as SinglePageRequest,
|
{
|
||||||
});
|
singlePageRequest: singlePage as SinglePageRequest,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await apiClient.singlePage.publishSinglePage({
|
||||||
|
name: singlePageData.metadata.name,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Publish single page failed", e);
|
||||||
|
}
|
||||||
|
|
||||||
// Create menu and menu items
|
// Create menu and menu items
|
||||||
const menuItemPromises = menuItems.map((item) => {
|
const menuItemPromises = menuItems.map((item) => {
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
"spec": {
|
"spec": {
|
||||||
"children": [],
|
"children": [],
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
"categoryRef": {
|
"targetRef": {
|
||||||
"version": "content.halo.run/v1alpha1",
|
"group": "content.halo.run",
|
||||||
|
"version": "v1alpha1",
|
||||||
"kind": "Post",
|
"kind": "Post",
|
||||||
"name": "76514a40-6ef1-4ed9-b58a-e26945bde3ca"
|
"name": "5152aea5-c2e8-4717-8bba-2263d46e19d5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apiVersion": "v1alpha1",
|
"apiVersion": "v1alpha1",
|
||||||
|
@ -30,8 +31,9 @@
|
||||||
"href": "",
|
"href": "",
|
||||||
"children": [],
|
"children": [],
|
||||||
"priority": 2,
|
"priority": 2,
|
||||||
"tagRef": {
|
"targetRef": {
|
||||||
"version": "content.halo.run/v1alpha1",
|
"group": "content.halo.run",
|
||||||
|
"version": "v1alpha1",
|
||||||
"kind": "Tag",
|
"kind": "Tag",
|
||||||
"name": "c33ceabb-d8f1-4711-8991-bb8f5c92ad7c"
|
"name": "c33ceabb-d8f1-4711-8991-bb8f5c92ad7c"
|
||||||
}
|
}
|
||||||
|
@ -46,8 +48,9 @@
|
||||||
"href": "",
|
"href": "",
|
||||||
"children": [],
|
"children": [],
|
||||||
"priority": 3,
|
"priority": 3,
|
||||||
"singlePageRef": {
|
"targetRef": {
|
||||||
"version": "content.halo.run/v1alpha1",
|
"group": "content.halo.run",
|
||||||
|
"version": "v1alpha1",
|
||||||
"kind": "SinglePage",
|
"kind": "SinglePage",
|
||||||
"name": "373a5f79-f44f-441a-9df1-85a4f553ece8"
|
"name": "373a5f79-f44f-441a-9df1-85a4f553ece8"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"template": "",
|
"template": "",
|
||||||
"cover": "",
|
"cover": "",
|
||||||
"deleted": false,
|
"deleted": false,
|
||||||
"publish": true,
|
"publish": false,
|
||||||
"publishTime": "",
|
"publishTime": "",
|
||||||
"pinned": false,
|
"pinned": false,
|
||||||
"allowComment": true,
|
"allowComment": true,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"template": "",
|
"template": "",
|
||||||
"cover": "",
|
"cover": "",
|
||||||
"deleted": false,
|
"deleted": false,
|
||||||
"publish": true,
|
"publish": false,
|
||||||
"publishTime": "",
|
"publishTime": "",
|
||||||
"pinned": false,
|
"pinned": false,
|
||||||
"allowComment": true,
|
"allowComment": true,
|
||||||
|
|
Loading…
Reference in New Issue