@coffic/cosy-ui 0.8.10 → 0.8.12
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/src-astro/alert/index.ts +7 -15
- package/dist/src-astro/assets/iconData.ts +100 -0
- package/dist/src-astro/button/index_astro.ts +2 -56
- package/dist/src-astro/card/CardCourse.astro +31 -11
- package/dist/src-astro/card/index.ts +15 -25
- package/dist/src-astro/code-container/CodeContainer.astro +205 -5
- package/dist/src-astro/code-container/index.ts +9 -13
- package/dist/src-astro/contact/index.ts +16 -20
- package/dist/src-astro/errors/index.ts +0 -62
- package/dist/src-astro/footer/index.ts +1 -30
- package/dist/src-astro/header/Header.astro +1 -2
- package/dist/src-astro/header/index.ts +1 -40
- package/dist/src-astro/hero/index.ts +1 -39
- package/dist/src-astro/icons/ChartIcon.astro +28 -0
- package/dist/src-astro/icons/DashboardIcon.astro +28 -0
- package/dist/src-astro/icons/DeleteIcon.astro +28 -0
- package/dist/src-astro/icons/DocumentIcon.astro +28 -0
- package/dist/src-astro/icons/DownloadIcon.astro +28 -0
- package/dist/src-astro/icons/EditIcon.astro +28 -0
- package/dist/src-astro/icons/FolderIcon.astro +28 -0
- package/dist/src-astro/icons/HeartIcon.astro +28 -0
- package/dist/src-astro/icons/HomeIcon.astro +28 -0
- package/dist/src-astro/icons/MailIcon.astro +28 -0
- package/dist/src-astro/icons/MessageIcon.astro +28 -0
- package/dist/src-astro/icons/NotificationIcon.astro +28 -0
- package/dist/src-astro/icons/ReportIcon.astro +28 -0
- package/dist/src-astro/icons/SaveIcon.astro +28 -0
- package/dist/src-astro/icons/SecurityIcon.astro +28 -0
- package/dist/src-astro/icons/StarIcon.astro +28 -0
- package/dist/src-astro/icons/ToolsIcon.astro +28 -0
- package/dist/src-astro/icons/UploadIcon.astro +28 -0
- package/dist/src-astro/icons/UsersIcon.astro +28 -0
- package/dist/src-astro/icons/WalletIcon.astro +28 -0
- package/dist/src-astro/icons/index.ts +20 -0
- package/dist/src-astro/layout-app/index.ts +5 -9
- package/dist/src-astro/layout-dashboard/DashboardLayout.astro +159 -555
- package/dist/src-astro/layout-dashboard/DashboardSidebar.astro +219 -0
- package/dist/src-astro/layout-dashboard/DashboardTopNavbar.astro +164 -0
- package/dist/src-astro/layout-dashboard/index.ts +14 -8
- package/dist/src-astro/layout-dashboard/tools.ts +0 -0
- package/dist/src-astro/layout-dashboard/types.ts +319 -0
- package/package.json +1 -1
- package/dist/src-astro/alert/EAlertBasic.astro +0 -11
- package/dist/src-astro/alert/EAlertBasicContainer.astro +0 -11
- package/dist/src-astro/alert/EAlertCustomStyle.astro +0 -16
- package/dist/src-astro/alert/EAlertCustomStyleContainer.astro +0 -11
- package/dist/src-astro/alert/EAlertError.astro +0 -6
- package/dist/src-astro/alert/EAlertInfo.astro +0 -6
- package/dist/src-astro/alert/EAlertSuccess.astro +0 -6
- package/dist/src-astro/alert/EAlertTypesContainer.astro +0 -43
- package/dist/src-astro/alert/EAlertWarning.astro +0 -6
- package/dist/src-astro/alert/EAlertWithTitle.astro +0 -12
- package/dist/src-astro/alert/EAlertWithTitleContainer.astro +0 -11
- package/dist/src-astro/button/ButtonBasic.astro +0 -18
- package/dist/src-astro/button/ButtonBasicContainer.astro +0 -11
- package/dist/src-astro/button/ButtonBlock.astro +0 -5
- package/dist/src-astro/button/ButtonError.astro +0 -5
- package/dist/src-astro/button/ButtonGhost.astro +0 -5
- package/dist/src-astro/button/ButtonIconBoth.astro +0 -9
- package/dist/src-astro/button/ButtonIconLeft.astro +0 -8
- package/dist/src-astro/button/ButtonIconRight.astro +0 -8
- package/dist/src-astro/button/ButtonInfo.astro +0 -5
- package/dist/src-astro/button/ButtonLinkContainer.astro +0 -19
- package/dist/src-astro/button/ButtonNeutral.astro +0 -5
- package/dist/src-astro/button/ButtonOutline.astro +0 -5
- package/dist/src-astro/button/ButtonShapeCircle.astro +0 -5
- package/dist/src-astro/button/ButtonShapeDefault.astro +0 -5
- package/dist/src-astro/button/ButtonShapeSquare.astro +0 -5
- package/dist/src-astro/button/ButtonShapes.astro +0 -23
- package/dist/src-astro/button/ButtonShapesContainer.astro +0 -29
- package/dist/src-astro/button/ButtonSizes.astro +0 -15
- package/dist/src-astro/button/ButtonSizesContainer.astro +0 -11
- package/dist/src-astro/button/ButtonStates.astro +0 -12
- package/dist/src-astro/button/ButtonStatesContainer.astro +0 -11
- package/dist/src-astro/button/ButtonSuccess.astro +0 -5
- package/dist/src-astro/button/ButtonVariantsContainer.astro +0 -73
- package/dist/src-astro/button/ButtonWarning.astro +0 -5
- package/dist/src-astro/button/ButtonWide.astro +0 -5
- package/dist/src-astro/button/ButtonWidth.astro +0 -8
- package/dist/src-astro/button/ButtonWidthContainer.astro +0 -19
- package/dist/src-astro/button/ButtonWithIcons.astro +0 -25
- package/dist/src-astro/button/ButtonWithIconsContainer.astro +0 -29
- package/dist/src-astro/card/CardBasic.astro +0 -5
- package/dist/src-astro/card/ECardBasic.astro +0 -13
- package/dist/src-astro/card/ECardBasicContainer.astro +0 -11
- package/dist/src-astro/card/ECardClickable.astro +0 -16
- package/dist/src-astro/card/ECardClickableContainer.astro +0 -11
- package/dist/src-astro/card/ECardCompact.astro +0 -13
- package/dist/src-astro/card/ECardCompactContainer.astro +0 -11
- package/dist/src-astro/card/ECardCustomStyle.astro +0 -17
- package/dist/src-astro/card/ECardCustomStyleContainer.astro +0 -11
- package/dist/src-astro/card/ECardWithImage.astro +0 -16
- package/dist/src-astro/card/ECardWithImageContainer.astro +0 -11
- package/dist/src-astro/card/ECardWithSubtitle.astro +0 -13
- package/dist/src-astro/card/ECardWithSubtitleContainer.astro +0 -11
- package/dist/src-astro/code-container/ECodeContainerBasic.astro +0 -19
- package/dist/src-astro/code-container/ECodeContainerMultiple.astro +0 -49
- package/dist/src-astro/contact/EContactBasic.astro +0 -15
- package/dist/src-astro/contact/EContactBasicContainer.astro +0 -11
- package/dist/src-astro/contact/EContactCompact.astro +0 -11
- package/dist/src-astro/contact/EContactCompactContainer.astro +0 -11
- package/dist/src-astro/contact/EContactCustomStyle.astro +0 -21
- package/dist/src-astro/contact/EContactCustomStyleContainer.astro +0 -11
- package/dist/src-astro/contact/EContactSocial.astro +0 -20
- package/dist/src-astro/contact/EContactSocialContainer.astro +0 -11
- package/dist/src-astro/contact/EContactWithTitle.astro +0 -17
- package/dist/src-astro/contact/EContactWithTitleContainer.astro +0 -11
- package/dist/src-astro/errors/E403Basic.astro +0 -11
- package/dist/src-astro/errors/E403BasicContainer.astro +0 -20
- package/dist/src-astro/errors/E404Basic.astro +0 -11
- package/dist/src-astro/errors/E404BasicContainer.astro +0 -20
- package/dist/src-astro/errors/E404WithDebug.astro +0 -18
- package/dist/src-astro/errors/E500Basic.astro +0 -11
- package/dist/src-astro/errors/E500BasicContainer.astro +0 -20
- package/dist/src-astro/errors/E503Maintenance.astro +0 -20
- package/dist/src-astro/errors/E503MaintenanceContainer.astro +0 -21
- package/dist/src-astro/errors/EErrorPageCustomStyle.astro +0 -21
- package/dist/src-astro/errors/EErrorPageCustomStyleContainer.astro +0 -21
- package/dist/src-astro/errors/EErrorPageShowcase.astro +0 -68
- package/dist/src-astro/errors/EErrorPageShowcaseContainer.astro +0 -21
- package/dist/src-astro/footer/EFooterBasic.astro +0 -18
- package/dist/src-astro/footer/EFooterBasicContainer.astro +0 -11
- package/dist/src-astro/footer/EFooterComplete.astro +0 -50
- package/dist/src-astro/footer/EFooterCompleteContainer.astro +0 -11
- package/dist/src-astro/footer/EFooterFeaturesContainer.astro +0 -40
- package/dist/src-astro/footer/EFooterWithLogo.astro +0 -28
- package/dist/src-astro/footer/EFooterWithLogoContainer.astro +0 -11
- package/dist/src-astro/footer/EFooterWithNavigation.astro +0 -24
- package/dist/src-astro/footer/EFooterWithNavigationContainer.astro +0 -11
- package/dist/src-astro/footer/EFooterWithProducts.astro +0 -24
- package/dist/src-astro/footer/EFooterWithProductsContainer.astro +0 -11
- package/dist/src-astro/footer/EFooterWithSocial.astro +0 -24
- package/dist/src-astro/footer/EFooterWithSocialContainer.astro +0 -11
- package/dist/src-astro/header/HeaderBasic.astro +0 -19
- package/dist/src-astro/header/HeaderCustomNavbarCenter.astro +0 -28
- package/dist/src-astro/header/HeaderCustomNavbarEnd.astro +0 -25
- package/dist/src-astro/header/HeaderCustomNavbarStart.astro +0 -27
- package/dist/src-astro/header/HeaderCustomPosition.astro +0 -34
- package/dist/src-astro/header/HeaderWithNavigation.astro +0 -27
- package/dist/src-astro/hero/EHeroAlignCenter.astro +0 -13
- package/dist/src-astro/hero/EHeroAlignContainer.astro +0 -27
- package/dist/src-astro/hero/EHeroAlignLeft.astro +0 -13
- package/dist/src-astro/hero/EHeroAlignRight.astro +0 -13
- package/dist/src-astro/hero/EHeroBackgroundContainer.astro +0 -18
- package/dist/src-astro/hero/EHeroBackgroundImage.astro +0 -16
- package/dist/src-astro/hero/EHeroBackgroundImageContainer.astro +0 -11
- package/dist/src-astro/hero/EHeroBasic.astro +0 -12
- package/dist/src-astro/hero/EHeroBasicContainer.astro +0 -11
- package/dist/src-astro/hero/EHeroGradientBackground.astro +0 -10
- package/dist/src-astro/hero/EHeroPlainBackground.astro +0 -10
- package/dist/src-astro/hero/EHeroWithButton.astro +0 -14
- package/dist/src-astro/hero/EHeroWithButtonContainer.astro +0 -11
- package/dist/src-astro/hero/EHeroWithImage.astro +0 -16
- package/dist/src-astro/hero/EHeroWithImageContainer.astro +0 -11
- package/dist/src-astro/layout-app/AppLayoutBasic.astro +0 -54
- package/dist/src-astro/layout-dashboard/DashboardLayoutBasic.astro +0 -51
@@ -0,0 +1,219 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component DashboardSidebar
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* DashboardSidebar 组件提供仪表盘布局的侧边栏导航功能。
|
7
|
+
* 包含系统名称显示、导航菜单和折叠/展开功能。
|
8
|
+
*
|
9
|
+
* @usage
|
10
|
+
* ```astro
|
11
|
+
* ---
|
12
|
+
* import { DashboardSidebar } from '@coffic/cosy-ui';
|
13
|
+
*
|
14
|
+
* const navItems = [
|
15
|
+
* { href: "/dashboard", icon: "home", text: "仪表盘" },
|
16
|
+
* { href: "/dashboard/users", icon: "user", text: "用户管理" }
|
17
|
+
* ];
|
18
|
+
* ---
|
19
|
+
*
|
20
|
+
* <DashboardSidebar
|
21
|
+
* systemName="管理系统"
|
22
|
+
* navItems={navItems}
|
23
|
+
* />
|
24
|
+
* ```
|
25
|
+
*
|
26
|
+
* @props
|
27
|
+
* - systemName?: string - 系统名称,默认为"管理系统"
|
28
|
+
* - navItems: NavItem[] - 导航项目
|
29
|
+
* - currentPath?: string - 当前路径,用于高亮当前页面
|
30
|
+
* - size?: 'sm' | 'md' | 'lg' | 'xl' - 侧边栏尺寸,默认为"md"
|
31
|
+
* - theme?: SidebarTheme - 侧边栏主题,默认为"default"
|
32
|
+
*
|
33
|
+
* @slots
|
34
|
+
* - footer - 侧边栏底部自定义内容,可用于展示用户信息等
|
35
|
+
*/
|
36
|
+
|
37
|
+
import '../../style.ts';
|
38
|
+
import {
|
39
|
+
getNavItemIcon,
|
40
|
+
getSidebarWidth,
|
41
|
+
getSidebarTheme,
|
42
|
+
type NavItem,
|
43
|
+
type SidebarSize,
|
44
|
+
type SidebarTheme,
|
45
|
+
} from './types';
|
46
|
+
import AstroIcon from '../icons/AstroIcon.astro';
|
47
|
+
|
48
|
+
export interface Props {
|
49
|
+
/**
|
50
|
+
* 系统名称
|
51
|
+
* @default "管理系统"
|
52
|
+
*/
|
53
|
+
systemName?: string;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* 导航项目
|
57
|
+
*/
|
58
|
+
navItems: NavItem[];
|
59
|
+
|
60
|
+
/**
|
61
|
+
* 当前路径,用于高亮当前页面
|
62
|
+
*/
|
63
|
+
currentPath?: string;
|
64
|
+
|
65
|
+
/**
|
66
|
+
* 侧边栏尺寸
|
67
|
+
* @default "md"
|
68
|
+
*/
|
69
|
+
size?: SidebarSize;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* 侧边栏主题
|
73
|
+
* @default "default"
|
74
|
+
*/
|
75
|
+
theme?: SidebarTheme;
|
76
|
+
}
|
77
|
+
|
78
|
+
const {
|
79
|
+
systemName = '管理系统',
|
80
|
+
navItems,
|
81
|
+
currentPath = '',
|
82
|
+
size = 'md',
|
83
|
+
theme = 'default',
|
84
|
+
} = Astro.props;
|
85
|
+
|
86
|
+
const themeStyles = getSidebarTheme(theme);
|
87
|
+
---
|
88
|
+
|
89
|
+
<aside
|
90
|
+
class:list={[
|
91
|
+
getSidebarWidth(size),
|
92
|
+
'cosy:min-h-full cosy:flex cosy:flex-col',
|
93
|
+
themeStyles.bg,
|
94
|
+
themeStyles.textColor,
|
95
|
+
]}>
|
96
|
+
<!-- 侧边栏头部 -->
|
97
|
+
<div
|
98
|
+
class:list={[
|
99
|
+
'cosy:navbar cosy:border-b',
|
100
|
+
themeStyles.headerBg,
|
101
|
+
themeStyles.borderColor,
|
102
|
+
]}>
|
103
|
+
<div class="cosy:navbar-start">
|
104
|
+
<a
|
105
|
+
href="/dashboard"
|
106
|
+
class="cosy:btn cosy:btn-ghost cosy:text-lg cosy:font-semibold cosy:no-underline">
|
107
|
+
<span class="cosy:text-xl">⚡</span>
|
108
|
+
<span class="cosy:hidden cosy:lg:block">{systemName}</span>
|
109
|
+
</a>
|
110
|
+
</div>
|
111
|
+
<div class="cosy:navbar-end">
|
112
|
+
<button class="cosy:btn cosy:btn-ghost cosy:btn-sm" id="collapse-sidebar">
|
113
|
+
<AstroIcon name="menu" size="16px" stroke="currentColor" />
|
114
|
+
</button>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
<!-- 导航菜单 -->
|
119
|
+
<div class="cosy:flex-1 cosy:overflow-y-auto">
|
120
|
+
<ul
|
121
|
+
class="cosy:menu cosy:p-4 cosy:space-y-1 cosy:list-none cosy:no-underline">
|
122
|
+
{
|
123
|
+
navItems.map((item: NavItem) => {
|
124
|
+
const isActive =
|
125
|
+
currentPath === item.href ||
|
126
|
+
(item.items &&
|
127
|
+
item.items.some(
|
128
|
+
(subitem: NavItem) => currentPath === subitem.href
|
129
|
+
));
|
130
|
+
|
131
|
+
return (
|
132
|
+
<li>
|
133
|
+
<a
|
134
|
+
href={item.href}
|
135
|
+
class:list={[
|
136
|
+
'cosy:no-underline',
|
137
|
+
{ 'cosy:menu-active': isActive },
|
138
|
+
]}>
|
139
|
+
<AstroIcon
|
140
|
+
name={getNavItemIcon(item)}
|
141
|
+
size="16px"
|
142
|
+
stroke="currentColor"
|
143
|
+
/>
|
144
|
+
<span>{item.text}</span>
|
145
|
+
{item.badge && (
|
146
|
+
<span class="cosy:badge cosy:badge-primary cosy:badge-sm">
|
147
|
+
{item.badge}
|
148
|
+
</span>
|
149
|
+
)}
|
150
|
+
</a>
|
151
|
+
|
152
|
+
{item.items && (
|
153
|
+
<ul class="cosy:ml-4 cosy:list-none cosy:no-underline">
|
154
|
+
{item.items.map((subitem: NavItem) => {
|
155
|
+
const isSubActive = currentPath === subitem.href;
|
156
|
+
return (
|
157
|
+
<li>
|
158
|
+
<a
|
159
|
+
href={subitem.href}
|
160
|
+
class:list={[
|
161
|
+
'cosy:text-sm cosy:no-underline',
|
162
|
+
{ 'cosy:menu-active': isSubActive },
|
163
|
+
]}>
|
164
|
+
<AstroIcon
|
165
|
+
name={getNavItemIcon(subitem)}
|
166
|
+
size="14px"
|
167
|
+
stroke="currentColor"
|
168
|
+
/>
|
169
|
+
<span>{subitem.text}</span>
|
170
|
+
{subitem.badge && (
|
171
|
+
<span class="cosy:badge cosy:badge-primary cosy:badge-xs">
|
172
|
+
{subitem.badge}
|
173
|
+
</span>
|
174
|
+
)}
|
175
|
+
</a>
|
176
|
+
</li>
|
177
|
+
);
|
178
|
+
})}
|
179
|
+
</ul>
|
180
|
+
)}
|
181
|
+
</li>
|
182
|
+
);
|
183
|
+
})
|
184
|
+
}
|
185
|
+
</ul>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<!-- 侧边栏底部自定义内容 -->
|
189
|
+
<div class:list={['cosy:mt-auto cosy:border-t', themeStyles.borderColor]}>
|
190
|
+
<slot name="footer" />
|
191
|
+
</div>
|
192
|
+
</aside>
|
193
|
+
|
194
|
+
<script>
|
195
|
+
// 侧边栏折叠/展开功能
|
196
|
+
document.addEventListener('DOMContentLoaded', () => {
|
197
|
+
const collapseSidebarBtn = document.getElementById('collapse-sidebar');
|
198
|
+
const drawerToggle = document.getElementById(
|
199
|
+
'dashboard-drawer'
|
200
|
+
) as HTMLInputElement;
|
201
|
+
|
202
|
+
if (collapseSidebarBtn && drawerToggle) {
|
203
|
+
collapseSidebarBtn.addEventListener('click', () => {
|
204
|
+
drawerToggle.checked = !drawerToggle.checked;
|
205
|
+
// 保存状态到本地存储
|
206
|
+
localStorage.setItem(
|
207
|
+
'sidebarCollapsed',
|
208
|
+
drawerToggle.checked.toString()
|
209
|
+
);
|
210
|
+
});
|
211
|
+
}
|
212
|
+
|
213
|
+
// 从本地存储恢复状态
|
214
|
+
const savedState = localStorage.getItem('sidebarCollapsed');
|
215
|
+
if (savedState && drawerToggle) {
|
216
|
+
drawerToggle.checked = savedState === 'true';
|
217
|
+
}
|
218
|
+
});
|
219
|
+
</script>
|
@@ -0,0 +1,164 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component DashboardTopNavbar
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* DashboardTopNavbar 组件提供仪表盘布局的顶部导航栏功能。
|
7
|
+
* 包含菜单切换按钮、面包屑导航、搜索框、通知和用户信息。
|
8
|
+
*
|
9
|
+
* @usage
|
10
|
+
* ```astro
|
11
|
+
* ---
|
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
|
+
* ];
|
20
|
+
* ---
|
21
|
+
*
|
22
|
+
* <DashboardTopNavbar
|
23
|
+
* title="仪表盘"
|
24
|
+
* userName="管理员"
|
25
|
+
* userAvatar="/avatar.jpg"
|
26
|
+
* userMenuItems={userMenuItems}
|
27
|
+
* />
|
28
|
+
* ```
|
29
|
+
*
|
30
|
+
* @props
|
31
|
+
* - title: string - 页面标题,用于面包屑导航
|
32
|
+
* - userName?: string - 用户名
|
33
|
+
* - userAvatar?: string - 用户头像
|
34
|
+
* - userMenuItems?: UserMenuItem[] - 用户菜单项,默认包含个人资料、设置、退出登录,图标会自动匹配
|
35
|
+
*/
|
36
|
+
|
37
|
+
import '../../style.ts';
|
38
|
+
import AstroIcon from '../icons/AstroIcon.astro';
|
39
|
+
import type { UserMenuItem } from './types';
|
40
|
+
import { getUserMenuItemIcon } from './types';
|
41
|
+
|
42
|
+
export interface Props {
|
43
|
+
/**
|
44
|
+
* 页面标题,用于面包屑导航
|
45
|
+
*/
|
46
|
+
title: string;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* 用户名
|
50
|
+
*/
|
51
|
+
userName?: string;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* 用户头像
|
55
|
+
*/
|
56
|
+
userAvatar?: string;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* 用户菜单项
|
60
|
+
*/
|
61
|
+
userMenuItems?: UserMenuItem[];
|
62
|
+
}
|
63
|
+
|
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;
|
74
|
+
---
|
75
|
+
|
76
|
+
<div class="cosy:navbar cosy:bg-base-100 cosy:shadow-sm">
|
77
|
+
<div class="cosy:navbar-start">
|
78
|
+
<label
|
79
|
+
for="dashboard-drawer"
|
80
|
+
class="cosy:btn cosy:btn-square cosy:btn-ghost cosy:lg:hidden">
|
81
|
+
<AstroIcon name="menu" size="16px" stroke="currentColor" />
|
82
|
+
</label>
|
83
|
+
|
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}
|
87
|
+
</div>
|
88
|
+
</div>
|
89
|
+
|
90
|
+
<div class="cosy:navbar-end cosy:gap-2">
|
91
|
+
<!-- 搜索框 -->
|
92
|
+
<div class="cosy:form-control cosy:hidden cosy:lg:flex">
|
93
|
+
<div class="cosy:input-group">
|
94
|
+
<input
|
95
|
+
type="text"
|
96
|
+
placeholder="搜索..."
|
97
|
+
class="cosy:input cosy:input-bordered cosy:input-sm cosy:w-48"
|
98
|
+
/>
|
99
|
+
<button class="cosy:btn cosy:btn-square cosy:btn-sm">
|
100
|
+
<AstroIcon name="search" size="16px" stroke="currentColor" />
|
101
|
+
</button>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<!-- 通知 -->
|
106
|
+
<div class="cosy:indicator">
|
107
|
+
<button class="cosy:btn cosy:btn-ghost cosy:btn-circle">
|
108
|
+
<AstroIcon name="notification" size="18px" stroke="currentColor" />
|
109
|
+
</button>
|
110
|
+
<span
|
111
|
+
class="cosy:badge cosy:badge-xs cosy:badge-primary cosy:indicator-item"
|
112
|
+
>3</span
|
113
|
+
>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<!-- 用户信息 -->
|
117
|
+
{
|
118
|
+
userName && (
|
119
|
+
<div class="cosy:dropdown cosy:dropdown-end">
|
120
|
+
<div
|
121
|
+
tabindex="0"
|
122
|
+
role="button"
|
123
|
+
class="cosy:btn cosy:btn-ghost cosy:gap-2">
|
124
|
+
{userAvatar ? (
|
125
|
+
<div class="cosy:avatar">
|
126
|
+
<div class="cosy:w-8 cosy:rounded-full">
|
127
|
+
<img src={userAvatar} alt={userName} />
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
) : (
|
131
|
+
<div class="cosy:avatar cosy:placeholder">
|
132
|
+
<div class="cosy:bg-primary cosy:text-primary-content cosy:rounded-full cosy:w-8">
|
133
|
+
<span class="cosy:text-sm">{userName.charAt(0)}</span>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
)}
|
137
|
+
<span class="cosy:hidden cosy:lg:block">{userName}</span>
|
138
|
+
</div>
|
139
|
+
<ul
|
140
|
+
tabindex="0"
|
141
|
+
class="cosy:dropdown-content cosy:menu cosy:p-2 cosy:shadow cosy:bg-base-100 cosy:rounded-box cosy:w-52">
|
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
|
+
})}
|
159
|
+
</ul>
|
160
|
+
</div>
|
161
|
+
)
|
162
|
+
}
|
163
|
+
</div>
|
164
|
+
</div>
|
@@ -1,11 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
import { extractSimpleExample } from '../utils/component';
|
1
|
+
/**
|
2
|
+
* 仪表盘布局组件
|
3
|
+
*/
|
5
4
|
|
6
|
-
|
5
|
+
import DashboardLayout from './DashboardLayout.astro';
|
6
|
+
import DashboardSidebar from './DashboardSidebar.astro';
|
7
|
+
import DashboardTopNavbar from './DashboardTopNavbar.astro';
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
export {
|
10
|
+
DashboardLayout,
|
11
|
+
DashboardSidebar,
|
12
|
+
DashboardTopNavbar
|
11
13
|
};
|
14
|
+
|
15
|
+
// 导出类型和函数
|
16
|
+
export type { NavItem, SidebarSize, SidebarTheme, ContentTheme } from './types';
|
17
|
+
export { getIconFromHref, getNavItemIcon, getSidebarWidth, getSidebarTheme, getContentTheme } from './types';
|
File without changes
|