Skip to content

Commit dbf3ee1

Browse files
committed
提升主题支持并优化标签组件
- 升级 Vue 至 3.5.17,更新依赖。 - 添加主题切换支持,扩展图片路径解析功能。 - 替换标签渲染逻辑为新组件 `UnifiedTag`,确保视觉一致性。 - 小幅优化样式与交互,提升整体用户体验。
1 parent 99727cc commit dbf3ee1

File tree

11 files changed

+758
-625
lines changed

11 files changed

+758
-625
lines changed

package-lock.json

Lines changed: 532 additions & 554 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"vue": "^3.2.45"
12+
"vue": "^3.5.17"
1313
},
1414
"devDependencies": {
1515
"@vicons/ionicons5": "^0.12.0",

public/img/fol_mk2_guild_dark.jpg

157 KB
Loading

public/img/fol_mk2_guild_light.jpg

154 KB
Loading

public/img/fol_mk2_qq_dark.jpg

204 KB
Loading

public/img/fol_mk2_qq_light.jpg

176 KB
Loading

src/components/HomeHead.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<n-card embedded
33
:bordered="false">
4-
<n-page-header subtitle="探寻你的梦中情档">
4+
<n-page-header subtitle="探寻你的梦中情档" style="user-select: none;">
55
<template #title>
6-
<n-text style="font-size: 24px;" class="title">Simple Robot</n-text>
6+
<n-text style="font-size: 24px; user-select: none;" class="title">Simple Robot</n-text>
77
</template>
88

99
<n-menu v-model:value="menuActiveKey"
@@ -20,6 +20,7 @@
2020
:src="logoSvg"
2121
color="FFFFFF00"
2222
:img-props="{draggable: false}"
23+
style="user-select: none;"
2324
/>
2425
</template>
2526
<template #extra>

src/components/Index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<n-config-provider :theme="theme">
3-
<div id="center-body">
3+
<div id="center-body" :data-theme="theme ? 'dark' : 'light'">
44
<n-layout position="absolute">
55
<n-layout-header bordered>
66
<HomeHead @theme-active-change="onThemeActiveChange" :init-theme-active-value="initThemeActiveValue"/>
@@ -39,7 +39,7 @@
3939
</n-card>
4040
<n-card embedded :bordered="false">
4141
<n-collapse-item name="作品展示">
42-
<ShowCards/>
42+
<ShowCards :theme="theme" />
4343
<template #header>
4444
<n-divider title-placement="left" style="user-select: none">
4545
<n-text strong style="font-size: 19px" class="sub-text">作品展示</n-text>

src/components/RepoDocCards.vue

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
</n-image-group>
2020

2121
<n-space size="small">
22-
<component v-for="{ component, props } in card.tags"
23-
v-bind="props"
24-
:is="component"
25-
v-html="props.name" />
22+
<UnifiedTag
23+
v-for="tag in card.tags"
24+
:key="tag.name"
25+
:name="tag.name"
26+
:type="tag.type"
27+
:allow-html="true"
28+
/>
2629
</n-space>
2730

2831

@@ -54,7 +57,10 @@
5457
*/
5558
5659
// Naive UI 组件导入
57-
import {NA, NButton, NCard, NGi, NGrid, NImage, NImageGroup, NP, NSpace, NTag} from "naive-ui";
60+
import {NA, NButton, NCard, NGi, NGrid, NImage, NImageGroup, NP, NSpace} from "naive-ui";
61+
62+
// 统一标签组件导入
63+
import UnifiedTag from "./common/UnifiedTag.vue";
5864
5965
// ==================== 类型定义 ====================
6066
@@ -91,7 +97,7 @@ interface LinkConfig {
9197
*/
9298
interface ComponentCard {
9399
name: string;
94-
tags: ReturnType<typeof Tag>[];
100+
tags: TagConfig[];
95101
shields: ReturnType<typeof Shield>[];
96102
description: string;
97103
links: LinkConfig[][];
@@ -100,21 +106,6 @@ interface ComponentCard {
100106
101107
// ==================== 辅助函数 ====================
102108
103-
/**
104-
* 创建标签组件配置
105-
* @param props - 标签属性配置
106-
* @returns 标签组件配置对象
107-
*/
108-
function Tag(props: TagConfig) {
109-
return {
110-
component: NTag,
111-
props: {
112-
round: props.round ?? true,
113-
size: props.size ?? 'small',
114-
...props
115-
}
116-
};
117-
}
118109
119110
/**
120111
* 创建徽章组件配置
@@ -134,22 +125,22 @@ function Shield(props: ShieldConfig) {
134125
// ==================== 预定义标签 ====================
135126
136127
/** 官方标签 - 标识官方维护的组件 */
137-
const officialTag = Tag({ name: 'Official', type: 'info' });
128+
const officialTag: TagConfig = { name: 'Official', type: 'info' };
138129
139130
/** 核心标签 - 标识核心库组件 */
140-
const coreTag = Tag({ name: '核心', type: 'info' });
131+
const coreTag: TagConfig = { name: '核心', type: 'info' };
141132
142133
/** 组件标签 - 标识组件库类型 */
143-
const componentTag = Tag({ name: "组件", type: "success" });
134+
const componentTag: TagConfig = { name: "组件", type: "success" };
144135
145136
/** 开发中标签 - 标识正在开发的组件 */
146-
const WIPTag = Tag({ name: '<b>🚧WIP</b>', type: 'warning' });
137+
const WIPTag: TagConfig = { name: '<b>🚧WIP</b>', type: 'warning' };
147138
148139
/** 期待协助标签 - 标识需要社区帮助的组件 */
149-
const helpWanted = Tag({ name: '<b>🤝期待协助</b>', type: 'success' });
140+
const helpWanted: TagConfig = { name: '<b>🤝期待协助</b>', type: 'success' };
150141
151142
/** 已废弃标签 - 标识不再维护的组件 */
152-
const deadTag = Tag({ name: '<b>💀阵亡</b>', type: 'error' });
143+
const deadTag: TagConfig = { name: '<b>💀阵亡</b>', type: 'error' };
153144
154145
const componentCards: ComponentCard[] = [
155146
{
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<template>
2+
<n-tag
3+
:type="type"
4+
size="small"
5+
round
6+
v-bind="$attrs"
7+
>
8+
<span v-if="allowHtml" v-html="name"></span>
9+
<span v-else>{{ name }}</span>
10+
</n-tag>
11+
</template>
12+
13+
<script setup lang="ts">
14+
/**
15+
* 统一标签组件 - UnifiedTag
16+
* 基于"作品展示"中的Tag样式,提供统一的标签显示效果
17+
* 特点:小尺寸(small)、圆角(round)、支持多种类型和HTML内容
18+
*/
19+
20+
import {NTag} from "naive-ui";
21+
22+
// ==================== 类型定义 ====================
23+
24+
/**
25+
* 标签类型枚举
26+
*/
27+
type TagType = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'error';
28+
29+
/**
30+
* 组件属性接口
31+
*/
32+
interface Props {
33+
/** 标签显示的名称/内容 */
34+
name: string;
35+
/** 标签类型,决定颜色主题 */
36+
type?: TagType;
37+
/** 是否允许HTML内容(用于支持富文本标签) */
38+
allowHtml?: boolean;
39+
}
40+
41+
// ==================== 属性定义 ====================
42+
43+
/**
44+
* 组件属性,设置默认值
45+
*/
46+
const props = withDefaults(defineProps<Props>(), {
47+
type: 'default',
48+
allowHtml: false
49+
});
50+
51+
// 继承所有未声明的属性,允许传递给底层的 n-tag 组件
52+
defineOptions({
53+
inheritAttrs: false
54+
});
55+
</script>
56+
57+
<style scoped>
58+
/**
59+
* 统一标签样式
60+
* 基于"作品展示"的设计规范,确保视觉一致性
61+
*/
62+
63+
/* 标签基础样式已由 naive-ui 的 n-tag 组件提供 */
64+
/* size="small" 和 round 属性确保了与"作品展示"一致的外观 */
65+
66+
/**
67+
* 如果需要额外的自定义样式,可以在这里添加
68+
* 例如:特殊的间距、动画效果等
69+
*/
70+
</style>

0 commit comments

Comments
 (0)