Skip to content

Commit 1af48fe

Browse files
authored
feat: add dark theme (#10)
* feat: add dark theme * feat: add dark theme
1 parent d1a009e commit 1af48fe

16 files changed

+148
-47
lines changed

.vitepress/theme/Home.vue

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
</div>
2121
<!-- 第二行:大图片 -->
2222
<div class="row2">
23-
<img
24-
class="main-img"
25-
:src="getImgUrl(item.imgUrl)"
26-
alt="主图"
27-
/>
23+
<img
24+
:src="getImgUrl(
25+
isDark
26+
? `images/${item.imgUrl}-dark.svg`
27+
: `images/${item.imgUrl}.svg`
28+
)"
29+
alt="OpenTiny NEXT"
30+
class="logo-icon"
31+
/>
2832
</div>
2933
<!-- 第三行:描述文本 -->
3034
<div class="row3">{{ item.desc }} </div>
@@ -43,9 +47,18 @@
4347
</template>
4448
<script setup>
4549
import { useData } from "vitepress";
50+
import { ref, onMounted } from 'vue';
4651
4752
const { site } = useData();
4853
54+
// 暗色模式状态
55+
const isDark = ref(false);
56+
57+
// 初始化暗色模式状态
58+
onMounted(() => {
59+
isDark.value = document.documentElement.classList.contains('dark');
60+
});
61+
4962
const getImgUrl = (imgPath) => {
5063
return site.value.base + imgPath;
5164
};
@@ -55,31 +68,31 @@ const homeList = [
5568
icon: 'images/tiny-vue-logo-active.svg',
5669
title: 'TinyVue',
5770
titleTip: 'vue组件库',
58-
imgUrl: 'images/banner1.svg',
71+
imgUrl: 'tiny-vue-banner',
5972
link: 'vue-playground',
6073
desc: 'OpenTiny NEXT-SDKs 是一套前端智能应用开发工具包,旨在简化 WebAgent 的集成与使用,支持多种编程语言和前端框架,帮助开发者快速实现智能化功能。'
6174
},
6275
{
6376
icon: 'images/tiny-engine-logo-active.svg',
6477
title: 'TinyEngine',
6578
titleTip: '低代码引擎',
66-
imgUrl: 'images/banner2.svg',
79+
imgUrl: 'tiny-engine-banner',
6780
link: 'tiny-engine#/tiny-engine-editor',
6881
desc: 'OpenTiny NEXT-SDKs 是一套前端智能应用开发工具包,旨在简化 WebAgent 的集成与使用,支持多种编程语言和前端框架,帮助开发者快速实现智能化功能。'
6982
},
7083
{
7184
icon: 'images/next-sdk-logo-active.svg',
7285
title: 'NEXT-SDKs',
7386
titleTip: '智能应用开发工具包',
74-
imgUrl: 'images/banner3.svg',
87+
imgUrl: 'next-sdk-banner',
7588
link: '',
7689
desc: 'OpenTiny NEXT-SDKs 是一套前端智能应用开发工具包,旨在简化 WebAgent 的集成与使用,支持多种编程语言和前端框架,帮助开发者快速实现智能化功能。'
7790
},
7891
{
7992
icon: 'images/tiny-robot-logo-active.svg',
8093
title: 'TinyRobot',
8194
titleTip: 'AI智能助手',
82-
imgUrl: 'images/banner4.svg',
95+
imgUrl: 'tiny-robot-banner',
8396
link: '',
8497
desc: 'OpenTiny NEXT-SDKs 是一套前端智能应用开发工具包,旨在简化 WebAgent 的集成与使用,支持多种编程语言和前端框架,帮助开发者快速实现智能化功能。'
8598
},
@@ -119,6 +132,9 @@ const homeList = [
119132
flex: 0 0 calc((100% - 3 * 30px) / 4);
120133
max-width: calc((100% - 3 * 30px) / 4);
121134
}
135+
.dark .small-box {
136+
background: rgba(38,38,38,1);
137+
}
122138
.row1 {
123139
display: flex;
124140
align-items: flex-start;
@@ -178,6 +194,27 @@ const homeList = [
178194
pointer-events: none;
179195
cursor: not-allowed;
180196
}
197+
.dark .link {
198+
color: #5291FF;
199+
}
200+
.dark .link.disabled {
201+
color: #808080;
202+
}
203+
.dark .row3{
204+
color: #b3b3b3;
205+
}
206+
.dark .row1-title{
207+
color: #e6e6e6;
208+
}
209+
.dark .row1-content{
210+
color: #b3b3b3;
211+
}
212+
.dark .home-title{
213+
color: #e6e6e6;
214+
}
215+
.dark .home-desc{
216+
color: #b3b3b3;
217+
}
181218
182219
/* 响应式断点:3列 / 2列 / 1列,同时在 <980px 时调整标题与描述 */
183220
@media (max-width: 1600px) {
@@ -240,4 +277,7 @@ const homeList = [
240277
padding: 20px;
241278
}
242279
}
280+
.logo-icon{
281+
background: rgba(38,38,38,1);
282+
}
243283
</style>

.vitepress/theme/components/CustomHeader.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<img
1111
:src="getImgUrl(
1212
isDark
13-
? 'images/logo2.svg'
14-
: 'images/logo2.svg'
13+
? 'images/logo-dark.svg'
14+
: 'images/logo.svg'
1515
)"
1616
alt="OpenTiny NEXT"
1717
class="logo-icon"
@@ -113,8 +113,8 @@
113113
<img
114114
:src="getImgUrl(
115115
isDark
116-
? 'images/logo2.svg'
117-
: 'images/logo2.svg'
116+
? 'images/logo-dark.svg'
117+
: 'images/logo.svg'
118118
)"
119119
alt="OpenTiny NEXT"
120120
class="logo-icon"
@@ -194,7 +194,7 @@
194194
class="home-link home-link-mb"
195195
>
196196
<img
197-
:src="getImgUrl('images/logo.svg')"
197+
:src="getImgUrl('images/logo1.svg')"
198198
alt="OpenTiny NEXT"
199199
class="logo-icon"
200200
/>
@@ -342,6 +342,9 @@ watch(
342342
.logo-icon {
343343
height: 32px;
344344
}
345+
.modal-header .logo-icon {
346+
height: 16px;
347+
}
345348
346349
.logo-text {
347350
font-size: 20px;
@@ -410,6 +413,9 @@ watch(
410413
background-color: #e6e6e6;
411414
color: var(--vp-c-text-1);
412415
}
416+
.dark .tool-button:hover {
417+
background: rgba(255, 255, 255, 0.05);
418+
}
413419
.tool-switch {
414420
position: relative;
415421
border-radius: 11px;

.vitepress/theme/components/customContent.vue

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="home-logo">
55
<a :href="backHome" rel="noopener noreferrer">
66
<img
7-
:src="getImgUrl(isDark ? 'images/mini-logo.svg' : 'images/mini-logo.svg') "
7+
:src="getImgUrl(isDark ? 'images/mini-logo-dark.svg' : 'images/mini-logo.svg') "
88
class="home-logo-icon"
99
/>
1010
</a>
@@ -61,7 +61,7 @@
6161
<div class="home-logo-mb">
6262
<a href="/" class="logo-link">
6363
<img
64-
:src="getImgUrl(isDark ? 'images/logo2.svg' : 'images/logo2.svg')"
64+
:src="getImgUrl(isDark ? 'images/logo-dark.svg' : 'images/logo.svg')"
6565
alt="OpenTiny NEXT"
6666
class="logo-icon"
6767
/>
@@ -131,7 +131,7 @@
131131
class="home-link home-link-mb"
132132
>
133133
<img
134-
:src="getImgUrl('images/logo.svg')"
134+
:src="getImgUrl('images/logo1.svg')"
135135
alt="OpenTiny NEXT"
136136
class="logo-icon"
137137
/>
@@ -157,12 +157,18 @@
157157
</div>
158158
</template>
159159
<script setup lang="ts">
160-
import { reactive, ref, watch } from "vue";
160+
import { reactive, ref, watch ,onMounted } from "vue";
161161
import { useRoute ,useData } from "vitepress";
162162
// 获取 VitePress 数据
163163
const { site } = useData();
164164
const route = useRoute();
165+
// 暗色模式状态
166+
const isDark = ref(false);
165167
168+
// 初始化暗色模式状态
169+
onMounted(() => {
170+
isDark.value = document.documentElement.classList.contains('dark');
171+
});
166172
const showModal = ref(false);
167173
168174
const backHome = ref('/');
@@ -295,10 +301,11 @@ watch(
295301
height: 2px;
296302
background-color: #dbdbdb;
297303
}
298-
.home-logo-icon {
299-
height: 32px;
300-
width: 32px;
301-
margin: 14px 12px;
304+
.dark .home-logo-mb ::before {
305+
background: rgba(255, 255, 255, 0.1);
306+
}
307+
.dark .home-logo-icon {
308+
background: #1a1a1a;
302309
}
303310
.sidebar {
304311
width: 56px;
@@ -533,6 +540,9 @@ watch(
533540
background-color: #fafafa;
534541
border-radius: 8px;
535542
}
543+
.dark .modal-tab:hover {
544+
background: rgba(255, 255, 255, 0.2);
545+
}
536546
537547
.modal-tab-title {
538548
font-size: 16px;
@@ -565,6 +575,15 @@ watch(
565575
font-weight: 500;
566576
color: #495057;
567577
}
578+
.dark .sidebar{
579+
background: #1a1a1a;
580+
}
581+
.dark .home-logo::before {
582+
background: rgba(255, 255, 255, 0.1);
583+
}
584+
.dark .icon-wrapper:hover {
585+
background: rgba(255, 255, 255, 0.1);
586+
}
568587
569588
@media (max-width: 680px) {
570589
.sidebar {

.vitepress/theme/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@
4545

4646
.VPContent {
4747
padding: 0 !important;
48-
}
48+
}
49+
50+
.dark .opentiny-playground-layout {
51+
background-image: url('images/bg-playground-home-dark.png');
52+
background-color: #000000;
53+
}

0 commit comments

Comments
 (0)