UNPKG

@tencentcloud/chat-uikit-uniapp

Version:

TUIKit 是基于 IM SDK 实现的一套 UI 组件,其包含会话、聊天、群组、个人资料等功能,基于这些精心设计的 UI 组件,您可以快速构建优雅的、可靠的、可扩展的 Chat 应用。

28 lines (27 loc) 808 B
export default function unifyPromiseVue2() { try { // eslint-disable-next-line no-inner-declarations function isPromise(obj) { return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } // Unified vue2 API Promise return format to be consistent with vue3 // eslint-disable-next-line no-undef (uni as any).addInterceptor({ returnValue(res) { if (!isPromise(res)) { return res; } return new Promise((resolve, reject) => { res.then((res) => { if (res[0]) { reject(res[0]); } else { resolve(res[1]); } }); }); }, }); // eslint-disable-next-line no-empty } catch (error) { } }