Ahmad Kholid 2 年之前
父节点
当前提交
7edcdb4b66

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.24.2",
+  "version": "1.24.3",
   "description": "An extension for automating your browser by connecting blocks",
   "repository": {
     "type": "git",

+ 2 - 1
src/components/newtab/storage/StorageVariables.vue

@@ -116,7 +116,8 @@ function deleteVariable({ id }) {
 function editVariable({ id, name, value }) {
   state.id = id;
   editState.name = name;
-  editState.value = value;
+  editState.value =
+    typeof value !== 'string' ? JSON.stringify(value, null, 2) : value;
   editState.type = 'edit';
   editState.show = true;
 }

+ 1 - 1
src/components/newtab/workflow/edit/EditLoopData.vue

@@ -119,7 +119,7 @@
         :label="t('workflow.blocks.loop-data.startIndex')"
         placeholder="0"
         class="w-full mt-2"
-        @change="updateData({ startIndex: +$event || 0 })"
+        @change="updateData({ startIndex: $event })"
       />
       <ui-checkbox
         :model-value="data.resumeLastWorkflow"

+ 4 - 2
src/workflowEngine/blocksHandler/handlerCreateElement.js

@@ -45,20 +45,22 @@ async function handleCreateElement(block, { refData }) {
 
   data.preloadScripts = preloadScripts;
 
+  const isMV3 =
+    (data.javascript || data.preloadScripts.length > 0) && !this.engine.isMV2;
   const payload = {
     ...block,
     data,
     preloadCSS: data.preloadScripts.filter((item) => item.type === 'style'),
   };
 
-  if (data.javascript && !this.engine.isMV2) {
+  if (isMV3) {
     payload.data.dontInjectJS = true;
     payload.data.automaScript = getAutomaScript({ ...refData, secrets: {} });
   }
 
   await this._sendMessageToTab(payload, {}, data.runBeforeLoad ?? false);
 
-  if (data.javascript && !this.engine.isMV2) {
+  if (isMV3) {
     const target = {
       tabId: this.activeTab.id,
       frameIds: [this.activeTab.frameId || 0],

+ 13 - 4
src/workflowEngine/utils/webhookUtil.js

@@ -29,11 +29,20 @@ const renderContent = async (content, contentType) => {
         formContent = await getFile(path, { returnValue: true });
 
         if (!filename) {
-          const { pathname } = new URL(path);
-          filename = pathname.split('/').pop();
+          filename = path.split('/').pop();
         }
-      } else if (path.includes('base64')) {
-        const response = await fetch(path);
+
+        if (!formContent) throw new Error('File not found');
+      } else {
+        let base64Str = '';
+
+        if (path.includes('base64')) {
+          base64Str = path;
+        } else {
+          base64Str = `data:text/plain;base64,${window.btoa(path)}`;
+        }
+
+        const response = await fetch(base64Str);
         const result = await response.blob();
 
         formContent = result;