Skip to content

Commit e8873bb

Browse files
committed
代码输出部分采用组件库
1 parent 1ce7b21 commit e8873bb

1 file changed

Lines changed: 29 additions & 31 deletions

File tree

src/components/codeDisplay.vue

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
<template>
2-
<div class="plot-data output" :class="{ collapse }">
3-
<span class="output-title"
4-
>{{ t("title.output") }}
5-
<button class="codeCollapse" @click="collapse = !collapse">
6-
{{ t(collapse ? "buttons.expand" : "buttons.collapse") }}
7-
</button>
8-
</span>
9-
<pre>{{ formatted }}</pre>
2+
<div class="plot-data output">
3+
<span class="output-title">{{ t("title.output") }} </span>
4+
<s-fold folded>
5+
<s-button
6+
slot="trigger"
7+
type="text"
8+
@click="folded = !folded"
9+
id="codeFoldButton"
10+
>
11+
<s-icon
12+
slot="start"
13+
:name="folded ? 'chevron_up' : 'chevron_down'"
14+
></s-icon>
15+
{{ t(folded ? "buttons.expand" : "buttons.collapse") }}</s-button
16+
>
17+
<pre id="formattedCode">{{ formatted }}</pre>
18+
</s-fold>
1019
</div>
1120
</template>
1221

@@ -38,48 +47,37 @@ watch(
3847
{ immediate: true }
3948
);
4049
41-
const collapse = ref(true);
50+
const folded = ref(true);
4251
</script>
4352

4453
<style>
4554
.plot-data.output {
4655
border-top: var(--s-color-outline-variant) 1px solid;
47-
padding: 15px 15px;
48-
height: 260px;
56+
padding: 8px 15px;
4957
display: flex;
5058
flex-direction: column;
5159
gap: 10px;
5260
overflow: hidden;
5361
}
5462
.plot-data.output .output-title {
55-
font-size: 20px;
63+
font-size: 18px;
5664
font-weight: bold;
57-
display: block;
65+
position: absolute;
66+
top: 8px;
67+
left: 15px;
68+
line-height: 40px;
5869
}
5970
.plot-data.output pre {
6071
flex-grow: 1;
6172
overflow: scroll;
6273
user-select: all;
6374
margin: 0;
6475
}
65-
66-
.plot-data.output.collapse {
67-
height: 30px;
68-
}
69-
70-
.codeCollapse{
71-
float: right;
72-
height:100%;
73-
padding:0 10px;
74-
border:var(--s-color-outline-variant) 1px solid;
75-
border-radius: 5px;
76-
opacity: 0.75;
77-
}
78-
.codeCollapse:hover{
79-
opacity: 1;
76+
#codeFoldButton {
77+
margin-left: 100%;
78+
transform: translateX(-100%);
8079
}
81-
.codeCollapse:active{
82-
opacity: 1;
83-
filter: brightness(0.5);
80+
#formattedCode {
81+
height: 200px;
8482
}
8583
</style>

0 commit comments

Comments
 (0)