@coffic/cosy-ui 0.8.12 → 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.
Files changed (80) hide show
  1. package/dist/app.css +1 -1
  2. package/dist/index-astro.ts +18 -10
  3. package/dist/{src-astro → src}/utils/language.ts +1 -1
  4. package/dist/src/utils/link.ts +250 -0
  5. package/dist/{src-astro → src}/utils/path.ts +1 -1
  6. package/dist/src-astro/article/index.ts +1 -1
  7. package/dist/src-astro/assets/iconData.ts +5 -0
  8. package/dist/src-astro/banner/index.ts +1 -1
  9. package/dist/src-astro/code-container/CodeContainer.astro +6 -91
  10. package/dist/src-astro/confirm-dialog/ConfirmDialog.astro +119 -0
  11. package/dist/src-astro/confirm-dialog/index.ts +2 -0
  12. package/dist/src-astro/confirm-dialog/types.ts +47 -0
  13. package/dist/src-astro/cosy.ts +1 -1
  14. package/dist/src-astro/database/index.ts +3 -0
  15. package/dist/src-astro/entities/BlogDoc.ts +1 -1
  16. package/dist/src-astro/entities/CourseDoc.ts +1 -1
  17. package/dist/src-astro/entities/ExperimentDoc.ts +1 -1
  18. package/dist/src-astro/entities/LessonDoc.ts +1 -1
  19. package/dist/src-astro/entities/MetaDoc.ts +1 -1
  20. package/dist/src-astro/entities/Tag.ts +1 -1
  21. package/dist/src-astro/errors/403.astro +1 -1
  22. package/dist/src-astro/errors/404.astro +1 -1
  23. package/dist/src-astro/errors/500.astro +1 -1
  24. package/dist/src-astro/errors/503.astro +1 -1
  25. package/dist/src-astro/flex/index.ts +1 -1
  26. package/dist/src-astro/footer/Footer.astro +1 -1
  27. package/dist/src-astro/grid/index.ts +1 -1
  28. package/dist/src-astro/heading/index.ts +1 -1
  29. package/dist/src-astro/icons/LogOut.astro +28 -0
  30. package/dist/src-astro/icons/index.ts +1 -0
  31. package/dist/src-astro/image/index.ts +1 -1
  32. package/dist/src-astro/language-switcher/index.ts +1 -1
  33. package/dist/src-astro/layout-basic/index.ts +1 -1
  34. package/dist/src-astro/layout-dashboard/DashboardLayout.astro +76 -1
  35. package/dist/src-astro/layout-dashboard/tools.ts +158 -0
  36. package/dist/src-astro/layout-dashboard/types.ts +1 -154
  37. package/dist/src-astro/link/index.ts +1 -1
  38. package/dist/src-astro/login/Login.astro +251 -0
  39. package/dist/src-astro/login/index.ts +2 -0
  40. package/dist/src-astro/logout/Logout.astro +117 -0
  41. package/dist/src-astro/logout/index.ts +2 -0
  42. package/dist/src-astro/module/index.ts +1 -1
  43. package/dist/src-astro/nav-item/NavItems.astro +1 -1
  44. package/dist/src-astro/nav-item/index.ts +1 -1
  45. package/dist/src-astro/nav-section/index.ts +1 -1
  46. package/dist/src-astro/register/Register.astro +289 -0
  47. package/dist/src-astro/register/index.ts +2 -0
  48. package/dist/src-astro/sidebar/Sidebar.astro +1 -1
  49. package/dist/src-astro/sidebar/index.ts +1 -1
  50. package/dist/src-astro/sidebar-nav/SidebarNav.astro +1 -1
  51. package/dist/src-astro/sidebar-nav/index.ts +1 -1
  52. package/dist/src-astro/speak/index.ts +1 -1
  53. package/dist/src-astro/stack/index.ts +1 -1
  54. package/dist/src-astro/team-member/TeamMemberBasic.astro +1 -1
  55. package/dist/src-astro/team-member/TeamMemberCustomStyle.astro +1 -1
  56. package/dist/src-astro/team-member/TeamMemberGroup.astro +1 -1
  57. package/dist/src-astro/team-member/TeamMemberWithSocial.astro +1 -1
  58. package/dist/src-astro/team-member/index.ts +1 -1
  59. package/dist/src-astro/text/index.ts +1 -1
  60. package/dist/src-astro/theme-switcher/ThemeSwitcher.astro +1 -1
  61. package/dist/src-astro/theme-switcher/index.ts +1 -1
  62. package/dist/src-astro/toast/Toast.astro +114 -0
  63. package/dist/src-astro/toast/ToastContainer.astro +249 -0
  64. package/dist/src-astro/toast/index.ts +4 -0
  65. package/dist/src-astro/toast/types.ts +78 -0
  66. package/dist/src-astro/toc/TableOfContents.astro +2 -2
  67. package/dist/src-astro/toc/index.ts +1 -1
  68. package/dist/src-astro/types/nav.ts +26 -1
  69. package/dist/vue/utils/link.ts +238 -238
  70. package/package.json +1 -1
  71. package/dist/src-astro/utils/link.ts +0 -250
  72. /package/dist/{src-astro → src}/utils/component.ts +0 -0
  73. /package/dist/{src-astro → src}/utils/i18n.ts +0 -0
  74. /package/dist/{src-astro → src}/utils/image.ts +0 -0
  75. /package/dist/{src-astro → src}/utils/lang_entry.ts +0 -0
  76. /package/dist/{src-astro → src}/utils/lang_package.ts +0 -0
  77. /package/dist/{src-astro → src}/utils/logger.ts +0 -0
  78. /package/dist/{src-astro → src}/utils/social.ts +0 -0
  79. /package/dist/{src-astro → src}/utils/theme.ts +0 -0
  80. /package/dist/{src-astro → src}/utils/url.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { BlogEntry } from '../database/BlogDB';
