import {dayjs} from "element-plus"; /** * * @param {string} type * @returns {boolean} */ export function isImage(type) { return type ? ['png', 'jpg', 'jpeg', 'gif', 'webp'].includes(type.toLowerCase()) : false; } export function formatDate(time, format = 'MM-DD') { return dayjs(time).format(format); } export function formatSize(a, b = 2) { if (0 == a) return "0 B"; let c = 1024, d = b || 2, e = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], f = Math.floor(Math.log(a) / Math.log(c)); return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f]; } export default { isImage, formatSize, formatDate }