|
@@ -11,7 +11,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-button type="primary" style="margin-top:20px" v-auth="'save'" @click="saveCode">保存脚本</el-button>
|
|
|
- <el-button type="primary" style="margin-top:20px" v-auth="'debug'" @click="mock">调试</el-button>
|
|
|
+ <el-button type="primary" style="margin-top:20px" v-auth="'debug'" :loading="runing" @click="mock">调试</el-button>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
@@ -54,6 +54,7 @@ const inputData = ref('')
|
|
|
const outputData = ref('')
|
|
|
const content = ref('')
|
|
|
const functionName = ref('parse')
|
|
|
+const runing = ref(false)
|
|
|
const mirrorRef = ref()
|
|
|
|
|
|
onMounted(() => {
|
|
@@ -103,7 +104,7 @@ function validate() {
|
|
|
|
|
|
async function mock() {
|
|
|
outputData.value = ''
|
|
|
-
|
|
|
+
|
|
|
await validate()
|
|
|
|
|
|
if (!inputData.value) return ElMessage.error('请输入参数')
|
|
@@ -114,18 +115,31 @@ async function mock() {
|
|
|
return ElMessage.error('请先输入可执行脚本')
|
|
|
}
|
|
|
|
|
|
+ // 远程调试
|
|
|
+ runing.value = true
|
|
|
+ api.product.scriptRun({
|
|
|
+ functionName: functionName.value,
|
|
|
+ scriptInfo: funStr,
|
|
|
+ jsonData: inputData.value,
|
|
|
+ }).then((res: any) => {
|
|
|
+ // outputData.value = typeof res.data === 'object' ? JSON.stringify(res.data, null, 2) : res.data
|
|
|
+ outputData.value = res.data
|
|
|
+ }).finally(() => {
|
|
|
+ runing.value = false
|
|
|
+ })
|
|
|
|
|
|
- const worker = new Worker('./worker.js');
|
|
|
- // 向 Worker 发送消息
|
|
|
- worker.postMessage({ type: 'runFunction', functionString: funStr, functionName: functionName.value, params: inputData.value });
|
|
|
- // 监听 Worker 返回的消息
|
|
|
- worker.addEventListener('message', ({ data }) => {
|
|
|
- worker.terminate()
|
|
|
- if (data.isOk) {
|
|
|
- return outputData.value = typeof data.data === 'object' ? JSON.stringify(data.data, null, 2) : data.data
|
|
|
- }
|
|
|
- ElMessage.error(data.message)
|
|
|
- });
|
|
|
+ // 本地调试
|
|
|
+ // const worker = new Worker('./worker.js');
|
|
|
+ // // 向 Worker 发送消息
|
|
|
+ // worker.postMessage({ type: 'runFunction', functionString: funStr, functionName: functionName.value, params: inputData.value });
|
|
|
+ // // 监听 Worker 返回的消息
|
|
|
+ // worker.addEventListener('message', ({ data }) => {
|
|
|
+ // worker.terminate()
|
|
|
+ // if (data.isOk) {
|
|
|
+ // return outputData.value = typeof data.data === 'object' ? JSON.stringify(data.data, null, 2) : data.data
|
|
|
+ // }
|
|
|
+ // ElMessage.error(data.message)
|
|
|
+ // });
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -137,6 +151,7 @@ async function mock() {
|
|
|
.input,
|
|
|
.output {
|
|
|
margin-top: 14px;
|
|
|
+
|
|
|
:deep(.el-textarea__inner) {
|
|
|
height: calc(50vh - 200px);
|
|
|
}
|