2
- import { LinkUtil } from '../utils/link';
2
+ import { LinkUtil } from '../../src/utils/link';
3
3
  import Tag from './Tag';
4
4
  import { BaseDoc } from './BaseDoc';
5
5
  import { COLLECTION_BLOG } from '../database/BlogDB';
@@ -2,7 +2,7 @@ import { cosyLogger } from '../cosy';
2
2
  import { SidebarItemEntity } from './SidebarItem';
3
3
  import type { CourseEntry } from '../database/CourseDB';
4
4
  import { courseDB } from '../database/CourseDB';
5
- import { LinkUtil } from '../utils/link';
5
+ import { LinkUtil } from '../../src/utils/link';
6
6
  import { COLLECTION_COURSE } from '../database/CourseDB';
7
7
  import { BaseDoc } from './BaseDoc';
8
8
 
@@ -2,7 +2,7 @@ import type { ExperimentEntry } from '../database/ExperimentDB';
2
2
  import { experimentDB } from '../database/ExperimentDB';
3
3
  import { cosyLogger } from '../cosy';
4
4
  import { SidebarItemEntity } from './SidebarItem';
5
- import { LinkUtil } from '../utils/link';
5
+ import { LinkUtil } from '../../src/utils/link';
6
6
  import { COLLECTION_EXPERIMENT } from '../database/ExperimentDB';
7
7
  import { BaseDoc } from './BaseDoc';
8
8
  import type { IHeadingType } from '../types/heading';
@@ -2,7 +2,7 @@ import type { LessonEntry } from '../database/LessonDB';
2
2
  import { lessonDB } from '../database/LessonDB';
3
3
  import { cosyLogger } from '../cosy';
4
4
  import { SidebarItemEntity } from './SidebarItem';
5
- import { LinkUtil } from '../utils/link';
5
+ import { LinkUtil } from '../../src/utils/link';
6
6
  import { COLLECTION_LESSON } from '../database/LessonDB';
7
7
  import { BaseDoc } from './BaseDoc';
8
8
  import type { IHeadingType } from '../types/heading';
@@ -1,6 +1,6 @@
1
1
  import { SidebarItemEntity } from './SidebarItem';
