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

调整布局

parent ffebc5f7
...@@ -167,11 +167,11 @@ function click_line(clicked) { // 点击某一行 ...@@ -167,11 +167,11 @@ function click_line(clicked) { // 点击某一行
} }
const edit_mode = ref(true) // 编辑模式,对应的是播放模式 const edit_mode = ref(true) // 编辑模式,对应的是播放模式
const loading = ref(false) // 发送请求等待后端返回的状态 const loading = ref(false) // 发送请求等待后端返回的状态
const solution_output = ref('')
function getMD5(string){ // not provide function getMD5(string){ // 获取字符串的md5
return CryptoJS.MD5(string).toString(CryptoJS.enc.Hex) return CryptoJS.MD5(string).toString(CryptoJS.enc.Hex)
} }
function generate_random_string(length = 32) { // not provide function generate_random_string(length = 32) { // 生成32位随机字符串
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = ''; let result = '';
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
...@@ -179,7 +179,7 @@ function generate_random_string(length = 32) { // not provide ...@@ -179,7 +179,7 @@ function generate_random_string(length = 32) { // not provide
} }
return result; return result;
} }
function query_oj_solution(solution_id){ function query_oj_solution(solution_id){ // 查询solution信息
const key = 'cd57c770-5384-493e-e231-51e74438287a' const key = 'cd57c770-5384-493e-e231-51e74438287a'
const nonce = generate_random_string() const nonce = generate_random_string()
const appID = 'ProgrammingLearningJudgingPlatform' const appID = 'ProgrammingLearningJudgingPlatform'
...@@ -202,6 +202,7 @@ function query_oj_solution(solution_id){ ...@@ -202,6 +202,7 @@ function query_oj_solution(solution_id){
if(resp.code == 10000){ if(resp.code == 10000){
code_input.value = resp.data.code code_input.value = resp.data.code
stdin_input.value = resp.data.input stdin_input.value = resp.data.input
solution_output.value = resp.data.output
loading.value = true loading.value = true
try_failed.value = false try_failed.value = false
send_request() send_request()
...@@ -213,7 +214,7 @@ function query_oj_solution(solution_id){ ...@@ -213,7 +214,7 @@ function query_oj_solution(solution_id){
console.error(error); console.error(error);
}); });
} }
function get_oj_solution_id(){ function get_oj_solution_id(){ // 从网址获取solutionID
const currentUrl = window.location.href; const currentUrl = window.location.href;
const queryObject = new URLSearchParams(window.location.search); const queryObject = new URLSearchParams(window.location.search);
const solution_id = queryObject.get('solution'); const solution_id = queryObject.get('solution');
...@@ -244,7 +245,8 @@ provide('app', { ...@@ -244,7 +245,8 @@ provide('app', {
highlight_lines, highlight_lines,
click_line, click_line,
edit_mode, edit_mode,
feature_show_new_vars feature_show_new_vars,
solution_output
}) })
</script> </script>
...@@ -275,13 +277,13 @@ provide('app', { ...@@ -275,13 +277,13 @@ provide('app', {
<div class="out-big-box"> <div class="out-big-box">
<div class="big-box"> <div class="big-box">
<StdinEditor /> <ControlPanel />
</div> </div>
</div> </div>
<div class="out-big-box"> <div class="out-big-box">
<div class="big-box"> <div class="big-box">
<ControlPanel /> <StdinEditor />
</div> </div>
</div> </div>
......
...@@ -86,15 +86,6 @@ const stack_to_render = computed(() => { // 当前帧的stack ...@@ -86,15 +86,6 @@ const stack_to_render = computed(() => { // 当前帧的stack
return current_stack.value['stack_to_render'] return current_stack.value['stack_to_render']
} catch (e) { } } catch (e) { }
}) })
const stdout = computed(() => { // 从开始到当前帧的累计输出
try {
return current_stack.value['stdout']
} catch (e) { }
return ''
})
const has_stdout = computed(() => { // 当前帧是否有输出
return stdout.value.length > 0
})
const highlight_addresses = ref({}) // 高亮的地址及其颜色代号 const highlight_addresses = ref({}) // 高亮的地址及其颜色代号
watch(current_step, () => { watch(current_step, () => {
...@@ -107,16 +98,6 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map}) ...@@ -107,16 +98,6 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map})
<template> <template>
<div class="flex-container"> <div class="flex-container">
<div class="func-box" v-show="has_stdout">
<div class="big-box">
<div class="small-box head-box">输出</div>
</div>
<div class="big-box">
<div class="small-box">
<pre>{{ stdout }}</pre>
</div>
</div>
</div>
<div class="func-box" v-if="has_globals"> <div class="func-box" v-if="has_globals">
<div class="big-box"> <div class="big-box">
<div class="small-box head-box">全局变量</div> <div class="small-box head-box">全局变量</div>
...@@ -132,9 +113,6 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map}) ...@@ -132,9 +113,6 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map})
:changed="check_changed(value2)" /> :changed="check_changed(value2)" />
</div> </div>
</div> </div>
<!-- <button @click="click">log</button> -->
<!-- <div>{{ stack_to_render }}</div> -->
</template> </template>
<style scoped> <style scoped>
...@@ -144,17 +122,11 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map}) ...@@ -144,17 +122,11 @@ provide('stack_view',{highlight_addresses,check_changed,current_var_map})
border-radius: 0.5rem; border-radius: 0.5rem;
padding: 0.2rem; padding: 0.2rem;
margin-right: 0.5rem; margin-right: 0.5rem;
/* width: min-content;
height: min-content; */
} }
.flex-container { .flex-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* grid-auto-flow: column;
grid-template-columns: auto;
grid-template-rows: auto; */
/* grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); */
height: 100%; height: 100%;
width: calc(100% + 0.5rem); width: calc(100% + 0.5rem);
gap: 1rem; gap: 1rem;
......
...@@ -2,16 +2,55 @@ ...@@ -2,16 +2,55 @@
import { computed, inject } from 'vue'; import { computed, inject } from 'vue';
const { stdin_input, edit_mode } = inject('app') const { stdin_input, edit_mode, solution_output, get_step, current_step } = inject('app')
const placeholder = '将你的测试用例粘贴到这里\n(如果有的话)' const stdin_placeholder = '你的测试用例\n(如果有的话)'
const stdout_placeholder = '程序的输出'
const display_solution_output = computed(()=>{
return '答案:\n' + solution_output.value
})
const show_solution_output = computed(()=>{
if(solution_output.value.length == 0){
return false
}else{
return true
}
})
const css_grid_template_columns = computed(()=>{
if(show_solution_output.value){
return '1fr 1fr 1fr'
}else{
return '1fr 1fr'
}
})
const current_stack = computed(() => { // 当前要显示的帧(主要显示stack部分)
return get_step(current_step.value)
})
const stdout = computed(() => { // 从开始到当前帧的累计输出
try {
return current_stack.value['stdout']
} catch (e) { }
return ''
})
</script> </script>
<template> <template>
<textarea class="code-input" v-model="stdin_input" :placeholder="placeholder" :readonly="!edit_mode"></textarea> <div class="grid-container">
<textarea class="code-input" v-model="stdin_input" :placeholder="stdin_placeholder" :readonly="!edit_mode"></textarea>
<textarea class="code-input" v-model="stdout" :placeholder="stdout_placeholder" readonly></textarea>
<textarea class="code-input" v-model="display_solution_output" v-if="show_solution_output" readonly></textarea>
</div>
</template> </template>
<style scoped> <style scoped>
@import '@/assets/code-input.css'; @import '@/assets/code-input.css';
.grid-container{
display: grid;
grid-template-columns: v-bind(css_grid_template_columns);
gap: 1rem;
height: 100%;
}
</style> </style>
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