xiongzhu 2 лет назад
Родитель
Сommit
dcfc0d0176
3 измененных файлов с 137 добавлено и 8 удалено
  1. 2 0
      src/enums/index.js
  2. 132 5
      src/views/CreateTask.vue
  3. 3 3
      src/views/TaskView.vue

+ 2 - 0
src/enums/index.js

@@ -40,5 +40,7 @@ export const TaskType = {
     removeLiquidity: 'removeLiquidity',
     addLiquiditySyncSwap: 'addLiquiditySyncSwap',
     removeLiquiditySyncSwap: 'removeLiquiditySyncSwap',
+    addLiquidityMute: 'addLiquidityMute',
+    removeLiquidityMute: 'removeLiquidityMute',
     mint: 'mint'
 }

+ 132 - 5
src/views/CreateTask.vue

@@ -18,12 +18,15 @@
                             </ElIcon>
                         </ElFormItem>
                         <ElFormItem prop="type">
-                            <ElSelect v-model="item.type">
+                            <!-- <ElSelect v-model="item.type">
                                 <ElOption v-for="key in TaskType" :key="key" :label="TaskType[key]" :value="key" />
-                            </ElSelect>
+                            </ElSelect> -->
+                            <ElCascader v-model="item.type" :options="options" class="w-52" />
                         </ElFormItem>
 
-                        <template v-if="item.type !== 'removeLiquidity' && item.type !== 'mint'">
+                        <template
+                            v-if="item.type && item.type.length && !/removeLiquidity|mint/.test(item.type.slice(-1))"
+                        >
                             <ElFormItem prop="amountType">
                                 <ElRadioGroup v-model="item.amountType">
                                     <ElRadio label="amount">随机金额</ElRadio>
@@ -72,7 +75,7 @@
 
                         <div class="flex-1"></div>
                         <ElFormItem class="">
-                            <ElButton :icon="TrashX" type="danger" @click="removeItem(i)">删除</ElButton>
+                            <ElButton :icon="TrashX" type="danger" @click="removeItem(i)" title="删除"></ElButton>
                         </ElFormItem>
                     </ElForm>
                 </ElCard>
@@ -122,6 +125,130 @@ import { ElMessage } from 'element-plus'
 import { http } from '@/plugins/http'
 import { useStorage } from '@vueuse/core'
 
+const options = [
+    {
+        label: '跨链',
+        value: 'bridge',
+        children: [
+            {
+                label: 'ETH→ZK',
+                value: 'eth2zk',
+                children: [
+                    {
+                        label: '官方',
+                        value: 'bridge2zk'
+                    },
+                    {
+                        label: '小飞碟',
+                        value: 'orbiter2zk'
+                    }
+                ]
+            },
+            {
+                label: 'ZK→ETH',
+                value: 'zk2eth',
+                children: [
+                    {
+                        label: '官方',
+                        value: 'bridge2eth'
+                    },
+                    {
+                        label: '小飞碟',
+                        value: 'orbiter2eth'
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        label: 'Swap',
+        value: 'swap',
+        children: [
+            {
+                label: 'ETH→USDC',
+                value: 'eth2usdc',
+                children: [
+                    {
+                        label: 'iZUMi',
+                        value: 'swapUsdc'
+                    },
+                    {
+                        label: 'SyncSwap',
+                        value: 'syncSwapUsdc'
+                    },
+                    {
+                        label: 'Mute',
+                        value: 'muteSwapUsdc'
+                    }
+                ]
+            },
+            {
+                label: 'USDC→ETH',
+                value: 'usdc2eth',
+                children: [
+                    {
+                        label: 'iZUMi',
+                        value: 'swapEth'
+                    },
+                    {
+                        label: 'SyncSwap',
+                        value: 'syncSwapEth'
+                    },
+                    {
+                        label: 'Mute',
+                        value: 'muteSwapEth'
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        label: '流动性',
+        value: 'liquidity',
+        children: [
+            {
+                label: 'Add',
+                value: 'add',
+                children: [
+                    {
+                        label: 'iZUMi',
+                        value: 'addLiquidity'
+                    },
+                    {
+                        label: 'SyncSwap',
+                        value: 'addLiquiditySyncSwap'
+                    },
+                    {
+                        label: 'Mute',
+                        value: 'addLiquidityMute'
+                    }
+                ]
+            },
+            {
+                label: 'Remove',
+                value: 'remove',
+                children: [
+                    {
+                        label: 'iZUMi',
+                        value: 'removeLiquidity'
+                    },
+                    {
+                        label: 'SyncSwap',
+                        value: 'removeLiquiditySyncSwap'
+                    },
+                    {
+                        label: 'Mute',
+                        value: 'removeLiquidityMute'
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        label: 'Mint',
+        value: 'mint'
+    }
+]
 const props = defineProps(['modelValue', 'accounts'])
 const emit = defineEmits(['update:modelValue', 'createTask'])
 const creatingTask = ref(false)
@@ -228,7 +355,7 @@ async function createTask() {
     try {
         await http.put('/tasks', {
             accounts: props.accounts.map((item) => item.id),
-            items: items.value.map((i) => ({ ...i })),
+            items: items.value.map((i) => ({ ...i, type: i.type.slice(-1)[0] })),
             startTime: data.value.startTime,
             delay: data.value.delay
         })

+ 3 - 3
src/views/TaskView.vue

@@ -29,9 +29,9 @@
             <ElTableColumn prop="progress" label="进度" :formatter="progressFormatter" width="100" />
             <ElTableColumn label="操作" align="center" width="100">
                 <template #default="{ row }">
-                    <ElButton @click="delTask(row)" type="danger" :disabled="row.status === 'in_progress'"
-                        >删除</ElButton
-                    >
+                    <ElButton @click="delTask(row)" type="danger" :disabled="row.status === 'in_progress'">
+                        删除
+                    </ElButton>
                 </template>
             </ElTableColumn>
         </PagingTable>