File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2499,38 +2499,6 @@ body {
24992499 gap : 16px ;
25002500}
25012501
2502- /* 挂件抽屉:主题切换按钮 */
2503- .widgets-theme-btn {
2504- display : flex;
2505- align-items : center;
2506- justify-content : center;
2507- gap : 8px ;
2508- width : 100% ;
2509- padding : 10px 14px ;
2510- border : 1px solid var (--border );
2511- border-radius : 10px ;
2512- background : transparent;
2513- color : var (--text );
2514- font-size : 13px ;
2515- font-weight : 650 ;
2516- cursor : pointer;
2517- transition : background 0.15s ease, border-color 0.15s ease;
2518- }
2519-
2520- .widgets-theme-btn : hover {
2521- background : rgba (74 , 163 , 255 , 0.08 );
2522- border-color : rgba (74 , 163 , 255 , 0.3 );
2523- }
2524-
2525- [data-theme = 'dark' ] .widgets-theme-btn {
2526- background : rgba (255 , 255 , 255 , 0.04 );
2527- }
2528-
2529- [data-theme = 'dark' ] .widgets-theme-btn : hover {
2530- background : rgba (255 , 255 , 255 , 0.08 );
2531- border-color : rgba (255 , 255 , 255 , 0.15 );
2532- }
2533-
25342502/* 兼容旧样式:
25352503 早期版本用 .site-top-actions / .top-action-btn / .theme-toggle 组织顶栏。
25362504 现在顶栏已切换到 .site-brand / .site-nav,但仍可能有页面引用旧 class。
Original file line number Diff line number Diff line change 99 </span >
1010 <span class =" right-dock-text" >个人信息</span >
1111 </button >
12+
13+ <button type =" button" class =" right-dock-btn" @click =" onToggle" :aria-label =" isDark ? '切换到浅色模式' : '切换到深色模式'" >
14+ <span class =" right-dock-ico" aria-hidden =" true" >{{ isDark ? '☀' : '☽' }}</span >
15+ <span class =" right-dock-text" >{{ isDark ? '浅色' : '深色' }}</span >
16+ </button >
1217 </div >
1318</template >
1419
1520<script setup>
16- import { ref } from ' vue'
21+ import { onMounted , ref } from ' vue'
22+ import { toggleTheme as applyToggle } from ' ../theme'
1723
1824const emit = defineEmits ([' toggle-profile' ])
1925const expanded = ref (false )
26+ const isDark = ref (false )
27+
28+ function sync () {
29+ isDark .value = document .documentElement .getAttribute (' data-theme' ) === ' dark'
30+ }
31+
32+ function onToggle () {
33+ applyToggle ()
34+ sync ()
35+ }
2036
2137function onLeave () {
2238 expanded .value = false
2339}
40+
41+ onMounted (() => {
42+ sync ()
43+ })
2444 </script >
Original file line number Diff line number Diff line change 77 </div >
88 <div class =" widgets-drawer-body" >
99 <ProfileCard :profile =" profile " />
10-
11- <button type =" button" class =" widgets-theme-btn" @click =" onToggle" >
12- <span aria-hidden =" true" >{{ isDark ? '☀' : '☽' }}</span >
13- {{ isDark ? '浅色模式' : '深色模式' }}
14- </button >
15-
1610 <BlogInfoCard />
1711 </div >
1812 </aside >
1913</template >
2014
2115<script setup>
22- import { onMounted , ref } from ' vue'
23- import { toggleTheme as applyToggle } from ' ../theme'
2416import ProfileCard from ' ./ProfileCard.vue'
2517import BlogInfoCard from ' ./BlogInfoCard.vue'
2618
@@ -30,18 +22,4 @@ defineProps({
3022})
3123
3224const emit = defineEmits ([' close' ])
33- const isDark = ref (false )
34-
35- function sync () {
36- isDark .value = document .documentElement .getAttribute (' data-theme' ) === ' dark'
37- }
38-
39- function onToggle () {
40- applyToggle ()
41- sync ()
42- }
43-
44- onMounted (() => {
45- sync ()
46- })
4725 </script >
You can’t perform that action at this time.
0 commit comments