@@ -123,7 +123,7 @@ remote_websocket_server_url_only_ws=
123123![ ] ( https://cloud.zerlei.cn/f/3lfW/Screenshot_20250913_005106.png )
124124如同前台工具页面描述,你需要首先定义一个config. 指定打印机 纸张大小等.然后再根据config,去发出一个print 请求.
125125
126- 参考注释: 1. [ config] ( https://wpp.zerlei.cn/structPrinterConfig ) 2. [ page] ( https://wpp.zerlei.cn/structPrintedPage )
126+ 参考注释: 1.[ config] ( https://wpp.zerlei.cn/structPrinterConfig ) 2. [ page] ( https://wpp.zerlei.cn/structPrintedPage )
127127
128128
129129
@@ -153,23 +153,118 @@ fetch("/command", {
153153
154154- websocket 使用textmessagae
155155
156+ ### 1.0 基础数据格式
157+
158+ [ 参考] ( https://wpp.zerlei.cn/WebInterface_8h )
159+
160+ ** 基本返回:**
161+
162+ ``` cpp
163+ struct RespBase {
164+ RespBase() = delete;
165+ /**
166+ * @brief 是否成功
167+ *
168+ * /
169+ bool is_success = false;
170+ /**
171+ * @brief uid,websocket 的消息request 和 resp 不限制对应关系,uid 保证了他们的联系, 也就是 uid 相同 的 request 和 response 对应
172+ * 由request端生成 -> 对应 respnse 携带
173+ * 可选的,如果使用http 请求,就不需要
174+ * /
175+ std::optional<int > uid;
176+ };
177+
178+ ```
179+ 所有返回均继承此返回.
180+
181+
182+ **错误返回:**
183+
184+ ```cpp
185+ struct RespError : RespBase {
186+ /**
187+ * @brief 错误信息
188+ *
189+ */
190+ QString msg{""};
191+ };
192+
193+ ```
194+
195+ 对应的json格式:
196+
197+ ``` json
198+ {
199+ "is_success" : false ,
200+ "uid" : 0 ,
201+ "msg" : " unknow error!"
202+ }
203+
204+ ```
156205
157206### 1.1 获得工具安装电脑上的打印机和纸张信息
158207
208+ 此机器上,可以获取的打印机驱动.
209+ 建议在[ config] ( https://wpp.zerlei.cn/structPrinterConfig ) 中,设置is_use_printer_default_config = 1; 使用打印机默认配置
210+
211+ [参考](https:// wpp.zerlei.cn/structRequestGetPrintersInfo)
212+
213+ 例如 request json:
214+
215+ ```json
216+ {
217+ "method":"get_printers_info",
218+ "uid":0
219+ }
220+ ```
221+ response json:
222+
223+ ``` json
224+ {
225+ "is_success" : true ,
226+ "uid" : 0 ,
227+ "data" :[
228+ {
229+ "printer_name" : " CUPS" ,
230+ "supported_paper_names" :[
231+ " A4" ,
232+ " A1"
233+ ]
234+ }
235+ ]
236+ }
237+
238+ ```
159239### 1.2 添加一个打印配置
160240
241+ [ 参考] ( https://wpp.zerlei.cn/structRespAddConfig )
242+
161243### 1.3 获得打印配置
162244
245+ [ 参考] ( https://wpp.zerlei.cn/structRequestGetAllConfigs )
246+
163247### 1.4 删除一个打印配置
164248
249+ [ 参考] ( https://wpp.zerlei.cn/structRequestDelConfig )
250+
165251### 1.5 更改一个打印配置
166252
253+ [ 参考] ( https://wpp.zerlei.cn/structRequestUpdateConfig )
254+
167255### 1.6 发一个打印命令
168256
257+ [ 参考] ( https://wpp.zerlei.cn/structRequestPrintPage )
258+
169259### 1.7 获得打印过的页面
170260
171- ### 1.8 获得 websocket 端口
261+ [ 参考] ( https://wpp.zerlei.cn/structRequestGetPagesDesc )
262+
263+ ### 1.8 获得 websocket server 端口
264+
265+ > 此工具的前端帮助页面被后台http服务托管,所以httpserver地址等于` window.herf ` ,是已知的. 但主要交互方式使用websocket
172266
267+ [ 参考] ( https://wpp.zerlei.cn/structRequestGetWebsocketServerPort )
173268
174269## 2 源码和编译
175270
0 commit comments