Skip to content

Commit

Permalink
fix: 优化文章未发布时的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Nov 13, 2023
1 parent 9002af3 commit abc9095
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/components/publish/SinglePublishSelectPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const formData = reactive({
enabledConfigArray: [] as DynamicConfig[],
postMeta: {} as any,
unpublishCount: 0,
})
// methods
Expand Down Expand Up @@ -98,6 +99,7 @@ const handlePreview = async (event: any, key: string) => {
const isPublish = checkHasPublished(key)
if (!isPublish) {
formData.unpublishCount++
return
}
Expand All @@ -109,25 +111,22 @@ const handlePreview = async (event: any, key: string) => {
}
const handlePreviewAll = async (event: any) => {
if (formData.enabledConfigArray.length == 0) {
ElMessage.error("文章未发布过,请至少发布到一个平台!")
return
}
ElMessageBox.confirm(
`将在默认浏览器打开所有已发布平台的文章预览页面,是否继续?`,
"温馨提示",
{
type: "error",
icon: markRaw(Warning),
confirmButtonText: t("main.opt.ok"),
cancelButtonText: t("main.opt.cancel"),
}
)
ElMessageBox.confirm(`将在默认浏览器打开所有已发布平台的文章预览页面,是否继续?`, "温馨提示", {
type: "error",
icon: markRaw(Warning),
confirmButtonText: t("main.opt.ok"),
cancelButtonText: t("main.opt.cancel"),
})
.then(async () => {
for (const enabledCfg of formData.enabledConfigArray) {
await handlePreview(event, enabledCfg.platformKey)
}
if (formData.enabledConfigArray.length === 0 || formData.unpublishCount === formData.enabledConfigArray.length) {
// 重置,准备下一次点击
formData.unpublishCount = 0
ElMessage.error("文章未发布过,请至少发布到一个平台!")
}
})
.catch(() => {})
}
Expand Down

0 comments on commit abc9095

Please sign in to comment.