Skip to content

Commit ef58395

Browse files
🎨 Refactor CSS styles for improved layout and responsiveness; update Display component to conditionally apply 'main-display' class based on embed mode
1 parent dc341d5 commit ef58395

File tree

4 files changed

+71
-30
lines changed

4 files changed

+71
-30
lines changed

src/assets/main.css

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,73 @@
11
@import url(./markdown.css);
22

33
:root {
4-
--global-padding: 1rem;
4+
--global-padding: 1rem;
55
}
66

77
body {
8-
font-family: 'Roboto Mono', Consolas, "PingFang SC", "system-ui", "-apple-system", "BlinkMacSystemFont", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
9-
font-size: 1rem;
10-
line-height: 1.5;
11-
margin: 0;
12-
padding: 0;
13-
overflow: hidden;
8+
font-family: 'Roboto Mono', Consolas, "PingFang SC", "system-ui", "-apple-system", "BlinkMacSystemFont", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
9+
font-size: 1rem;
10+
line-height: 1.5;
11+
margin: 0;
12+
padding: 0;
13+
overflow: hidden;
1414
}
1515

1616
.btn {
17-
border-radius: 10em;
18-
padding: 0.5em 1em;
19-
border: 1px solid #0004;
20-
background-color: rgb(247, 247, 247);
21-
transform: translate(0, 10px);
22-
transition: all 0.3s, transform 0.05s;
23-
right: 26px;
17+
border-radius: 10em;
18+
padding: 0.5em 1em;
19+
border: 1px solid #0004;
20+
background-color: rgb(247, 247, 247);
21+
transform: translate(0, 10px);
22+
transition: all 0.3s, transform 0.05s;
23+
right: 26px;
2424

25-
font-weight: normal;
25+
font-weight: normal;
2626
}
2727

2828
.btn:hover {
29-
background-color: rgb(241, 241, 241);
29+
background-color: rgb(241, 241, 241);
3030
}
3131

3232
.btn:active {
33-
transform: translate(0, 10px) scale(0.9);
33+
transform: translate(0, 10px) scale(0.9);
34+
}
35+
36+
.main-display {
37+
width: 90%;
38+
max-width: 900px;
39+
min-width: 280px;
40+
margin-left: auto;
41+
margin-right: auto;
42+
box-sizing: border-box;
43+
transition: width 0.2s;
44+
height: fit-content !important;
45+
}
46+
47+
@media (max-width: 900px) {
48+
.main-display {
49+
width: 96%;
50+
max-width: 700px;
51+
min-width: 220px;
52+
}
53+
}
54+
55+
@media (max-width: 700px) {
56+
.main-display {
57+
width: 98%;
58+
max-width: 98%;
59+
min-width: 160px;
60+
padding-left: 8px;
61+
padding-right: 8px;
62+
}
63+
}
64+
65+
@media (max-width: 500px) {
66+
.main-display {
67+
width: 100%;
68+
max-width: 100%;
69+
min-width: 0;
70+
padding-left: 4px;
71+
padding-right: 4px;
72+
}
3473
}

src/components/Display.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
嵌入模式
99
</button>
1010
</div>
11-
<div v-html="parsed_markdown" class="markdown md"></div>
11+
<div v-html="parsed_markdown" class="markdown md" :class="(embed_mode ? 'main-display' : '')"></div>
1212
<div v-html="inject_css"></div>
1313
</template>
1414

@@ -26,11 +26,12 @@ import router from "@/router/index.ts";
2626
const VITE_SINGLE_FILE_RENDER = import.meta.env.VITE_SINGLE_FILE_RENDER == "True";
2727
2828
const props = defineProps<{
29+
embed_mode?: boolean;
2930
show_copy_button?: boolean;
3031
show_embed_button?: boolean;
3132
}>();
3233
33-
const { show_copy_button, show_embed_button } = props;
34+
const { show_copy_button, show_embed_button, embed_mode } = props;
3435
3536
const md = markdownit({
3637
html: true,

src/views/EmbedView.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
import Display from "../components/Display.vue";
33
import content, { user_css } from "../content.ts";
44
import { onMounted } from "vue";
5-
import { encode, decode } from "js-base64";
5+
import { decode } from "js-base64";
66
77
onMounted(() => {
88
// 解析 URL 参数
99
const params = new URLSearchParams(window.location.search);
1010
1111
// 解析 content 参数(base64 编码)
12-
const contentParam = params.get('content');
12+
const contentParam = params.get("content");
1313
if (contentParam) {
1414
try {
1515
// 使用 js-base64 进行 UTF-8 安全的 base64 解码
1616
const decodedContent = decode(contentParam);
1717
content.value = decodedContent;
1818
} catch (error) {
19-
console.error('Error decoding content parameter:', error);
20-
console.error('Content param:', contentParam);
19+
console.error("Error decoding content parameter:", error);
20+
console.error("Content param:", contentParam);
2121
}
2222
}
2323
2424
// 解析 style 参数
25-
const styleParam = params.get('style');
25+
const styleParam = params.get("style");
2626
if (styleParam) {
2727
try {
2828
// 使用 js-base64 进行 UTF-8 安全的 base64 解码
2929
user_css.value = decode(styleParam);
3030
} catch (error) {
31-
console.error('Error decoding style parameter:', error);
32-
console.error('Style param:', styleParam);
31+
console.error("Error decoding style parameter:", error);
32+
console.error("Style param:", styleParam);
3333
// 如果解码失败,尝试直接使用参数值
3434
user_css.value = styleParam;
3535
}
@@ -39,7 +39,7 @@ onMounted(() => {
3939

4040
<template>
4141
<div class="embed-container">
42-
<Display />
42+
<Display :embed_mode="true" />
4343
</div>
4444
</template>
4545

@@ -49,5 +49,6 @@ onMounted(() => {
4949
height: 100vh;
5050
padding: 0;
5151
margin: 0;
52+
overflow: auto;
5253
}
53-
</style>
54+
</style>

src/views/HomeView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const VITE_SINGLE_FILE_RENDER = import.meta.env.VITE_SINGLE_FILE_RENDER == "True
1717

1818
<!-- Display Panel -->
1919
<div class="flex">
20-
<Display :show_copy_button="true" :show_embed_button="true" />
20+
<Display :show_copy_button="true" :show_embed_button="true" :embed_mode="false" />
2121
</div>
2222
</div>
2323
</template>
@@ -44,4 +44,4 @@ const VITE_SINGLE_FILE_RENDER = import.meta.env.VITE_SINGLE_FILE_RENDER == "True
4444
border-color: v-bind('VITE_SINGLE_FILE_RENDER ? "none" : "#0005"');
4545
box-shadow: v-bind('VITE_SINGLE_FILE_RENDER ? "none" : "0 0 30px #0002"');
4646
}
47-
</style>
47+
</style>

0 commit comments

Comments
 (0)