UNPKG

@coze/uniapp-api

Version:

Official Coze UniApp SDK for seamless AI integration into your applications | 扣子官方 UniApp SDK,助您轻松集成 AI 能力到应用中

24 lines (23 loc) 881 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWebSocketImplementation = getWebSocketImplementation; /* eslint-disable @typescript-eslint/no-explicit-any */ const index_1 = require("./index"); // 获取适当的WebSocket实现的工厂函数 function getWebSocketImplementation() { // 确保我们在UniApp环境中 if (typeof uni === 'undefined') { throw new Error('Not in a UniApp environment'); } // 获取系统信息 const systemInfo = uni.getSystemInfoSync(); // 根据平台选择适当的实现 if (systemInfo.uniPlatform === 'web' || systemInfo.uniPlatform === 'h5') { // 对于H5,我们可以使用浏览器原生的WebSocket return window.WebSocket; } else { // 对于其他平台,使用默认的UniApp实现 return index_1.UniAppWebSocket; } }