TestConfig.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!--
  2. * @Author: liuJie
  3. * @Date: 2026-01-27 14:45:03
  4. * @LastEditors: liuJie
  5. * @LastEditTime: 2026-01-27 18:19:49
  6. * @Describe: file describe
  7. -->
  8. <template>
  9. <div class="space-y-4">
  10. <!-- 失败时重试 -->
  11. <div class="space-y-2">
  12. <div class="flex items-center justify-between">
  13. <label class="text-sm font-medium text-gray-700">失败时重试</label>
  14. <el-switch v-model="retryState" @change="toggleRetry" />
  15. </div>
  16. <div class="space-y-2" v-if="config.retryEnabled">
  17. <div class="pl-[22px]">
  18. <p class="m-0 text-sm">最大重试次数</p>
  19. <el-slider v-model="config.maxRetries" show-input />
  20. </div>
  21. <div class="pl-[22px]">
  22. <p class="m-0 text-sm">重试间隔</p>
  23. <el-slider v-model="config.retryInterval" show-input />
  24. </div>
  25. </div>
  26. </div>
  27. <!-- 异常处理 -->
  28. <div class="space-y-2">
  29. <label class="text-sm font-medium text-gray-700 flex items-center gap-1">
  30. 异常处理
  31. <Icon icon="lucide:info" :height="14" :width="14" class="text-gray-400" />
  32. </label>
  33. <select v-model="config.errorHandling" @change="handleConfigChange"
  34. class="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white">
  35. <option value="none">无</option>
  36. <option value="stop">停止执行</option>
  37. <option value="continue">继续执行</option>
  38. <option value="retry">重试</option>
  39. </select>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup lang="ts">
  44. import { ref, watch } from 'vue'
  45. import { Icon } from '@iconify/vue'
  46. interface TestConfig {
  47. retryEnabled: boolean
  48. errorHandling: string,
  49. maxRetries?: number
  50. retryInterval?: number
  51. }
  52. interface Props {
  53. modelValue: TestConfig
  54. }
  55. interface Emits {
  56. (e: 'update:modelValue', value: TestConfig): void
  57. }
  58. const props = defineProps<Props>()
  59. const emit = defineEmits<Emits>()
  60. const retryState = ref(false)
  61. const config = ref<TestConfig>(props.modelValue || {
  62. retryEnabled: false,
  63. errorHandling: 'none',
  64. maxRetries: 3,
  65. retryInterval: 1000
  66. })
  67. watch(
  68. () => props.modelValue,
  69. (newVal) => {
  70. config.value = newVal || {
  71. retryEnabled: false,
  72. errorHandling: 'none'
  73. }
  74. }
  75. )
  76. const toggleRetry = () => {
  77. config.value.retryEnabled = !config.value.retryEnabled
  78. handleConfigChange()
  79. }
  80. const handleConfigChange = () => {
  81. emit('update:modelValue', config.value)
  82. }
  83. </script>