Commit 20713ac9 authored by Yuan Zhixiang's avatar Yuan Zhixiang
Browse files

添加隐藏的自定义功能,默认关闭“高亮新增的变量”

parent eed661f9
...@@ -223,6 +223,8 @@ function get_oj_solution_id(){ ...@@ -223,6 +223,8 @@ function get_oj_solution_id(){
} }
get_oj_solution_id() get_oj_solution_id()
const feature_show_new_vars = ref(false)
provide('app', { provide('app', {
loading, loading,
code_input, code_input,
...@@ -241,7 +243,8 @@ provide('app', { ...@@ -241,7 +243,8 @@ provide('app', {
click_step, click_step,
highlight_lines, highlight_lines,
click_line, click_line,
edit_mode edit_mode,
feature_show_new_vars
}) })
</script> </script>
......
...@@ -5,13 +5,17 @@ import EditButton from './buttons/EditButton.vue'; ...@@ -5,13 +5,17 @@ import EditButton from './buttons/EditButton.vue';
import RunButton from './buttons/RunButton.vue'; import RunButton from './buttons/RunButton.vue';
import PrevButton from './buttons/PrevButton.vue'; import PrevButton from './buttons/PrevButton.vue';
import NextButton from './buttons/NextButton.vue'; import NextButton from './buttons/NextButton.vue';
import CommandButton from './buttons/CommandButton.vue';
const { total_steps, edit_mode } = inject('app') const { total_steps, edit_mode, stdin_input } = inject('app')
const css_grid_template_columns = computed(() => { const css_grid_template_columns = computed(() => {
return `repeat(${total_steps.value}, 1fr)`; return `repeat(${total_steps.value}, 1fr)`;
}) })
const command_available = computed(()=>{
return stdin_input.value.startsWith("/set ")
})
</script> </script>
...@@ -25,6 +29,7 @@ const css_grid_template_columns = computed(() => { ...@@ -25,6 +29,7 @@ const css_grid_template_columns = computed(() => {
<RunButton v-show="edit_mode" /> <RunButton v-show="edit_mode" />
<PrevButton v-show="!edit_mode" /> <PrevButton v-show="!edit_mode" />
<NextButton v-show="!edit_mode" /> <NextButton v-show="!edit_mode" />
<CommandButton v-show="command_available" />
</div> </div>
</template> </template>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { computed, inject, provide, watch, ref } from 'vue'; import { computed, inject, provide, watch, ref } from 'vue';
import VarUnit from './VarUnit.vue'; import VarUnit from './VarUnit.vue';
const { get_step, current_step } = inject('app') const { get_step, current_step, feature_show_new_vars } = inject('app')
const current_stack = computed(() => { // 当前要显示的帧(主要显示stack部分) const current_stack = computed(() => { // 当前要显示的帧(主要显示stack部分)
return get_step(current_step.value + 1) return get_step(current_step.value + 1)
...@@ -68,7 +68,9 @@ function check_changed(value) { // 检查某个地址的值是否发生了变化 ...@@ -68,7 +68,9 @@ function check_changed(value) { // 检查某个地址的值是否发生了变化
return 'changed' return 'changed'
} }
} else { } else {
return 'new' if(feature_show_new_vars.value){
return 'new'
}
} }
} }
return 'x' return 'x'
......
<script setup>
import { computed, inject } from 'vue';
const { stdin_input, feature_show_new_vars } = inject('app')
const command = computed(()=>{
if(stdin_input.value.length <= 5){
return ''
}else{
return stdin_input.value.slice(5)
}
})
function click(){
const cmd = command.value
if(cmd == 'help'){
stdin_input.value = 'available commands:\n/set show_new_vars'
}
else if(cmd == 'show_new_vars'){
feature_show_new_vars.value = !feature_show_new_vars.value
stdin_input.value = 'feature_show_new_vars: ' + feature_show_new_vars.value
}
else{
stdin_input.value = 'unknown command\nuse /set help'
}
}
</script>
<template>
<button class="button" @click="click">执行</button>
</template>
<style scoped>
@import '@/assets/button.css';
</style>
\ No newline at end of file
...@@ -26,7 +26,7 @@ function click() { ...@@ -26,7 +26,7 @@ function click() {
@import '@/assets/button.css'; @import '@/assets/button.css';
.button { .button {
display: flex; display: inline-flex;
align-items: center; align-items: center;
/* 垂直居中 */ /* 垂直居中 */
} }
......
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