CodeSetter.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. <!-- 输出变量 -->
  12. <OutputVariables v-model="formData.outputVariables" />
  13. <!-- 测试配置 -->
  14. <TestConfig v-model="formData.testConfig" />
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup lang="ts">
  21. import { reactive } from 'vue'
  22. import InputVariables from '@/components/SetterCommon/Code/InputVariables.vue'
  23. import CodeEditor from '@/components/SetterCommon/Code/CodeEditor.vue'
  24. import OutputVariables from '@/components/SetterCommon/Code/OutputVariables.vue'
  25. import TestConfig from '@/components/SetterCommon/Code/TestConfig.vue'
  26. interface Variable {
  27. id: string
  28. name: string
  29. }
  30. interface OutputVariable {
  31. id: string
  32. name: string
  33. type: string
  34. }
  35. interface TestConfigData {
  36. retryEnabled: boolean
  37. errorHandling: string
  38. }
  39. // const props = withDefaults(defineProps<{
  40. // }>(), {
  41. // })
  42. //
  43. // const emit = defineEmits<{
  44. // }>()
  45. const formData = reactive({
  46. // 输入变量, 变量默认值
  47. inputVariables: [
  48. // { id: 'var_1', name: 'arg1' },
  49. ] as Variable[],
  50. // 代码内容
  51. code: `function main(arg1, arg2) {
  52. return {
  53. "result": arg1 + arg2,
  54. }`,
  55. // 编程语言
  56. language: 'JavaScript',
  57. // 输出变量
  58. outputVariables: [
  59. // { id: 'output_1', name: 'result', type: 'String' }
  60. ] as OutputVariable[],
  61. // 测试配置
  62. testConfig: {
  63. retryEnabled: false,
  64. errorHandling: 'none'
  65. } as TestConfigData
  66. })
  67. </script>