Skip to content

Commit b528636

Browse files
committed
评论功能5
1 parent 44e18e7 commit b528636

13 files changed

Lines changed: 80 additions & 149 deletions

yunyu-web/app/components/ThemeModeSwitch.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ import { computed, onMounted, ref } from 'vue'
55
* 主题切换组件。
66
* 作用:以前后台共用的单按钮方式切换明亮、暗黑、系统三种主题模式。
77
*/
8+
interface ThemeModeSwitchProps {
9+
/**
10+
* 组件展示风格。
11+
* 作用:允许在导航栏中使用纯图标样式,在后台继续复用默认按钮样式。
12+
*/
13+
variant?: 'default' | 'icon'
14+
}
15+
816
const colorMode = useColorMode()
917
const isMounted = ref(false)
18+
const props = withDefaults(defineProps<ThemeModeSwitchProps>(), {
19+
variant: 'default'
20+
})
1021
1122
const themeOptions = [
1223
{
@@ -56,6 +67,18 @@ const nextTheme = computed(() => {
5667
return themeOptions[nextIndex]
5768
})
5869
70+
/**
71+
* 计算按钮样式。
72+
* 作用:根据不同使用场景切换为默认按钮态或纯图标态,避免导航栏额外出现背景块。
73+
*/
74+
const buttonClassName = computed(() => {
75+
if (props.variant === 'icon') {
76+
return 'inline-flex size-10 items-center justify-center text-slate-600 transition duration-200 hover:text-slate-900 focus:outline-none focus:ring-0 dark:text-slate-300 dark:hover:text-slate-50'
77+
}
78+
79+
return 'inline-flex size-10 items-center justify-center rounded-[8px] border border-slate-200 bg-white text-slate-600 transition duration-200 hover:border-slate-300 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-sky-400/35 dark:border-slate-700 dark:bg-slate-950/70 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-slate-50'
80+
})
81+
5982
/**
6083
* 顺序切换主题模式。
6184
* 作用:按照“明亮 -> 暗黑 -> 系统”的顺序循环切换。
@@ -72,7 +95,7 @@ onMounted(() => {
7295
<template>
7396
<button
7497
type="button"
75-
class="inline-flex size-10 items-center justify-center rounded-[8px] border border-slate-200 bg-white text-slate-600 transition duration-200 hover:border-slate-300 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-sky-400/35 dark:border-slate-700 dark:bg-slate-950/70 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-slate-50"
98+
:class="buttonClassName"
7699
:aria-label="`当前主题:${activeTheme.label},点击切换到${nextTheme.label}`"
77100
:title="`当前主题:${activeTheme.label},点击切换到${nextTheme.label}`"
78101
@click="cycleTheme"

yunyu-web/app/layouts/default.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,14 @@ async function handleUserMenuSelect(item: { key: string }) {
266266
>
267267
<div class="flex min-w-0 items-center gap-3 sm:gap-4">
268268
<NuxtLink to="/" class="flex shrink-0 items-center gap-3">
269-
<div class="flex h-11 w-11 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,#38bdf8,#fb923c)] text-sm font-semibold text-white shadow-[0_12px_28px_-16px_rgba(56,189,248,0.7)]">
270-
269+
<div
270+
class="flex h-11 w-11 items-center justify-center overflow-hidden rounded-2xl shadow-[0_12px_28px_-18px_rgba(15,23,42,0.18)]"
271+
>
272+
<img
273+
src="/icon-512-maskable.png"
274+
alt="云屿图标"
275+
class="h-full w-full object-cover"
276+
>
271277
</div>
272278
<div class="min-w-0">
273279
<p class="text-[clamp(1.25rem,1.05rem+0.75vw,1.7rem)] font-semibold leading-[0.96] tracking-[-0.05em] [font-family:var(--font-display)]" :class="brandTitleClassName">云屿</p>
@@ -294,7 +300,7 @@ async function handleUserMenuSelect(item: { key: string }) {
294300
</div>
295301

296302
<div class="flex shrink-0 items-center gap-2">
297-
<ThemeModeSwitch />
303+
<ThemeModeSwitch variant="icon" />
298304

299305
<YunyuDropdownMenu
300306
v-if="isLoggedIn"

yunyu-web/nuxt.config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,23 @@ export default defineNuxtConfig({
3737
},
3838
{
3939
rel: 'icon',
40-
type: 'image/svg+xml',
41-
href: '/favicon.svg'
40+
type: 'image/x-icon',
41+
href: '/favicon.ico',
42+
sizes: 'any'
4243
},
4344
{
44-
rel: 'alternate icon',
45-
type: 'image/x-icon',
46-
href: '/favicon.ico'
45+
rel: 'apple-touch-icon',
46+
href: '/apple-touch-icon.png'
47+
},
48+
{
49+
rel: 'manifest',
50+
href: '/site.webmanifest'
4751
}
4852
],
4953
meta: [
5054
{ charset: 'utf-8' },
5155
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
56+
{ name: 'theme-color', content: '#f7f5ef' },
5257
{
5358
name: 'description',
5459
content: '云屿前端项目,基于 Nuxt 4 构建内容站与后台管理界面。'
52.8 KB
Loading

yunyu-web/public/favicon-back.svg

Lines changed: 0 additions & 35 deletions
This file was deleted.

yunyu-web/public/favicon-soft-cloud.svg

Lines changed: 0 additions & 54 deletions
This file was deleted.

yunyu-web/public/favicon.ico

952 Bytes
Binary file not shown.

yunyu-web/public/favicon.svg

Lines changed: 0 additions & 51 deletions
This file was deleted.
59.1 KB
Loading

yunyu-web/public/icon-192.png

50.7 KB
Loading

0 commit comments

Comments
 (0)