import { ElMessage } from "element-plus"; let msgBoxInstance: any = null; /** * [showMessage 统一封装消息] * * @return {[params]} [return description] */ export const showMessage = (params: { type: string; message: string; icon?: string; duration?: number; }) => { if (msgBoxInstance) { msgBoxInstance.close(); } msgBoxInstance = ElMessage(params as any); }; /** * [倒计时] * * @return {[params]} [return description] */ export function startCountdown( duration: number, onTick?: (args: number) => void, onComplete?: () => void ) { let time = duration; const timer = setInterval(() => { time--; if (typeof onTick === "function") { onTick(time); } if (time <= 0) { clearInterval(timer); if (typeof onComplete === "function") { onComplete(); } } }, 1000); } export const webSiteFlagRelation: Record = { 'user': '1', // 海外用户 'distributor': '2' // 国内分销商 } const webSiteContactRelation: Record = { 'user': 'email', // 海外用户 'distributor': 'mobile' // 国内分销商 } export const webSiteLanguageRelation: Record = { 'user': 'en', // 海外用户 'distributor': 'zh' // 国内分销商 } export const getContactType = () => { const config = useRuntimeConfig() const contactType = webSiteContactRelation[config.public.appType]; return contactType; }