Skip to content

Commit 7d61781

Browse files
authored
feat: address the issues with returning to the homepage and styles (#8)
1 parent 4d15511 commit 7d61781

File tree

2 files changed

+134
-24
lines changed

2 files changed

+134
-24
lines changed

.vitepress/theme/components/CustomHeader.vue

Lines changed: 115 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,6 @@
124124
</div>
125125

126126
<div class="nav-buttons">
127-
<button class="nav-button" @click="openSearch">
128-
<svg
129-
width="16"
130-
height="16"
131-
fill="none"
132-
stroke="currentColor"
133-
viewBox="0 0 24 24"
134-
>
135-
<path
136-
stroke-linecap="round"
137-
stroke-linejoin="round"
138-
stroke-width="2"
139-
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
140-
/>
141-
</svg>
142-
</button>
143127
<button class="nav-button" @click="showModal = true">
144128
<svg
145129
width="16"
@@ -162,6 +146,77 @@
162146

163147
</div>
164148
</header>
149+
<!-- 弹框 -->
150+
<div class="modal-overlay-home" v-if="showModal" @click="showModal = false">
151+
<div class="modal-home" @click.stop>
152+
<div class="modal-theme-mb">
153+
<span>外观切换</span>
154+
<!-- 移动端主题切换 -->
155+
<button @click="toggleDark" class="tool-switch" title="Toggle theme">
156+
<svg
157+
v-if="!isDark"
158+
class="normal-svg"
159+
width="16"
160+
height="16"
161+
fill="none"
162+
stroke="currentColor"
163+
viewBox="0 0 24 24"
164+
>
165+
<path
166+
stroke-linecap="round"
167+
stroke-linejoin="round"
168+
stroke-width="2"
169+
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"
170+
/>
171+
</svg>
172+
<svg
173+
v-else
174+
class="dark-svg"
175+
width="16"
176+
height="16"
177+
fill="none"
178+
stroke="currentColor"
179+
viewBox="0 0 24 24"
180+
>
181+
<path
182+
stroke-linecap="round"
183+
stroke-linejoin="round"
184+
stroke-width="2"
185+
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
186+
/>
187+
</svg>
188+
</button>
189+
</div>
190+
<div class="modal-header">
191+
<a
192+
href="https://opentiny.design"
193+
title="OpenTiny"
194+
class="home-link home-link-mb"
195+
>
196+
<img
197+
:src="'images/logo.svg'"
198+
alt="OpenTiny NEXT"
199+
class="logo-icon"
200+
/>
201+
<span>OpenTiny</span>
202+
<svg
203+
width="3"
204+
height="24"
205+
viewBox="0 -9 3 24"
206+
class="h-5 rotate-0 overflow-visible text-white/90"
207+
>
208+
<path
209+
d="M0 0L3 3L0 6"
210+
fill="none"
211+
stroke="currentColor"
212+
stroke-width="1.5"
213+
stroke-linecap="round"
214+
></path>
215+
</svg>
216+
</a>
217+
</div>
218+
</div>
219+
</div>
165220
</div>
166221
</template>
167222

@@ -175,8 +230,6 @@ const { site, theme } = useData();
175230
const route = useRoute();
176231
const router = useRouter();
177232
178-
const showModal = ref(false);
179-
180233
// 获取主题配置
181234
const themeConfig = computed(() => theme.value);
182235
@@ -219,6 +272,7 @@ const toggleDark = () => {
219272
}
220273
};
221274
275+
const showModal = ref(false);
222276
223277
224278
const prefix = site.value.base || '/';
@@ -317,6 +371,10 @@ watch(
317371
background-color: var(--home-link-bg-color);
318372
}
319373
374+
.home-link svg{
375+
width: 8px;
376+
}
377+
320378
.home-link-mb {
321379
width: 182px;
322380
line-height: 38px;
@@ -376,7 +434,45 @@ watch(
376434
border-radius: 50%;
377435
}
378436
379-
437+
.modal-overlay-home {
438+
position: fixed;
439+
overflow-y: auto;
440+
z-index: 99;
441+
inset: 0;
442+
backdrop-filter: blur(4px);
443+
background-color: rgba(255, 255, 255, 0.05) !important;
444+
}
445+
.dark .modal-overlay-home {
446+
background: rgba(0, 0, 0, 0.8);
447+
}
448+
.modal-overlay-home .modal-home {
449+
position: fixed;
450+
top: 64px;
451+
right: 0;
452+
width: 250px;
453+
454+
border-radius: 12px;
455+
padding: 20px;
456+
background: #ffffff;
457+
overflow: hidden;
458+
z-index: 1000;
459+
animation: modal-appear 0.3s ease-out;
460+
border: 1px solid rgba(0, 0, 0, 0.2);
461+
}
462+
.dark .modal-home {
463+
background: rgba(0, 0, 0);
464+
border: 1px solid rgba(255, 255, 255, 0.2);
465+
}
466+
@keyframes modal-appear {
467+
from {
468+
opacity: 0;
469+
transform: translateY(-20px) scale(0.9);
470+
}
471+
to {
472+
opacity: 1;
473+
transform: translateY(0) scale(1);
474+
}
475+
}
380476
/* 响应式设计 */
381477
@media (min-width: 980px) {
382478
.header-top {

.vitepress/theme/components/customContent.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="custom-content">
33
<div class="sidebar">
44
<div class="home-logo">
5-
<a href="/" rel="noopener noreferrer">
5+
<a :href="backHome" rel="noopener noreferrer">
66
<img
77
:src="isDark ? 'images/mini-logo.svg' : 'images/mini-logo.svg'"
88
class="home-logo-icon"
@@ -158,11 +158,16 @@
158158
</template>
159159
<script setup lang="ts">
160160
import { reactive, ref, watch } from "vue";
161-
import { useRoute } from "vitepress";
161+
import { useRoute ,useData } from "vitepress";
162+
// 获取 VitePress 数据
163+
const { site } = useData();
162164
const route = useRoute();
163165
164166
const showModal = ref(false);
165167
168+
const backHome = ref('/');
169+
backHome.value = site.value.base;
170+
166171
const iconLists = reactive([
167172
{
168173
src: "images/tiny-vue-logo.svg",
@@ -199,7 +204,7 @@ const iconLists = reactive([
199204
]);
200205
201206
const tipIdx = ref(null);
202-
const linkUrl = ref("https://opentiny.design/vue-playground");
207+
const linkUrl = ref("https://opentiny.design/vue-playground?cmpId=button&fileName=click.vue&apiMode=Composition&mode=pc&theme=os");
203208
function showTip(idx) {
204209
tipIdx.value = idx;
205210
}
@@ -211,6 +216,11 @@ const changeIcon = (idx) => {
211216
icon.isActive = index === idx;
212217
});
213218
};
219+
const changeIconActive = (key) => {
220+
iconLists.forEach((icon, index) => {
221+
icon.isActive = iconLists[index].title === key;
222+
});
223+
};
214224
215225
interface TabItem {
216226
key: string;
@@ -228,13 +238,17 @@ const getModalTabClasses = (tab: TabItem) => ({
228238
watch(
229239
() => route.path,
230240
() => {
241+
let title = "TinyVue";
231242
if (route.path.includes("/vue-playground")) {
232-
linkUrl.value = "https://opentiny.design/vue-playground";
243+
linkUrl.value = "https://opentiny.design/vue-playground?cmpId=button&fileName=click.vue&apiMode=Composition&mode=pc&theme=os";
244+
title = "TinyVue";
233245
} else if (route.path.includes("/tiny-engine")) {
234246
linkUrl.value = "https://opentiny.design/tiny-engine#/tiny-engine-editor";
247+
title = "TinyEngine";
235248
} else {
236-
linkUrl.value = "https://opentiny.design/vue-playground";
249+
linkUrl.value = "https://opentiny.design/vue-playground?cmpId=button&fileName=click.vue&apiMode=Composition&mode=pc&theme=os";
237250
}
251+
changeIconActive(title);
238252
},
239253
{ deep: true, immediate: true }
240254
);

0 commit comments

Comments
 (0)