From 2af5f043b60c1f7ac38ecccc8f5bf44743134325 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 12 十二月 2025 18:08:00 +0800
Subject: [PATCH] test

---
 api/request.js |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/api/request.js b/api/request.js
index 421f7cc..7f74ded 100644
--- a/api/request.js
+++ b/api/request.js
@@ -14,15 +14,24 @@
 	apiCount: {
 		agv_state: 0,
 		laser_data: 0,
-		current_teaching:0
+		current_teaching: 0
+	},
+
+	parseJson(str) {
+		try {
+			const obj = JSON.parse(str)
+			return obj
+		} catch (ex) {
+			return undefined
+		}
 	},
 	addLog(item) {
 		if (!getApp().globalData.withLog) {
 			return
 		}
 		if (item.statusCode == 200) {
-			const ret = JSON.parse(item.data)
-			if (ret.code == 0) {
+			const ret = this.parseJson(item.data)
+			if (ret?.code === 0) {
 				if (item.url.indexOf("get_agv_state") > 0) {
 
 					if (this.apiCount.agv_state % 20 != 0) {
@@ -32,14 +41,14 @@
 					this.apiCount.agv_state = 1;
 				}
 				if (item.url.indexOf("get_current_teaching_data") > 0) {
-				
+
 					if (this.apiCount.current_teaching % 20 != 0) {
 						this.apiCount.current_teaching++;
 						return
 					}
 					this.apiCount.current_teaching = 1;
 				}
-				
+
 				// if (item.url.indexOf("laser_data") > 0) {
 
 				// 	if (ret.data?.base_map?.image_base64) {
@@ -84,6 +93,7 @@
 		}
 		const list = session.getValue("request_log") || []
 
+
 		list.unshift(item)
 
 		if (list.length > 512) {
@@ -105,8 +115,8 @@
 		options.method = options.method || this.common.method;
 		options.dataType = options.dataType || this.common.dataType;
 
-		if (options.url.indexOf("get_agv_state") < 0 && options.url.indexOf("laser_data") < 0
-		 && options.url.indexOf("taskGroupStatus") < 0 &&options.url.indexOf("get_current_teaching_data") < 0) {
+		if (options.url.indexOf("get_agv_state") < 0 && options.url.indexOf("laser_data") < 0 &&
+			options.url.indexOf("taskGroupStatus") < 0 && options.url.indexOf("get_current_teaching_data") < 0) {
 			console.log("url", options.url, options.data)
 		}
 		return new Promise((resolve, reject) => {
@@ -118,8 +128,10 @@
 				method: options.method,
 				dataType: options.dataType,
 				success: (result) => {
-					if (options.url.indexOf("get_agv_state") < 0 && options.url.indexOf("laser_data") < 0 
-							&& options.url.indexOf("taskGroupStatus") < 0 &&options.url.indexOf("get_current_teaching_data") < 0) { //
+					if (options.url.indexOf("get_agv_state") < 0 && options.url.indexOf(
+							"laser_data") < 0 &&
+						options.url.indexOf("taskGroupStatus") < 0 && options.url.indexOf(
+							"get_current_teaching_data") < 0) { //
 						console.log("result", result)
 					}
 

--
Gitblit v1.9.1