@lobehub/chat 1.42.5 → 1.43.0
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/CHANGELOG.md +58 -0
- package/changelog/v1.json +21 -0
- package/docs/.cdn.cache.json +1 -0
- package/docs/changelog/2025-01-03-user-profile.mdx +27 -0
- package/docs/changelog/2025-01-03-user-profile.zh-CN.mdx +26 -0
- package/docs/self-hosting/advanced/auth/next-auth/wechat.mdx +3 -1
- package/docs/self-hosting/advanced/auth/next-auth/wechat.zh-CN.mdx +2 -2
- package/locales/ar/auth.json +76 -4
- package/locales/bg-BG/auth.json +75 -3
- package/locales/de-DE/auth.json +78 -6
- package/locales/en-US/auth.json +78 -6
- package/locales/es-ES/auth.json +75 -3
- package/locales/fa-IR/auth.json +77 -5
- package/locales/fr-FR/auth.json +78 -6
- package/locales/it-IT/auth.json +76 -4
- package/locales/ja-JP/auth.json +76 -4
- package/locales/ko-KR/auth.json +75 -3
- package/locales/nl-NL/auth.json +76 -4
- package/locales/pl-PL/auth.json +76 -4
- package/locales/pt-BR/auth.json +76 -4
- package/locales/ru-RU/auth.json +75 -3
- package/locales/tr-TR/auth.json +74 -3
- package/locales/vi-VN/auth.json +75 -3
- package/locales/zh-CN/auth.json +75 -3
- package/locales/zh-TW/auth.json +75 -3
- package/package.json +13 -3
- package/src/app/(main)/(mobile)/me/(home)/__tests__/UserBanner.test.tsx +4 -0
- package/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +0 -46
- package/src/app/(main)/(mobile)/me/(home)/features/UserBanner.tsx +11 -14
- package/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx +6 -21
- package/src/app/(main)/(mobile)/me/profile/features/Category.tsx +38 -21
- package/src/app/(main)/(mobile)/me/profile/layout.tsx +0 -3
- package/src/app/(main)/(mobile)/me/profile/page.tsx +3 -3
- package/src/app/(main)/chat/(workspace)/@topic/features/TopicListContent/ByTimeMode/index.tsx +1 -1
- package/src/app/(main)/chat/loading.tsx +2 -2
- package/src/app/(main)/discover/loading.tsx +2 -8
- package/src/app/(main)/files/loading.tsx +2 -2
- package/src/app/(main)/profile/(home)/Client.tsx +53 -0
- package/src/app/(main)/profile/(home)/[[...slugs]]/page.tsx +38 -0
- package/src/app/(main)/profile/@category/default.tsx +9 -0
- package/src/app/(main)/profile/@category/features/CategoryContent.tsx +38 -0
- package/src/app/(main)/profile/_layout/Desktop/Header.tsx +85 -0
- package/src/app/(main)/profile/_layout/Desktop/SideBar.tsx +42 -0
- package/src/app/(main)/profile/_layout/Desktop/index.tsx +48 -0
- package/src/app/(main)/profile/_layout/Mobile/Header.tsx +23 -5
- package/src/app/(main)/profile/_layout/Mobile/index.tsx +12 -5
- package/src/app/(main)/profile/_layout/type.ts +6 -0
- package/src/app/(main)/profile/error.tsx +5 -0
- package/src/app/(main)/profile/features/ClerkProfile.tsx +72 -0
- package/src/app/(main)/profile/hooks/useCategory.tsx +51 -0
- package/src/app/(main)/profile/layout.tsx +7 -17
- package/src/app/(main)/profile/loading.tsx +2 -22
- package/src/app/(main)/profile/not-found.tsx +3 -0
- package/src/app/(main)/profile/security/page.tsx +34 -0
- package/src/app/(main)/profile/stats/Client.tsx +52 -0
- package/src/app/(main)/profile/stats/features/AiHeatmaps.tsx +130 -0
- package/src/app/(main)/profile/stats/features/AssistantsRank.tsx +115 -0
- package/src/app/(main)/profile/stats/features/ModelsRank.tsx +84 -0
- package/src/app/(main)/profile/stats/features/ShareButton/Preview.tsx +159 -0
- package/src/app/(main)/profile/stats/features/ShareButton/ShareModal.tsx +87 -0
- package/src/app/(main)/profile/stats/features/ShareButton/TotalCard.tsx +39 -0
- package/src/app/(main)/profile/stats/features/ShareButton/index.tsx +26 -0
- package/src/app/(main)/profile/stats/features/TimeLabel.tsx +30 -0
- package/src/app/(main)/profile/stats/features/TopicsRank.tsx +103 -0
- package/src/app/(main)/profile/stats/features/TotalAssistants.tsx +56 -0
- package/src/app/(main)/profile/stats/features/TotalMessages.tsx +56 -0
- package/src/app/(main)/profile/stats/features/TotalTopics.tsx +53 -0
- package/src/app/(main)/profile/stats/features/TotalWords.tsx +54 -0
- package/src/app/(main)/profile/stats/features/Welcome.tsx +86 -0
- package/src/app/(main)/profile/{[[...slugs]] → stats}/page.tsx +4 -5
- package/src/app/(main)/repos/[id]/evals/dataset/page.tsx +2 -2
- package/src/app/(main)/repos/[id]/evals/evaluation/page.tsx +2 -2
- package/src/app/(main)/settings/@category/features/CategoryContent.tsx +1 -1
- package/src/app/(main)/settings/_layout/Desktop/index.tsx +1 -1
- package/src/app/(main)/settings/_layout/Mobile/Header.tsx +1 -1
- package/src/app/(main)/settings/_layout/Mobile/index.tsx +2 -0
- package/src/app/(main)/settings/common/features/Theme/index.tsx +2 -17
- package/src/app/(main)/settings/loading.tsx +2 -2
- package/src/components/Loading/BrandTextLoading/index.tsx +2 -2
- package/src/components/Statistic/index.tsx +15 -0
- package/src/components/StatisticCard/TitleWithPercentage.tsx +80 -0
- package/src/components/StatisticCard/growthPercentage.tsx +8 -0
- package/src/components/StatisticCard/index.tsx +209 -0
- package/src/const/url.ts +3 -3
- package/src/database/server/models/__tests__/message.test.ts +346 -35
- package/src/database/server/models/__tests__/session.test.ts +185 -2
- package/src/database/server/models/__tests__/topic.test.ts +136 -0
- package/src/database/server/models/__tests__/user.test.ts +140 -1
- package/src/database/server/models/message.ts +109 -14
- package/src/database/server/models/session.ts +75 -4
- package/src/database/server/models/topic.ts +43 -3
- package/src/database/server/models/user.ts +22 -0
- package/src/database/utils/genWhere.ts +39 -0
- package/src/features/ShareModal/ShareImage/index.tsx +11 -24
- package/src/features/ShareModal/ShareImage/type.ts +1 -6
- package/src/features/User/DataStatistics.tsx +21 -14
- package/src/features/User/UserPanel/PanelContent.tsx +12 -16
- package/src/features/User/UserPanel/useMenu.tsx +4 -6
- package/src/features/User/__tests__/PanelContent.test.tsx +4 -0
- package/src/features/User/__tests__/useMenu.test.tsx +1 -21
- package/src/hooks/useActiveTabKey.ts +34 -1
- package/src/{features/ShareModal/ShareImage → hooks}/useScreenshot.ts +51 -6
- package/src/locales/default/auth.ts +74 -2
- package/src/server/ld.test.ts +1 -1
- package/src/server/modules/AssistantStore/index.ts +3 -2
- package/src/server/routers/lambda/message.ts +35 -6
- package/src/server/routers/lambda/session.ts +17 -3
- package/src/server/routers/lambda/topic.ts +17 -3
- package/src/server/routers/lambda/user.ts +4 -0
- package/src/server/services/changelog/index.ts +1 -1
- package/src/services/message/_deprecated.ts +16 -0
- package/src/services/message/client.test.ts +0 -18
- package/src/services/message/client.ts +12 -9
- package/src/services/message/server.ts +12 -4
- package/src/services/message/type.ts +15 -3
- package/src/services/session/_deprecated.ts +5 -0
- package/src/services/session/client.ts +6 -2
- package/src/services/session/server.ts +6 -2
- package/src/services/session/type.ts +7 -1
- package/src/services/topic/_deprecated.ts +5 -0
- package/src/services/topic/client.ts +6 -2
- package/src/services/topic/server.ts +7 -1
- package/src/services/topic/type.ts +7 -2
- package/src/services/user/_deprecated.ts +4 -0
- package/src/services/user/client.ts +4 -0
- package/src/services/user/server.ts +4 -0
- package/src/services/user/type.ts +5 -0
- package/src/store/global/initialState.ts +6 -0
- package/src/store/user/slices/auth/action.test.ts +1 -33
- package/src/store/user/slices/auth/action.ts +0 -9
- package/src/store/user/slices/common/action.test.ts +2 -2
- package/src/types/message/index.ts +5 -0
- package/src/types/session/index.ts +8 -0
- package/src/types/topic/topic.ts +7 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/time.ts +23 -0
- package/src/app/(main)/profile/[[...slugs]]/Client.tsx +0 -76
- package/src/components/Loading/BrandTextLoading/LobeChatText/SVG.tsx +0 -44
- package/src/components/Loading/BrandTextLoading/LobeChatText/index.tsx +0 -6
- package/src/components/Loading/BrandTextLoading/LobeChatText/style.css +0 -32
- package/src/hooks/useActiveSettingsKey.ts +0 -20
@@ -0,0 +1,87 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { type FormItemProps, FormModal, FormModalProps } from '@lobehub/ui';
|
4
|
+
import { Segmented, Skeleton } from 'antd';
|
5
|
+
import { createStyles } from 'antd-style';
|
6
|
+
import dynamic from 'next/dynamic';
|
7
|
+
import { memo, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
|
10
|
+
import { ImageType, imageTypeOptions, useScreenshot } from '@/hooks/useScreenshot';
|
11
|
+
|
12
|
+
const Preview = dynamic(() => import('./Preview'), {
|
13
|
+
loading: () => (
|
14
|
+
<Skeleton.Button
|
15
|
+
active
|
16
|
+
block
|
17
|
+
size={'large'}
|
18
|
+
style={{
|
19
|
+
height: 400,
|
20
|
+
width: '100%',
|
21
|
+
}}
|
22
|
+
/>
|
23
|
+
),
|
24
|
+
});
|
25
|
+
|
26
|
+
const useStyles = createStyles(({ css, prefixCls }) => ({
|
27
|
+
preview: css`
|
28
|
+
.${prefixCls}-form-item-label {
|
29
|
+
display: none;
|
30
|
+
}
|
31
|
+
`,
|
32
|
+
}));
|
33
|
+
|
34
|
+
type FieldType = {
|
35
|
+
imageType: ImageType;
|
36
|
+
};
|
37
|
+
|
38
|
+
const DEFAULT_FIELD_VALUE: FieldType = {
|
39
|
+
imageType: ImageType.JPG,
|
40
|
+
};
|
41
|
+
|
42
|
+
const ShareModal = memo<FormModalProps & { mobile?: boolean }>(({ open, onCancel, mobile }) => {
|
43
|
+
const { t } = useTranslation(['chat', 'common']);
|
44
|
+
const [fieldValue, setFieldValue] = useState<FieldType>(DEFAULT_FIELD_VALUE);
|
45
|
+
const { styles } = useStyles();
|
46
|
+
const { loading, onDownload } = useScreenshot({
|
47
|
+
imageType: fieldValue.imageType,
|
48
|
+
title: 'stats',
|
49
|
+
width: mobile ? 440 : undefined,
|
50
|
+
});
|
51
|
+
|
52
|
+
const items: FormItemProps[] = [
|
53
|
+
{
|
54
|
+
children: <Preview />,
|
55
|
+
className: styles.preview,
|
56
|
+
divider: false,
|
57
|
+
minWidth: '100%',
|
58
|
+
},
|
59
|
+
{
|
60
|
+
children: <Segmented options={imageTypeOptions} />,
|
61
|
+
divider: false,
|
62
|
+
label: t('shareModal.imageType'),
|
63
|
+
minWidth: undefined,
|
64
|
+
name: 'imageType',
|
65
|
+
},
|
66
|
+
];
|
67
|
+
|
68
|
+
return (
|
69
|
+
<FormModal
|
70
|
+
allowFullscreen
|
71
|
+
footer={null}
|
72
|
+
initialValues={DEFAULT_FIELD_VALUE}
|
73
|
+
items={items}
|
74
|
+
itemsType={'flat'}
|
75
|
+
onCancel={onCancel}
|
76
|
+
onFinish={onDownload}
|
77
|
+
onValuesChange={(_, v) => setFieldValue(v)}
|
78
|
+
open={open}
|
79
|
+
submitLoading={loading}
|
80
|
+
submitText={t('shareModal.download')}
|
81
|
+
title={t('share', { ns: 'common' })}
|
82
|
+
width={480}
|
83
|
+
/>
|
84
|
+
);
|
85
|
+
});
|
86
|
+
|
87
|
+
export default ShareModal;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { useTheme } from 'antd-style';
|
2
|
+
import { memo } from 'react';
|
3
|
+
import { Flexbox } from 'react-layout-kit';
|
4
|
+
|
5
|
+
interface TotalCardProps {
|
6
|
+
count: string | number;
|
7
|
+
title: string;
|
8
|
+
}
|
9
|
+
|
10
|
+
const TotalCard = memo<TotalCardProps>(({ title, count }) => {
|
11
|
+
const theme = useTheme();
|
12
|
+
return (
|
13
|
+
<Flexbox
|
14
|
+
padding={12}
|
15
|
+
style={{
|
16
|
+
background: theme.isDarkMode ? theme.colorFillTertiary : theme.colorFillQuaternary,
|
17
|
+
borderRadius: theme.borderRadiusLG,
|
18
|
+
}}
|
19
|
+
>
|
20
|
+
<div
|
21
|
+
style={{
|
22
|
+
fontSize: 13,
|
23
|
+
}}
|
24
|
+
>
|
25
|
+
{title}
|
26
|
+
</div>
|
27
|
+
<div
|
28
|
+
style={{
|
29
|
+
fontSize: 20,
|
30
|
+
fontWeight: 'bold',
|
31
|
+
}}
|
32
|
+
>
|
33
|
+
{count}
|
34
|
+
</div>
|
35
|
+
</Flexbox>
|
36
|
+
);
|
37
|
+
});
|
38
|
+
|
39
|
+
export default TotalCard;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { ActionIcon } from '@lobehub/ui';
|
4
|
+
import { Share2Icon } from 'lucide-react';
|
5
|
+
import { memo, useState } from 'react';
|
6
|
+
|
7
|
+
import { DESKTOP_HEADER_ICON_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
|
8
|
+
|
9
|
+
import ShareModal from './ShareModal';
|
10
|
+
|
11
|
+
const ShareButton = memo<{ mobile?: boolean }>(({ mobile }) => {
|
12
|
+
const [open, setOpen] = useState(false);
|
13
|
+
|
14
|
+
return (
|
15
|
+
<>
|
16
|
+
<ActionIcon
|
17
|
+
icon={Share2Icon}
|
18
|
+
onClick={() => setOpen(true)}
|
19
|
+
size={mobile ? MOBILE_HEADER_ICON_SIZE : DESKTOP_HEADER_ICON_SIZE}
|
20
|
+
/>
|
21
|
+
<ShareModal mobile={mobile} onCancel={() => setOpen(false)} open={open} />
|
22
|
+
</>
|
23
|
+
);
|
24
|
+
});
|
25
|
+
|
26
|
+
export default ShareButton;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
2
|
+
import { useTheme } from 'antd-style';
|
3
|
+
import { Loader2, LucideIcon } from 'lucide-react';
|
4
|
+
import { memo } from 'react';
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
6
|
+
|
7
|
+
const TimeLabel = memo<{
|
8
|
+
date?: string;
|
9
|
+
icon: LucideIcon;
|
10
|
+
title: string;
|
11
|
+
}>(({ date, icon, title }) => {
|
12
|
+
const theme = useTheme();
|
13
|
+
return (
|
14
|
+
<Flexbox
|
15
|
+
align={'center'}
|
16
|
+
gap={4}
|
17
|
+
horizontal
|
18
|
+
style={{
|
19
|
+
color: theme.colorTextDescription,
|
20
|
+
fontSize: 12,
|
21
|
+
}}
|
22
|
+
>
|
23
|
+
<Icon icon={icon} />
|
24
|
+
{title}:{' '}
|
25
|
+
{date ? <span style={{ fontWeight: 'bold' }}>{date}</span> : <Icon icon={Loader2} spin />}
|
26
|
+
</Flexbox>
|
27
|
+
);
|
28
|
+
});
|
29
|
+
|
30
|
+
export default TimeLabel;
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import { BarList } from '@lobehub/charts';
|
2
|
+
import { ActionIcon, FormGroup, Icon, Modal } from '@lobehub/ui';
|
3
|
+
import { useTheme } from 'antd-style';
|
4
|
+
import { MaximizeIcon, MessageSquareIcon } from 'lucide-react';
|
5
|
+
import Link from 'next/link';
|
6
|
+
import { useRouter } from 'next/navigation';
|
7
|
+
import qs from 'query-string';
|
8
|
+
import { memo, useState } from 'react';
|
9
|
+
import { useTranslation } from 'react-i18next';
|
10
|
+
import { Flexbox } from 'react-layout-kit';
|
11
|
+
|
12
|
+
import { FORM_STYLE } from '@/const/layoutTokens';
|
13
|
+
import { useClientDataSWR } from '@/libs/swr';
|
14
|
+
import { topicService } from '@/services/topic';
|
15
|
+
import { TopicRankItem } from '@/types/topic';
|
16
|
+
|
17
|
+
export const TopicsRank = memo(() => {
|
18
|
+
const [open, setOpen] = useState(false);
|
19
|
+
const { t } = useTranslation('auth');
|
20
|
+
const theme = useTheme();
|
21
|
+
const router = useRouter();
|
22
|
+
const { data, isLoading } = useClientDataSWR('rank-topics', async () =>
|
23
|
+
topicService.rankTopics(),
|
24
|
+
);
|
25
|
+
|
26
|
+
const showExtra = Boolean(data && data?.length > 5);
|
27
|
+
|
28
|
+
const mapData = (item: TopicRankItem) => {
|
29
|
+
const link = qs.stringifyUrl({
|
30
|
+
query: {
|
31
|
+
session: item.sessionId,
|
32
|
+
topic: item.id,
|
33
|
+
},
|
34
|
+
url: '/chat',
|
35
|
+
});
|
36
|
+
return {
|
37
|
+
icon: (
|
38
|
+
<Icon color={theme.colorTextDescription} icon={MessageSquareIcon} size={{ fontSize: 16 }} />
|
39
|
+
),
|
40
|
+
link,
|
41
|
+
name: (
|
42
|
+
<Link href={link} style={{ color: 'inherit' }}>
|
43
|
+
{item.title}
|
44
|
+
</Link>
|
45
|
+
),
|
46
|
+
value: item.count,
|
47
|
+
};
|
48
|
+
};
|
49
|
+
|
50
|
+
return (
|
51
|
+
<>
|
52
|
+
<FormGroup
|
53
|
+
extra={
|
54
|
+
showExtra && (
|
55
|
+
<ActionIcon
|
56
|
+
icon={MaximizeIcon}
|
57
|
+
onClick={() => setOpen(true)}
|
58
|
+
size={{ blockSize: 28, fontSize: 20 }}
|
59
|
+
/>
|
60
|
+
)
|
61
|
+
}
|
62
|
+
style={FORM_STYLE.style}
|
63
|
+
title={t('stats.topicsRank.title')}
|
64
|
+
variant={'pure'}
|
65
|
+
>
|
66
|
+
<Flexbox paddingBlock={16}>
|
67
|
+
<BarList
|
68
|
+
data={data?.slice(0, 5).map((item) => mapData(item)) || []}
|
69
|
+
height={220}
|
70
|
+
leftLabel={t('stats.topicsRank.left')}
|
71
|
+
loading={isLoading || !data}
|
72
|
+
noDataText={{
|
73
|
+
desc: t('stats.empty.desc'),
|
74
|
+
title: t('stats.empty.title'),
|
75
|
+
}}
|
76
|
+
onValueChange={(item) => router.push(item.link)}
|
77
|
+
rightLabel={t('stats.topicsRank.right')}
|
78
|
+
/>
|
79
|
+
</Flexbox>
|
80
|
+
</FormGroup>
|
81
|
+
{showExtra && (
|
82
|
+
<Modal
|
83
|
+
footer={null}
|
84
|
+
loading={isLoading || !data}
|
85
|
+
onCancel={() => setOpen(false)}
|
86
|
+
open={open}
|
87
|
+
title={t('stats.topicsRank.title')}
|
88
|
+
>
|
89
|
+
<BarList
|
90
|
+
data={data?.map((item) => mapData(item)) || []}
|
91
|
+
height={340}
|
92
|
+
leftLabel={t('stats.assistantsRank.left')}
|
93
|
+
loading={isLoading || !data}
|
94
|
+
onValueChange={(item) => router.push(item.link)}
|
95
|
+
rightLabel={t('stats.assistantsRank.right')}
|
96
|
+
/>
|
97
|
+
</Modal>
|
98
|
+
)}
|
99
|
+
</>
|
100
|
+
);
|
101
|
+
});
|
102
|
+
|
103
|
+
export default TopicsRank;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { useTheme } from 'antd-style';
|
2
|
+
import { memo } from 'react';
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
|
5
|
+
import Statistic from '@/components/Statistic';
|
6
|
+
import StatisticCard from '@/components/StatisticCard';
|
7
|
+
import TitleWithPercentage from '@/components/StatisticCard/TitleWithPercentage';
|
8
|
+
import { useClientDataSWR } from '@/libs/swr';
|
9
|
+
import { sessionService } from '@/services/session';
|
10
|
+
import { formatIntergerNumber } from '@/utils/format';
|
11
|
+
import { lastMonth } from '@/utils/time';
|
12
|
+
|
13
|
+
import TotalCard from './ShareButton/TotalCard';
|
14
|
+
|
15
|
+
const TotalMessages = memo<{ inShare?: boolean; mobile?: boolean }>(({ mobile, inShare }) => {
|
16
|
+
const { t } = useTranslation('auth');
|
17
|
+
const theme = useTheme();
|
18
|
+
const { data, isLoading } = useClientDataSWR('stats-sessions', async () => ({
|
19
|
+
count: await sessionService.countSessions(),
|
20
|
+
prevCount: await sessionService.countSessions({ endDate: lastMonth().format('YYYY-MM-DD') }),
|
21
|
+
}));
|
22
|
+
|
23
|
+
if (inShare)
|
24
|
+
return (
|
25
|
+
<TotalCard
|
26
|
+
count={formatIntergerNumber(data?.prevCount) || '--'}
|
27
|
+
title={t('stats.assistants')}
|
28
|
+
/>
|
29
|
+
);
|
30
|
+
|
31
|
+
return (
|
32
|
+
<StatisticCard
|
33
|
+
highlight={mobile ? undefined : theme.purple}
|
34
|
+
loading={isLoading || !data}
|
35
|
+
statistic={{
|
36
|
+
description: (
|
37
|
+
<Statistic
|
38
|
+
title={t('date.prevMonth')}
|
39
|
+
value={formatIntergerNumber(data?.prevCount) || '--'}
|
40
|
+
/>
|
41
|
+
),
|
42
|
+
precision: 0,
|
43
|
+
value: data?.count || '--',
|
44
|
+
}}
|
45
|
+
title={
|
46
|
+
<TitleWithPercentage
|
47
|
+
count={data?.count}
|
48
|
+
prvCount={data?.prevCount}
|
49
|
+
title={t('stats.assistants')}
|
50
|
+
/>
|
51
|
+
}
|
52
|
+
/>
|
53
|
+
);
|
54
|
+
});
|
55
|
+
|
56
|
+
export default TotalMessages;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { useTheme } from 'antd-style';
|
2
|
+
import { memo } from 'react';
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
|
5
|
+
import Statistic from '@/components/Statistic';
|
6
|
+
import StatisticCard from '@/components/StatisticCard';
|
7
|
+
import TitleWithPercentage from '@/components/StatisticCard/TitleWithPercentage';
|
8
|
+
import { useClientDataSWR } from '@/libs/swr';
|
9
|
+
import { messageService } from '@/services/message';
|
10
|
+
import { formatIntergerNumber } from '@/utils/format';
|
11
|
+
import { lastMonth } from '@/utils/time';
|
12
|
+
|
13
|
+
import TotalCard from './ShareButton/TotalCard';
|
14
|
+
|
15
|
+
const TotalMessages = memo<{ inShare?: boolean; mobile?: boolean }>(({ inShare, mobile }) => {
|
16
|
+
const { t } = useTranslation('auth');
|
17
|
+
const theme = useTheme();
|
18
|
+
const { data, isLoading } = useClientDataSWR('stats-messages', async () => ({
|
19
|
+
count: await messageService.countMessages(),
|
20
|
+
prevCount: await messageService.countMessages({ endDate: lastMonth().format('YYYY-MM-DD') }),
|
21
|
+
}));
|
22
|
+
|
23
|
+
if (inShare)
|
24
|
+
return (
|
25
|
+
<TotalCard
|
26
|
+
count={formatIntergerNumber(data?.prevCount) || '--'}
|
27
|
+
title={t('stats.messages')}
|
28
|
+
/>
|
29
|
+
);
|
30
|
+
|
31
|
+
return (
|
32
|
+
<StatisticCard
|
33
|
+
highlight={mobile ? undefined : theme.yellow}
|
34
|
+
loading={isLoading || !data}
|
35
|
+
statistic={{
|
36
|
+
description: (
|
37
|
+
<Statistic
|
38
|
+
title={t('date.prevMonth')}
|
39
|
+
value={formatIntergerNumber(data?.prevCount) || '--'}
|
40
|
+
/>
|
41
|
+
),
|
42
|
+
precision: 0,
|
43
|
+
value: data?.count || '--',
|
44
|
+
}}
|
45
|
+
title={
|
46
|
+
<TitleWithPercentage
|
47
|
+
count={data?.count}
|
48
|
+
prvCount={data?.prevCount}
|
49
|
+
title={t('stats.messages')}
|
50
|
+
/>
|
51
|
+
}
|
52
|
+
/>
|
53
|
+
);
|
54
|
+
});
|
55
|
+
|
56
|
+
export default TotalMessages;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { useTheme } from 'antd-style';
|
2
|
+
import { memo } from 'react';
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
|
5
|
+
import Statistic from '@/components/Statistic';
|
6
|
+
import StatisticCard from '@/components/StatisticCard';
|
7
|
+
import TitleWithPercentage from '@/components/StatisticCard/TitleWithPercentage';
|
8
|
+
import { useClientDataSWR } from '@/libs/swr';
|
9
|
+
import { topicService } from '@/services/topic';
|
10
|
+
import { formatIntergerNumber } from '@/utils/format';
|
11
|
+
import { lastMonth } from '@/utils/time';
|
12
|
+
|
13
|
+
import TotalCard from './ShareButton/TotalCard';
|
14
|
+
|
15
|
+
const TotalMessages = memo<{ inShare?: boolean; mobile?: boolean }>(({ inShare, mobile }) => {
|
16
|
+
const { t } = useTranslation('auth');
|
17
|
+
const theme = useTheme();
|
18
|
+
const { data, isLoading } = useClientDataSWR('stats-topics', async () => ({
|
19
|
+
count: await topicService.countTopics(),
|
20
|
+
prevCount: await topicService.countTopics({ endDate: lastMonth().format('YYYY-MM-DD') }),
|
21
|
+
}));
|
22
|
+
|
23
|
+
if (inShare)
|
24
|
+
return (
|
25
|
+
<TotalCard count={formatIntergerNumber(data?.prevCount) || '--'} title={t('stats.topics')} />
|
26
|
+
);
|
27
|
+
|
28
|
+
return (
|
29
|
+
<StatisticCard
|
30
|
+
highlight={mobile ? undefined : theme.gold}
|
31
|
+
loading={isLoading || !data}
|
32
|
+
statistic={{
|
33
|
+
description: (
|
34
|
+
<Statistic
|
35
|
+
title={t('date.prevMonth')}
|
36
|
+
value={formatIntergerNumber(data?.prevCount) || '--'}
|
37
|
+
/>
|
38
|
+
),
|
39
|
+
precision: 0,
|
40
|
+
value: data?.count || '--',
|
41
|
+
}}
|
42
|
+
title={
|
43
|
+
<TitleWithPercentage
|
44
|
+
count={data?.count}
|
45
|
+
prvCount={data?.prevCount}
|
46
|
+
title={t('stats.topics')}
|
47
|
+
/>
|
48
|
+
}
|
49
|
+
/>
|
50
|
+
);
|
51
|
+
});
|
52
|
+
|
53
|
+
export default TotalMessages;
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { memo } from 'react';
|
2
|
+
import { useTranslation } from 'react-i18next';
|
3
|
+
|
4
|
+
import Statistic from '@/components/Statistic';
|
5
|
+
import StatisticCard from '@/components/StatisticCard';
|
6
|
+
import TitleWithPercentage from '@/components/StatisticCard/TitleWithPercentage';
|
7
|
+
import { useClientDataSWR } from '@/libs/swr';
|
8
|
+
import { messageService } from '@/services/message';
|
9
|
+
import { formatShortenNumber } from '@/utils/format';
|
10
|
+
import { lastMonth } from '@/utils/time';
|
11
|
+
|
12
|
+
import TotalCard from './ShareButton/TotalCard';
|
13
|
+
|
14
|
+
const TotalWords = memo<{ inShare?: boolean }>(({ inShare }) => {
|
15
|
+
const { t } = useTranslation('auth');
|
16
|
+
|
17
|
+
const { data, isLoading } = useClientDataSWR('stats-words', async () => ({
|
18
|
+
count: await messageService.countWords(),
|
19
|
+
prevCount: await messageService.countWords({ endDate: lastMonth().format('YYYY-MM-DD') }),
|
20
|
+
}));
|
21
|
+
|
22
|
+
if (inShare)
|
23
|
+
return (
|
24
|
+
<TotalCard count={formatShortenNumber(data?.prevCount) || '--'} title={t('stats.words')} />
|
25
|
+
);
|
26
|
+
|
27
|
+
return (
|
28
|
+
<StatisticCard
|
29
|
+
loading={isLoading || !data}
|
30
|
+
statistic={{
|
31
|
+
description: (
|
32
|
+
<Statistic
|
33
|
+
title={t('date.prevMonth')}
|
34
|
+
value={formatShortenNumber(data?.prevCount) || '--'}
|
35
|
+
/>
|
36
|
+
),
|
37
|
+
precision: 0,
|
38
|
+
style: {
|
39
|
+
fontWeight: 'bold',
|
40
|
+
},
|
41
|
+
value: formatShortenNumber(data?.count) || '--',
|
42
|
+
}}
|
43
|
+
title={
|
44
|
+
<TitleWithPercentage
|
45
|
+
count={data?.count}
|
46
|
+
prvCount={data?.prevCount}
|
47
|
+
title={t('stats.words')}
|
48
|
+
/>
|
49
|
+
}
|
50
|
+
/>
|
51
|
+
);
|
52
|
+
});
|
53
|
+
|
54
|
+
export default TotalWords;
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { FluentEmoji } from '@lobehub/ui';
|
2
|
+
import { Skeleton } from 'antd';
|
3
|
+
import { useTheme } from 'antd-style';
|
4
|
+
import { Clock3Icon, ClockArrowUp } from 'lucide-react';
|
5
|
+
import { memo } from 'react';
|
6
|
+
import { Trans, useTranslation } from 'react-i18next';
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
8
|
+
|
9
|
+
import TimeLabel from '@/app/(main)/profile/stats/features/TimeLabel';
|
10
|
+
import { BRANDING_NAME } from '@/const/branding';
|
11
|
+
import { useClientDataSWR } from '@/libs/swr';
|
12
|
+
import { userService } from '@/services/user';
|
13
|
+
import { useUserStore } from '@/store/user';
|
14
|
+
import { userProfileSelectors } from '@/store/user/slices/auth/selectors';
|
15
|
+
import { formatIntergerNumber } from '@/utils/format';
|
16
|
+
|
17
|
+
const formatEnglishNumber = (number: number) => {
|
18
|
+
if (number === 1) return '1st';
|
19
|
+
if (number === 2) return '2nd';
|
20
|
+
if (number === 3) return '3rd';
|
21
|
+
return `${formatIntergerNumber(number)}th`;
|
22
|
+
};
|
23
|
+
|
24
|
+
const Welcome = memo<{ mobile?: boolean }>(({ mobile }) => {
|
25
|
+
const { t, i18n } = useTranslation('auth');
|
26
|
+
const theme = useTheme();
|
27
|
+
const [nickname, username] = useUserStore((s) => [
|
28
|
+
userProfileSelectors.nickName(s),
|
29
|
+
userProfileSelectors.username(s),
|
30
|
+
]);
|
31
|
+
|
32
|
+
const { data, isLoading } = useClientDataSWR('welcome', async () =>
|
33
|
+
userService.getUserRegistrationDuration(),
|
34
|
+
);
|
35
|
+
|
36
|
+
return (
|
37
|
+
<Flexbox gap={8} padding={mobile ? 16 : 0}>
|
38
|
+
<Flexbox
|
39
|
+
align={'center'}
|
40
|
+
gap={8}
|
41
|
+
horizontal
|
42
|
+
style={{
|
43
|
+
fontSize: mobile ? 16 : 20,
|
44
|
+
fontWeight: 500,
|
45
|
+
}}
|
46
|
+
>
|
47
|
+
<div>
|
48
|
+
<Trans
|
49
|
+
components={{
|
50
|
+
span:
|
51
|
+
isLoading || !data ? (
|
52
|
+
<Skeleton.Button active style={{ height: 24 }} />
|
53
|
+
) : (
|
54
|
+
<span style={{ fontWeight: 'bold' }} />
|
55
|
+
),
|
56
|
+
}}
|
57
|
+
i18nKey="stats.welcome"
|
58
|
+
ns={'auth'}
|
59
|
+
values={{
|
60
|
+
appName: BRANDING_NAME,
|
61
|
+
days:
|
62
|
+
i18n.language === 'en-US'
|
63
|
+
? formatEnglishNumber(Number(data?.duration || 1))
|
64
|
+
: formatIntergerNumber(Number(data?.duration || 1)),
|
65
|
+
username: nickname || username,
|
66
|
+
}}
|
67
|
+
/>
|
68
|
+
</div>
|
69
|
+
{!mobile && <FluentEmoji emoji={'🫶'} size={32} type={'anim'} />}
|
70
|
+
</Flexbox>
|
71
|
+
<Flexbox
|
72
|
+
gap={16}
|
73
|
+
horizontal
|
74
|
+
style={{
|
75
|
+
color: theme.colorTextDescription,
|
76
|
+
}}
|
77
|
+
wrap={'wrap'}
|
78
|
+
>
|
79
|
+
<TimeLabel date={data?.createdAt} icon={Clock3Icon} title={t('stats.createdAt')} />
|
80
|
+
<TimeLabel date={data?.updatedAt} icon={ClockArrowUp} title={t('stats.updatedAt')} />
|
81
|
+
</Flexbox>
|
82
|
+
</Flexbox>
|
83
|
+
);
|
84
|
+
});
|
85
|
+
|
86
|
+
export default Welcome;
|
@@ -5,17 +5,16 @@ import { isMobileDevice } from '@/utils/server/responsive';
|
|
5
5
|
import Client from './Client';
|
6
6
|
|
7
7
|
export const generateMetadata = async () => {
|
8
|
-
const { t } = await translation('
|
8
|
+
const { t } = await translation('auth');
|
9
9
|
return metadataModule.generate({
|
10
|
-
description: t('
|
11
|
-
title: t('
|
12
|
-
url: '/profile',
|
10
|
+
description: t('header.desc'),
|
11
|
+
title: t('tab.stats'),
|
12
|
+
url: '/profile/stats',
|
13
13
|
});
|
14
14
|
};
|
15
15
|
|
16
16
|
const Page = async () => {
|
17
17
|
const mobile = await isMobileDevice();
|
18
|
-
|
19
18
|
return <Client mobile={mobile} />;
|
20
19
|
};
|
21
20
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { createStyles } from 'antd-style';
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
5
5
|
|
6
|
-
import
|
6
|
+
import Loading from '@/components/Loading/BrandTextLoading';
|
7
7
|
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
8
8
|
|
9
9
|
import DatasetDetail from './DatasetDetail';
|
@@ -34,7 +34,7 @@ const Dataset = ({ params }: Props) => {
|
|
34
34
|
const isEmpty = data?.length === 0;
|
35
35
|
|
36
36
|
return isLoading ? (
|
37
|
-
<
|
37
|
+
<Loading />
|
38
38
|
) : isEmpty ? (
|
39
39
|
<EmptyGuide knowledgeBaseId={knowledgeBaseId} />
|
40
40
|
) : (
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { Flexbox } from 'react-layout-kit';
|
4
4
|
|
5
|
-
import
|
5
|
+
import Loading from '@/components/Loading/BrandTextLoading';
|
6
6
|
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
7
7
|
|
8
8
|
import EmptyGuide from './EmptyGuide';
|
@@ -24,7 +24,7 @@ const Evaluation = ({ params }: Props) => {
|
|
24
24
|
const isEmpty = data?.length === 0;
|
25
25
|
|
26
26
|
return isLoading ? (
|
27
|
-
<
|
27
|
+
<Loading />
|
28
28
|
) : isEmpty ? (
|
29
29
|
<EmptyGuide knowledgeBaseId={knowledgeBaseId} />
|
30
30
|
) : (
|
@@ -4,7 +4,7 @@ import { memo } from 'react';
|
|
4
4
|
import urlJoin from 'url-join';
|
5
5
|
|
6
6
|
import Menu from '@/components/Menu';
|
7
|
-
import { useActiveSettingsKey } from '@/hooks/
|
7
|
+
import { useActiveSettingsKey } from '@/hooks/useActiveTabKey';
|
8
8
|
import { useQuery } from '@/hooks/useQuery';
|
9
9
|
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
10
10
|
import { SettingsTabs } from '@/store/global/initialState';
|
@@ -9,7 +9,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
import InitClientDB from '@/features/InitClientDB';
|
10
10
|
import Footer from '@/features/Setting/Footer';
|
11
11
|
import SettingContainer from '@/features/Setting/SettingContainer';
|
12
|
-
import { useActiveSettingsKey } from '@/hooks/
|
12
|
+
import { useActiveSettingsKey } from '@/hooks/useActiveTabKey';
|
13
13
|
import { SettingsTabs } from '@/store/global/initialState';
|
14
14
|
|
15
15
|
import { LayoutProps } from '../type';
|
@@ -7,7 +7,7 @@ import { memo } from 'react';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
8
8
|
import { Flexbox } from 'react-layout-kit';
|
9
9
|
|
10
|
-
import { useActiveSettingsKey } from '@/hooks/
|
10
|
+
import { useActiveSettingsKey } from '@/hooks/useActiveTabKey';
|
11
11
|
import { SettingsTabs } from '@/store/global/initialState';
|
12
12
|
import { useUserStore } from '@/store/user';
|
13
13
|
import { authSelectors } from '@/store/user/selectors';
|