Commit 91422663 authored by Yuan Zhixiang's avatar Yuan Zhixiang
Browse files

修复CodeViewer行号问题

parent 6201cc97
......@@ -71,6 +71,16 @@ function send_request() { // 将输入的代码/测试用例发送给后端
}
}
const data = ref({}) // 后端返回的数据
const code_view = computed(() => {
try{
return data.value['code']
}
catch (e){}
return ''
})
const code_view_split = computed(() => {
return String(code_view.value).split('\n');
})
function parse_result() { // 解析后端返回的结果
remove_back_slash_r()
loading.value = false
......@@ -238,6 +248,7 @@ provide('app', {
stdin_input,
send_request,
data,
code_view_split,
success,
exception_msg,
get_step,
......
<script setup>
import { computed, inject } from 'vue';
import { inject } from 'vue';
import LineUnit from './LineUnit.vue';
const { data } = inject('app');
const code = computed(() => {
return data.value['code'];
})
const code_split = computed(() => {
return String(code.value).split('\n');
})
const { code_view_split } = inject('app');
</script>
<template>
<div class="container">
<LineUnit v-for="(item, index) in code_split" :code="item" :line="index + 1" />
<LineUnit v-for="(item, index) in code_view_split" :code="item" :line="index + 1" />
</div>
</template>
......
......@@ -3,13 +3,13 @@ import { computed, inject, watch, getCurrentInstance } from 'vue';
const props = defineProps(['line', 'code'])
const { current_line, click_line, highlight_lines, total_steps, prev_line, current_step } = inject('app')
const { current_line, click_line, highlight_lines, code_view_split, prev_line, current_step } = inject('app')
const line = computed(() => { // 行号
return props.line
})
const line_string = computed(()=>{
const zero_count = String(total_steps.value).length - String(line.value).length
const zero_count = String(code_view_split.value.length).length - String(line.value).length
if(zero_count <= 0){
return line.value
}else{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment