Ahmad Kholid 3 年之前
父節點
當前提交
3480b18787

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.10.0",
+  "version": "1.10.1",
   "description": "An extension for automating your browser by connecting blocks",
   "license": "MIT",
   "repository": {

+ 1 - 1
src/background/index.js

@@ -155,7 +155,7 @@ async function checkVisitWebTriggers(tabId, tabUrl) {
 
     const matchUrl = tabUrl.match(isRegex ? new RegExp(url, 'g') : url);
 
-    return matchUrl && id !== workflowState.workflowId;
+    return matchUrl && id !== workflowState?.workflowId;
   });
 
   if (triggeredWorkflow) {

+ 5 - 1
src/content/handleTestCondition.js

@@ -13,7 +13,11 @@ function handleConditionElement({ data, type }) {
     exists: () => Boolean(element),
     notExists: () => !element,
     text: () => element?.innerText ?? null,
-    visibleScreen: () => visibleInViewport(element),
+    visibleScreen: () => {
+      if (!element) return false;
+
+      return visibleInViewport(element);
+    },
     visible: () => {
       if (!element) return false;
 

+ 2 - 2
src/content/services/recordWorkflow/App.vue

@@ -146,7 +146,7 @@
               >
                 <option value="" selected>Select column [none]</option>
                 <option
-                  v-for="column in selectState.workflowColumns"
+                  v-for="column in addBlockState.workflowColumns"
                   :key="column.id"
                   :value="column.id"
                 >
@@ -277,7 +277,7 @@ function addFlowItem() {
       saveData,
       assignVariable,
       waitForSelector: true,
-      column: addBlockState.column,
+      dataColumn: addBlockState.column,
       variableName: addBlockState.varName,
       selector: selectState.list
         ? selectState.listSelector

+ 28 - 30
src/popup/pages/Recording.vue

@@ -170,40 +170,38 @@ function generateDrawflow(startBlock, startBlockData) {
 }
 async function stopRecording() {
   if (state.isGenerating) return;
-  if (state.flows.length === 0) {
-    router.push('/');
-    return;
-  }
 
   try {
     state.isGenerating = true;
 
-    if (state.workflowId) {
-      const workflow = Workflow.find(state.workflowId);
-      const drawflow =
-        typeof workflow.drawflow === 'string'
-          ? JSON.parse(workflow.drawflow)
-          : workflow.drawflow;
-      const node = drawflow.drawflow.Home.data[state.connectFrom.id];
-      const updatedDrawflow = generateDrawflow(state.connectFrom, node);
-
-      Object.assign(drawflow.drawflow.Home.data, updatedDrawflow);
-
-      await Workflow.update({
-        where: state.workflowId,
-        data: {
-          drawflow: JSON.stringify(drawflow),
-        },
-      });
-    } else {
-      const drawflow = generateDrawflow();
-
-      await Workflow.insert({
-        data: {
-          name: state.name,
-          drawflow: JSON.stringify(drawflow),
-        },
-      });
+    if (state.flows.length !== 0) {
+      if (state.workflowId) {
+        const workflow = Workflow.find(state.workflowId);
+        const drawflow =
+          typeof workflow.drawflow === 'string'
+            ? JSON.parse(workflow.drawflow)
+            : workflow.drawflow;
+        const node = drawflow.drawflow.Home.data[state.connectFrom.id];
+        const updatedDrawflow = generateDrawflow(state.connectFrom, node);
+
+        Object.assign(drawflow.drawflow.Home.data, updatedDrawflow);
+
+        await Workflow.update({
+          where: state.workflowId,
+          data: {
+            drawflow: JSON.stringify(drawflow),
+          },
+        });
+      } else {
+        const drawflow = generateDrawflow();
+
+        await Workflow.insert({
+          data: {
+            name: state.name,
+            drawflow: JSON.stringify(drawflow),
+          },
+        });
+      }
     }
 
     await browser.storage.local.remove(['isRecording', 'recording']);

+ 19 - 8
src/utils/referenceData/mustacheReplacer.js

@@ -104,18 +104,29 @@ function replacer(str, { regex, tagLen, modifyPath, data }) {
     let key = match.slice(tagLen, -tagLen).trim();
 
     if (!key) return '';
-    if (modifyPath && typeof modifyPath === 'function') {
+
+    let result = '';
+    const isFunction = extractStrFunction(key);
+    const funcRef = isFunction && data.functions[isFunction.name];
+
+    if (modifyPath && !funcRef) {
       key = modifyPath(key);
     }
 
-    let result = '';
-    const funcRef = extractStrFunction(key);
+    if (funcRef) {
+      const funcParams = isFunction.params.map((param) => {
+        const { value, list } = replacer(param, {
+          data,
+          tagLen: 1,
+          regex: /\[(.*?)\]/,
+        });
+
+        Object.assign(replaceResult.list, list);
+
+        return value;
+      });
 
-    if (funcRef && data.functions[funcRef.name]) {
-      result = data.functions[funcRef.name]?.apply(
-        { refData: data },
-        funcRef.params
-      );
+      result = funcRef.apply({ refData: data }, funcParams);
     } else {
       const { dataKey, path } = keyParser(key, data);