更新记录
1.0.0(2024-03-24)
初始化发布
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 4.4 | 12 | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | - | × | × | × | × |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | 12 | - | × |
概述
XF-SseUTS封装了服务器推送事件(Server-Sent Events),它是一种用于从服务器向客户端推送实时数据的HTML5技术,可以实现ChatGPT打字机效果。
插件接口
createSse
创建SSE连接,并实时监听服务器数据
uni-app项目中(nvue)调用示例:
import { createSse } from "@/uni_modules/XF-SseUTS"
createSse({
url: '',
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { createSse } from "@/uni_modules/XF-SseUTS";
import { CreateSseOptions } from "@/uni_modules/XF-SseUTS/utssdk/interface.uts";
let options = {
url: '',
complete: (res : any) => {
console.log(res)
}
} as CreateSseOptions;
createSse(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
closeSse
关闭SSE连接
uni-app项目中(nvue)调用示例:
import { closeSse } from "@/uni_modules/XF-SseUTS"
closeSse({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { closeSse } from "@/uni_modules/XF-SseUTS";
import { CloseSseOptions } from "@/uni_modules/XF-SseUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as CloseSseOptions;
closeSse(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本