Browse Source

feat: update zh-cn locale

Ahmad Kholid 3 năm trước cách đây
mục cha
commit
efd7bf8e49

+ 3 - 0
src/background/workflow-engine/engine.js

@@ -2,6 +2,7 @@ import browser from 'webextension-polyfill';
 import { nanoid } from 'nanoid';
 import { tasks } from '@/utils/shared';
 import {
+  clearCache,
   toCamelCase,
   sleep,
   parseJSON,
@@ -361,6 +362,8 @@ class WorkflowEngine {
         });
       }
 
+      if (status === 'success') clearCache(this.workflow);
+
       this.isDestroyed = true;
       this.eventListeners = {};
     } catch (error) {

+ 5 - 22
src/components/newtab/workflow/WorkflowSettings.vue

@@ -66,7 +66,7 @@
           {{ t('workflow.settings.clearCache.description') }}
         </p>
       </div>
-      <ui-button @click="clearCache">
+      <ui-button @click="onClearCacheClick">
         {{ t('workflow.settings.clearCache.btn') }}
       </ui-button>
     </div>
@@ -76,8 +76,7 @@
 import { onMounted, reactive, watch } from 'vue';
 import { useI18n } from 'vue-i18n';
 import { useToast } from 'vue-toastification';
-import browser from 'webextension-polyfill';
-import { debounce, parseJSON } from '@/utils/helper';
+import { clearCache, debounce } from '@/utils/helper';
 
 const props = defineProps({
   workflow: {
@@ -131,25 +130,9 @@ const settings = reactive({
   restartTimes: 3,
 });
 
-async function clearCache() {
-  try {
-    await browser.storage.local.remove(`last-state:${props.workflow.id}`);
-
-    const flows = parseJSON(props.workflow.drawflow, null);
-    const blocks = flows && flows.drawflow.Home.data;
-
-    if (blocks) {
-      Object.values(blocks).forEach(({ name, id }) => {
-        if (name !== 'loop-data') return;
-
-        localStorage.removeItem(`index:${id}`);
-      });
-    }
-
-    toast(t('workflow.settings.clearCache.info'));
-  } catch (error) {
-    console.error(error);
-  }
+async function onClearCacheClick() {
+  const cacheCleared = await clearCache(props.workflow);
+  if (cacheCleared) toast(t('workflow.settings.clearCache.info'));
 }
 
 watch(

+ 20 - 4
src/locales/zh/newtab.json

@@ -1,6 +1,7 @@
 {
   "home": {
-    "viewAll": "查看全部"
+    "viewAll": "查看全部",
+    "communities": "社区"
   },
   "welcome": {
     "title": "欢迎使用 Automa! 🎉",
@@ -79,6 +80,12 @@
     "clickToEnable": "单击启用",
     "toggleSidebar": "切换侧栏",
     "cantEdit": "无法编辑共享的工作流",
+    "conditionBuilder": {
+      "title": "条件生成器",
+      "add": "附加条件",
+      "and": "AND",
+      "or": "OR"
+    },
     "host": {
       "title": "主机工作流程",
       "set": "设为主机工作流",
@@ -156,21 +163,29 @@
     },
     "settings": {
       "saveLog": "保存工作流日志",
+      "executedBlockOnWeb": "在网页上显示已执行的模块",
+      "clearCache": {
+        "title": "清理缓存",
+        "description": "清除工作流的缓存(状态和循环索引)",
+        "info": "成功清除工作流缓存",
+        "btn": "清理"
+      },
       "reuseLastState": {
         "title": "重用上一个工作流状态",
-        "description": "Use the state data (table, variables, and global data) from the last executed"
+        "description": "使用上次执行的工作流状态数据(表、变量和全局数据)"
       },
-      "executedBlockOnWeb": "在网页上显示已执行的模块",
       "debugMode": {
         "title": "调试模式",
-        "description": "Execute the workflow using the Chrome DevTools Protocol"
+        "description": "使用 Chrome DevTools 协议执行工作流"
       },
       "restartWorkflow": {
         "for": "重新启动",
         "times": "次数"
+        "description": "工作流可以重启的最大次数"
       },
       "onError": {
         "title": "工作流出错时",
+        "description": "设置当工作流发生错误时要执行的操作",
         "items": {
           "keepRunning": "继续运行",
           "stopWorkflow": "停止工作流",
@@ -222,6 +237,7 @@
     "messages": {
       "url-empty": "URL 为空",
       "invalid-url": "URL 无效",
+      "no-permission": "没有权限",
       "conditions-empty": "条件为空",
       "invalid-proxy-host": "无效的代理主机",
       "workflow-disabled": "工作流已禁用",

+ 24 - 0
src/utils/helper.js

@@ -1,3 +1,5 @@
+import browser from 'webextension-polyfill';
+
 export function scrollIfNeeded(element) {
   const { top, left, bottom, right } = element.getBoundingClientRect();
   const isInViewport =
@@ -198,3 +200,25 @@ export function debounce(callback, time = 200) {
     });
   };
 }
+
+export async function clearCache(workflow) {
+  try {
+    await browser.storage.local.remove(`last-state:${workflow.id}`);
+
+    const flows = parseJSON(workflow.drawflow, null);
+    const blocks = flows && flows.drawflow.Home.data;
+
+    if (blocks) {
+      Object.values(blocks).forEach(({ name, id }) => {
+        if (name !== 'loop-data') return;
+
+        localStorage.removeItem(`index:${id}`);
+      });
+    }
+
+    return true;
+  } catch (error) {
+    console.error(error);
+    return false;
+  }
+}