Skip to content

Commit

Permalink
fix: 修复强制删除提示不明确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 8, 2023
1 parent 2b00149 commit e5d745e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/components/publish/BatchPublishIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const props = defineProps({
// uses
const { t } = useVueI18n()
const { doSinglePublish, doSingleDelete } = usePublish()
const { doSinglePublish, doSingleDelete, doForceSingleDelete } = usePublish()
const { blogApi } = useSiyuanApi()
const { getPublishCfg } = usePublishConfig()
Expand Down Expand Up @@ -177,6 +177,16 @@ const doDelete = async () => {
}
}
const handleForceDelete = async (key: string, id: string, publishCfg: IPublishCfg) => {
try {
await doForceSingleDelete(key, id, publishCfg)
} catch (error) {
ElMessage.error(error.message)
} finally {
formData.isDeleteLoading = false
}
}
const syncDynList = (selectedKeys: string[]) => {
formData.dynList = selectedKeys
}
Expand Down Expand Up @@ -211,7 +221,7 @@ onMounted(async () => {
[{{ errRet.key }}] {{ StrUtil.isEmptyString(errRet.name) ? "" : `[${errRet.name}]` }} {{ errRet.errMsg }}
<a
href="javascript:void(0)"
@click="doSingleDelete(errRet.key, props.id, formData.publishCfg as IPublishCfg)"
@click="handleForceDelete(errRet.key, props.id, formData.publishCfg as IPublishCfg)"
>强制解除关联</a
>
</div>
Expand Down
12 changes: 8 additions & 4 deletions src/composables/usePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { reactive, toRaw } from "vue"
import { SypConfig } from "~/syp.config.ts"
import {AliasTranslator, DateUtil, ObjectUtil, StrUtil} from "zhi-common"
import { AliasTranslator, DateUtil, ObjectUtil, StrUtil } from "zhi-common"
import { BlogAdaptor, BlogConfig, PageTypeEnum, Post, PostStatusEnum } from "zhi-blog-api"
import { useVueI18n } from "~/src/composables/useVueI18n.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
Expand All @@ -39,6 +39,7 @@ import { IPublishCfg } from "~/src/types/IPublishCfg.ts"
import { usePublishConfig } from "~/src/composables/usePublishConfig.ts"
import { YamlConvertAdaptor } from "~/src/platforms/yamlConvertAdaptor.ts"
import { YamlFormatObj } from "~/src/models/yamlFormatObj.ts"
import { ElMessage } from "element-plus"

/**
* 通用发布组件
Expand Down Expand Up @@ -244,9 +245,10 @@ const usePublish = () => {
if (updatedPostMeta.hasOwnProperty(posidKey)) {
delete updatedPostMeta[posidKey]
}
if (updatedPostMeta.hasOwnProperty("custom-slug")) {
delete updatedPostMeta["custom-slug"]
}
// 别名不能删除,因为别的平台可能还用
// if (updatedPostMeta.hasOwnProperty("custom-slug")) {
// delete updatedPostMeta["custom-slug"]
// }

setting[id] = updatedPostMeta
await updateSetting(setting)
Expand All @@ -256,8 +258,10 @@ const usePublish = () => {
timeout: 2000,
})
logger.info(`[${key}] [${id}] 文章发布信息已强制移除`)
ElMessage.success(`[${key}] [${id}] 文章发布信息已强制移除`)
}
} catch (e) {
ElMessage.error(t("main.opt.failure") + "=>" + e)
logger.error(e)
await kernelApi.pushErrMsg({
msg: t("main.opt.failure") + "=>" + e,
Expand Down

0 comments on commit e5d745e

Please sign in to comment.