Skip to content

Commit 0a6cf9d

Browse files
committed
fix: execution style
1 parent 83d3c92 commit 0a6cf9d

File tree

4 files changed

+148
-60
lines changed

4 files changed

+148
-60
lines changed

src/components/crossPlatforms.vue

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<script setup lang="ts">
2-
import { computed, Fragment, onMounted, reactive, ref, Ref } from 'vue';
3-
import codeBlock from './codeBlock.vue';
4-
import { useDetectDeviceType } from '@/hooks/detectDeviceType';
2+
import { computed, Fragment, onMounted, reactive, ref, Ref } from "vue";
3+
import CodeBlock from "./codeBlock.vue";
4+
import { useDetectDeviceType } from "@/hooks/detectDeviceType";
55
66
const deviceType = useDetectDeviceType();
7-
const currenClickPlatform = ref('');
7+
const currenClickPlatform = ref("");
88
9-
if (deviceType.value !== 'other') {
9+
if (deviceType.value !== "other") {
1010
currenClickPlatform.value = deviceType.value;
1111
} else {
12-
currenClickPlatform.value = 'apple';
12+
currenClickPlatform.value = "apple";
1313
}
1414
1515
function showCode(type: string) {
1616
currenClickPlatform.value = type;
1717
}
1818
const platforms = [
1919
{
20-
type: 'apple',
21-
icon: 'fa-brands fa-apple',
22-
iconColor: '#8465ff',
20+
type: "apple",
21+
icon: "fa-brands fa-apple",
22+
iconColor: "#8465ff",
2323
code: `brew tap pivot-studio/tap
2424
brew install pivot-lang`,
2525
},
2626
{
27-
type: 'windows',
28-
icon: 'fa-brands fa-windows',
29-
iconColor: '#409eff',
27+
type: "windows",
28+
icon: "fa-brands fa-windows",
29+
iconColor: "#409eff",
3030
code: `scoop bucket add pivot https://github.com/Pivot-Studio/scoop
3131
scoop install plc`,
3232
},
3333
{
34-
type: 'linux',
35-
icon: 'fa-brands fa-linux',
36-
iconColor: 'rgb(200, 150, 50)',
34+
type: "linux",
35+
icon: "fa-brands fa-linux",
36+
iconColor: "rgb(200, 150, 50)",
3737
code: `apt install wget gnupg
3838
wget -O - https://lang.pivotstudio.cn/apt/public.key | apt-key add -
3939
echo "deb [arch=amd64] https://lang.pivotstudio.cn/apt/repo focal main
@@ -46,15 +46,25 @@ apt install pivot-lang`,
4646
];
4747
4848
const curShowCode = computed(() => {
49-
return platforms.find((item) => item.type === currenClickPlatform.value)?.code;
49+
return platforms.find((item) => item.type === currenClickPlatform.value)
50+
?.code;
5051
});
5152
</script>
5253
<template>
5354
<div id="advantage">
5455
<div class="gradient-font title">Cross Platforms</div>
55-
<div class="detail-describe">Install Pivot Lang compiler with only a few commands!</div>
56+
<div class="detail-describe">
57+
Install Pivot Lang compiler with only a few commands!
58+
</div>
5659
<div class="advantages">
57-
<div v-for="item in platforms" :class="{ 'advantage-item': true, 'selected-item': item.type === currenClickPlatform }" :key="item.type">
60+
<div
61+
v-for="item in platforms"
62+
:class="{
63+
'advantage-item': true,
64+
'selected-item': item.type === currenClickPlatform,
65+
}"
66+
:key="item.type"
67+
>
5868
<font-awesome-icon
5969
@click="showCode(item.type)"
6070
inverse
@@ -67,7 +77,9 @@ const curShowCode = computed(() => {
6777
/>
6878
</div>
6979
</div>
70-
<codeBlock class="code-block'" :code="curShowCode"></codeBlock>
80+
<div class="code-block-container">
81+
<CodeBlock class="code-block'" :code="curShowCode"></CodeBlock>
82+
</div>
7183
</div>
7284
</template>
7385
<style lang="scss" scoped>
@@ -115,4 +127,9 @@ const curShowCode = computed(() => {
115127
.v-leave-to {
116128
opacity: 0;
117129
}
130+
.code-block-container {
131+
display: flex;
132+
justify-content: center;
133+
margin: 50px 0;
134+
}
118135
</style>

src/components/tabList.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
<script lang="ts" setup>
22
import { PlMonaco } from "@pivot-lang/create-monaco";
33
import axios from "axios";
4-
import { ref } from "vue";
4+
import { nextTick } from "vue";
5+
import { onMounted, ref } from "vue";
56
67
const props = defineProps<{
78
tablist: string[];
89
val: string;
910
code: string;
1011
}>();
12+
1113
const emit = defineEmits(["updateVal", "updateOutput"]);
1214
function updateVal(val: string) {
1315
emit("updateVal", val);
1416
}
1517
1618
let isRunning = ref(false);
1719
20+
onMounted(async () => {
21+
// props.code于onMounted中更新
22+
await nextTick();
23+
run(props.code);
24+
});
25+
1826
async function run(params: string) {
1927
isRunning.value = true;
2028
try {
21-
let re = await axios.post<{ runOutput: string, status:number, compileOutput: string }>(
22-
"https://code.lang.pivotstudio.cn/coderunner",
23-
{
24-
code: params,
25-
}
26-
);
29+
let re = await axios.post<{
30+
runOutput: string;
31+
status: number;
32+
compileOutput: string;
33+
}>("https://code.lang.pivotstudio.cn/coderunner", {
34+
code: params,
35+
});
2736
isRunning.value = false;
2837
if (re.data.status === 1) {
2938
emit("updateOutput", re.data.compileOutput);

src/pages/index.vue

Lines changed: 87 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import { ref, onMounted, watch } from "vue";
1616
import { basicCode } from "@/constant";
1717
import { memberList } from "@/constant";
1818
import createMonaco, { PlMonaco } from "@pivot-lang/create-monaco";
19-
import codeBlock from "@/components/codeBlock.vue";
19+
import CodeBlock from "@/components/codeBlock.vue";
2020
import { cp } from "fs";
2121
const tabVal = ref("hello world");
2222
const tabList = basicCode.map((item) => item.title);
2323
let monaco: PlMonaco;
2424
let code = ref("");
25-
let runresult = ref("");
25+
let runResult = ref("");
2626
function gotoEmail() {
2727
window.location.href = "mailto:[email protected]";
2828
}
@@ -57,24 +57,28 @@ watch(
5757
With the help of Web Assembly technology, we are able to provide support
5858
for some of the Pivot Lang syntax in the browser for you to experience.
5959
</div>
60-
<div class="code-box">
61-
<TabList
62-
@updateVal="(val:string) => (tabVal = val)"
63-
@updateOutput="(re) => (runresult = re)"
64-
:tablist="tabList"
65-
:val="tabVal"
66-
:code="code"
67-
></TabList>
68-
<div class="code-container">
69-
<div id="container"></div>
60+
<div class="code-now-container">
61+
<div class="code-box">
62+
<TabList
63+
@updateVal="(val:string) => (tabVal = val)"
64+
@updateOutput="
65+
(re) =>
66+
(runResult = re[re.length - 1] === '\n' ? re.slice(0, -1) : re)
67+
"
68+
:tablist="tabList"
69+
:val="tabVal"
70+
:code="code"
71+
></TabList>
72+
<div class="code-container">
73+
<div id="container"></div>
74+
</div>
75+
</div>
76+
<div class="execution">
77+
<div class="execution-title">Execution</div>
78+
<CodeBlock class="code-block" :code="runResult"></CodeBlock>
7079
</div>
7180
</div>
7281
</div>
73-
<codeBlock
74-
v-if="runresult"
75-
class="code-block'"
76-
:code="runresult"
77-
></codeBlock>
7882
<div id="advantage">
7983
<div class="gradient-font title">Immix Garbage Collector</div>
8084
<div class="detail-describe">
@@ -144,6 +148,10 @@ watch(
144148
.title {
145149
text-align: center;
146150
margin: 50px;
151+
152+
@media (max-width: 600px) {
153+
margin: 50px 25px 15px 25px;
154+
}
147155
}
148156
.detail-describe {
149157
margin: 0 auto;
@@ -156,20 +164,69 @@ watch(
156164
#code-show {
157165
min-height: calc(100vh - 100px);
158166
}
159-
.code-box {
160-
position: absolute;
161-
left: 50%;
162-
transform: translate(-50%);
163-
max-width: 74.5vw;
164-
.code-container {
165-
border-bottom: 10px #1e1e1e solid;
166-
border-radius: 10px;
167+
.code-now-container {
168+
display: flex;
169+
justify-content: cen;
170+
.code-box {
171+
// position: absolute;
172+
// left: 50%;
173+
// transform: translate(-50%);
174+
width: 60%;
175+
max-width: 800px;
176+
.code-container {
177+
border-bottom: 10px #1e1e1e solid;
178+
border-radius: 10px;
179+
height: 100%;
180+
}
181+
#container {
182+
height: 100%;
183+
max-height: calc(100vh - 400px);
184+
width: 100%;
185+
}
186+
}
187+
188+
.execution {
189+
width: 25%;
190+
margin: 30px 0 0 50px;
191+
.execution-title {
192+
color: wheat;
193+
margin-left: 5px;
194+
margin-bottom: 10px;
195+
font-weight: bold;
196+
}
197+
198+
.code-toolbar {
199+
pre {
200+
height: 100%;
201+
background-color: rgba(50, 50, 70, 0.5);
202+
}
203+
}
204+
.toolbar {
205+
display: none;
206+
}
167207
}
168-
#container {
169-
height: 800px;
170-
width: 800px;
171-
max-height: calc(100vh - 400px);
172-
max-width: 80vw;
208+
209+
@media (max-width: 800px) {
210+
flex-direction: column;
211+
align-items: center;
212+
.code-box {
213+
width: 70%;
214+
height: 40vh;
215+
}
216+
217+
.execution {
218+
width: 70%;
219+
margin: 80px 0 0;
220+
max-height: 300px;
221+
222+
pre {
223+
height: 100%;
224+
max-height: 80px;
225+
}
226+
.code-toolbar {
227+
width: 100%;
228+
}
229+
}
173230
}
174231
}
175232
.team-card {

src/style.scss

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ body {
1010
body {
1111
margin: 0;
1212
background-color: black;
13-
font-family: -apple-system, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
13+
font-family: -apple-system, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
14+
Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
1415
&::-webkit-scrollbar {
1516
width: 12px;
1617
}
@@ -64,7 +65,12 @@ body {
6465
font-size: 58px;
6566
font-weight: 860;
6667
line-height: 150%;
67-
background: linear-gradient(180deg, rgba(186, 255, 243, 0) 50.04%, rgba(189, 255, 244, 0.44) 100.09%), linear-gradient(64.57deg, #75fff3 7.22%, #599aff 90.07%);
68+
background: linear-gradient(
69+
180deg,
70+
rgba(186, 255, 243, 0) 50.04%,
71+
rgba(189, 255, 244, 0.44) 100.09%
72+
),
73+
linear-gradient(64.57deg, #75fff3 7.22%, #599aff 90.07%);
6874
-webkit-background-clip: text;
6975
-webkit-text-fill-color: transparent;
7076
@media (max-width: 1200px) {
@@ -103,10 +109,9 @@ body {
103109
}
104110

105111
.code-toolbar {
106-
margin: 50px auto;
107112
max-width: 720px;
108113
@media (max-width: 800px) {
109-
width: 60vw;
114+
width: 70vw;
110115
transition: all 0.7s ease;
111116
}
112117
}

0 commit comments

Comments
 (0)