|
@@ -1,67 +1,83 @@
|
|
|
<template>
|
|
|
- <div class="workflow-settings">
|
|
|
- <div class="mb-4 flex">
|
|
|
- <div class="flex-1">
|
|
|
- <p class="mb-1 capitalize">
|
|
|
+ <div
|
|
|
+ class="workflow-settings space-y-4 divide-y dark:divide-gray-700 divide-gray-100"
|
|
|
+ >
|
|
|
+ <div class="flex items-center">
|
|
|
+ <div class="mr-4 flex-1">
|
|
|
+ <p>
|
|
|
{{ t('workflow.settings.onError.title') }}
|
|
|
</p>
|
|
|
- <ui-select v-model="settings.onError" class="w-full max-w-sm">
|
|
|
- <option v-for="item in onError" :key="item.id" :value="item.id">
|
|
|
- {{ t(`workflow.settings.onError.items.${item.name}`) }}
|
|
|
- </option>
|
|
|
- </ui-select>
|
|
|
- </div>
|
|
|
- <label v-if="settings.onError === 'restart-workflow'" class="ml-2">
|
|
|
- <p class="mb-1 capitalize">
|
|
|
- {{ t('workflow.settings.restartWorkflow.for') }}
|
|
|
+ <p class="text-gray-600 dark:text-gray-200 text-sm leading-tight">
|
|
|
+ {{ t('workflow.settings.onError.description') }}
|
|
|
</p>
|
|
|
- <div class="flex items-center bg-input transition-colors rounded-lg">
|
|
|
- <input
|
|
|
- v-model.number="settings.restartTimes"
|
|
|
- type="number"
|
|
|
- class="py-2 px-4 w-32 rounded-lg bg-transparent"
|
|
|
- />
|
|
|
- <span class="px-2">
|
|
|
- {{ t('workflow.settings.restartWorkflow.times') }}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </label>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <p class="mb-1 capitalize">
|
|
|
- {{ t('workflow.settings.blockDelay.title') }}
|
|
|
- <span :title="t('workflow.settings.blockDelay.description')">
|
|
|
- 🛈
|
|
|
+ </div>
|
|
|
+ <ui-select v-model="settings.onError">
|
|
|
+ <option v-for="item in onError" :key="item.id" :value="item.id">
|
|
|
+ {{ t(`workflow.settings.onError.items.${item.name}`) }}
|
|
|
+ </option>
|
|
|
+ </ui-select>
|
|
|
+ <div
|
|
|
+ v-if="settings.onError === 'restart-workflow'"
|
|
|
+ :title="t('workflow.settings.restartWorkflow.description')"
|
|
|
+ class="flex items-center bg-input transition-colors rounded-lg ml-4"
|
|
|
+ >
|
|
|
+ <input
|
|
|
+ v-model.number="settings.restartTimes"
|
|
|
+ type="number"
|
|
|
+ class="py-2 pl-2 text-right appearance-none w-12 rounded-lg bg-transparent"
|
|
|
+ />
|
|
|
+ <span class="px-2 text-sm">
|
|
|
+ {{ t('workflow.settings.restartWorkflow.times') }}
|
|
|
</span>
|
|
|
- </p>
|
|
|
- <ui-input
|
|
|
- v-model.number="settings.blockDelay"
|
|
|
- type="number"
|
|
|
- class="w-full max-w-sm"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="flex mt-6">
|
|
|
- <ui-switch v-model="settings.debugMode" class="mr-4" />
|
|
|
- <p class="capitalize">{{ t('workflow.settings.debugMode') }}</p>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="flex mt-6">
|
|
|
- <ui-switch v-model="settings.reuseLastState" class="mr-4" />
|
|
|
- <p class="capitalize">{{ t('workflow.settings.reuseLastState') }}</p>
|
|
|
+ <div class="flex items-center pt-4">
|
|
|
+ <div class="mr-4 flex-1">
|
|
|
+ <p>
|
|
|
+ {{ t('workflow.settings.blockDelay.title') }}
|
|
|
+ </p>
|
|
|
+ <p class="text-gray-600 dark:text-gray-200 text-sm leading-tight">
|
|
|
+ {{ t('workflow.settings.blockDelay.description') }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <ui-input v-model.number="settings.blockDelay" type="number" />
|
|
|
</div>
|
|
|
- <div class="flex mt-6">
|
|
|
- <ui-switch v-model="settings.saveLog" class="mr-4" />
|
|
|
- <p class="capitalize">{{ t('workflow.settings.saveLog') }}</p>
|
|
|
+ <div
|
|
|
+ v-for="item in settingItems"
|
|
|
+ :key="item.id"
|
|
|
+ class="flex items-center pt-4"
|
|
|
+ >
|
|
|
+ <div class="mr-4 flex-1">
|
|
|
+ <p>
|
|
|
+ {{ item.name }}
|
|
|
+ </p>
|
|
|
+ <p class="text-gray-600 dark:text-gray-200 text-sm leading-tight">
|
|
|
+ {{ item.description }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <ui-switch v-model="settings[item.id]" class="mr-4" />
|
|
|
</div>
|
|
|
- <div class="flex mt-6">
|
|
|
- <ui-switch v-model="settings.executedBlockOnWeb" class="mr-4" />
|
|
|
- <p class="capitalize">{{ t('workflow.settings.executedBlockOnWeb') }}</p>
|
|
|
+ <div class="flex items-center pt-4">
|
|
|
+ <div class="mr-4 flex-1">
|
|
|
+ <p>
|
|
|
+ {{ t('workflow.settings.clearCache.title') }}
|
|
|
+ </p>
|
|
|
+ <p class="text-gray-600 dark:text-gray-200 text-sm leading-tight">
|
|
|
+ {{ t('workflow.settings.clearCache.description') }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <ui-button @click="clearCache">
|
|
|
+ {{ t('workflow.settings.clearCache.btn') }}
|
|
|
+ </ui-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { onMounted, reactive, watch } from 'vue';
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
-import { debounce } from '@/utils/helper';
|
|
|
+import { useToast } from 'vue-toastification';
|
|
|
+import browser from 'webextension-polyfill';
|
|
|
+import { debounce, parseJSON } from '@/utils/helper';
|
|
|
|
|
|
const props = defineProps({
|
|
|
workflow: {
|
|
@@ -72,6 +88,7 @@ const props = defineProps({
|
|
|
const emit = defineEmits(['update']);
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
+const toast = useToast();
|
|
|
|
|
|
const onError = [
|
|
|
{
|
|
@@ -87,11 +104,54 @@ const onError = [
|
|
|
name: 'restartWorkflow',
|
|
|
},
|
|
|
];
|
|
|
+const settingItems = [
|
|
|
+ {
|
|
|
+ id: 'debugMode',
|
|
|
+ name: t('workflow.settings.debugMode.title'),
|
|
|
+ description: t('workflow.settings.debugMode.description'),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'reuseLastState',
|
|
|
+ name: t('workflow.settings.reuseLastState.title'),
|
|
|
+ description: t('workflow.settings.reuseLastState.description'),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'saveLog',
|
|
|
+ name: t('workflow.settings.saveLog'),
|
|
|
+ description: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'executedBlockOnWeb',
|
|
|
+ name: t('workflow.settings.executedBlockOnWeb'),
|
|
|
+ description: '',
|
|
|
+ },
|
|
|
+];
|
|
|
|
|
|
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);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
watch(
|
|
|
settings,
|
|
|
debounce((newSettings) => {
|