mirror of https://github.com/halo-dev/halo
fix: publish time of the post cannot be displayed back (#3671)
#### What type of PR is this? /kind bug /area console /milestone 2.5.x /cherry-pick release-2.4 #### What this PR does / why we need it: 修复文章设置中的发布时间无法回显导致重新保存时丢失发布时间的问题。 #### Which issue(s) this PR fixes: Fixes #3669 #### Special notes for your reviewer: 测试方式: 1. 新建或者修改已有文章的设置。 2. 检查时间输入框的时间是否显示正确。 3. 检查保存之后时间是否显示正确。 #### Does this PR introduce a user-facing change? ```release-note 修复 Console 端文章设置中的发布时间无法回显导致重新保存时丢失发布时间的问题。 ```pull/3668/head^2
parent
0b21758347
commit
03f7e583f6
|
@ -62,7 +62,7 @@ const initialFormState: SinglePageRequest = {
|
||||||
cover: "",
|
cover: "",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
publish: false,
|
publish: false,
|
||||||
publishTime: "",
|
publishTime: undefined,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
allowComment: true,
|
allowComment: true,
|
||||||
visible: "PUBLIC",
|
visible: "PUBLIC",
|
||||||
|
|
|
@ -28,7 +28,7 @@ const initialFormState: SinglePage = {
|
||||||
cover: "",
|
cover: "",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
publish: false,
|
publish: false,
|
||||||
publishTime: "",
|
publishTime: undefined,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
allowComment: true,
|
allowComment: true,
|
||||||
visible: "PUBLIC",
|
visible: "PUBLIC",
|
||||||
|
@ -286,18 +286,16 @@ watchEffect(() => {
|
||||||
const { templates } = useThemeCustomTemplates("page");
|
const { templates } = useThemeCustomTemplates("page");
|
||||||
|
|
||||||
// publishTime
|
// publishTime
|
||||||
const publishTime = computed(() => {
|
const publishTime = computed({
|
||||||
const { publishTime } = formState.value.spec;
|
get() {
|
||||||
if (publishTime) {
|
const { publishTime } = formState.value.spec;
|
||||||
return toDatetimeLocal(publishTime);
|
return publishTime ? toDatetimeLocal(publishTime) : undefined;
|
||||||
}
|
},
|
||||||
return "";
|
set(value) {
|
||||||
|
formState.value.spec.publishTime = value ? toISOString(value) : undefined;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onPublishTimeChange = (value: string) => {
|
|
||||||
formState.value.spec.publishTime = value ? toISOString(value) : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
// slug
|
// slug
|
||||||
const { handleGenerateSlug } = useSlugify(
|
const { handleGenerateSlug } = useSlugify(
|
||||||
computed(() => formState.value.spec.title),
|
computed(() => formState.value.spec.title),
|
||||||
|
@ -443,11 +441,10 @@ const { handleGenerateSlug } = useSlugify(
|
||||||
type="select"
|
type="select"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
:model-value="publishTime"
|
v-model="publishTime"
|
||||||
:label="$t('core.page.settings.fields.publish_time.label')"
|
:label="$t('core.page.settings.fields.publish_time.label')"
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
name="publishTime"
|
name="publishTime"
|
||||||
@input="onPublishTimeChange"
|
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
v-model="formState.spec.template"
|
v-model="formState.spec.template"
|
||||||
|
|
|
@ -62,7 +62,7 @@ const initialFormState: PostRequest = {
|
||||||
cover: "",
|
cover: "",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
publish: false,
|
publish: false,
|
||||||
publishTime: "",
|
publishTime: undefined,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
allowComment: true,
|
allowComment: true,
|
||||||
visible: "PUBLIC",
|
visible: "PUBLIC",
|
||||||
|
|
|
@ -28,7 +28,7 @@ const initialFormState: Post = {
|
||||||
cover: "",
|
cover: "",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
publish: false,
|
publish: false,
|
||||||
publishTime: "",
|
publishTime: undefined,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
allowComment: true,
|
allowComment: true,
|
||||||
visible: "PUBLIC",
|
visible: "PUBLIC",
|
||||||
|
@ -247,18 +247,16 @@ watchEffect(() => {
|
||||||
const { templates } = useThemeCustomTemplates("post");
|
const { templates } = useThemeCustomTemplates("post");
|
||||||
|
|
||||||
// publishTime convert
|
// publishTime convert
|
||||||
const publishTime = computed(() => {
|
const publishTime = computed({
|
||||||
const { publishTime } = formState.value.spec;
|
get() {
|
||||||
if (publishTime) {
|
const { publishTime } = formState.value.spec;
|
||||||
return toDatetimeLocal(publishTime);
|
return publishTime ? toDatetimeLocal(publishTime) : undefined;
|
||||||
}
|
},
|
||||||
return "";
|
set(value) {
|
||||||
|
formState.value.spec.publishTime = value ? toISOString(value) : undefined;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onPublishTimeChange = (value: string) => {
|
|
||||||
formState.value.spec.publishTime = value ? toISOString(value) : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const annotationsFormRef = ref<InstanceType<typeof AnnotationsForm>>();
|
const annotationsFormRef = ref<InstanceType<typeof AnnotationsForm>>();
|
||||||
|
|
||||||
// slug
|
// slug
|
||||||
|
@ -418,10 +416,9 @@ const { handleGenerateSlug } = useSlugify(
|
||||||
type="select"
|
type="select"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
:model-value="publishTime"
|
v-model="publishTime"
|
||||||
:label="$t('core.post.settings.fields.publish_time.label')"
|
:label="$t('core.post.settings.fields.publish_time.label')"
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
@input="onPublishTimeChange"
|
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
v-model="formState.spec.template"
|
v-model="formState.spec.template"
|
||||||
|
|
Loading…
Reference in New Issue