| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 36 | 33 | ||
| entry/ | 06-May-2025 | - | 1,534 | 1,402 | ||
| hvigor/ | 06-May-2025 | - | 23 | 22 | ||
| screenshots/device/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 143 | 12 | 11 | |
| README.md | D | 06-May-2025 | 646 | 16 | 9 | |
| README_zh.md | D | 06-May-2025 | 2.7 KiB | 76 | 53 | |
| build-profile.json5 | D | 06-May-2025 | 1 KiB | 43 | 41 | |
| hvigorfile.ts | D | 06-May-2025 | 158 | 2 | 1 | |
| hvigorw | D | 06-May-2025 | 2.1 KiB | 62 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 72 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 808 | 26 | 25 | |
| ohosTest.md | D | 06-May-2025 | 1.8 KiB | 22 | 18 |
README.md
1# RPC 2 3### Introduction 4 5This sample shows the data exchange between the frontend and backend of a device. After the offering and quantity are selected at the frontend, the backend calculates the result and displays it at the frontend. 6 7### Usage 8 91. Touch the blank box of an offering type. The offering selection list is displayed. Select an offering. The corresponding content is displayed in the blank box. 102. Touch **+** or **-** next to the offering selection box and select the quantity of the offering. 113. Touch **Confirm an order**. The total price is displayed. 12 13### Constraints 14 15This sample can only be run on standard-system devices. 16
README_zh.md
1# RPC连接 2 3### 介绍 4 5本示例使用[@ohos.rpc](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ipc-kit/js-apis-rpc.md) 相关接口,实现了一个前台选择商品和数目,后台计算总价的功能,使用rpc进行前台和后台的通信。 6 7### 效果预览 8 9|主页|选择列表| 10|-----------------|----------------------| 11||| 12 13使用说明: 14 151. 点击商品种类的空白方框,弹出商品选择列表,选择点击对应的商品,空白方框显示相应内容。 16 172. 点击商品选择框后的 **+** 或 **-** 按钮,选择商品所对应的数量。 18 193. 点击 **Confirm an order** 按钮,根据相应的菜品数量与单价,计算出总价并显示。 20 21### 工程目录 22``` 23entry/src/main/ets/ 24|---common 25| |---CustomDialogList.ets // 选项弹窗 26| |---FlexList.ets // 首页视频种类列表 27| |---Logger.ets // 日志工具 28| |---TitleBar.ets // 头部 29|---entryability 30| |---EntryAbility.ets // 入口文件 31|---model 32| |---OptionsData.ets // 选项懒加载 33| |---ProcessData.ets // 封装了获取总价的api 34| |---ReceivedData.ets // 重写了请求方法 35|---muck 36| |---MyData.ets // muck数据 37|---pages 38| |---Index.ets // 首页 39``` 40 41### 具体实现 42 43* 发送数据:在首页的sortString()中通过rpc.MessageSequence.create()创建MessageSequence对象,然后通过MessageSequence.writeStringArray()将 44 我们的处理过的购物数据写入MessageSequence对象中,通过rpc.RemoteObject.sendMessageRequest()将我们得出总价所需要的参数发送到进程中, 45 源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) ; 46 47* 读取数据:处理MessageRequest请求的接口封装在ReceivedData里面,在这里接收传递来的数据,然后经过处理得出总价, 48 并通过rpc.MessageParcel.writeInt()写入MessageParcel对象,源码参考:[ReceivedData.ets](entry/src/main/ets/model/ReceivedData.ets) 。 49 50### 相关权限 51 52不涉及。 53 54### 依赖 55 56不涉及。 57 58### 约束与限制 59 601.本示例仅支持在标准系统上运行。 61 622.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400 构建 2023年4月7日)及以上版本才可编译运行。 63 643.本示例已适配API version 9版本SDK,版本号:3.2.11.9。 65 66### 下载 67 68如需单独下载本工程,执行如下命令: 69 70``` 71git init 72git config core.sparsecheckout true 73echo code/BasicFeature/Connectivity/RPC/ > .git/info/sparse-checkout 74git remote add origin https://gitee.com/openharmony/applications_app_samples.git 75git pull origin master 76```