Skip to content

Commit cf60df8

Browse files
committed
代码框标题翻译,折叠功能
1 parent e241b78 commit cf60df8

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed

src/App.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,14 @@ function handleImport() {
160160
#editor {
161161
border-right: var(--c-border) 1px solid;
162162
position: relative;
163+
display: flex;
164+
flex-direction: column;
163165
}
164166
.editor-inner {
165167
overflow: scroll;
166-
position: absolute;
167-
top: 0;
168-
left: 0;
169-
right: 0;
170-
bottom: 300px;
168+
flex-grow: 1;
171169
}
170+
172171
#graph {
173172
flex-grow: 1;
174173
position: relative;

src/components/codeDisplay.vue

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
<template>
2-
<div class="plot-data output">
3-
<span class="output-title">代码</span>
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>
49
<pre>{{ formatted }}</pre>
510
</div>
611
</template>
712

813
<script setup lang="ts">
14+
import { useI18n } from "vue-i18n";
15+
const { t } = useI18n();
16+
917
import JSON5 from "json5";
1018
import prettier from "prettier/standalone";
1119
import prettierPluginBabel from "prettier/plugins/babel";
@@ -29,32 +37,50 @@ watch(
2937
},
3038
{ immediate: true }
3139
);
40+
41+
const collapse = ref(true);
3242
</script>
3343

3444
<style>
3545
.plot-data.output {
36-
position: absolute;
37-
left: 0;
38-
right: 0;
39-
bottom: 0;
4046
border-top: var(--c-border) 1px solid;
41-
padding: 20px 15px;
47+
padding: 15px 15px;
4248
height: 260px;
49+
display: flex;
50+
flex-direction: column;
51+
gap: 10px;
52+
overflow: hidden;
4353
}
4454
.plot-data.output .output-title {
4555
font-size: 20px;
4656
font-weight: bold;
4757
display: block;
48-
margin-bottom: 10px;
4958
}
5059
.plot-data.output pre {
51-
position: absolute;
52-
top: 60px;
53-
bottom: 15px;
54-
left: 15px;
55-
right: 15px;
56-
margin: 0;
60+
flex-grow: 1;
5761
overflow: scroll;
5862
user-select: all;
63+
margin: 0;
64+
}
65+
66+
.plot-data.output.collapse {
67+
height: 30px;
68+
}
69+
70+
.codeCollapse{
71+
float: right;
72+
height:100%;
73+
padding:0 10px;
74+
background: var(--c-bk3);
75+
border:var(--c-border) 1px solid;
76+
border-radius: 5px;
77+
opacity: 0.75;
78+
}
79+
.codeCollapse:hover{
80+
opacity: 1;
81+
}
82+
.codeCollapse:active{
83+
opacity: 1;
84+
filter: brightness(0.5);
5985
}
6086
</style>

src/components/nav.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
</span>
1212
<div class="grow"></div>
13-
<select v-model="locale">
13+
<select v-model="locale" id="language">
1414
<option value="zh-CN">简体中文</option>
1515
<option value="en-US">English</option>
1616
</select>
@@ -48,4 +48,20 @@ const { locale } = useI18n();
4848
align-items: center;
4949
padding: 0 15px;
5050
}
51+
52+
.grow {
53+
flex-grow: 1;
54+
}
55+
56+
#language {
57+
border: var(--c-border) 1px solid;
58+
background: var(--c-bk3);
59+
border-radius: 5px;
60+
padding: 5px 8px;
61+
color: var(--text);
62+
font-size: 15px;
63+
}
64+
#language:focus {
65+
border-color: var(--c-accent);
66+
}
5167
</style>

src/i18n.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default createI18n({
4141
vectorOffset: "起点坐标",
4242
location: "位置",
4343
},
44+
title: {
45+
output: "输出代码",
46+
},
4447
},
4548
"en-US": {
4649
buttons: {
@@ -80,6 +83,9 @@ export default createI18n({
8083
vectorOffset: "Offset",
8184
location: "Location",
8285
},
86+
title: {
87+
output: "Output code",
88+
},
8389
},
8490
},
8591
});

0 commit comments

Comments
 (0)