import { notification } from 'ant-design-vue';
import { downloadByUrl } from '@/utils/tools';
import { IconLoading } from '@arco-design/web-vue/es/icon';
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
import icon2 from '@/assets/img/media-account/icon-success.png';
import icon3 from "@/assets/img/media-account/icon-warn.png"
interface RenderNotificationData {
total_number: number;
success_number: number;
fail_number: number;
file?: string;
}
// 下载通知框
export function showExportNotification(label: string, others: { id?: string, duration?: number }) {
const { id = '', duration = 3 } = others ?? {}
notification.warning({
key: id,
icon: () => null,
message: () => null,
description: (
),
duration,
class: 'w-450px rounded-2px bg-#F0EDFF',
});
}
// 下载失败框
export function showFailExportNotification(label: string, others: { id?: string, duration?: number, onReDownload?: Function }) {
const { id = '', duration = 0, onReDownload } = others ?? {}
notification.warning({
key: id,
icon: () => null,
message: () => null,
description: (
{label}
onReDownload?.()}>重新下载
),
duration,
class: 'w-500px rounded-2px bg-#FFE9E7',
});
}
export const showImportResultNotification = (data: RenderNotificationData) => {
const { total_number, success_number, fail_number, file } = data;
const hasError = fail_number > 0;
const handleDownloadError = (file?: string) => {
file && downloadByUrl(file);
};
notification.warning({
icon: () => null,
message: () => null,
description: (
导入完成
共导入 {total_number} 个账号,导入成功 {success_number} 个
{hasError && (
,失败 {fail_number} 个
)}
{hasError && (
handleDownloadError(file)}
>
下载问题表格
)}
),
duration: 3000,
class: `w-400px rounded-2px ${hasError ? 'bg-#FFF7E5' : 'bg-#EBF7F2'}`,
});
};