@lark-apaas/miaoda-core 0.1.0-alpha.1
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/LICENSE +13 -0
- package/README.md +8 -0
- package/lib/apis/components/AppContainer.d.ts +1 -0
- package/lib/apis/components/AppContainer.js +2 -0
- package/lib/apis/components/ErrorRender.d.ts +1 -0
- package/lib/apis/components/ErrorRender.js +2 -0
- package/lib/apis/components/NotFoundRender.d.ts +1 -0
- package/lib/apis/components/NotFoundRender.js +2 -0
- package/lib/apis/components/SidebarNav.d.ts +1 -0
- package/lib/apis/components/SidebarNav.js +2 -0
- package/lib/apis/components/TopNav.d.ts +1 -0
- package/lib/apis/components/TopNav.js +2 -0
- package/lib/apis/components/User.d.ts +1 -0
- package/lib/apis/components/User.js +1 -0
- package/lib/apis/components/Welcome.d.ts +1 -0
- package/lib/apis/components/Welcome.js +2 -0
- package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
- package/lib/apis/constants/img-resources/avatar.js +12 -0
- package/lib/apis/constants/img-resources/banner.d.ts +24 -0
- package/lib/apis/constants/img-resources/banner.js +25 -0
- package/lib/apis/constants/img-resources/cover.d.ts +36 -0
- package/lib/apis/constants/img-resources/cover.js +37 -0
- package/lib/apis/dataloom.d.ts +1 -0
- package/lib/apis/dataloom.js +2 -0
- package/lib/apis/hooks/useCurrentAppInfo.d.ts +1 -0
- package/lib/apis/hooks/useCurrentAppInfo.js +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
- package/lib/apis/logger.d.ts +1 -0
- package/lib/apis/logger.js +1 -0
- package/lib/apis/tools/generateImage.d.ts +1 -0
- package/lib/apis/tools/generateImage.js +1 -0
- package/lib/apis/tools/generateTextStream.d.ts +1 -0
- package/lib/apis/tools/generateTextStream.js +1 -0
- package/lib/apis/tools/getAppInfo.d.ts +1 -0
- package/lib/apis/tools/getAppInfo.js +1 -0
- package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
- package/lib/apis/tools/getCurrentUserProfile.js +1 -0
- package/lib/apis/tools/storage.d.ts +1 -0
- package/lib/apis/tools/storage.js +4 -0
- package/lib/apis/udt-types.d.ts +16 -0
- package/lib/apis/udt-types.js +0 -0
- package/lib/apis/utils/registerChinaMap.d.ts +1 -0
- package/lib/apis/utils/registerChinaMap.js +103319 -0
- package/lib/components/AppContainer/IframeBridge.d.ts +2 -0
- package/lib/components/AppContainer/IframeBridge.js +80 -0
- package/lib/components/AppContainer/PageHoc.d.ts +4 -0
- package/lib/components/AppContainer/PageHoc.js +20 -0
- package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
- package/lib/components/AppContainer/dayjsPlugins.js +69 -0
- package/lib/components/AppContainer/index.d.ts +7 -0
- package/lib/components/AppContainer/index.js +65 -0
- package/lib/components/AppContainer/sonner.css +101 -0
- package/lib/components/AppContainer/sonner.d.ts +8 -0
- package/lib/components/AppContainer/sonner.js +26 -0
- package/lib/components/ErrorRender/index.d.ts +5 -0
- package/lib/components/ErrorRender/index.js +79 -0
- package/lib/components/NotFoundRender/index.d.ts +3 -0
- package/lib/components/NotFoundRender/index.js +59 -0
- package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
- package/lib/components/SidebarNav/DrawerNav.js +64 -0
- package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
- package/lib/components/SidebarNav/DropdownNav.js +40 -0
- package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
- package/lib/components/SidebarNav/Sidebar.js +33 -0
- package/lib/components/SidebarNav/index.d.ts +5 -0
- package/lib/components/SidebarNav/index.js +61 -0
- package/lib/components/TopNav/BottomNav.d.ts +12 -0
- package/lib/components/TopNav/BottomNav.js +81 -0
- package/lib/components/TopNav/TitleBar.d.ts +10 -0
- package/lib/components/TopNav/TitleBar.js +127 -0
- package/lib/components/TopNav/TopNav.d.ts +10 -0
- package/lib/components/TopNav/TopNav.js +86 -0
- package/lib/components/TopNav/index.d.ts +12 -0
- package/lib/components/TopNav/index.js +65 -0
- package/lib/components/User/UserDisplay.d.ts +9 -0
- package/lib/components/User/UserDisplay.js +39 -0
- package/lib/components/User/UserProfile/UserProfile.css +34 -0
- package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
- package/lib/components/User/UserProfile/UserProfile.js +41 -0
- package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
- package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
- package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
- package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
- package/lib/components/User/UserProfile/index.d.ts +1 -0
- package/lib/components/User/UserProfile/index.js +2 -0
- package/lib/components/User/UserProfile/type.d.ts +8 -0
- package/lib/components/User/UserProfile/type.js +0 -0
- package/lib/components/User/UserProfile/utils.d.ts +5 -0
- package/lib/components/User/UserProfile/utils.js +26 -0
- package/lib/components/User/UserSelect.css +11 -0
- package/lib/components/User/UserSelect.d.ts +11 -0
- package/lib/components/User/UserSelect.js +171 -0
- package/lib/components/User/UserWithAvatar.d.ts +3 -0
- package/lib/components/User/UserWithAvatar.js +41 -0
- package/lib/components/User/index.d.ts +7 -0
- package/lib/components/User/index.js +5 -0
- package/lib/components/User/type.d.ts +13 -0
- package/lib/components/User/type.js +0 -0
- package/lib/components/Welcome/index.d.ts +3 -0
- package/lib/components/Welcome/index.js +33 -0
- package/lib/components/common/LogoInfo.d.ts +5 -0
- package/lib/components/common/LogoInfo.js +30 -0
- package/lib/components/common/NavItem.d.ts +20 -0
- package/lib/components/common/NavItem.js +112 -0
- package/lib/components/common/NavMenu.d.ts +9 -0
- package/lib/components/common/NavMenu.js +50 -0
- package/lib/components/common/UserAvatarLayout.d.ts +4 -0
- package/lib/components/common/UserAvatarLayout.js +41 -0
- package/lib/components/common/UserAvatarMenu.d.ts +4 -0
- package/lib/components/common/UserAvatarMenu.js +58 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +10 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +7 -0
- package/lib/components/theme/ThemeProvider.d.ts +20 -0
- package/lib/components/theme/ThemeProvider.js +75 -0
- package/lib/components/theme/constants.d.ts +48 -0
- package/lib/components/theme/constants.js +556 -0
- package/lib/components/theme/index.d.ts +4 -0
- package/lib/components/theme/index.js +5 -0
- package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
- package/lib/components/theme/miaoDarkTheme.js +310 -0
- package/lib/components/theme/miaoLightTheme.d.ts +2 -0
- package/lib/components/theme/miaoLightTheme.js +296 -0
- package/lib/components/theme/ui-config.d.ts +49 -0
- package/lib/components/theme/ui-config.js +758 -0
- package/lib/components/theme/util.d.ts +20 -0
- package/lib/components/theme/util.js +188 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +5 -0
- package/lib/hooks/useCurrentAppInfo.d.ts +6 -0
- package/lib/hooks/useCurrentAppInfo.js +20 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
- package/lib/hooks/useCurrentUserProfile.js +26 -0
- package/lib/hooks/useIsMobile.d.ts +1 -0
- package/lib/hooks/useIsMobile.js +20 -0
- package/lib/hooks/useLogout.d.ts +4 -0
- package/lib/hooks/useLogout.js +23 -0
- package/lib/hooks/useTheme.d.ts +4 -0
- package/lib/hooks/useTheme.js +8 -0
- package/lib/hooks/useUpdatingRef.d.ts +1 -0
- package/lib/hooks/useUpdatingRef.js +7 -0
- package/lib/index.css +3 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/integrations/dataloom.d.ts +1 -0
- package/lib/integrations/dataloom.js +18 -0
- package/lib/integrations/generateImage.d.ts +1 -0
- package/lib/integrations/generateImage.js +32 -0
- package/lib/integrations/generateTextStream.d.ts +26 -0
- package/lib/integrations/generateTextStream.js +83 -0
- package/lib/integrations/getAppInfo.d.ts +2 -0
- package/lib/integrations/getAppInfo.js +4 -0
- package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
- package/lib/integrations/getCurrentUserProfile.js +5 -0
- package/lib/logger/index.d.ts +6 -0
- package/lib/logger/index.js +54 -0
- package/lib/override.css +29 -0
- package/lib/tailwind-theme.css +435 -0
- package/lib/types/common.d.ts +11 -0
- package/lib/types/common.js +0 -0
- package/lib/types/index.d.ts +40 -0
- package/lib/types/index.js +0 -0
- package/lib/utils/copyToClipboard.d.ts +6 -0
- package/lib/utils/copyToClipboard.js +32 -0
- package/lib/utils/getAppId.d.ts +11 -0
- package/lib/utils/getAppId.js +9 -0
- package/lib/utils/getEnvPath.d.ts +4 -0
- package/lib/utils/getEnvPath.js +4 -0
- package/lib/utils/getParentOrigin.d.ts +5 -0
- package/lib/utils/getParentOrigin.js +7 -0
- package/lib/utils/getUserProfile.d.ts +47 -0
- package/lib/utils/getUserProfile.js +33 -0
- package/lib/utils/url.d.ts +8 -0
- package/lib/utils/url.js +22 -0
- package/lib/utils/utils.d.ts +11 -0
- package/lib/utils/utils.js +9 -0
- package/package.json +130 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import react, { forwardRef, useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { NavLink, matchPath, useLocation } from "react-router-dom";
|
|
4
|
+
import { Button } from "antd";
|
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
6
|
+
import { MoreHorizontal } from "lucide-react";
|
|
7
|
+
const HashLink = /*#__PURE__*/ forwardRef(({ className, to, name, icon, onClick, direction, hideActive = false }, _ref)=>{
|
|
8
|
+
const [isActive, setIsActive] = useState(false);
|
|
9
|
+
useEffect(()=>{
|
|
10
|
+
const checkHash = ()=>{
|
|
11
|
+
setIsActive(window.location.hash === to);
|
|
12
|
+
};
|
|
13
|
+
checkHash();
|
|
14
|
+
window.addEventListener('hashchange', checkHash);
|
|
15
|
+
return ()=>window.removeEventListener('hashchange', checkHash);
|
|
16
|
+
}, [
|
|
17
|
+
to
|
|
18
|
+
]);
|
|
19
|
+
const iconNode = icon ? /*#__PURE__*/ react.createElement(icon, {
|
|
20
|
+
className: 'w-6 h-6'
|
|
21
|
+
}) : null;
|
|
22
|
+
return /*#__PURE__*/ jsxs(Button, {
|
|
23
|
+
variant: "link",
|
|
24
|
+
href: to,
|
|
25
|
+
onClick: ()=>{
|
|
26
|
+
setIsActive(true);
|
|
27
|
+
onClick?.();
|
|
28
|
+
},
|
|
29
|
+
color: isActive && !hideActive ? 'primary' : 'default',
|
|
30
|
+
className: clsxWithTw('miao-nav p-0 b-0 h-full w-full', 'transition-colors inline-flex gap-1 items-center overflow-hidden', {
|
|
31
|
+
'flex-col': 'vertical' === direction,
|
|
32
|
+
'w-full': 'vertical' === direction,
|
|
33
|
+
'justify-center': 'horizontal' === direction,
|
|
34
|
+
'text-inherit': !isActive
|
|
35
|
+
}, className),
|
|
36
|
+
children: [
|
|
37
|
+
iconNode,
|
|
38
|
+
name ? /*#__PURE__*/ jsx("span", {
|
|
39
|
+
className: clsxWithTw('truncate w-full', {
|
|
40
|
+
'text-center': 'vertical' === direction
|
|
41
|
+
}),
|
|
42
|
+
children: name
|
|
43
|
+
}) : null
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
HashLink.displayName = 'HashLink';
|
|
48
|
+
const NavItem = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
49
|
+
const isHashLink = props.to.startsWith('#');
|
|
50
|
+
if (isHashLink) return /*#__PURE__*/ jsx(HashLink, {
|
|
51
|
+
ref: ref,
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/ jsx(NavLink, {
|
|
55
|
+
ref: ref,
|
|
56
|
+
to: props.to,
|
|
57
|
+
end: true,
|
|
58
|
+
onClick: props.onClick,
|
|
59
|
+
className: ()=>clsxWithTw('inline-flex justify-center'),
|
|
60
|
+
children: ({ isActive: linkIsActive })=>/*#__PURE__*/ jsxs(Button, {
|
|
61
|
+
variant: "link",
|
|
62
|
+
color: linkIsActive && !props.hideActive || props.forceActive ? 'primary' : 'default',
|
|
63
|
+
className: clsxWithTw('miao-nav p-0 b-0 h-full w-full', 'transition-colors inline-flex gap-1 items-center overflow-hidden', {
|
|
64
|
+
'flex-col': 'vertical' === props.direction,
|
|
65
|
+
'justify-center': 'horizontal' === props.direction,
|
|
66
|
+
'text-inherit': !(linkIsActive && !props.hideActive || props.forceActive)
|
|
67
|
+
}, props.className),
|
|
68
|
+
children: [
|
|
69
|
+
props.icon ? /*#__PURE__*/ jsx(props.icon, {
|
|
70
|
+
className: "w-6 h-6"
|
|
71
|
+
}) : null,
|
|
72
|
+
props.name ? /*#__PURE__*/ jsx("span", {
|
|
73
|
+
className: clsxWithTw('truncate w-full', {
|
|
74
|
+
' text-center': 'vertical' === props.direction
|
|
75
|
+
}),
|
|
76
|
+
children: props.name
|
|
77
|
+
}) : null
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
NavItem.displayName = 'NavItem';
|
|
83
|
+
const MoreNavItem = ({ expandedNavItemsPath, onClick, isExpanded, name = '更多', ...restProps })=>{
|
|
84
|
+
const { pathname } = useLocation();
|
|
85
|
+
const isActive = useMemo(()=>{
|
|
86
|
+
const matched = expandedNavItemsPath.some((path)=>{
|
|
87
|
+
const match = matchPath(path, pathname);
|
|
88
|
+
return match && match.pathname === pathname;
|
|
89
|
+
});
|
|
90
|
+
return matched;
|
|
91
|
+
}, [
|
|
92
|
+
expandedNavItemsPath,
|
|
93
|
+
pathname
|
|
94
|
+
]);
|
|
95
|
+
const handleClick = useCallback((e)=>{
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
onClick?.();
|
|
98
|
+
}, [
|
|
99
|
+
onClick
|
|
100
|
+
]);
|
|
101
|
+
return /*#__PURE__*/ jsx(NavItem, {
|
|
102
|
+
icon: MoreHorizontal,
|
|
103
|
+
name: name,
|
|
104
|
+
to: "",
|
|
105
|
+
hideActive: !isActive,
|
|
106
|
+
forceActive: isExpanded || isActive,
|
|
107
|
+
onClick: handleClick,
|
|
108
|
+
...restProps
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
MoreNavItem.displayName = 'MoreNavItem';
|
|
112
|
+
export { MoreNavItem, NavItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BaseNavProps } from '../../types';
|
|
3
|
+
type NavMenuProps = BaseNavProps & {
|
|
4
|
+
mode?: 'horizontal' | 'vertical';
|
|
5
|
+
iconClassName?: string;
|
|
6
|
+
onClick?: (key: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export default function NavMenu({ navList, className, iconClassName, mode, onClick, }: NavMenuProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Menu } from "antd";
|
|
3
|
+
import react, { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { NavLink, useLocation } from "react-router-dom";
|
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
6
|
+
function NavMenu({ navList, className, iconClassName = '', mode = 'horizontal', onClick }) {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const [currentMenu, setCurrentMenu] = useState(location.pathname);
|
|
9
|
+
useEffect(()=>{
|
|
10
|
+
setCurrentMenu(location.pathname);
|
|
11
|
+
}, [
|
|
12
|
+
location
|
|
13
|
+
]);
|
|
14
|
+
const menuItems = useMemo(()=>navList?.map((n)=>({
|
|
15
|
+
label: /*#__PURE__*/ jsxs(NavLink, {
|
|
16
|
+
to: n.to,
|
|
17
|
+
end: true,
|
|
18
|
+
className: ({ isActive })=>clsxWithTw('flex items-center', {
|
|
19
|
+
'text-[var(--ant-menu-horizontal-item-selected-color)]': isActive
|
|
20
|
+
}),
|
|
21
|
+
children: [
|
|
22
|
+
n.icon ? /*#__PURE__*/ react.createElement(n.icon, {
|
|
23
|
+
className: clsxWithTw('w-4 h-4', iconClassName)
|
|
24
|
+
}) : null,
|
|
25
|
+
/*#__PURE__*/ jsx("span", {
|
|
26
|
+
children: n.name
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
}),
|
|
30
|
+
key: n.to
|
|
31
|
+
})), [
|
|
32
|
+
navList
|
|
33
|
+
]);
|
|
34
|
+
return /*#__PURE__*/ jsx(Menu, {
|
|
35
|
+
className: clsxWithTw('bg-inherit h-full', className),
|
|
36
|
+
items: menuItems,
|
|
37
|
+
selectedKeys: [
|
|
38
|
+
currentMenu
|
|
39
|
+
],
|
|
40
|
+
onClick: (info)=>{
|
|
41
|
+
setCurrentMenu(info.key);
|
|
42
|
+
onClick?.(info.key);
|
|
43
|
+
},
|
|
44
|
+
mode: mode,
|
|
45
|
+
style: {
|
|
46
|
+
borderBottomWidth: 0
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export { NavMenu as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Button } from "antd";
|
|
4
|
+
import { LogOut } from "lucide-react";
|
|
5
|
+
import { useCurrentUserProfile, useLogout } from "../../hooks/index.js";
|
|
6
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
7
|
+
function UserAvatarLayout({ className }) {
|
|
8
|
+
const { name, avatar } = useCurrentUserProfile();
|
|
9
|
+
const { handlerLogout } = useLogout();
|
|
10
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
11
|
+
children: name ? /*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: clsxWithTw('py-4 px-5 border-gray-200 border-t', className),
|
|
13
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
14
|
+
className: "flex items-center justify-between",
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsxs("div", {
|
|
17
|
+
className: "flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap",
|
|
18
|
+
children: [
|
|
19
|
+
avatar ? /*#__PURE__*/ jsx("img", {
|
|
20
|
+
src: avatar,
|
|
21
|
+
alt: name,
|
|
22
|
+
className: "h-8 w-8 rounded-full"
|
|
23
|
+
}) : null,
|
|
24
|
+
/*#__PURE__*/ jsx("span", {
|
|
25
|
+
className: "text-sm font-medium truncate",
|
|
26
|
+
children: name
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
}),
|
|
30
|
+
/*#__PURE__*/ jsx(Button, {
|
|
31
|
+
type: "text",
|
|
32
|
+
className: "text-inherit",
|
|
33
|
+
icon: /*#__PURE__*/ jsx(LogOut, {}),
|
|
34
|
+
onClick: handlerLogout
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
}) : null
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { UserAvatarLayout as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Avatar, Dropdown, Menu } from "antd";
|
|
4
|
+
import { LogOut } from "lucide-react";
|
|
5
|
+
import { useCurrentUserProfile, useLogout } from "../../hooks/index.js";
|
|
6
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
7
|
+
function UserAvatarMenu({ className }) {
|
|
8
|
+
const { name, avatar } = useCurrentUserProfile();
|
|
9
|
+
const { handlerLogout } = useLogout();
|
|
10
|
+
if (!name) return null;
|
|
11
|
+
return /*#__PURE__*/ jsx(Dropdown, {
|
|
12
|
+
placement: "bottomRight",
|
|
13
|
+
overlay: /*#__PURE__*/ jsxs(Menu, {
|
|
14
|
+
className: clsxWithTw('min-w-48', className),
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsx(Menu.Item, {
|
|
17
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
18
|
+
className: "flex items-center gap-2",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(Avatar, {
|
|
21
|
+
src: avatar,
|
|
22
|
+
className: "w-10 h-10"
|
|
23
|
+
}),
|
|
24
|
+
/*#__PURE__*/ jsx("span", {
|
|
25
|
+
className: "flex-1 text-ellipsis overflow-hidden whitespace-nowrap max-w-[120px]",
|
|
26
|
+
children: name
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
})
|
|
30
|
+
}, "user-info"),
|
|
31
|
+
/*#__PURE__*/ jsx(Menu.Divider, {}),
|
|
32
|
+
/*#__PURE__*/ jsx(Menu.Item, {
|
|
33
|
+
onClick: handlerLogout,
|
|
34
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
35
|
+
className: "flex items-center gap-2",
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx(LogOut, {}),
|
|
38
|
+
/*#__PURE__*/ jsx("span", {
|
|
39
|
+
children: "退出登录"
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
}, "logout")
|
|
44
|
+
]
|
|
45
|
+
}),
|
|
46
|
+
trigger: [
|
|
47
|
+
'click'
|
|
48
|
+
],
|
|
49
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
50
|
+
className: "cursor-pointer py-3 flex items-center justify-center",
|
|
51
|
+
children: /*#__PURE__*/ jsx(Avatar, {
|
|
52
|
+
src: avatar,
|
|
53
|
+
className: "w-8 h-8"
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export { UserAvatarMenu as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as UserAvatarMenu } from './UserAvatarMenu';
|
|
2
|
+
export { default as UserAvatarLayout } from './UserAvatarLayout';
|
|
3
|
+
export { default as NavMenu } from './NavMenu';
|
|
4
|
+
export { default as LogoInfo } from './LogoInfo';
|
|
5
|
+
export * from './NavItem';
|
|
6
|
+
export declare const TopHeaderThemeClass = "bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b";
|
|
7
|
+
export declare const DropdownThemeClass = "bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b";
|
|
8
|
+
export declare const BottomBarThemeClass = "bg-white dark:bg-gray-800 text-[#646A73] dark:text-gray-300";
|
|
9
|
+
export declare const MaskThemeClass = "bg-black/55";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import UserAvatarMenu from "./UserAvatarMenu.js";
|
|
2
|
+
import UserAvatarLayout from "./UserAvatarLayout.js";
|
|
3
|
+
import NavMenu from "./NavMenu.js";
|
|
4
|
+
import LogoInfo from "./LogoInfo.js";
|
|
5
|
+
export * from "./NavItem.js";
|
|
6
|
+
const TopHeaderThemeClass = 'bg-white text-gray-900 border-gray-200 dark:bg-neutral-50 dark:text-white dark:border-gray-700 border-b';
|
|
7
|
+
const DropdownThemeClass = TopHeaderThemeClass;
|
|
8
|
+
const BottomBarThemeClass = 'bg-white dark:bg-gray-800 text-[#646A73] dark:text-gray-300';
|
|
9
|
+
const MaskThemeClass = 'bg-black/55';
|
|
10
|
+
export { BottomBarThemeClass, DropdownThemeClass, LogoInfo, MaskThemeClass, NavMenu, TopHeaderThemeClass, UserAvatarLayout, UserAvatarMenu };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './SidebarNav';
|
|
2
|
+
export * from './User';
|
|
3
|
+
export * from './TopNav';
|
|
4
|
+
export * from './SidebarNav';
|
|
5
|
+
export * from './User';
|
|
6
|
+
export * from './theme';
|
|
7
|
+
export * from './AppContainer';
|
|
8
|
+
export * from './ErrorRender';
|
|
9
|
+
export * from './NotFoundRender';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./SidebarNav/index.js";
|
|
2
|
+
export * from "./User/index.js";
|
|
3
|
+
export * from "./TopNav/index.js";
|
|
4
|
+
export * from "./theme/index.js";
|
|
5
|
+
export * from "./AppContainer/index.js";
|
|
6
|
+
export * from "./ErrorRender/index.js";
|
|
7
|
+
export * from "./NotFoundRender/index.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { ITheme } from '../../types';
|
|
4
|
+
import { IThemeMeta } from './util';
|
|
5
|
+
export interface IBaseThemeProviderProps {
|
|
6
|
+
defaultTheme?: ITheme;
|
|
7
|
+
themeMeta?: Partial<IThemeMeta>;
|
|
8
|
+
}
|
|
9
|
+
interface ThemeProviderProps extends IBaseThemeProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** 是否启用系统主题自动切换 */
|
|
12
|
+
enableSystemTheme?: boolean;
|
|
13
|
+
}
|
|
14
|
+
type ThemeProviderState = {
|
|
15
|
+
theme: ITheme;
|
|
16
|
+
setTheme: (theme: ITheme) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const ThemeProviderContext: React.Context<ThemeProviderState>;
|
|
19
|
+
export declare function ThemeProvider({ children, defaultTheme, themeMeta, enableSystemTheme, ...props }: ThemeProviderProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { ConfigProvider } from "antd";
|
|
4
|
+
import { generateDarkTheme, generateLightTheme } from "./util.js";
|
|
5
|
+
import { findValueByPixel, themeMetaOptions } from "./constants.js";
|
|
6
|
+
const initialState = {
|
|
7
|
+
theme: 'system',
|
|
8
|
+
setTheme: ()=>null
|
|
9
|
+
};
|
|
10
|
+
const ThemeProviderContext = /*#__PURE__*/ createContext(initialState);
|
|
11
|
+
const themeKey = 'miao-ui-theme';
|
|
12
|
+
function ThemeProvider({ children, defaultTheme = 'light', themeMeta = {}, enableSystemTheme = false, ...props }) {
|
|
13
|
+
const [theme, setTheme] = useState(()=>localStorage.getItem(themeKey) || defaultTheme);
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
const root = window.document.documentElement;
|
|
16
|
+
root.classList.remove('light', 'dark');
|
|
17
|
+
root.classList.add(theme);
|
|
18
|
+
}, [
|
|
19
|
+
theme,
|
|
20
|
+
enableSystemTheme
|
|
21
|
+
]);
|
|
22
|
+
useEffect(()=>{
|
|
23
|
+
const root = window.document.documentElement;
|
|
24
|
+
if (void 0 !== themeMeta.spacing) {
|
|
25
|
+
const { rem } = findValueByPixel(`${themeMeta.spacing}`, themeMetaOptions.themeSpaces) || {
|
|
26
|
+
rem: '0.25'
|
|
27
|
+
};
|
|
28
|
+
root.style.setProperty('--spacing', `${rem}rem`);
|
|
29
|
+
}
|
|
30
|
+
if (void 0 !== themeMeta.borderRadius) {
|
|
31
|
+
const { rem } = findValueByPixel(`${themeMeta.borderRadius}`, themeMetaOptions.themeRadius) || {
|
|
32
|
+
rem: '0.625'
|
|
33
|
+
};
|
|
34
|
+
root.style.setProperty('--radius', `${rem}rem`);
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
themeMeta
|
|
38
|
+
]);
|
|
39
|
+
const value = {
|
|
40
|
+
theme,
|
|
41
|
+
setTheme: (theme)=>{
|
|
42
|
+
localStorage.setItem(themeKey, theme);
|
|
43
|
+
setTheme(theme);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const antdTheme = useMemo(()=>{
|
|
47
|
+
const res = findValueByPixel(`${themeMeta.spacing}`, themeMetaOptions.themeSpaces) || {
|
|
48
|
+
pixel: '36',
|
|
49
|
+
rem: '0.25',
|
|
50
|
+
size: {
|
|
51
|
+
sizeUnit: '4',
|
|
52
|
+
sizeStep: '4'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const transformThemeMeta = {
|
|
56
|
+
colorPrimary: themeMeta.colorPrimary,
|
|
57
|
+
borderRadius: Number(themeMeta.borderRadius),
|
|
58
|
+
sizeUnit: Number(res.size.sizeUnit),
|
|
59
|
+
sizeStep: Number(res.size.sizeStep)
|
|
60
|
+
};
|
|
61
|
+
return 'dark' === theme ? generateDarkTheme(transformThemeMeta) : generateLightTheme(transformThemeMeta);
|
|
62
|
+
}, [
|
|
63
|
+
theme,
|
|
64
|
+
themeMeta
|
|
65
|
+
]);
|
|
66
|
+
return /*#__PURE__*/ jsx(ThemeProviderContext.Provider, {
|
|
67
|
+
...props,
|
|
68
|
+
value: value,
|
|
69
|
+
children: /*#__PURE__*/ jsx(ConfigProvider, {
|
|
70
|
+
theme: antdTheme,
|
|
71
|
+
children: children
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export { ThemeProvider, ThemeProviderContext };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface IThemeMeta {
|
|
2
|
+
themeColors: {
|
|
3
|
+
title: string;
|
|
4
|
+
options: {
|
|
5
|
+
value: string;
|
|
6
|
+
color: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
themeRadius: {
|
|
10
|
+
title: string;
|
|
11
|
+
options: {
|
|
12
|
+
value: {
|
|
13
|
+
pixel: string;
|
|
14
|
+
rem: string;
|
|
15
|
+
};
|
|
16
|
+
iconUrl: string;
|
|
17
|
+
size: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
themeSpaces: {
|
|
21
|
+
title: string;
|
|
22
|
+
options: {
|
|
23
|
+
value: {
|
|
24
|
+
pixel: string;
|
|
25
|
+
rem: string;
|
|
26
|
+
size: {
|
|
27
|
+
sizeUnit: string;
|
|
28
|
+
sizeStep: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
iconUrl: string;
|
|
32
|
+
size: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare const themeMetaOptions: Omit<IThemeMeta, 'colorPrimary' | 'borderRadius' | 'spacing'>;
|
|
37
|
+
export declare const themeTailwindRadius: {};
|
|
38
|
+
type ThemeColorTokenMap = {
|
|
39
|
+
light: Record<string, string>;
|
|
40
|
+
dark: Record<string, string>;
|
|
41
|
+
};
|
|
42
|
+
export declare const themeColorTokenMap: ThemeColorTokenMap;
|
|
43
|
+
export declare function getKeyByColor(colorValue: string, theme: keyof ThemeColorTokenMap): string;
|
|
44
|
+
export declare function findValueByPixel(pixelValue: string, themeSpaces: typeof themeMetaOptions.themeSpaces | typeof themeMetaOptions.themeRadius): {
|
|
45
|
+
pixel: string;
|
|
46
|
+
rem: string;
|
|
47
|
+
};
|
|
48
|
+
export {};
|