Browse Source

对接剪切板

huangxiaojing 3 years ago
parent
commit
218e3df621

+ 27 - 1
screenAndroid/WXdraw.js

@@ -63,7 +63,16 @@ function doConnect() {
 			},
 			"type": "bitRate"
 		}
-		wsss.send(JSON.stringify(bitRate))
+		wsss.send(JSON.stringify(bitRate));
+		// 获取实时截图
+		var screenPic = {
+			type: 'getScreenPic',
+      data: {
+        taskUid: '346789',
+        intervalTime: 0
+      }
+		}
+		wsss.send(JSON.stringify(screenPic));
 	};
 	wsss.onerror = function (evt) {
 		wsss.close();
@@ -74,6 +83,23 @@ function doConnect() {
 			})
 		}
 	};
+	wsss.onmessage = function(res) {
+		var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
+		if (result.type === 'cutting') {
+			if (result.data.status === 0) {
+				$.toast('复制成功', "text");
+			} else {
+				$.toast(result.msg, "text");
+			}
+			return
+		}
+		var unit8Arr = new Uint8Array(result);
+		if (unit8Arr[0] == 0x68 && unit8Arr[1] == 0x09) {
+			unit8Arr = unit8Arr.slice(12,unit8Arr.length-2);
+			var base64 = 'data:image/jpg;base64,' + window.btoa(String.fromCharCode(...new Uint8Array(unit8Arr)));
+			$(".loading_sceen_pic").attr('src', base64)
+		}
+	}
 }
 
 $('body').on("click", function () {

+ 7 - 20
screenAndroid/WXtrialInterface.html

@@ -90,7 +90,7 @@
 				</div>
 			</div>
 		</div>
-		<div class="loading"></div>
+		<img class="loading loading_sceen_pic" />
 	</div>
 	<div class="mask">
 		<div class="box-shear-plate"></div>
@@ -472,26 +472,13 @@
 			});
 		}
 		function handleCopy(content) {
-			$.ajax({
-				url: baseUrl + "/api/wsi/v1/config/cut",
-				data: JSON.stringify({
-					str: content,
-					userCardId: form.userCardId
-				}),
-				headers: {
-					'Authorization': form.token
-				},
-				contentType: "application/json;charset=UTF-8",
-				type: 'post',
-				dataType: 'json',
-				success: function (res) {
-					if (res.status === 0) {
-						$.toast('复制成功', "text");
-					} else {
-						$.toast(res.msg, "text");
-					}
+			var cutting = {
+				"type":"cutting",
+				"data":{
+						"str": content
 				}
-			})
+			};
+			wsss.send(JSON.stringify(cutting));
 		}
 		// 删除剪贴板
 		function handleDelete(id) {

+ 0 - 5
screenAndroid/css/WXtrialInterface.css

@@ -328,11 +328,6 @@ html {
 	z-index: 1;
 	left: 0;
 	top: 0;
-	display: flex;
-	align-items: center;
-	justify-content: center;
-	background: url(../img/homebg.jpg) no-repeat;
-	background-size: 100% 100%;
 }
 
 .mask {

+ 26 - 0
screenIos/WXdraw.js

@@ -64,6 +64,15 @@ function doConnect() {
 			"type": "bitRate"
 		}
 		wsss.send(JSON.stringify(bitRate))
+		// 获取实时截图
+		var screenPic = {
+			type: 'getScreenPic',
+      data: {
+        taskUid: '346789',
+        intervalTime: 0
+      }
+		}
+		wsss.send(JSON.stringify(screenPic));
 	};
 	wsss.onerror = function () {
 		wsss.close();
@@ -74,6 +83,23 @@ function doConnect() {
 			})
 		}
 	};
+	wsss.onmessage = function(res) {
+		var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
+		if (result.type === 'cutting') {
+			if (result.data.status === 0) {
+				$.toast('复制成功', "text");
+			} else {
+				$.toast(result.msg, "text");
+			}
+			return
+		}
+		var unit8Arr = new Uint8Array(result);
+		if (unit8Arr[0] == 0x68 && unit8Arr[1] == 0x09) {
+			unit8Arr = unit8Arr.slice(12,unit8Arr.length-2);
+			var base64 = 'data:image/jpg;base64,' + window.btoa(String.fromCharCode(...new Uint8Array(unit8Arr)));
+			$(".loading_sceen_pic").attr('src', base64)
+		}
+	}
 }
 $('body').on("click", function () {
 	draw_graph('pencil', this)

+ 9 - 22
screenIos/WXtrialInterface.html

@@ -88,7 +88,7 @@
 				</div>
 			</div>
 		</div>
-		<div class="loading"></div>
+		<img class="loading loading_sceen_pic" />
 	</div>
 	<div class="mask">
 		<div class="box-shear-plate"></div>
@@ -280,26 +280,13 @@
 			});
 		}
 		function handleCopy(content) {
-			$.ajax({
-				url: baseUrl + "/api/wsi/v1/config/cut",
-				data: JSON.stringify({
-					str: content,
-					userCardId: form.userCardId
-				}),
-				headers: {
-					'Authorization': form.token
-				},
-				contentType: "application/json;charset=UTF-8",
-				type: 'post',
-				dataType: 'json',
-				success: function (res) {
-					if (res.status === 0) {
-						$.toast('复制成功', "text");
-					} else {
-						$.toast(res.msg, "text");
-					}
+			var cutting = {
+				"type":"cutting",
+				"data":{
+						"str": content
 				}
-			})
+			}
+			wsss.send(JSON.stringify(cutting));
 		}
 		// 删除剪贴板
 		function handleDelete(id) {
@@ -687,9 +674,9 @@
 			if (input[0] == 0x68) {
 				if(input[23] == 0x5c){
 					if(CheckVerifyCode(input)) {
-						decodeWoker.postMessage(ConfigChannel('RK3923C1201900139'));					
+						webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));					
 						var checkBuffer = GetScreenState();
-						decodeWoker.postMessage(checkBuffer);
+						webSocketWorker.postMessage(checkBuffer);
 					}
 					else {
 						$.toast("画面异常,请重新进入", "text");

+ 0 - 5
screenIos/css/WXtrialInterface.css

@@ -328,11 +328,6 @@ html {
 	z-index: 1;
 	left: 0;
 	top: 0;
-	display: flex;
-	align-items: center;
-	justify-content: center;
-	background: url(../img/homebg.png) no-repeat;
-	background-size: 100% 100%;
 }
 
 .mask {