CodeSetter.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="bg-white w-full">
  3. <div class="w-full">
  4. <!-- Content -->
  5. <div class="p-4">
  6. <div class="space-y-6">
  7. <!-- 输入变量 -->
  8. <InputVariables v-model="formData.inputVariables" />
  9. <!-- 代码编辑器 -->
  10. <CodeEditor v-model="formData.code" v-model:language="formData.language"
  11. value-format="javascript" />
  12. <!-- 输出变量 -->
  13. <OutputVariables v-model="formData.outputVariables" />
  14. <!-- 测试配置 -->
  15. <TestConfig v-model="formData.testConfig" />
  16. <!-- 异常处理 -->
  17. <ErrorHandling v-model="formData.errorHandler" />
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup lang="ts">
  24. import { reactive } from 'vue'
  25. import InputVariables from '@/components/SetterCommon/Code/InputVariables.vue'
  26. import CodeEditor from '@/components/SetterCommon/Code/CodeEditor.vue'
  27. import OutputVariables from '@/components/SetterCommon/Code/OutputVariables.vue'
  28. import TestConfig from '@/components/SetterCommon/Code/TestConfig.vue'
  29. import ErrorHandling from '@/components/SetterCommon/Code/ErrorHandling.vue'
  30. interface Variable {
  31. id: string
  32. name: string
  33. }
  34. interface OutputVariable {
  35. id: string
  36. name: string
  37. type: string
  38. }
  39. interface TestConfigData {
  40. retryEnabled: boolean
  41. maxRetries: number
  42. retryInterval: number
  43. }
  44. interface ErrorHandler {
  45. errorHandling: string
  46. errorCodeReturn: string,
  47. language: string
  48. }
  49. // const props = withDefaults(defineProps<{
  50. // }>(), {
  51. // })
  52. //
  53. // const emit = defineEmits<{
  54. // }>()
  55. const formData = reactive({
  56. // 输入变量, 变量默认值
  57. inputVariables: [
  58. // { id: 'var_1', name: 'arg1' },
  59. ] as Variable[],
  60. // 代码内容
  61. code: ``,
  62. // 编程语言
  63. language: 'javascript',
  64. // 输出变量
  65. outputVariables: [
  66. // { id: 'output_1', name: 'result', type: 'String' }
  67. ] as OutputVariable[],
  68. // 测试配置
  69. testConfig: {
  70. retryEnabled: false,
  71. maxRetries: 0,
  72. retryInterval: 100,
  73. } as TestConfigData,
  74. // 错误补救
  75. errorHandler: {
  76. errorHandling: 'none',
  77. errorCodeReturn: '',
  78. language: 'javascript',
  79. } as ErrorHandler
  80. })
  81. </script>