Skip to content

Commit

Permalink
fix: 修复可能出现的postid不存在的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 6, 2023
1 parent 602c26a commit 51f63b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/publish/SinglePublishSelectPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const handleSingleDoPublish = (key: string) => {
const checkHasPublished = (key: string) => {
const postidKey = getDynPostidKey(key)
const postMetaValue = formData.postMeta[postidKey]
const postMetaValue = formData.postMeta.hasOwnProperty(postidKey) ? formData.postMeta[postidKey] : undefined
return !StrUtil.isEmptyString(postMetaValue)
}
Expand Down
7 changes: 5 additions & 2 deletions src/composables/usePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const usePublish = () => {
throw new Error("配置错误,posidKey不能为空,请检查配置")
}
const postMeta = singleFormData.setting[id] ?? {}
singleFormData.postid = postMeta[posidKey] ?? ""
const postMetaValue = postMeta.hasOwnProperty(posidKey) ? postMeta[posidKey] : undefined
singleFormData.postid = postMetaValue ?? ""
}

singleFormData.isAdd = StrUtil.isEmptyString(singleFormData.postid)
Expand Down Expand Up @@ -180,7 +181,9 @@ const usePublish = () => {
if (singleFormData.publishProcessStatus) {
const postMeta = singleFormData.setting[id] ?? {}
const updatedPostMeta = { ...postMeta }
delete updatedPostMeta[posidKey]
if (updatedPostMeta.hasOwnProperty(posidKey)) {
delete updatedPostMeta[posidKey]
}

singleFormData.setting[id] = updatedPostMeta
await updateSetting(singleFormData.setting)
Expand Down

0 comments on commit 51f63b4

Please sign in to comment.