Skip to content

Commit 0bd8072

Browse files
committed
✨feat: 正式添加彩虹动画效果
将首页样式更新逻辑中的路径判断从根路径修改为'/vitepress/',以适应新的路由结构。同时,在样式文件中添加了`vars.scss`的导入,确保样式变量的使用,提升样式的可维护性和一致性。
1 parent 1dac257 commit 0bd8072

3 files changed

Lines changed: 136 additions & 2 deletions

File tree

docs/.vitepress/theme/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default {
6161
if (typeof window !== 'undefined') {
6262
watch(
6363
() => router.route.data.relativePath,
64-
() => updateHomePageStyle(location.pathname === '/'),
64+
() => updateHomePageStyle(location.pathname === '/vitepress/'),
6565
{ immediate: true },
6666
)
6767
}

docs/.vitepress/theme/style/index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
@import "./vp-code.css";
33
@import "./vp-code-group.css";
44
@import "./rainbow.scss";
5-
@import "./blur.css";
5+
@import "./blur.css";
6+
@import "./vars.scss";
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/**
2+
* Customize default theme styling by overriding CSS variables:
3+
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
4+
*/
5+
6+
/**
7+
* Colors
8+
* -------------------------------------------------------------------------- */
9+
:root {
10+
--vp-c-gutter: var(--vp-c-divider);
11+
--vp-code-block-bg: rgba(125, 125, 125, 0.04);
12+
--vp-code-tab-divider: var(--vp-c-divider);
13+
--vp-code-copy-code-bg: rgba(125, 125, 125, 0.1);
14+
--vp-code-copy-code-hover-bg: rgba(125, 125, 125, 0.2);
15+
--vp-c-disabled-bg: rgba(125, 125, 125, 0.2);
16+
--vp-code-tab-text-color: var(--vp-c-text-2);
17+
--vp-code-tab-active-text-color: var(--vp-c-text-1);
18+
--vp-code-tab-hover-text-color: var(--vp-c-text-1);
19+
--vp-code-copy-code-active-text: var(--vp-c-text-2);
20+
--vp-c-text-dark-3: rgba(56, 56, 56, 0.8);
21+
--vp-c-brand-lightest: var(--vp-c-brand-1);
22+
23+
--vp-c-highlight-bg: var(--vp-c-brand-light);
24+
--vp-c-highlight-text: var(--vp-c-bg);
25+
}
26+
27+
.dark {
28+
--vp-code-block-bg: rgba(0, 0, 0, 0.2);
29+
--vp-c-text-code: #c0cec0;
30+
}
31+
32+
/**
33+
* Component: Button
34+
* -------------------------------------------------------------------------- */
35+
:root {
36+
--vp-button-brand-border: var(--vp-c-brand-light);
37+
--vp-button-brand-text: var(--vp-c-white);
38+
--vp-button-brand-bg: var(--vp-c-brand-1);
39+
--vp-button-brand-hover-border: var(--vp-c-brand-light);
40+
--vp-button-brand-hover-text: var(--vp-c-white);
41+
--vp-button-brand-hover-bg: var(--vp-c-brand-light);
42+
--vp-button-brand-active-border: var(--vp-c-brand-light);
43+
--vp-button-brand-active-text: var(--vp-c-white);
44+
--vp-button-brand-active-bg: var(--vp-button-brand-bg);
45+
}
46+
47+
/**
48+
* Component: Home
49+
* -------------------------------------------------------------------------- */
50+
:root {
51+
--vp-home-hero-name-color: transparent;
52+
--vp-home-hero-name-background: -webkit-linear-gradient(
53+
120deg,
54+
var(--vp-c-brand-1) 30%,
55+
var(--vp-c-brand-next)
56+
);
57+
--vp-home-hero-image-background-image: linear-gradient(
58+
-45deg,
59+
var(--vp-c-brand-1) 30%,
60+
var(--vp-c-brand-next)
61+
);
62+
--vp-home-hero-image-filter: blur(80px);
63+
}
64+
65+
@media (min-width: 640px) {
66+
:root {
67+
--vp-home-hero-image-filter: blur(120px);
68+
}
69+
}
70+
71+
@media (min-width: 960px) {
72+
:root {
73+
--vp-home-hero-image-filter: blur(120px);
74+
}
75+
}
76+
77+
/* Safari has a very bad performance on gradient and filter */
78+
.browser-safari,
79+
.browser-firefox {
80+
--vp-home-hero-image-background-image: transparent;
81+
--vp-home-hero-image-filter: "";
82+
}
83+
84+
/**
85+
* Component: Custom Block
86+
* -------------------------------------------------------------------------- */
87+
// :root {
88+
// --vp-custom-block-tip-border: var(--vp-c-brand-1);
89+
// --vp-custom-block-tip-text: var(--vp-c-brand-darker);
90+
// --vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
91+
// }
92+
// .dark {
93+
// --vp-custom-block-tip-border: var(--vp-c-brand-1);
94+
// --vp-custom-block-tip-text: var(--vp-c-brand-lightest);
95+
// --vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
96+
// }
97+
98+
/**
99+
* Component: Algolia
100+
* -------------------------------------------------------------------------- */
101+
.DocSearch {
102+
--docsearch-primary-color: var(--vp-c-brand-1) !important;
103+
}
104+
105+
/* 去掉横线 */
106+
.vp-doc a {
107+
text-decoration: none;
108+
}
109+
110+
111+
.VPFeature {
112+
display: block;
113+
border: 1px solid var(--vp-c-bg-soft);
114+
border-radius: 12px;
115+
height: 100%;
116+
background-color: var(--vp-c-bg-soft);
117+
transition: border-color .25s,background-color .25s,transform 0.4s;
118+
}
119+
120+
.VPFeature.link:hover {
121+
border-color: var(--vp-c-brand-1);
122+
123+
}
124+
125+
/* 卡片悬浮效果 */
126+
.VPFeatures .items .item {
127+
transition: transform 0.3s;
128+
}
129+
130+
.VPFeatures .items .item:hover {
131+
border-color: var(--vp-c-brand-1) !important;
132+
transform: translateY(-5px);
133+
}

0 commit comments

Comments
 (0)