Update (major): fix bugs

This commit is contained in:
2023-08-01 22:37:51 +08:00
parent 511382f6c1
commit f25fea8d68
22 changed files with 92 additions and 50 deletions

View File

@@ -456,39 +456,46 @@ export default {
errors.push("post title");
}
if (!(this.post.publish_date != null)) {
errors.push("publish date");
}
if (!(this.post.slug?.length > 0)) {
errors.push("post slug");
}
if (!(this.post.excerpt?.length > 0)) {
errors.push("post excerpt");
}
if (this.post.status == "publish") {
if (!(this.post.publish_date != null)) {
errors.push("publish date");
}
if (!(this.post.featured_image?.length > 0)) {
errors.push("post featured image");
}
if (!(this.post.excerpt?.length > 0)) {
errors.push("post excerpt");
}
if (!(this.post.body.blocks?.length > 0)) {
errors.push("Post body");
}
if (!(this.post.featured_image?.length > 0)) {
errors.push("post featured image");
}
if (
!(this.post.locale_slug?.length > 0) ||
!(this.post.locale_id != null)
) {
errors.push("Country locality");
}
if (!(this.post.body.blocks?.length > 0)) {
errors.push("Post body");
}
if (!(this.post.categories != null)) {
errors.push("Category");
if (
!(this.post.locale_slug?.length > 0) ||
!(this.post.locale_id != null)
) {
errors.push("Country locality");
}
if (!(this.post.categories != null)) {
errors.push("Category");
}
}
if (errors.length > 0) {
alert("HAIYA many errors! pls fix " + errors.join(", "));
alert(
"HAIYA many errors! For " +
this.post.status +
" status, pls fix " +
errors.join(", ")
);
} else {
this.savePost();
}
@@ -615,6 +622,26 @@ export default {
slug = slug.replace(/\s+/g, "-");
return slug;
},
setAuthor() {
if (this.post.id == null) {
if (this.post.author_id == null) {
for (const [key, _item] of Object.entries(this.authors)) {
this.post.author_id = _item.id;
break;
}
}
}
},
setLocalCategory() {
if (this.post.id == null) {
if (this.post.categories == null) {
for (const [key, _item] of Object.entries(this.localeCategories)) {
this.post.categories = _item.id;
break;
}
}
}
},
},
mounted() {
this.config.tools.image.config.endpoints.byFile = route(
@@ -631,8 +658,12 @@ export default {
setTimeout(
function () {
this.fetchLocaleCategories(this.post.locale_slug);
this.fetchAuthors();
this.fetchLocaleCategories(this.post.locale_slug).then(() => {
this.setLocalCategory();
});
this.fetchAuthors().then(() => {
this.setAuthor();
});
if (this.postId != null) {
this.fetchPostData(this.postId).then(() => {