# UniappStreamRequest **Repository Path**: scenario-samples/uniapp-stream-request ## Basic Information - **Project Name**: UniappStreamRequest - **Description**: 本示例主要基于requestInStream和on("dataReceive")方法实现流式请求的功能。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-19 - **Last Updated**: 2026-01-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## uni-app实现流式请求示例 ## 场景介绍 本示例主要基于[requestInStream](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-http#requestinstream10)和[on("dataReceive")](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-http#ondatareceive10)方法实现流式请求的功能。 ## 效果预览 ## 实现思路 NetworkKit的[requestInStream](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-http#requestinstream10)方法和[on("dataReceive")](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-http#ondatareceive10)方法可处理流式请求的响应,将其封装成UTS插件供uni-app侧调用。 运行示例:
1.先启动服务端,然后使用ipconfig拿到服务端ip,配置到端侧`/pages/index/index.vue`。 2.启动端侧示例后,在手机上点击‘点击发起流式请求’。 3.接收到多条流式响应数据,效果如图。
## 说明 服务端搭建:参考[本地部署大语言模型](https://zhuanlan.zhihu.com/p/1902065034726740122)在服务端搭建大语言模型。 ## 约束与限制 * 本示例支持API Version 20 Release及以上版本。 * 本示例支持HarmonyOS 6.0.0 Release SDK及以上版本。 * 本示例需要使用DevEco Studio 6.0.0 Release及以上版本进行编译运行。 ## 工程目录 ``` ├─App.vue // 应用配置,用来配置App全局样式以及监听、应用生命周期 ├─index.html // 用于web加载渲染的root节点 ├─main.js // Vue初始化入口文件 ├─manifest.json // 应用相关配置 ├─pages.json // 配置页面路由、导航条、选项卡等页面类信息 ├─uni.scss // 内置的常用样式变量 ├─pages │ └─index │ └─index.vue // 首页 ├─static // 静态资源文件 └─uni_modules // 插件目录,用于存放uni-app的插件 ``` ## 参考文档 [http请求requestInStream接口如何使用](https://developer.huawei.com/consumer/cn/doc/architecture-guides/office-v1_2-ts_22-0000002359681920#section9526101103112) [调用ArkTS API](https://uniapp.dcloud.net.cn/tutorial/harmony/native-api.html)