|
@@ -348,19 +348,56 @@ async function getTaskUrlMapData(activityId) {
|
|
|
|
|
|
|
|
async function getTaskMapData(activityId) {
|
|
async function getTaskMapData(activityId) {
|
|
|
const codeString = await getFlowManagementJs(activityId);
|
|
const codeString = await getFlowManagementJs(activityId);
|
|
|
- const regex = /var taskMap = JSON\.parse\('({.*})'\);/;
|
|
|
|
|
- const match = codeString.match(regex);
|
|
|
|
|
- if (match) {
|
|
|
|
|
- const taskMapContent = match[1]; // 获取 JSON 字符串内容
|
|
|
|
|
- let taskMapObject = null;
|
|
|
|
|
- try {
|
|
|
|
|
- taskMapObject = JSON.parse(taskMapContent);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
|
|
+ if (!codeString) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ const codeSegment = codeString.split("\n\n");
|
|
|
|
|
+ const codeDataStr = codeSegment[1];
|
|
|
|
|
+ if (!codeDataStr) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ codeDataStr = codeDataStr.trim();
|
|
|
|
|
+ if (codeDataStr.indexOf('var taskMap') > -1) {
|
|
|
|
|
+ const regex = /var taskMap = JSON\.parse\('({.*})'\);/;
|
|
|
|
|
+ const match = codeString.match(regex);
|
|
|
|
|
+ if (match) {
|
|
|
|
|
+ const taskMapContent = match[1]; // 获取 JSON 字符串内容
|
|
|
|
|
+ let taskMapObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ taskMapObject = JSON.parse(taskMapContent);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ return taskMapObject;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const regex = /([a-zA-Z_]\w*)\s*\(/g; // 匹配函数名称,后接左右括号
|
|
|
|
|
+ const matches = [];
|
|
|
|
|
+ let match;
|
|
|
|
|
+ while ((match = regex.exec(codeString)) !== null) {
|
|
|
|
|
+ matches.push(match[1]); // 将匹配的函数名称添加到数组中
|
|
|
|
|
+ }
|
|
|
|
|
+ // 去重
|
|
|
|
|
+ const uniqueMatches = [...new Set(matches)];
|
|
|
|
|
+ let taskMapObject = null;
|
|
|
|
|
+ if (uniqueMatches.length == 1) {
|
|
|
|
|
+ taskMapObject = {};
|
|
|
|
|
+ let funcName = uniqueMatches[0];
|
|
|
|
|
+ const regex = new RegExp(`${funcName}\\("([^"]+)",\\s*({.*?})\\);`, 'g');
|
|
|
|
|
+ let match;
|
|
|
|
|
+ while ((match = regex.exec(codeDataStr)) !== null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const id = match[1];
|
|
|
|
|
+ const urlObject = JSON.parse(match[2]);
|
|
|
|
|
+ taskMapObject[id] = urlObject;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return taskMapObject;
|
|
return taskMapObject;
|
|
|
}
|
|
}
|
|
|
- return null;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function getFlowManagementJs(activityId) {
|
|
async function getFlowManagementJs(activityId) {
|
|
@@ -386,7 +423,7 @@ async function getFlowManagementJs(activityId) {
|
|
|
};
|
|
};
|
|
|
let result = await magicJS.http.get(options).then(response => {
|
|
let result = await magicJS.http.get(options).then(response => {
|
|
|
try {
|
|
try {
|
|
|
- let rspData = response.body;
|
|
|
|
|
|
|
+ let rspData = response.body.trim();
|
|
|
magicJS.logger.info(`FlowManagementJs=${rspData}`);
|
|
magicJS.logger.info(`FlowManagementJs=${rspData}`);
|
|
|
return rspData;
|
|
return rspData;
|
|
|
} catch (e) {
|
|
} catch (e) {
|