// @if process.env.BUILD_TARGET ='MINI' import { UIKitModal } from '../UIKitModal'; // @endif // @if process.env.BUILD_TARGET!='MINI' import TuiStore from '../TUIStore/tuiStore'; import { StoreName } from '../const/call'; import { NAME } from '../const/index'; import { t } from '../locales'; const TUIStore = TuiStore.getInstance(); // @endif // @if process.env.BUILD_TARGET!='MINI' const WEB_MODAL_ERROR_CODES = [ -1001, -1002, -1101, 60003, 60004, 60006, -1201, 30000, 20007, 101002, ]; const WEB_MODAL_ERROR_MAP = { '-1001': { id: 10001, key: 'error.10001' }, '-1002': { id: 10002, key: 'error.10002' }, '-1101': { id: 10004, key: 'error.10004' }, '60003': { id: 10005, key: 'error.10005' }, '60004': { id: 10006, key: 'error.10006' }, '60006': { id: 10007, key: 'error.10007' }, '-1201': { id: 10008, key: 'error.10008' }, '30000': { id: 10012, key: 'error.10012' }, '20007': { id: 10013, key: 'error.10013' }, '101002': { id: 10014, key: 'error.10014' } }; // @endif // @if process.env.BUILD_TARGET ='MINI' const MINI_MODAL_ERROR_CODES = [ -1001, -1002, 101002, ]; const MINI_MODAL_ERROR_MAP = { '-1001': { id: 10001, content: '您的应用还未开通音视频通话能力' }, '-1002': { id: 10002, content: '您暂不支持使用该能力,请前往购买页购买开通' }, '101002': { id: 10014, content: '发起通话失败,用户 ID 无效,请确认该用户已注册' } } // @endif export function handleModalError(error) { if (!error || !error?.code) { return; } // @if process.env.BUILD_TARGET!='MINI' handleWebModalError(error); // @endif // @if process.env.BUILD_TARGET='MINI' handleMiniModalError(error); // @endif } // @if process.env.BUILD_TARGET!='MINI' function handleWebModalError(error) { if (!WEB_MODAL_ERROR_CODES.includes(error.code)) { return; } const errorInfo = WEB_MODAL_ERROR_MAP[error.code.toString()]; if (errorInfo) { let content = t(errorInfo.key); TUIStore.update(StoreName.CALL, NAME.MODAL_ERROR, { id: errorInfo.id, content: content, title: t('error') }); } } // @endif // @if process.env.BUILD_TARGET='MINI' function handleMiniModalError(error) { if (!MINI_MODAL_ERROR_CODES.includes(error.code)) { return; } const errorInfo = MINI_MODAL_ERROR_MAP[error.code.toString()]; if (errorInfo) { UIKitModal.openModal({ id: errorInfo.id, content: errorInfo.content, title: '错误', type: 'error' }); } } // @endif