2
2
  import type { MetaEntry } from '../database/MetaDB';
3
- import { LinkUtil } from '../utils/link';
3
+ import { LinkUtil } from '../../src/utils/link';
4
4
  import { BaseDoc } from './BaseDoc';
5
5
  import { metaDB } from '../database/MetaDB';
6
6
  import { COLLECTION_META } from '../database/MetaDB';
@@ -1,7 +1,7 @@
1
1
  import { blogDB } from '../database/BlogDB';
2
2
  import { SidebarItemEntity } from './SidebarItem';
3
3
  import { type ITagStaticPath } from '../types/static-path';
4
- import { LinkUtil } from '../utils/link';
4
+ import { LinkUtil } from '../../src/utils/link';
5
5
 
6
6
  export class Tag {
7
7
  name: string;
@@ -35,7 +35,7 @@
35
35
  */
36
36
 
37
37
  import '../../style.ts';
38
- import { LinkUtil } from '../utils/link.ts';
38
+ import { LinkUtil } from '../../src/utils/link.ts';
39
39
 
40
40
  const baseUrl = LinkUtil.getBaseUrl();
41
41
  const path = Astro.url.pathname;
@@ -36,7 +36,7 @@
36
36
  */
37
37
 
38
38
  import '../../style.ts';
39
- import { LinkUtil } from '../utils/link.ts';
39
+ import { LinkUtil } from '../../src/utils/link.ts';
40
40
 
41
41
  const baseUrl = LinkUtil.getBaseUrl();
42
42
  const path = Astro.url.pathname;
@@ -35,7 +35,7 @@
35
35
  */
36
36
 
37
37
  import '../../style.ts';
38
- import { LinkUtil } from '../utils/link.ts';
38
+ import { LinkUtil } from '../../src/utils/link.ts';
39
39
 
40
40
  const baseUrl = LinkUtil.getBaseUrl();
41
41
  const path = Astro.url.pathname;
@@ -40,7 +40,7 @@
40
40
  */
41
41
 
42
42
  import '../../style.ts';
43
- import { LinkUtil } from '../utils/link.ts';
43
+ import { LinkUtil } from '../../src/utils/link.ts';
44
44
 
45
45
  const baseUrl = LinkUtil.getBaseUrl();
46
46
  const path = Astro.url.pathname;
@@ -1,7 +1,7 @@
1
1
  import Flex from './Flex.astro';
2
2
  import FlexBasic from './FlexBasic.astro';
3
3
  import BasicSourceCode from './FlexBasic.astro?raw';
4
- import { extractSimpleExample } from '../utils/component';
4
+ import { extractSimpleExample } from '../../src/utils/component';
5
5
 
6
6
  export { Flex, FlexBasic };
7
7
 
@@ -145,7 +145,7 @@
145
145
  * - 社交媒体图标包含屏幕阅读器专用的文本说明
146
146
  */
147
147
 
148
- import { processSocialLink } from '../utils/social.ts';
148
+ import { processSocialLink } from '../../src/utils/social.ts';
149
149
  import {
150
150
  SocialIcon,
151
151
  LanguageUtil,
@@ -1,7 +1,7 @@
1
1
  import Grid from './Grid.astro';
2
2
  import GridBasic from './GridBasic.astro';
3
3
  import BasicSourceCode from './GridBasic.astro?raw';
4
- import { extractSimpleExample } from '../utils/component';
4
+ import { extractSimpleExample } from '../../src/utils/component';
5
5
 
6
6
  export { Grid, GridBasic };
7
7
 
@@ -1,7 +1,7 @@
1
1
  import Heading from './Heading.astro';
2
2
  import HeadingBasic from './HeadingBasic.astro';
3
3
  import BasicSourceCode from './HeadingBasic.astro?raw';
4
- import { extractSimpleExample } from '../utils/component';
4
+ import { extractSimpleExample } from '../../src/utils/component';
5
5
 
6
6
  export { Heading, HeadingBasic };
7
7
 
@@ -0,0 +1,28 @@
1
+ ---
2
+ import AstroIcon from './AstroIcon.astro';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const {
22
+ size = '24px',
23
+ color = 'currentColor',
24
+ class: className = '',
25
+ } = Astro.props;
26
+ ---
27
+
28
+ <AstroIcon name="logOut" size={size} stroke={color} class={className} />
@@ -43,4 +43,5 @@ export { default as ReportIcon } from './ReportIcon.astro';
43
43
  export { default as SecurityIcon } from './SecurityIcon.astro';
44
44
  export { default as UploadIcon } from './UploadIcon.astro';
45
45
  export { default as DownloadIcon } from './DownloadIcon.astro';
46
+ export { default as LogOut } from './LogOut.astro';
46
47
 
@@ -5,7 +5,7 @@ import ImageLoading from './ImageLoading.astro';
5
5
  import BasicSourceCode from './ImageBasic.astro?raw';
6
6
  import EffectsSourceCode from './ImageEffects.astro?raw';
7
7
  import LoadingSourceCode from './ImageLoading.astro?raw';
8
- import { extractSimpleExample } from '../utils/component';
8
+ import { extractSimpleExample } from '../../src/utils/component';
9
9
 
10
10
  export { Image, ImageBasic, ImageEffects, ImageLoading };
11
11
 
@@ -1,7 +1,7 @@
1
1
  import LanguageSwitcher from './LanguageSwitcher.astro';
2
2
  import LanguageSwitcherBasic from './LanguageSwitcherBasic.astro';
3
3
  import BasicSourceCode from './LanguageSwitcherBasic.astro?raw';
4
- import { extractSimpleExample } from '../utils/component';
4
+ import { extractSimpleExample } from '../../src/utils/component';
5
5
 
6
6
  export { LanguageSwitcher, LanguageSwitcherBasic };
7
7
 
@@ -1,7 +1,7 @@
1
1
  import BaseLayout from './BaseLayout.astro';
2
2
  import BaseLayoutBasic from './BaseLayoutBasic.astro';
3
3
  import BasicSourceCode from './BaseLayoutBasic.astro?raw';
4
- import { extractSimpleExample } from '../utils/component';
4
+ import { extractSimpleExample } from '../../src/utils/component';
5
5
 
6
6
  export { BaseLayout, BaseLayoutBasic };
7
7
 
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @description
6
6
  * DashboardLayout 组件适用于管理后台的布局,包含侧边栏导航和顶部导航栏。
7
- * 提供了完整的管理界面框架,包括响应式设计和暗色主题支持。
7
+ * 提供了完整的管理界面框架,包括响应式设计、暗色主题支持和内置 Toast 通知系统。
8
8
  *
9
9
  * @design
10
10
  * 设计理念:
@@ -12,6 +12,7 @@
12
12
  * 2. 响应式布局 - 在不同设备上提供良好的用户体验
13
13
  * 3. 可定制性 - 支持自定义导航项、系统名称和用户信息
14
14
  * 4. 状态保持 - 记住用户的侧边栏折叠状态
15
+ * 5. 统一通知 - 内置 Toast 系统,提供一致的消息提示体验
15
16
  *
16
17
  * @usage
17
18
  * 基本用法:
@@ -81,9 +82,55 @@
81
82
  * >
82
83
  * <h1>仪表盘内容</h1>
83
84
  * <p>这是带有背景的主要内容</p>
85
+ *
86
+ * <script>
87
+ * // 在页面中使用 toast
88
+ * function handleAction() {
89
+ * // 简单用法
90
+ * showToast('操作成功!');
91
+ *
92
+ * // 带选项的用法
93
+ * showToast({
94
+ * message: '数据保存成功',
95
+ * type: 'success',
96
+ * duration: 2000
97
+ * });
98
+ * }
99
+ * </script>
84
100
  * </DashboardLayout>
85
101
  * ```
86
102
  *
103
+ * Toast 使用示例:
104
+ * ```javascript
105
+ * // 成功消息
106
+ * showToast({
107
+ * message: '保存成功!',
108
+ * type: 'success'
109
+ * });
110
+ *
111
+ * // 错误消息
112
+ * showToast({
113
+ * message: '网络连接失败',
114
+ * type: 'error',
115
+ * duration: 5000
116
+ * });
117
+ *
118
+ * // 警告消息
119
+ * showToast({
120
+ * message: '请注意数据安全',
121
+ * type: 'warning'
122
+ * });
123
+ *
124
+ * // 信息消息
125
+ * showToast({
126
+ * message: '系统将在 5 分钟后维护',
127
+ * type: 'info'
128
+ * });
129
+ *
130
+ * // 简化用法
131
+ * showToast('这是一条简单的消息');
132
+ * ```
133
+ *
87
134
  * @props
88
135
  * - title: string - 页面标题
89
136
  * - description?: string - 页面描述
@@ -109,6 +156,7 @@
109
156
  import { BaseLayout } from '../../index-astro';
110
157
  import DashboardSidebar from './DashboardSidebar.astro';
111
158
  import DashboardTopNavbar from './DashboardTopNavbar.astro';
159
+ import { ToastContainer, ConfirmDialog } from '../../index-astro';
112
160
  import '../../style.ts';
113
161
  import {
114
162
  type NavItem,
@@ -195,6 +243,18 @@ export interface Props {
195
243
  */
196
244
  'class:list'?: any;
197
245
 
246
+ /**
247
+ * 是否启用 Toast 功能
248
+ * @default true
249
+ */
250
+ enableToast?: boolean;
251
+
252
+ /**
253
+ * 是否启用确认对话框功能
254
+ * @default true
255
+ */
256
+ enableConfirmDialog?: boolean;
257
+
198
258
  /**
199
259
  * 调试模式
200
260
  * @default false
@@ -214,6 +274,8 @@ const {
214
274
  sidebarSize = 'md',
215
275
  sidebarTheme = 'default',
216
276
  mainBackgroundTheme = 'transparent',
277
+ enableToast = true,
278
+ enableConfirmDialog = true,
217
279
  head,
218
280
  class: className,
219
281
  'class:list': classList,
@@ -271,6 +333,19 @@ const mainBackgroundStyles = getMainBackgroundTheme(mainBackgroundTheme);
271
333
  </main>
272
334
  </div>
273
335
  </div>
336
+
337
+ <!-- Toast 容器 -->
338
+ {enableToast && <ToastContainer />}
339
+
340
+ {
341
+ enableConfirmDialog && (
342
+ <ConfirmDialog
343
+ id="dashboard-confirm"
344
+ title="确认操作"
345
+ message="您确定要执行此操作吗?"
346
+ />
347
+ )
348
+ }
274
349
  </BaseLayout>
275
350
 
276
351
  <script>
@@ -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
+ }
@@ -163,157 +163,4 @@ export function getMainBackgroundTheme(theme: MainBackgroundTheme = 'transparent
163
163
  return mainBackgroundThemeMap[theme];
164
164
  }
165
165
 
166
- /**
167
- * 基于 href 关键词匹配图标名称的映射表
168
- */
169
- const hrefToIconMap: Record<string, string> = {
170
- // 主页相关
171
- 'dashboard': 'dashboard',
172
- 'home': 'home',
173
- 'index': 'home',
174
-
175
- // 用户相关
176
- 'user': 'user',
177
- 'users': 'users',
178
- 'profile': 'user',
179
- 'account': 'user',
180
- 'member': 'users',
181
- 'team': 'users',
182
-
183
- // 设置相关
184
- 'setting': 'settings',
185
- 'config': 'settings',
186
- 'preference': 'settings',
187
- 'admin': 'settings',
188
- 'manage': 'settings',
189
- 'tool': 'tools',
190
-
191
- // 数据相关
192
- 'chart': 'chart',
193
- 'analytics': 'chart',
194
- 'report': 'report',
195
- 'statistic': 'chart',
196
- 'data': 'chart',
197
-
198
- // 文档相关
199
- 'doc': 'document',
200
- 'document': 'document',
201
- 'file': 'document',
202
- 'page': 'document',
203
- 'article': 'document',
204
- 'content': 'document',
205
-
206
- // 日历和时间
207
- 'calendar': 'calendar',
208
- 'schedule': 'calendar',
209
- 'event': 'calendar',
210
- 'date': 'calendar',
211
-
212
- // 通知和消息
213
- 'notification': 'notification',
214
- 'message': 'message',
215
- 'chat': 'message',
216
- 'mail': 'mail',
217
- 'email': 'mail',
218
- 'inbox': 'inboxArchive',
219
-
220
- // 搜索
221
- 'search': 'search',
222
- 'find': 'search',
223
-
224
- // 收藏和标记
225
- 'favorite': 'star',
226
- 'bookmark': 'star',
227
- 'star': 'star',
228
- 'like': 'heart',
229
-
230
- // 文件夹和目录
231
- 'folder': 'folder',
232
- 'directory': 'folder',
233
- 'category': 'folder',
234
-
235
- // 安全和权限
236
- 'security': 'security',
237
- 'permission': 'security',
238
- 'auth': 'security',
239
- 'login': 'security',
240
-
241
- // 财务相关
242
- 'payment': 'wallet',
243
- 'billing': 'wallet',
244
- 'finance': 'wallet',
245
- 'money': 'wallet',
246
- 'wallet': 'wallet',
247
-
248
- // 操作相关
249
- 'edit': 'edit',
250
- 'delete': 'delete',
251
- 'remove': 'delete',
252
- 'save': 'save',
253
- 'download': 'download',
254
- 'upload': 'upload',
255
- 'refresh': 'refresh',
256
- 'logout': 'logout',
257
- 'signin': 'login',
258
- 'signout': 'logout',
259
- 'exit': 'logout',
260
-
261
- // 工具和实用程序
262
- 'clipboard': 'clipboard',
263
- 'link': 'link',
264
- 'menu': 'menu',
265
- 'close': 'close',
266
- 'check': 'check',
267
- 'help': 'help',
268
- 'support': 'help',
269
- };
270
-
271
- /**
272
- * 根据 href 自动推断图标名称
273
- * @param href 链接地址
274
- * @param fallbackIcon 如果匹配失败时使用的默认图标
275
- * @returns 图标名称
276
- */
277
- export function getIconFromHref(href: string, fallbackIcon: string = 'folder'): string {
278
- // 将 href 转换为小写并移除路径分隔符
279
- const normalizedHref = href.toLowerCase().replace(/[\/\-_]/g, '');
280
-
281
- // 遍历映射表,找到匹配的关键词
282
- for (const [keyword, iconName] of Object.entries(hrefToIconMap)) {
283
- if (normalizedHref.includes(keyword)) {
284
- return iconName;
285
- }
286
- }
287
-
288
- return fallbackIcon;
289
- }
290
-
291
- /**
292
- * 根据 NavItem 获取完整的图标信息
293
- * @param item 导航项
294
- * @returns 图标名称
295
- */
296
- export function getNavItemIcon(item: NavItem): string {
297
- // 如果显式指定了图标,优先使用
298
- if (item.icon) {
299
- return item.icon;
300
- }
301
-
302
- // 否则根据 href 自动推断
303
- return getIconFromHref(item.href);
304
- }
305
-
306
- /**
307
- * 根据 UserMenuItem 获取完整的图标信息
308
- * @param item 用户菜单项
309
- * @returns 图标名称
310
- */
311
- export function getUserMenuItemIcon(item: UserMenuItem): string {
312
- // 如果显式指定了图标,优先使用
313
- if (item.icon) {
314
- return item.icon;
315
- }
316
-
317
- // 否则根据 href 自动推断,用户菜单默认图标为 'user'
318
- return getIconFromHref(item.href, 'user');
319
- }
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 '../utils/component';
8
+ import { extractSimpleExample } from '../../src/utils/component';
9
9
 
10
10
  export { Link, LinkBasic, LinkVariants, LinkAnimations };
11
11