@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,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
4
|
+
import { LogoInfo, NavMenu, TopHeaderThemeClass, UserAvatarLayout } from "../common/index.js";
|
|
5
|
+
function SidebarNav({ activeClassName, className, navList }) {
|
|
6
|
+
return /*#__PURE__*/ jsx("div", {
|
|
7
|
+
className: clsxWithTw('h-full overflow-y-auto scrollbar-none w-[260px] dark:border-gray-800', className),
|
|
8
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
9
|
+
className: clsxWithTw('fixed top-0 bottom-0 left-0 w-[260px] flex flex-col border-r', TopHeaderThemeClass, className),
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: "w-full px-2 pt-2 h-12 mb-3",
|
|
13
|
+
children: /*#__PURE__*/ jsx(LogoInfo, {
|
|
14
|
+
className: "px-2 pt-[9px] pb-[15px]"
|
|
15
|
+
})
|
|
16
|
+
}),
|
|
17
|
+
/*#__PURE__*/ jsx("div", {
|
|
18
|
+
className: "flex-1 overflow-auto min-h-0",
|
|
19
|
+
children: /*#__PURE__*/ jsx(NavMenu, {
|
|
20
|
+
navList: navList,
|
|
21
|
+
className: clsxWithTw('border-0', className),
|
|
22
|
+
activeClassName: activeClassName,
|
|
23
|
+
mode: "vertical"
|
|
24
|
+
})
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ jsx(UserAvatarLayout, {
|
|
27
|
+
className: "mt-2"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export { SidebarNav as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import { useIsMobile } from "../../hooks/useIsMobile.js";
|
|
4
|
+
import { useLocation } from "react-router-dom";
|
|
5
|
+
import DrawerNav from "./DrawerNav.js";
|
|
6
|
+
import Sidebar from "./Sidebar.js";
|
|
7
|
+
import DropdownNav from "./DropdownNav.js";
|
|
8
|
+
import { ConfigProvider } from "antd";
|
|
9
|
+
import { generateDarkTheme, generateLightTheme } from "../theme/util.js";
|
|
10
|
+
import { useTheme } from "../../hooks/useTheme.js";
|
|
11
|
+
function SideNavigationBar({ navList = [], className, activeClassName, mobileVariant = 'normal' }) {
|
|
12
|
+
const isMobile = useIsMobile();
|
|
13
|
+
const location = useLocation();
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
window.scrollTo(0, 0);
|
|
16
|
+
}, [
|
|
17
|
+
location.pathname
|
|
18
|
+
]);
|
|
19
|
+
if (isMobile) {
|
|
20
|
+
if ('dropdown' === mobileVariant) return /*#__PURE__*/ jsx(DropdownNav, {
|
|
21
|
+
navList: navList,
|
|
22
|
+
className: className,
|
|
23
|
+
activeClassName: activeClassName
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/ jsx(DrawerNav, {
|
|
26
|
+
navList: navList,
|
|
27
|
+
className: className,
|
|
28
|
+
activeClassName: activeClassName
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/ jsx(Sidebar, {
|
|
32
|
+
navList: navList,
|
|
33
|
+
className: className,
|
|
34
|
+
activeClassName: activeClassName
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function SideNavigation(props) {
|
|
38
|
+
const { theme } = useTheme();
|
|
39
|
+
const { darkColorPrimary, lightColorPrimary } = props;
|
|
40
|
+
const themeToken = useMemo(()=>{
|
|
41
|
+
if ('dark' === theme && darkColorPrimary) return generateDarkTheme({
|
|
42
|
+
colorPrimary: darkColorPrimary
|
|
43
|
+
});
|
|
44
|
+
if ('light' === theme && lightColorPrimary) return generateLightTheme({
|
|
45
|
+
colorPrimary: lightColorPrimary
|
|
46
|
+
});
|
|
47
|
+
return {};
|
|
48
|
+
}, [
|
|
49
|
+
theme,
|
|
50
|
+
darkColorPrimary,
|
|
51
|
+
lightColorPrimary
|
|
52
|
+
]);
|
|
53
|
+
return /*#__PURE__*/ jsx(ConfigProvider, {
|
|
54
|
+
theme: themeToken,
|
|
55
|
+
children: /*#__PURE__*/ jsx(SideNavigationBar, {
|
|
56
|
+
...props
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const SidebarNav = SideNavigation;
|
|
61
|
+
export { SideNavigation, SideNavigation as SidebarNav, SidebarNav as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 底部导航栏:应用模式,移动端转用
|
|
3
|
+
*/
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { NavItemProps } from '../common';
|
|
6
|
+
import { BaseNavProps } from '../../types';
|
|
7
|
+
interface BottomNavProps extends BaseNavProps {
|
|
8
|
+
navList: NavItemProps[];
|
|
9
|
+
maxBottomItems?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function BottomNav({ navList, className, maxBottomItems }: BottomNavProps): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
4
|
+
import { BottomBarThemeClass, MaskThemeClass, MoreNavItem, NavItem } from "../common/index.js";
|
|
5
|
+
function BottomNav({ navList = [], className, maxBottomItems = 6 }) {
|
|
6
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
7
|
+
const bottomBarRef = useRef(null);
|
|
8
|
+
const hasMoreItems = navList.length > maxBottomItems;
|
|
9
|
+
const bottomNavItems = hasMoreItems ? navList.slice(0, maxBottomItems - 1) : navList.slice(0, maxBottomItems);
|
|
10
|
+
const expandedNavItems = hasMoreItems ? navList.slice(maxBottomItems - 1) : [];
|
|
11
|
+
const expandedNavItemsPath = useMemo(()=>expandedNavItems.map((item)=>item.to), [
|
|
12
|
+
expandedNavItems
|
|
13
|
+
]);
|
|
14
|
+
const toggleExpanded = ()=>{
|
|
15
|
+
setIsExpanded(!isExpanded);
|
|
16
|
+
};
|
|
17
|
+
const collapsePanel = ()=>{
|
|
18
|
+
setIsExpanded(false);
|
|
19
|
+
};
|
|
20
|
+
const displayGridCols = bottomNavItems.length + (hasMoreItems ? 1 : 0);
|
|
21
|
+
useEffect(()=>{
|
|
22
|
+
if (bottomBarRef.current) {
|
|
23
|
+
const bottomNavMask = document.createElement('div');
|
|
24
|
+
bottomNavMask.className = 'w-full h-16';
|
|
25
|
+
bottomNavMask.style.height = `${bottomBarRef.current.offsetHeight}px`;
|
|
26
|
+
document.body.appendChild(bottomNavMask);
|
|
27
|
+
return ()=>{
|
|
28
|
+
document.body.removeChild(bottomNavMask);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
33
|
+
children: [
|
|
34
|
+
isExpanded ? /*#__PURE__*/ jsx("div", {
|
|
35
|
+
className: clsxWithTw('fixed inset-0 z-20', MaskThemeClass),
|
|
36
|
+
onClick: collapsePanel
|
|
37
|
+
}) : null,
|
|
38
|
+
/*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: clsxWithTw(BottomBarThemeClass, 'fixed inset-x-0 z-20 rounded-t-2xl shadow-lg transform transition-transform duration-300 ease-in-out', 'bottom-16', 'max-h-[calc(100vh-4rem)] overflow-y-auto', className, isExpanded ? 'translate-y-0' : 'translate-y-full'),
|
|
40
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
41
|
+
className: "grid grid-cols-4 gap-2 py-3",
|
|
42
|
+
children: expandedNavItems.map((item, index)=>/*#__PURE__*/ jsx(NavItem, {
|
|
43
|
+
direction: "vertical",
|
|
44
|
+
className: "text-xs h-20 gap-2",
|
|
45
|
+
...item,
|
|
46
|
+
onClick: collapsePanel
|
|
47
|
+
}, index))
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsxs("div", {
|
|
51
|
+
ref: bottomBarRef,
|
|
52
|
+
className: clsxWithTw(BottomBarThemeClass, 'pt-2.5 pb-2.5 fixed h-16 inset-x-0 bottom-0 z-20 border-gray-200 border-t grid items-center', {
|
|
53
|
+
'grid-cols-1': 1 === displayGridCols,
|
|
54
|
+
'grid-cols-2': 2 === displayGridCols,
|
|
55
|
+
'grid-cols-3': 3 === displayGridCols,
|
|
56
|
+
'grid-cols-4': 4 === displayGridCols,
|
|
57
|
+
'grid-cols-5': 5 === displayGridCols,
|
|
58
|
+
'grid-cols-6': 6 === displayGridCols
|
|
59
|
+
}, className),
|
|
60
|
+
children: [
|
|
61
|
+
bottomNavItems.map((item, index)=>/*#__PURE__*/ jsx(NavItem, {
|
|
62
|
+
className: "text-xs",
|
|
63
|
+
hideActive: isExpanded,
|
|
64
|
+
direction: "vertical",
|
|
65
|
+
onClick: collapsePanel,
|
|
66
|
+
...item
|
|
67
|
+
}, index)),
|
|
68
|
+
hasMoreItems ? /*#__PURE__*/ jsx(MoreNavItem, {
|
|
69
|
+
direction: "vertical",
|
|
70
|
+
className: "text-xs",
|
|
71
|
+
name: "更多",
|
|
72
|
+
onClick: toggleExpanded,
|
|
73
|
+
isExpanded: isExpanded,
|
|
74
|
+
expandedNavItemsPath: expandedNavItemsPath
|
|
75
|
+
}) : null
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export { BottomNav };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { Link, matchPath, useLocation } from "react-router-dom";
|
|
4
|
+
import { LogOut, MoreHorizontal, X } from "lucide-react";
|
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
6
|
+
import { useCurrentAppInfo, useCurrentUserProfile, useLogout } from "../../hooks/index.js";
|
|
7
|
+
import { DropdownThemeClass, MaskThemeClass, TopHeaderThemeClass } from "../common/index.js";
|
|
8
|
+
const TitleBar = ({ navList, className })=>{
|
|
9
|
+
const { pathname } = useLocation();
|
|
10
|
+
const title = useMemo(()=>{
|
|
11
|
+
const matched = navList.find((navItem)=>{
|
|
12
|
+
const match = matchPath(navItem.to, pathname);
|
|
13
|
+
return match && match.pathname === pathname;
|
|
14
|
+
});
|
|
15
|
+
return matched?.name;
|
|
16
|
+
}, [
|
|
17
|
+
navList,
|
|
18
|
+
pathname
|
|
19
|
+
]);
|
|
20
|
+
const { appName, appLogo } = useCurrentAppInfo();
|
|
21
|
+
const { name: userName, avatar: userAvatar } = useCurrentUserProfile();
|
|
22
|
+
const { handlerLogout } = useLogout();
|
|
23
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
24
|
+
const closeMenu = ()=>{
|
|
25
|
+
setIsMenuOpen(false);
|
|
26
|
+
};
|
|
27
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ jsx("header", {
|
|
30
|
+
className: clsxWithTw('px-2 md:px-4 sticky top-0 z-20 w-full h-14', TopHeaderThemeClass, className),
|
|
31
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
32
|
+
className: "flex justify-center items-center w-full h-full px-6",
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx("div", {
|
|
35
|
+
className: "font-semibold w-ful text-ellipsis overflow-hidden whitespace-nowrap",
|
|
36
|
+
children: title
|
|
37
|
+
}),
|
|
38
|
+
isMenuOpen ? /*#__PURE__*/ jsx(X, {
|
|
39
|
+
className: "w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 cursor-pointer",
|
|
40
|
+
onClick: ()=>setIsMenuOpen(!isMenuOpen)
|
|
41
|
+
}) : /*#__PURE__*/ jsx(MoreHorizontal, {
|
|
42
|
+
onClick: ()=>setIsMenuOpen(!isMenuOpen),
|
|
43
|
+
className: "w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 cursor-pointer"
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
isMenuOpen ? /*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: clsxWithTw('fixed inset-x-0 top-14 bottom-0 z-10', MaskThemeClass),
|
|
50
|
+
onClick: closeMenu
|
|
51
|
+
}) : null,
|
|
52
|
+
/*#__PURE__*/ jsx("div", {
|
|
53
|
+
className: clsxWithTw('fixed inset-x-0 z-10 transform transition-transform duration-300 ease-in-out', 'top-14', DropdownThemeClass, 'max-h-[calc(100vh-3.5rem)] overflow-y-auto', className, isMenuOpen ? 'translate-y-0 shadow-lg' : '-translate-y-full'),
|
|
54
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
55
|
+
className: "container space-y-4 py-6",
|
|
56
|
+
hidden: !isMenuOpen,
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ jsxs(Link, {
|
|
59
|
+
to: "/",
|
|
60
|
+
className: "flex flex-col justify-center items-center space-x-2",
|
|
61
|
+
onClick: closeMenu,
|
|
62
|
+
children: [
|
|
63
|
+
appLogo ? /*#__PURE__*/ jsx("img", {
|
|
64
|
+
src: appLogo,
|
|
65
|
+
alt: "avatar",
|
|
66
|
+
className: "w-14 h-14 mb-4"
|
|
67
|
+
}) : null,
|
|
68
|
+
/*#__PURE__*/ jsx("span", {
|
|
69
|
+
className: "text-xl text-center font-medium w-full text-ellipsis overflow-hidden whitespace-nowrap ",
|
|
70
|
+
children: appName || '新应用'
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsx("div", {
|
|
73
|
+
className: "text-center justify-center text-token-text-title font-medium leading-relaxed"
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
77
|
+
userAvatar ? /*#__PURE__*/ jsxs("div", {
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ jsxs("div", {
|
|
80
|
+
className: "flex items-center justify-between border-gray-200 border-t py-4 ",
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ jsx("div", {
|
|
83
|
+
children: "当前用户"
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ jsxs("div", {
|
|
86
|
+
className: "flex items-center",
|
|
87
|
+
children: [
|
|
88
|
+
/*#__PURE__*/ jsx("span", {
|
|
89
|
+
className: "flex-1 text-ellipsis overflow-hidden whitespace-nowrap",
|
|
90
|
+
children: userName
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ jsx("img", {
|
|
93
|
+
src: userAvatar,
|
|
94
|
+
alt: "avatar",
|
|
95
|
+
className: "w-8 h-8 rounded-full ml-2"
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsxs("div", {
|
|
102
|
+
className: "flex items-center justify-between border-t border-gray-200 py-4 cursor-pointer",
|
|
103
|
+
onClick: async ()=>{
|
|
104
|
+
await handlerLogout();
|
|
105
|
+
closeMenu();
|
|
106
|
+
},
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx("div", {
|
|
109
|
+
children: "退出登录"
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ jsx("div", {
|
|
112
|
+
className: "flex items-center",
|
|
113
|
+
children: /*#__PURE__*/ jsx(LogOut, {
|
|
114
|
+
className: "w-5 h-5"
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
}) : null
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
export { TitleBar };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 顶部标题导航栏:支持 PC 和移动端
|
|
3
|
+
* 移动端收起导航,点击下拉使用
|
|
4
|
+
*/
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { BaseNavProps } from '../../types';
|
|
7
|
+
export interface TopNavProps extends BaseNavProps {
|
|
8
|
+
align?: 'left' | 'center' | 'right';
|
|
9
|
+
}
|
|
10
|
+
export declare function TopNav({ navList, align, className, activeClassName }: TopNavProps): React.JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { Menu, X } from "lucide-react";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
6
|
+
import { useCurrentAppInfo } from "../../hooks/useCurrentAppInfo.js";
|
|
7
|
+
import { useCurrentUserProfile } from "../../hooks/useCurrentUserProfile.js";
|
|
8
|
+
import { DropdownThemeClass, NavMenu, TopHeaderThemeClass, UserAvatarMenu } from "../common/index.js";
|
|
9
|
+
function TopNav({ navList = [], align = 'left', className, activeClassName }) {
|
|
10
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
11
|
+
const navRef = useRef(null);
|
|
12
|
+
const { appName, appLogo } = useCurrentAppInfo();
|
|
13
|
+
const { avatar: userAvatar } = useCurrentUserProfile();
|
|
14
|
+
return /*#__PURE__*/ jsxs("header", {
|
|
15
|
+
ref: navRef,
|
|
16
|
+
className: clsxWithTw('miao-top-nav h-14 items-end w-[100vw] px-3 md:px-4 sticky top-0 z-50 shadow-xs flex', TopHeaderThemeClass, className),
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ jsxs("div", {
|
|
19
|
+
className: "flex w-full h-full items-center justify-between",
|
|
20
|
+
children: [
|
|
21
|
+
/*#__PURE__*/ jsx("div", {
|
|
22
|
+
className: "flex items-center gap-6 md:gap-10 text-ellipsis overflow-hidden whitespace-nowrap",
|
|
23
|
+
children: /*#__PURE__*/ jsx(Link, {
|
|
24
|
+
to: "/",
|
|
25
|
+
className: "flex items-center space-x-2 w-[100%]",
|
|
26
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
27
|
+
className: "flex items-center gap-2 w-[100%]",
|
|
28
|
+
children: [
|
|
29
|
+
appLogo ? /*#__PURE__*/ jsx("img", {
|
|
30
|
+
src: appLogo,
|
|
31
|
+
alt: "avatar",
|
|
32
|
+
className: "w-7 h-7"
|
|
33
|
+
}) : null,
|
|
34
|
+
/*#__PURE__*/ jsx("span", {
|
|
35
|
+
className: "max-w-[240px] font-medium w-full truncate",
|
|
36
|
+
title: appName,
|
|
37
|
+
children: appName || '新应用'
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ jsx("div", {
|
|
44
|
+
className: clsxWithTw('flex-1 overflow-hidden ml-5 hidden md:block h-full', {
|
|
45
|
+
'items-start': 'left' === align,
|
|
46
|
+
'items-center': 'center' === align,
|
|
47
|
+
'items-end': 'right' === align
|
|
48
|
+
}),
|
|
49
|
+
children: /*#__PURE__*/ jsx(NavMenu, {
|
|
50
|
+
navList: navList,
|
|
51
|
+
className: className,
|
|
52
|
+
activeClassName: activeClassName
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
userAvatar ? /*#__PURE__*/ jsx(UserAvatarMenu, {
|
|
56
|
+
className: className
|
|
57
|
+
}) : null,
|
|
58
|
+
navList.length > 0 ? /*#__PURE__*/ jsx("div", {
|
|
59
|
+
className: "md:hidden flex items-center",
|
|
60
|
+
children: isMenuOpen ? /*#__PURE__*/ jsx(X, {
|
|
61
|
+
className: "h-5 w-5 mx-3 cursor-pointer",
|
|
62
|
+
onClick: ()=>setIsMenuOpen(!isMenuOpen)
|
|
63
|
+
}) : /*#__PURE__*/ jsx(Menu, {
|
|
64
|
+
className: "h-5 w-5 mx-3 cursor-pointer",
|
|
65
|
+
onClick: ()=>setIsMenuOpen(!isMenuOpen)
|
|
66
|
+
})
|
|
67
|
+
}) : null
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
70
|
+
isMenuOpen && navList.length > 0 ? /*#__PURE__*/ jsx("div", {
|
|
71
|
+
className: "md:hidden",
|
|
72
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
73
|
+
className: clsxWithTw('overflow-y-auto max-h-[482px] border-t border-gray-200 py-2 absolute top-14 left-0 right-0 shadow-lg', DropdownThemeClass, className),
|
|
74
|
+
children: /*#__PURE__*/ jsx(NavMenu, {
|
|
75
|
+
navList: navList,
|
|
76
|
+
className: className,
|
|
77
|
+
activeClassName: activeClassName,
|
|
78
|
+
onClick: ()=>setIsMenuOpen(false),
|
|
79
|
+
mode: "vertical"
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}) : null
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { TopNav };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { NavProps } from '../../types';
|
|
3
|
+
interface NavBarProps extends Omit<NavProps, 'mobileVariant'> {
|
|
4
|
+
align?: 'left' | 'center' | 'right';
|
|
5
|
+
/**
|
|
6
|
+
* 移动端导航栏 变体
|
|
7
|
+
*/
|
|
8
|
+
mobileVariant?: 'bottomBar' | 'dropdown';
|
|
9
|
+
}
|
|
10
|
+
export declare function Navigation(props: NavBarProps): React.JSX.Element;
|
|
11
|
+
export { Navigation as TopNav };
|
|
12
|
+
export default Navigation;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import { useIsMobile } from "../../hooks/useIsMobile.js";
|
|
4
|
+
import { BottomNav } from "./BottomNav.js";
|
|
5
|
+
import { TitleBar } from "./TitleBar.js";
|
|
6
|
+
import { TopNav } from "./TopNav.js";
|
|
7
|
+
import { ConfigProvider } from "antd";
|
|
8
|
+
import { useTheme } from "../../hooks/useTheme.js";
|
|
9
|
+
import { useLocation } from "react-router-dom";
|
|
10
|
+
import { generateDarkTheme, generateLightTheme } from "../theme/util.js";
|
|
11
|
+
function NavigationBar({ navList = [], align, className, activeClassName, mobileVariant = 'dropdown' }) {
|
|
12
|
+
const isMobile = useIsMobile();
|
|
13
|
+
const location = useLocation();
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
window.scrollTo(0, 0);
|
|
16
|
+
}, [
|
|
17
|
+
location.pathname
|
|
18
|
+
]);
|
|
19
|
+
if (isMobile && 'bottomBar' === mobileVariant) {
|
|
20
|
+
if (0 === navList.length) return null;
|
|
21
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(TitleBar, {
|
|
24
|
+
className: className,
|
|
25
|
+
navList: navList
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsx(BottomNav, {
|
|
28
|
+
navList: navList,
|
|
29
|
+
className: className
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return /*#__PURE__*/ jsx(TopNav, {
|
|
35
|
+
navList: navList,
|
|
36
|
+
activeClassName: activeClassName,
|
|
37
|
+
align: align,
|
|
38
|
+
className: className
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function Navigation(props) {
|
|
42
|
+
const { theme } = useTheme();
|
|
43
|
+
const { darkColorPrimary, lightColorPrimary } = props;
|
|
44
|
+
const themeToken = useMemo(()=>{
|
|
45
|
+
if ('dark' === theme && darkColorPrimary) return generateDarkTheme({
|
|
46
|
+
colorPrimary: darkColorPrimary
|
|
47
|
+
});
|
|
48
|
+
if ('light' === theme && lightColorPrimary) return generateLightTheme({
|
|
49
|
+
colorPrimary: lightColorPrimary
|
|
50
|
+
});
|
|
51
|
+
return {};
|
|
52
|
+
}, [
|
|
53
|
+
theme,
|
|
54
|
+
darkColorPrimary,
|
|
55
|
+
lightColorPrimary
|
|
56
|
+
]);
|
|
57
|
+
return /*#__PURE__*/ jsx(ConfigProvider, {
|
|
58
|
+
theme: themeToken,
|
|
59
|
+
children: /*#__PURE__*/ jsx(NavigationBar, {
|
|
60
|
+
...props
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const components_TopNav = Navigation;
|
|
65
|
+
export { Navigation, Navigation as TopNav, components_TopNav as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IUserProfile } from '../../apis/udt-types';
|
|
3
|
+
export interface UserDisplayProps {
|
|
4
|
+
users: IUserProfile[];
|
|
5
|
+
size: 'small' | 'medium' | 'large';
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export declare const UserDisplay: React.FC<UserDisplayProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import react from "react";
|
|
3
|
+
import { Popover } from "antd";
|
|
4
|
+
import { UserWithAvatar } from "./UserWithAvatar.js";
|
|
5
|
+
import { clsxWithTw } from "../../utils/utils.js";
|
|
6
|
+
import { UserProfile } from "./UserProfile/index.js";
|
|
7
|
+
const UserDisplay = ({ users, size, className, style })=>{
|
|
8
|
+
const displayUsers = react.useMemo(()=>Array.isArray(users) ? users : [
|
|
9
|
+
users
|
|
10
|
+
].filter(Boolean), [
|
|
11
|
+
users
|
|
12
|
+
]);
|
|
13
|
+
if (!displayUsers.length) return null;
|
|
14
|
+
return /*#__PURE__*/ jsx("div", {
|
|
15
|
+
className: clsxWithTw('flex gap-1 flex-wrap', className),
|
|
16
|
+
style: style,
|
|
17
|
+
children: displayUsers.map((user)=>/*#__PURE__*/ jsx(Popover, {
|
|
18
|
+
placement: "bottomLeft",
|
|
19
|
+
trigger: "click",
|
|
20
|
+
content: /*#__PURE__*/ jsx(UserProfile, {
|
|
21
|
+
user_id: user.user_id
|
|
22
|
+
}),
|
|
23
|
+
arrow: false,
|
|
24
|
+
styles: {
|
|
25
|
+
body: {
|
|
26
|
+
padding: 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
30
|
+
children: /*#__PURE__*/ jsx(UserWithAvatar, {
|
|
31
|
+
data: user,
|
|
32
|
+
size: size,
|
|
33
|
+
className: "cursor-pointer hover:bg-[rgba(31,35,41,0.15)] active:bg-[rgba(31,35,41,0.2)]"
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}, user.user_id))
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export { UserDisplay };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.user-profile-skeleton-lines .ant-skeleton-paragraph > li {
|
|
2
|
+
border-radius: 100px;
|
|
3
|
+
height: 16px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.user-profile-button .ant-btn-icon {
|
|
7
|
+
height: 18px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.no-scrollbar {
|
|
11
|
+
scrollbar-width: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.no-scrollbar::-webkit-scrollbar {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.user-profile-avatar {
|
|
19
|
+
box-shadow: 0 6px 18px 6px #1f232908, 0 3px 6px -6px #1f23290d, 0 4px 8px #1f232908;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.user-profile-name-container {
|
|
23
|
+
margin-top: 10px;
|
|
24
|
+
padding-bottom: 4px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.user-profile-name {
|
|
28
|
+
color: #1f2937;
|
|
29
|
+
margin-bottom: 0;
|
|
30
|
+
font-size: 22px;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
line-height: 28px;
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { UserProfileUI } from "./UserProfileUI.js";
|
|
4
|
+
import { UserProfileSkeleton } from "./UserProfileSkeleton.js";
|
|
5
|
+
import { getUserProfile } from "../../../utils/getUserProfile.js";
|
|
6
|
+
import { INVALID_USER, formatI18nProfile } from "./utils.js";
|
|
7
|
+
import { UserProfileContainer } from "./UserProfileContainer.js";
|
|
8
|
+
import { logger } from "../../../logger/index.js";
|
|
9
|
+
function UserProfile(props) {
|
|
10
|
+
const { user_id } = props;
|
|
11
|
+
const [user, setUser] = useState(null);
|
|
12
|
+
const [loading, setLoading] = useState(true);
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
const fetchUser = async ()=>{
|
|
15
|
+
setLoading(true);
|
|
16
|
+
try {
|
|
17
|
+
const { data } = await getUserProfile({
|
|
18
|
+
userID: user_id
|
|
19
|
+
});
|
|
20
|
+
if (data.userProfile) {
|
|
21
|
+
const profile = data.userProfile;
|
|
22
|
+
setUser(formatI18nProfile(profile));
|
|
23
|
+
} else setUser(INVALID_USER);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
setUser(INVALID_USER);
|
|
26
|
+
logger.error('Failed to fetch user profile:', error);
|
|
27
|
+
} finally{
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
fetchUser();
|
|
32
|
+
}, [
|
|
33
|
+
user_id
|
|
34
|
+
]);
|
|
35
|
+
return /*#__PURE__*/ jsx(UserProfileContainer, {
|
|
36
|
+
children: loading || !user ? /*#__PURE__*/ jsx(UserProfileSkeleton, {}) : /*#__PURE__*/ jsx(UserProfileUI, {
|
|
37
|
+
user: user
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { UserProfile };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./UserProfile.css";
|
|
4
|
+
const UserProfileContainer = ({ children })=>/*#__PURE__*/ jsx("div", {
|
|
5
|
+
className: "w-[320px] h-[468px] rounded-[8px] overflow-y-auto no-scrollbar",
|
|
6
|
+
children: children
|
|
7
|
+
});
|
|
8
|
+
export { UserProfileContainer };
|