Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Yuan Zhixiang
c-render-vue
Commits
dff8d139
Commit
dff8d139
authored
Apr 26, 2024
by
Yuan Zhixiang
Browse files
添加 上一步提示
parent
e5914b8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/App.vue
View file @
dff8d139
...
@@ -125,9 +125,9 @@ const current_line = computed(() => { // 播放的当前代码对应的行数
...
@@ -125,9 +125,9 @@ const current_line = computed(() => { // 播放的当前代码对应的行数
return
get_step
(
current_step
.
value
)[
'
line
'
]
return
get_step
(
current_step
.
value
)[
'
line
'
]
}
catch
(
e
)
{
}
}
catch
(
e
)
{
}
})
})
const
next
_line
=
computed
(()
=>
{
// 播放的下一步代码对应的行数
const
prev
_line
=
computed
(()
=>
{
// 播放的下一步代码对应的行数
try
{
try
{
return
get_step
(
current_step
.
value
+
1
)[
'
line
'
]
return
get_step
(
current_step
.
value
-
1
)[
'
line
'
]
}
catch
(
e
)
{
}
}
catch
(
e
)
{
}
})
})
const
try_failed
=
ref
(
false
)
// 尝试运行代码失败
const
try_failed
=
ref
(
false
)
// 尝试运行代码失败
...
@@ -236,7 +236,7 @@ provide('app', {
...
@@ -236,7 +236,7 @@ provide('app', {
exception_msg
,
exception_msg
,
get_step
,
get_step
,
current_line
,
current_line
,
next
_line
,
prev
_line
,
try_failed
,
try_failed
,
total_steps
,
total_steps
,
current_step
,
current_step
,
...
...
src/components/LineUnit.vue
View file @
dff8d139
...
@@ -3,7 +3,7 @@ import { computed, inject } from 'vue';
...
@@ -3,7 +3,7 @@ import { computed, inject } from 'vue';
const
props
=
defineProps
([
'
line
'
,
'
code
'
])
const
props
=
defineProps
([
'
line
'
,
'
code
'
])
const
{
current_line
,
click_line
,
highlight_lines
,
total_steps
}
=
inject
(
'
app
'
)
const
{
current_line
,
click_line
,
highlight_lines
,
total_steps
,
prev_line
}
=
inject
(
'
app
'
)
const
line
=
computed
(()
=>
{
// 行号
const
line
=
computed
(()
=>
{
// 行号
return
props
.
line
return
props
.
line
...
@@ -27,11 +27,17 @@ const mark = computed(() => { // 代码左侧的标记
...
@@ -27,11 +27,17 @@ const mark = computed(() => { // 代码左侧的标记
if
(
line
.
value
==
current_line
.
value
)
{
if
(
line
.
value
==
current_line
.
value
)
{
return
'
→
'
return
'
→
'
}
}
if
(
line
.
value
==
prev_line
.
value
)
{
return
'
↗
'
}
return
'
'
return
'
'
})
})
const
is_current
=
computed
(()
=>
{
// 是当前行
const
is_current
=
computed
(()
=>
{
// 是当前行
return
line
.
value
==
current_line
.
value
return
line
.
value
==
current_line
.
value
})
})
const
is_prev
=
computed
(()
=>
{
return
line
.
value
==
prev_line
.
value
})
const
breakpoint
=
computed
(()
=>
{
const
breakpoint
=
computed
(()
=>
{
if
(
Object
.
values
(
highlight_lines
.
value
).
includes
(
line
.
value
))
{
if
(
Object
.
values
(
highlight_lines
.
value
).
includes
(
line
.
value
))
{
return
'
'
return
'
'
...
@@ -47,7 +53,7 @@ function click() {
...
@@ -47,7 +53,7 @@ function click() {
<
template
>
<
template
>
<div
class=
"code"
@
click=
"click"
>
<div
class=
"code"
@
click=
"click"
>
<pre
:class=
"
{ blue: is_current }">
{{
mark
}}
</pre>
<pre
:class=
"
{ blue: is_current
, 'light-blue': is_prev
}">
{{
mark
}}
</pre>
<pre
class=
"breakpoint"
>
{{
breakpoint
}}
</pre>
<pre
class=
"breakpoint"
>
{{
breakpoint
}}
</pre>
<pre>
{{
line_string
}}
</pre>
<pre>
{{
line_string
}}
</pre>
<pre
:class=
"
{ blue: is_current }">
{{
code
}}
</pre>
<pre
:class=
"
{ blue: is_current }">
{{
code
}}
</pre>
...
@@ -63,6 +69,10 @@ pre {
...
@@ -63,6 +69,10 @@ pre {
color
:
#00aeff
;
color
:
#00aeff
;
}
}
.light-blue
{
color
:
#c0e8ff
;
}
.code
{
.code
{
border
:
0rem
;
border
:
0rem
;
border-radius
:
0.3rem
;
border-radius
:
0.3rem
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment