@coffic/cosy-ui 0.8.11 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.css +1 -1
- package/dist/index-astro.ts +18 -10
- package/dist/{src-astro → src}/utils/language.ts +1 -1
- package/dist/src/utils/link.ts +250 -0
- package/dist/{src-astro → src}/utils/path.ts +1 -1
- package/dist/src-astro/article/index.ts +1 -1
- package/dist/src-astro/assets/iconData.ts +5 -0
- package/dist/src-astro/banner/index.ts +1 -1
- package/dist/src-astro/code-container/CodeContainer.astro +6 -91
- package/dist/src-astro/confirm-dialog/ConfirmDialog.astro +119 -0
- package/dist/src-astro/confirm-dialog/index.ts +2 -0
- package/dist/src-astro/confirm-dialog/types.ts +47 -0
- package/dist/src-astro/cosy.ts +1 -1
- package/dist/src-astro/database/index.ts +3 -0
- package/dist/src-astro/entities/BlogDoc.ts +1 -1
- package/dist/src-astro/entities/CourseDoc.ts +1 -1
- package/dist/src-astro/entities/ExperimentDoc.ts +1 -1
- package/dist/src-astro/entities/LessonDoc.ts +1 -1
- package/dist/src-astro/entities/MetaDoc.ts +1 -1
- package/dist/src-astro/entities/Tag.ts +1 -1
- package/dist/src-astro/errors/403.astro +1 -1
- package/dist/src-astro/errors/404.astro +1 -1
- package/dist/src-astro/errors/500.astro +1 -1
- package/dist/src-astro/errors/503.astro +1 -1
- package/dist/src-astro/flex/index.ts +1 -1
- package/dist/src-astro/footer/Footer.astro +1 -1
- package/dist/src-astro/grid/index.ts +1 -1
- package/dist/src-astro/heading/index.ts +1 -1
- package/dist/src-astro/icons/LogOut.astro +28 -0
- package/dist/src-astro/icons/index.ts +1 -0
- package/dist/src-astro/image/index.ts +1 -1
- package/dist/src-astro/language-switcher/index.ts +1 -1
- package/dist/src-astro/layout-basic/index.ts +1 -1
- package/dist/src-astro/layout-dashboard/DashboardLayout.astro +156 -23
- package/dist/src-astro/layout-dashboard/DashboardSidebar.astro +76 -63
- package/dist/src-astro/layout-dashboard/DashboardTopNavbar.astro +47 -15
- package/dist/src-astro/layout-dashboard/tools.ts +158 -0
- package/dist/src-astro/layout-dashboard/types.ts +37 -184
- package/dist/src-astro/link/index.ts +1 -1
- package/dist/src-astro/login/Login.astro +251 -0
- package/dist/src-astro/login/index.ts +2 -0
- package/dist/src-astro/logout/Logout.astro +117 -0
- package/dist/src-astro/logout/index.ts +2 -0
- package/dist/src-astro/module/index.ts +1 -1
- package/dist/src-astro/nav-item/NavItems.astro +1 -1
- package/dist/src-astro/nav-item/index.ts +1 -1
- package/dist/src-astro/nav-section/index.ts +1 -1
- package/dist/src-astro/register/Register.astro +289 -0
- package/dist/src-astro/register/index.ts +2 -0
- package/dist/src-astro/sidebar/Sidebar.astro +1 -1
- package/dist/src-astro/sidebar/index.ts +1 -1
- package/dist/src-astro/sidebar-nav/SidebarNav.astro +1 -1
- package/dist/src-astro/sidebar-nav/index.ts +1 -1
- package/dist/src-astro/speak/index.ts +1 -1
- package/dist/src-astro/stack/index.ts +1 -1
- package/dist/src-astro/team-member/TeamMemberBasic.astro +1 -1
- package/dist/src-astro/team-member/TeamMemberCustomStyle.astro +1 -1
- package/dist/src-astro/team-member/TeamMemberGroup.astro +1 -1
- package/dist/src-astro/team-member/TeamMemberWithSocial.astro +1 -1
- package/dist/src-astro/team-member/index.ts +1 -1
- package/dist/src-astro/text/index.ts +1 -1
- package/dist/src-astro/theme-switcher/ThemeSwitcher.astro +1 -1
- package/dist/src-astro/theme-switcher/index.ts +1 -1
- package/dist/src-astro/toast/Toast.astro +114 -0
- package/dist/src-astro/toast/ToastContainer.astro +249 -0
- package/dist/src-astro/toast/index.ts +4 -0
- package/dist/src-astro/toast/types.ts +78 -0
- package/dist/src-astro/toc/TableOfContents.astro +2 -2
- package/dist/src-astro/toc/index.ts +1 -1
- package/dist/src-astro/types/nav.ts +26 -1
- package/dist/vue/utils/link.ts +238 -238
- package/package.json +1 -1
- package/dist/src-astro/utils/link.ts +0 -250
- /package/dist/{src-astro → src}/utils/component.ts +0 -0
- /package/dist/{src-astro → src}/utils/i18n.ts +0 -0
- /package/dist/{src-astro → src}/utils/image.ts +0 -0
- /package/dist/{src-astro → src}/utils/lang_entry.ts +0 -0
- /package/dist/{src-astro → src}/utils/lang_package.ts +0 -0
- /package/dist/{src-astro → src}/utils/logger.ts +0 -0
- /package/dist/{src-astro → src}/utils/social.ts +0 -0
- /package/dist/{src-astro → src}/utils/theme.ts +0 -0
- /package/dist/{src-astro → src}/utils/url.ts +0 -0
@@ -10,12 +10,20 @@
|
|
10
10
|
* ```astro
|
11
11
|
* ---
|
12
12
|
* import { DashboardTopNavbar } from '@coffic/cosy-ui';
|
13
|
+
*
|
14
|
+
* const userMenuItems = [
|
15
|
+
* { href: '/profile', text: '个人资料' }, // 自动匹配 user 图标
|
16
|
+
* { href: '/settings', text: '设置' }, // 自动匹配 settings 图标
|
17
|
+
* { href: '/logout', text: '退出登录' }, // 自动匹配 logout 图标
|
18
|
+
* { href: '/help', text: '帮助中心', icon: 'help' } // 也可手动指定图标
|
19
|
+
* ];
|
13
20
|
* ---
|
14
21
|
*
|
15
22
|
* <DashboardTopNavbar
|
16
23
|
* title="仪表盘"
|
17
24
|
* userName="管理员"
|
18
25
|
* userAvatar="/avatar.jpg"
|
26
|
+
* userMenuItems={userMenuItems}
|
19
27
|
* />
|
20
28
|
* ```
|
21
29
|
*
|
@@ -23,10 +31,13 @@
|
|
23
31
|
* - title: string - 页面标题,用于面包屑导航
|
24
32
|
* - userName?: string - 用户名
|
25
33
|
* - userAvatar?: string - 用户头像
|
34
|
+
* - userMenuItems?: UserMenuItem[] - 用户菜单项,默认包含个人资料、设置、退出登录,图标会自动匹配
|
26
35
|
*/
|
27
36
|
|
28
37
|
import '../../style.ts';
|
29
38
|
import AstroIcon from '../icons/AstroIcon.astro';
|
39
|
+
import type { UserMenuItem } from './types';
|
40
|
+
import { getUserMenuItemIcon } from './types';
|
30
41
|
|
31
42
|
export interface Props {
|
32
43
|
/**
|
@@ -43,9 +54,23 @@ export interface Props {
|
|
43
54
|
* 用户头像
|
44
55
|
*/
|
45
56
|
userAvatar?: string;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* 用户菜单项
|
60
|
+
*/
|
61
|
+
userMenuItems?: UserMenuItem[];
|
46
62
|
}
|
47
63
|
|
48
|
-
const { title, userName, userAvatar } = Astro.props;
|
64
|
+
const { title, userName, userAvatar, userMenuItems } = Astro.props;
|
65
|
+
|
66
|
+
// 默认用户菜单项
|
67
|
+
const defaultUserMenuItems: UserMenuItem[] = [
|
68
|
+
{ href: '/profile', text: '个人资料' }, // 自动匹配 user 图标
|
69
|
+
{ href: '/settings', text: '设置' }, // 自动匹配 settings 图标
|
70
|
+
{ href: '/logout', text: '退出登录' }, // 自动匹配 logout 图标
|
71
|
+
];
|
72
|
+
|
73
|
+
const menuItems = userMenuItems || defaultUserMenuItems;
|
49
74
|
---
|
50
75
|
|
51
76
|
<div class="cosy:navbar cosy:bg-base-100 cosy:shadow-sm">
|
@@ -53,13 +78,12 @@ const { title, userName, userAvatar } = Astro.props;
|
|
53
78
|
<label
|
54
79
|
for="dashboard-drawer"
|
55
80
|
class="cosy:btn cosy:btn-square cosy:btn-ghost cosy:lg:hidden">
|
56
|
-
<AstroIcon name="menu" size="
|
81
|
+
<AstroIcon name="menu" size="16px" stroke="currentColor" />
|
57
82
|
</label>
|
58
83
|
|
59
|
-
<div
|
60
|
-
|
61
|
-
|
62
|
-
</ul>
|
84
|
+
<div
|
85
|
+
class="cosy:text-base-content/70 cosy:flex cosy:items-center cosy:h-full cosy:text-lg cosy:font-medium cosy:px-4">
|
86
|
+
{title}
|
63
87
|
</div>
|
64
88
|
</div>
|
65
89
|
|
@@ -115,15 +139,23 @@ const { title, userName, userAvatar } = Astro.props;
|
|
115
139
|
<ul
|
116
140
|
tabindex="0"
|
117
141
|
class="cosy:dropdown-content cosy:menu cosy:p-2 cosy:shadow cosy:bg-base-100 cosy:rounded-box cosy:w-52">
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
142
|
+
{menuItems.map((item) => {
|
143
|
+
const iconName = getUserMenuItemIcon(item);
|
144
|
+
return (
|
145
|
+
<li>
|
146
|
+
<a
|
147
|
+
href={item.href}
|
148
|
+
class="cosy:no-underline cosy:flex cosy:items-center cosy:gap-2">
|
149
|
+
<AstroIcon
|
150
|
+
name={iconName}
|
151
|
+
size="16px"
|
152
|
+
stroke="currentColor"
|
153
|
+
/>
|
154
|
+
{item.text}
|
155
|
+
</a>
|
156
|
+
</li>
|
157
|
+
);
|
158
|
+
})}
|
127
159
|
</ul>
|
128
160
|
</div>
|
129
161
|
)
|
@@ -0,0 +1,158 @@
|
|
1
|
+
/**
|
2
|
+
* Dashboard Layout 组件的工具函数
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* 基于 href 关键词匹配图标名称的映射表
|
7
|
+
*/
|
8
|
+
const hrefToIconMap: Record<string, string> = {
|
9
|
+
// 主页相关
|
10
|
+
'dashboard': 'dashboard',
|
11
|
+
'home': 'home',
|
12
|
+
'index': 'home',
|
13
|
+
|
14
|
+
// 用户相关
|
15
|
+
'user': 'user',
|
16
|
+
'users': 'users',
|
17
|
+
'profile': 'user',
|
18
|
+
'account': 'user',
|
19
|
+
'member': 'users',
|
20
|
+
'team': 'users',
|
21
|
+
|
22
|
+
// 设置相关
|
23
|
+
'setting': 'settings',
|
24
|
+
'config': 'settings',
|
25
|
+
'preference': 'settings',
|
26
|
+
'admin': 'settings',
|
27
|
+
'manage': 'settings',
|
28
|
+
'tool': 'tools',
|
29
|
+
|
30
|
+
// 数据相关
|
31
|
+
'chart': 'chart',
|
32
|
+
'analytics': 'chart',
|
33
|
+
'report': 'report',
|
34
|
+
'statistic': 'chart',
|
35
|
+
'data': 'chart',
|
36
|
+
|
37
|
+
// 文档相关
|
38
|
+
'doc': 'document',
|
39
|
+
'document': 'document',
|
40
|
+
'file': 'document',
|
41
|
+
'page': 'document',
|
42
|
+
'article': 'document',
|
43
|
+
'content': 'document',
|
44
|
+
|
45
|
+
// 日历和时间
|
46
|
+
'calendar': 'calendar',
|
47
|
+
'schedule': 'calendar',
|
48
|
+
'event': 'calendar',
|
49
|
+
'date': 'calendar',
|
50
|
+
|
51
|
+
// 通知和消息
|
52
|
+
'notification': 'notification',
|
53
|
+
'message': 'message',
|
54
|
+
'chat': 'message',
|
55
|
+
'mail': 'mail',
|
56
|
+
'email': 'mail',
|
57
|
+
'inbox': 'inboxArchive',
|
58
|
+
|
59
|
+
// 搜索
|
60
|
+
'search': 'search',
|
61
|
+
'find': 'search',
|
62
|
+
|
63
|
+
// 收藏和标记
|
64
|
+
'favorite': 'star',
|
65
|
+
'bookmark': 'star',
|
66
|
+
'star': 'star',
|
67
|
+
'like': 'heart',
|
68
|
+
|
69
|
+
// 文件夹和目录
|
70
|
+
'folder': 'folder',
|
71
|
+
'directory': 'folder',
|
72
|
+
'category': 'folder',
|
73
|
+
|
74
|
+
// 安全和权限
|
75
|
+
'security': 'security',
|
76
|
+
'permission': 'security',
|
77
|
+
'auth': 'security',
|
78
|
+
'login': 'security',
|
79
|
+
|
80
|
+
// 财务相关
|
81
|
+
'payment': 'wallet',
|
82
|
+
'billing': 'wallet',
|
83
|
+
'finance': 'wallet',
|
84
|
+
'money': 'wallet',
|
85
|
+
'wallet': 'wallet',
|
86
|
+
|
87
|
+
// 操作相关
|
88
|
+
'edit': 'edit',
|
89
|
+
'delete': 'delete',
|
90
|
+
'remove': 'delete',
|
91
|
+
'save': 'save',
|
92
|
+
'download': 'download',
|
93
|
+
'upload': 'upload',
|
94
|
+
'refresh': 'refresh',
|
95
|
+
'logout': 'logout',
|
96
|
+
'signin': 'login',
|
97
|
+
'signout': 'logout',
|
98
|
+
'exit': 'logout',
|
99
|
+
|
100
|
+
// 工具和实用程序
|
101
|
+
'clipboard': 'clipboard',
|
102
|
+
'link': 'link',
|
103
|
+
'menu': 'menu',
|
104
|
+
'close': 'close',
|
105
|
+
'check': 'check',
|
106
|
+
'help': 'help',
|
107
|
+
'support': 'help',
|
108
|
+
};
|
109
|
+
|
110
|
+
/**
|
111
|
+
* 根据 href 自动推断图标名称
|
112
|
+
* @param href 链接地址
|
113
|
+
* @param fallbackIcon 如果匹配失败时使用的默认图标
|
114
|
+
* @returns 图标名称
|
115
|
+
*/
|
116
|
+
export function getIconFromHref(href: string, fallbackIcon: string = 'folder'): string {
|
117
|
+
// 将 href 转换为小写并移除路径分隔符
|
118
|
+
const normalizedHref = href.toLowerCase().replace(/[\/\-_]/g, '');
|
119
|
+
|
120
|
+
// 遍历映射表,找到匹配的关键词
|
121
|
+
for (const [keyword, iconName] of Object.entries(hrefToIconMap)) {
|
122
|
+
if (normalizedHref.includes(keyword)) {
|
123
|
+
return iconName;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
return fallbackIcon;
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* 根据 NavItem 获取完整的图标信息
|
132
|
+
* @param item 导航项
|
133
|
+
* @returns 图标名称
|
134
|
+
*/
|
135
|
+
export function getNavItemIcon(item: { href: string; icon?: string }): string {
|
136
|
+
// 如果显式指定了图标,优先使用
|
137
|
+
if (item.icon) {
|
138
|
+
return item.icon;
|
139
|
+
}
|
140
|
+
|
141
|
+
// 否则根据 href 自动推断
|
142
|
+
return getIconFromHref(item.href);
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* 根据 UserMenuItem 获取完整的图标信息
|
147
|
+
* @param item 用户菜单项
|
148
|
+
* @returns 图标名称
|
149
|
+
*/
|
150
|
+
export function getUserMenuItemIcon(item: { href: string; text: string; icon?: string }): string {
|
151
|
+
// 如果显式指定了图标,优先使用
|
152
|
+
if (item.icon) {
|
153
|
+
return item.icon;
|
154
|
+
}
|
155
|
+
|
156
|
+
// 否则根据 href 自动推断,用户菜单默认图标为 'user'
|
157
|
+
return getIconFromHref(item.href, 'user');
|
158
|
+
}
|
@@ -10,6 +10,15 @@ export interface NavItem {
|
|
10
10
|
items?: NavItem[];
|
11
11
|
}
|
12
12
|
|
13
|
+
/**
|
14
|
+
* 用户菜单项接口
|
15
|
+
*/
|
16
|
+
export interface UserMenuItem {
|
17
|
+
href: string;
|
18
|
+
text: string;
|
19
|
+
icon?: string;
|
20
|
+
}
|
21
|
+
|
13
22
|
/**
|
14
23
|
* 侧边栏尺寸类型
|
15
24
|
*/
|
@@ -115,199 +124,43 @@ export function getSidebarTheme(theme: SidebarTheme = 'default') {
|
|
115
124
|
}
|
116
125
|
|
117
126
|
/**
|
118
|
-
*
|
127
|
+
* 主内容区域背景主题类型
|
119
128
|
*/
|
120
|
-
export type
|
129
|
+
export type MainBackgroundTheme = 'transparent' | 'base-100' | 'base-200' | 'base-300' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'gradient-warm' | 'gradient-cool' | 'gradient-rainbow' | 'gradient-sunset' | 'gradient-ocean' | 'gradient-forest';
|
121
130
|
|
122
|
-
/**
|
123
|
-
* 内容区域背景色主题配置映射
|
124
|
-
*/
|
125
|
-
export const contentThemeMap: Record<ContentTheme, { container: string; shadow: string }> = {
|
126
|
-
'card': {
|
127
|
-
container: 'cosy:card cosy:bg-base-100',
|
128
|
-
shadow: 'cosy:shadow-sm'
|
129
|
-
},
|
130
|
-
'transparent': {
|
131
|
-
container: '',
|
132
|
-
shadow: ''
|
133
|
-
},
|
134
|
-
'base': {
|
135
|
-
container: 'cosy:card cosy:bg-base-200',
|
136
|
-
shadow: 'cosy:shadow-sm'
|
137
|
-
},
|
138
|
-
'neutral': {
|
139
|
-
container: 'cosy:card cosy:bg-neutral',
|
140
|
-
shadow: 'cosy:shadow-sm'
|
141
|
-
},
|
142
|
-
'primary': {
|
143
|
-
container: 'cosy:card cosy:bg-primary cosy:text-primary-content',
|
144
|
-
shadow: 'cosy:shadow-sm'
|
145
|
-
},
|
146
|
-
'secondary': {
|
147
|
-
container: 'cosy:card cosy:bg-secondary cosy:text-secondary-content',
|
148
|
-
shadow: 'cosy:shadow-sm'
|
149
|
-
},
|
150
|
-
'accent': {
|
151
|
-
container: 'cosy:card cosy:bg-accent cosy:text-accent-content',
|
152
|
-
shadow: 'cosy:shadow-sm'
|
153
|
-
},
|
154
|
-
'info': {
|
155
|
-
container: 'cosy:card cosy:bg-info cosy:text-info-content',
|
156
|
-
shadow: 'cosy:shadow-sm'
|
157
|
-
},
|
158
|
-
'success': {
|
159
|
-
container: 'cosy:card cosy:bg-success cosy:text-success-content',
|
160
|
-
shadow: 'cosy:shadow-sm'
|
161
|
-
},
|
162
|
-
'warning': {
|
163
|
-
container: 'cosy:card cosy:bg-warning cosy:text-warning-content',
|
164
|
-
shadow: 'cosy:shadow-sm'
|
165
|
-
},
|
166
|
-
'error': {
|
167
|
-
container: 'cosy:card cosy:bg-error cosy:text-error-content',
|
168
|
-
shadow: 'cosy:shadow-sm'
|
169
|
-
}
|
170
|
-
};
|
171
131
|
|
172
|
-
/**
|
173
|
-
* 获取内容区域主题样式类
|
174
|
-
* @param theme 内容主题
|
175
|
-
* @returns 对应的样式配置
|
176
|
-
*/
|
177
|
-
export function getContentTheme(theme: ContentTheme = 'card') {
|
178
|
-
return contentThemeMap[theme];
|
179
|
-
}
|
180
132
|
|
181
133
|
/**
|
182
|
-
*
|
134
|
+
* 主内容区域背景主题配置映射
|
183
135
|
*/
|
184
|
-
const
|
185
|
-
|
186
|
-
'
|
187
|
-
'
|
188
|
-
'
|
189
|
-
|
190
|
-
|
191
|
-
'
|
192
|
-
'
|
193
|
-
'
|
194
|
-
'
|
195
|
-
'
|
196
|
-
'
|
197
|
-
|
198
|
-
|
199
|
-
'
|
200
|
-
'
|
201
|
-
'
|
202
|
-
'
|
203
|
-
'manage': 'settings',
|
204
|
-
'tool': 'tools',
|
205
|
-
|
206
|
-
// 数据相关
|
207
|
-
'chart': 'chart',
|
208
|
-
'analytics': 'chart',
|
209
|
-
'report': 'report',
|
210
|
-
'statistic': 'chart',
|
211
|
-
'data': 'chart',
|
212
|
-
|
213
|
-
// 文档相关
|
214
|
-
'doc': 'document',
|
215
|
-
'document': 'document',
|
216
|
-
'file': 'document',
|
217
|
-
'page': 'document',
|
218
|
-
'article': 'document',
|
219
|
-
'content': 'document',
|
220
|
-
|
221
|
-
// 日历和时间
|
222
|
-
'calendar': 'calendar',
|
223
|
-
'schedule': 'calendar',
|
224
|
-
'event': 'calendar',
|
225
|
-
'date': 'calendar',
|
226
|
-
|
227
|
-
// 通知和消息
|
228
|
-
'notification': 'notification',
|
229
|
-
'message': 'message',
|
230
|
-
'chat': 'message',
|
231
|
-
'mail': 'mail',
|
232
|
-
'email': 'mail',
|
233
|
-
'inbox': 'inboxArchive',
|
234
|
-
|
235
|
-
// 搜索
|
236
|
-
'search': 'search',
|
237
|
-
'find': 'search',
|
238
|
-
|
239
|
-
// 收藏和标记
|
240
|
-
'favorite': 'star',
|
241
|
-
'bookmark': 'star',
|
242
|
-
'star': 'star',
|
243
|
-
'like': 'heart',
|
244
|
-
|
245
|
-
// 文件夹和目录
|
246
|
-
'folder': 'folder',
|
247
|
-
'directory': 'folder',
|
248
|
-
'category': 'folder',
|
249
|
-
|
250
|
-
// 安全和权限
|
251
|
-
'security': 'security',
|
252
|
-
'permission': 'security',
|
253
|
-
'auth': 'security',
|
254
|
-
'login': 'security',
|
255
|
-
|
256
|
-
// 财务相关
|
257
|
-
'payment': 'wallet',
|
258
|
-
'billing': 'wallet',
|
259
|
-
'finance': 'wallet',
|
260
|
-
'money': 'wallet',
|
261
|
-
'wallet': 'wallet',
|
262
|
-
|
263
|
-
// 操作相关
|
264
|
-
'edit': 'edit',
|
265
|
-
'delete': 'delete',
|
266
|
-
'remove': 'delete',
|
267
|
-
'save': 'save',
|
268
|
-
'download': 'download',
|
269
|
-
'upload': 'upload',
|
270
|
-
'refresh': 'refresh',
|
271
|
-
|
272
|
-
// 工具和实用程序
|
273
|
-
'clipboard': 'clipboard',
|
274
|
-
'link': 'link',
|
275
|
-
'menu': 'menu',
|
276
|
-
'close': 'close',
|
277
|
-
'check': 'check',
|
136
|
+
export const mainBackgroundThemeMap: Record<MainBackgroundTheme, string> = {
|
137
|
+
'transparent': '',
|
138
|
+
'base-100': 'cosy:bg-base-100',
|
139
|
+
'base-200': 'cosy:bg-base-200',
|
140
|
+
'base-300': 'cosy:bg-base-300',
|
141
|
+
'neutral': 'cosy:bg-neutral',
|
142
|
+
'primary': 'cosy:bg-primary',
|
143
|
+
'secondary': 'cosy:bg-secondary',
|
144
|
+
'accent': 'cosy:bg-accent',
|
145
|
+
'info': 'cosy:bg-info',
|
146
|
+
'success': 'cosy:bg-success',
|
147
|
+
'warning': 'cosy:bg-warning',
|
148
|
+
'error': 'cosy:bg-error',
|
149
|
+
'gradient-warm': 'cosy:bg-gradient-to-br cosy:from-orange-100 cosy:via-red-50 cosy:to-pink-100',
|
150
|
+
'gradient-cool': 'cosy:bg-gradient-to-br cosy:from-blue-100 cosy:via-cyan-50 cosy:to-green-100',
|
151
|
+
'gradient-rainbow': 'cosy:bg-gradient-to-br cosy:from-purple-100 cosy:via-pink-50 cosy:to-blue-100',
|
152
|
+
'gradient-sunset': 'cosy:bg-gradient-to-br cosy:from-yellow-100 cosy:via-orange-50 cosy:to-red-100',
|
153
|
+
'gradient-ocean': 'cosy:bg-gradient-to-br cosy:from-blue-100 cosy:via-teal-50 cosy:to-cyan-100',
|
154
|
+
'gradient-forest': 'cosy:bg-gradient-to-br cosy:from-green-100 cosy:via-emerald-50 cosy:to-teal-100'
|
278
155
|
};
|
279
156
|
|
280
157
|
/**
|
281
|
-
*
|
282
|
-
* @param
|
283
|
-
* @
|
284
|
-
* @returns 图标名称
|
158
|
+
* 获取主内容区域背景主题样式类
|
159
|
+
* @param theme 主内容区域背景主题
|
160
|
+
* @returns 对应的样式类名
|
285
161
|
*/
|
286
|
-
export function
|
287
|
-
|
288
|
-
const normalizedHref = href.toLowerCase().replace(/[\/\-_]/g, '');
|
289
|
-
|
290
|
-
// 遍历映射表,找到匹配的关键词
|
291
|
-
for (const [keyword, iconName] of Object.entries(hrefToIconMap)) {
|
292
|
-
if (normalizedHref.includes(keyword)) {
|
293
|
-
return iconName;
|
294
|
-
}
|
295
|
-
}
|
296
|
-
|
297
|
-
return fallbackIcon;
|
162
|
+
export function getMainBackgroundTheme(theme: MainBackgroundTheme = 'transparent'): string {
|
163
|
+
return mainBackgroundThemeMap[theme];
|
298
164
|
}
|
299
165
|
|
300
|
-
|
301
|
-
* 根据 NavItem 获取完整的图标信息
|
302
|
-
* @param item 导航项
|
303
|
-
* @returns 图标名称
|
304
|
-
*/
|
305
|
-
export function getNavItemIcon(item: NavItem): string {
|
306
|
-
// 如果显式指定了图标,优先使用
|
307
|
-
if (item.icon) {
|
308
|
-
return item.icon;
|
309
|
-
}
|
310
|
-
|
311
|
-
// 否则根据 href 自动推断
|
312
|
-
return getIconFromHref(item.href);
|
313
|
-
}
|
166
|
+
export { getIconFromHref, getNavItemIcon, getUserMenuItemIcon } from './tools';
|
@@ -5,7 +5,7 @@ import LinkAnimations from './LinkAnimations.astro';
|
|
5
5
|
import BasicSourceCode from './LinkBasic.astro?raw';
|
6
6
|
import VariantsSourceCode from './LinkVariants.astro?raw';
|
7
7
|
import AnimationsSourceCode from './LinkAnimations.astro?raw';
|
8
|
-
import { extractSimpleExample } from '
|
8
|
+
import { extractSimpleExample } from '../../src/utils/component';
|
9
9
|
|
10
10
|
export { Link, LinkBasic, LinkVariants, LinkAnimations };
|
11
11
|
|