mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2025-10-15 06:39:08 +00:00

/kind feature ```release-note 提供解除 S3 关联功能(仅删除 Halo 附件记录,而不再对象存储中实际删除) ``` 在附件库中选择使用本插件上传或关联的文件的更多插件,会出现 解除 S3 关联 按钮。  对于其他附件,不会出现该按钮  本功能已支持权限管理。
38 lines
1.2 KiB
Vue
38 lines
1.2 KiB
Vue
<script setup lang="ts">
|
|
import {deleteApisS3OsHaloRunV1Alpha1AttachmentsByName} from "@/controller";
|
|
import type {Attachment} from "@halo-dev/api-client";
|
|
import {Dialog, Toast, VDropdownDivider, VDropdownItem} from "@halo-dev/components";
|
|
import {useQueryClient} from "@tanstack/vue-query";
|
|
|
|
const props = defineProps<{
|
|
attachment: Attachment;
|
|
}>();
|
|
const queryClient = useQueryClient();
|
|
|
|
const handleUnlink = () => {
|
|
Dialog.warning({
|
|
title: "解除 S3 关联",
|
|
description: "解除关联后,附件中的记录将会被删除,而对象存储中的文件仍然保留,若需重新关联请使用“关联 S3 文件”功能。",
|
|
confirmType: "danger",
|
|
confirmText: "确定",
|
|
cancelText: "取消",
|
|
onConfirm: async () => {
|
|
try {
|
|
await deleteApisS3OsHaloRunV1Alpha1AttachmentsByName({name: props.attachment.metadata.name});
|
|
Toast.success("解除关联成功");
|
|
} catch (e) {
|
|
console.error("Failed to delete attachment", e);
|
|
} finally {
|
|
queryClient.invalidateQueries({queryKey: ["attachments"]});
|
|
}
|
|
},
|
|
});
|
|
}
|
|
</script>
|
|
<template>
|
|
<div>
|
|
<VDropdownDivider/>
|
|
<VDropdownItem type="danger" @click="handleUnlink">解除 S3 关联</VDropdownItem>
|
|
</div>
|
|
</template>
|