@lobehub/chat 1.116.2 → 1.116.4
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/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- package/.github/workflows/release.yml +2 -0
- package/.i18nrc.js +1 -1
- package/CHANGELOG.md +50 -0
- package/apps/desktop/package.json +1 -1
- package/changelog/v1.json +18 -0
- package/locales/ar/components.json +12 -0
- package/locales/bg-BG/components.json +12 -0
- package/locales/de-DE/components.json +12 -0
- package/locales/en-US/components.json +12 -0
- package/locales/es-ES/components.json +12 -0
- package/locales/fa-IR/components.json +12 -0
- package/locales/fr-FR/components.json +12 -0
- package/locales/it-IT/components.json +12 -0
- package/locales/ja-JP/components.json +12 -0
- package/locales/ko-KR/components.json +12 -0
- package/locales/nl-NL/components.json +12 -0
- package/locales/pl-PL/components.json +12 -0
- package/locales/pt-BR/components.json +12 -0
- package/locales/ru-RU/components.json +12 -0
- package/locales/tr-TR/components.json +12 -0
- package/locales/vi-VN/components.json +12 -0
- package/locales/zh-CN/components.json +12 -0
- package/locales/zh-TW/components.json +12 -0
- package/package.json +5 -5
- package/packages/const/src/index.ts +2 -1
- package/packages/const/src/meta.ts +3 -2
- package/packages/const/src/settings/agent.ts +9 -4
- package/packages/const/src/settings/systemAgent.ts +0 -3
- package/packages/file-loaders/vitest.config.mts +3 -7
- package/packages/model-runtime/vitest.config.mts +3 -0
- package/packages/prompts/package.json +0 -1
- package/packages/prompts/src/chains/__tests__/abstractChunk.test.ts +52 -0
- package/packages/prompts/src/chains/__tests__/answerWithContext.test.ts +100 -0
- package/packages/prompts/src/chains/__tests__/rewriteQuery.test.ts +88 -0
- package/packages/prompts/src/chains/__tests__/summaryGenerationTitle.test.ts +107 -0
- package/packages/prompts/src/chains/abstractChunk.ts +0 -2
- package/packages/prompts/src/chains/rewriteQuery.ts +3 -1
- package/packages/prompts/src/index.test.ts +41 -0
- package/packages/prompts/src/prompts/systemRole/index.test.ts +136 -0
- package/packages/prompts/vitest.config.mts +3 -0
- package/packages/types/src/index.ts +2 -0
- package/packages/utils/package.json +5 -1
- package/packages/utils/src/client/index.ts +2 -0
- package/packages/utils/src/server/index.ts +5 -0
- package/packages/utils/vitest.config.mts +3 -0
- package/src/app/(backend)/middleware/auth/index.test.ts +2 -2
- package/src/app/(backend)/middleware/auth/index.ts +1 -1
- package/src/app/(backend)/oidc/consent/route.ts +1 -2
- package/src/app/(backend)/trpc/desktop/[trpc]/route.ts +26 -0
- package/src/app/(backend)/trpc/trpc.test.ts +10 -0
- package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +2 -2
- package/src/app/(backend)/webapi/plugin/gateway/route.ts +1 -1
- package/src/app/[variants]/(main)/files/[id]/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/sync/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +2 -1
- package/src/app/desktop/devtools/page.tsx +89 -0
- package/src/app/desktop/layout.tsx +31 -0
- package/src/components/HtmlPreview/HtmlPreviewAction.tsx +32 -0
- package/src/components/HtmlPreview/PreviewDrawer.tsx +133 -0
- package/src/components/HtmlPreview/index.ts +2 -0
- package/src/features/Conversation/components/ChatItem/ShareMessageModal/ShareText/index.tsx +1 -1
- package/src/features/Conversation/components/ChatItem/index.tsx +23 -0
- package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
- package/src/features/ShareModal/ShareText/index.tsx +1 -1
- package/src/libs/oidc-provider/adapter.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.ts +1 -2
- package/src/libs/trpc/lambda/middleware/keyVaults.ts +1 -2
- package/src/locales/default/components.ts +12 -0
- package/src/middleware.ts +3 -3
- package/src/server/routers/tools/search.test.ts +1 -1
- package/src/services/config.ts +2 -4
- package/src/utils/client/switchLang.ts +1 -1
- package/{packages/utils/src → src/utils}/server/pageProps.ts +2 -1
- package/tsconfig.json +1 -1
- package/vitest.config.mts +1 -0
- /package/{packages/const/src → src/const}/locale.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.test.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.ts +0 -0
- /package/{packages/utils/src → src/utils}/server/routeVariants.ts +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import { AgentRuntimeError } from '@lobechat/model-runtime';
|
2
2
|
import { ChatErrorType, ErrorType, TraceNameMap } from '@lobechat/types';
|
3
|
+
import { getXorPayload } from '@lobechat/utils/server';
|
3
4
|
import { PluginRequestPayload } from '@lobehub/chat-plugin-sdk';
|
4
5
|
import { createGatewayOnEdgeRuntime } from '@lobehub/chat-plugins-gateway';
|
5
6
|
|
@@ -8,7 +9,6 @@ import { LOBE_CHAT_TRACE_ID } from '@/const/trace';
|
|
8
9
|
import { getAppConfig } from '@/envs/app';
|
9
10
|
import { TraceClient } from '@/libs/traces';
|
10
11
|
import { createErrorResponse } from '@/utils/errorResponse';
|
11
|
-
import { getXorPayload } from '@/utils/server/xor';
|
12
12
|
import { getTracePayload } from '@/utils/trace';
|
13
13
|
|
14
14
|
import { parserPluginSettings } from './settings';
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getUserAuth } from '@lobechat/utils/server';
|
1
2
|
import { notFound } from 'next/navigation';
|
2
3
|
import { Flexbox } from 'react-layout-kit';
|
3
4
|
|
@@ -5,7 +6,6 @@ import FileViewer from '@/features/FileViewer';
|
|
5
6
|
import { createCallerFactory } from '@/libs/trpc/lambda';
|
6
7
|
import { lambdaRouter } from '@/server/routers/lambda';
|
7
8
|
import { PagePropsWithId } from '@/types/next';
|
8
|
-
import { getUserAuth } from '@/utils/server/auth';
|
9
9
|
|
10
10
|
import FileDetail from '../features/FileDetail';
|
11
11
|
import Header from './Header';
|
@@ -1,10 +1,10 @@
|
|
1
|
+
import { gerServerDeviceInfo } from '@lobechat/utils/server';
|
1
2
|
import { notFound } from 'next/navigation';
|
2
3
|
|
3
4
|
import { serverFeatureFlags } from '@/config/featureFlags';
|
4
5
|
import { metadataModule } from '@/server/metadata';
|
5
6
|
import { translation } from '@/server/translation';
|
6
7
|
import { DynamicLayoutProps } from '@/types/next';
|
7
|
-
import { gerServerDeviceInfo } from '@/utils/server/responsive';
|
8
8
|
import { RouteVariants } from '@/utils/server/routeVariants';
|
9
9
|
|
10
10
|
import Page from './index';
|
@@ -1,6 +1,7 @@
|
|
1
1
|
'use client';
|
2
2
|
|
3
|
-
import { DEFAULT_REWRITE_QUERY } from '
|
3
|
+
import { DEFAULT_REWRITE_QUERY } from '@lobechat/prompts';
|
4
|
+
|
4
5
|
import { isServerMode } from '@/const/version';
|
5
6
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
6
7
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { ActionIcon, SideNav } from '@lobehub/ui';
|
4
|
+
import { Cog, DatabaseIcon } from 'lucide-react';
|
5
|
+
import { memo, useState } from 'react';
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
7
|
+
|
8
|
+
import { BRANDING_NAME } from '@/const/branding';
|
9
|
+
import PostgresViewer from '@/features/DevPanel/PostgresViewer';
|
10
|
+
import SystemInspector from '@/features/DevPanel/SystemInspector';
|
11
|
+
import { useStyles } from '@/features/DevPanel/features/FloatPanel';
|
12
|
+
import { electronStylish } from '@/styles/electron';
|
13
|
+
|
14
|
+
const DevTools = memo(() => {
|
15
|
+
const { styles, theme, cx } = useStyles();
|
16
|
+
|
17
|
+
const items = [
|
18
|
+
{
|
19
|
+
children: <PostgresViewer />,
|
20
|
+
icon: <DatabaseIcon size={16} />,
|
21
|
+
key: 'Postgres Viewer',
|
22
|
+
},
|
23
|
+
{
|
24
|
+
children: <SystemInspector />,
|
25
|
+
icon: <Cog size={16} />,
|
26
|
+
key: 'System Status',
|
27
|
+
},
|
28
|
+
];
|
29
|
+
|
30
|
+
const [tab, setTab] = useState<string>(items[0].key);
|
31
|
+
|
32
|
+
return (
|
33
|
+
<Flexbox height={'100%'} style={{ overflow: 'hidden', position: 'relative' }} width={'100%'}>
|
34
|
+
<Flexbox
|
35
|
+
align={'center'}
|
36
|
+
className={cx(`panel-drag-handle`, styles.header, electronStylish.draggable)}
|
37
|
+
horizontal
|
38
|
+
justify={'center'}
|
39
|
+
>
|
40
|
+
<Flexbox align={'baseline'} gap={6} horizontal>
|
41
|
+
<b>{BRANDING_NAME} Dev Tools</b>
|
42
|
+
<span style={{ color: theme.colorTextDescription }}>/</span>
|
43
|
+
<span style={{ color: theme.colorTextDescription }}>{tab}</span>
|
44
|
+
</Flexbox>
|
45
|
+
</Flexbox>
|
46
|
+
<Flexbox
|
47
|
+
height={'100%'}
|
48
|
+
horizontal
|
49
|
+
style={{ background: theme.colorBgLayout, overflow: 'hidden', position: 'relative' }}
|
50
|
+
width={'100%'}
|
51
|
+
>
|
52
|
+
<SideNav
|
53
|
+
bottomActions={[]}
|
54
|
+
style={{
|
55
|
+
background: 'transparent',
|
56
|
+
width: 48,
|
57
|
+
}}
|
58
|
+
topActions={items.map((item) => (
|
59
|
+
<ActionIcon
|
60
|
+
active={tab === item.key}
|
61
|
+
icon={item.icon}
|
62
|
+
key={item.key}
|
63
|
+
onClick={() => setTab(item.key)}
|
64
|
+
title={item.key}
|
65
|
+
tooltipProps={{
|
66
|
+
placement: 'right',
|
67
|
+
}}
|
68
|
+
/>
|
69
|
+
))}
|
70
|
+
/>
|
71
|
+
{items.map((item) => (
|
72
|
+
<Flexbox
|
73
|
+
flex={1}
|
74
|
+
height={'100%'}
|
75
|
+
key={item.key}
|
76
|
+
style={{
|
77
|
+
display: tab === item.key ? 'flex' : 'none',
|
78
|
+
overflow: 'hidden',
|
79
|
+
}}
|
80
|
+
>
|
81
|
+
{item.children}
|
82
|
+
</Flexbox>
|
83
|
+
))}
|
84
|
+
</Flexbox>
|
85
|
+
</Flexbox>
|
86
|
+
);
|
87
|
+
});
|
88
|
+
|
89
|
+
export default DevTools;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { notFound } from 'next/navigation';
|
2
|
+
import { NuqsAdapter } from 'nuqs/adapters/next/app';
|
3
|
+
import { ReactNode } from 'react';
|
4
|
+
|
5
|
+
import { isDesktop } from '@/const/version';
|
6
|
+
import GlobalLayout from '@/layout/GlobalProvider';
|
7
|
+
import { ServerConfigStoreProvider } from '@/store/serverConfig/Provider';
|
8
|
+
|
9
|
+
interface RootLayoutProps {
|
10
|
+
children: ReactNode;
|
11
|
+
}
|
12
|
+
|
13
|
+
const RootLayout = async ({ children }: RootLayoutProps) => {
|
14
|
+
if (!isDesktop) return notFound();
|
15
|
+
|
16
|
+
return (
|
17
|
+
<html dir="ltr" suppressHydrationWarning>
|
18
|
+
<body>
|
19
|
+
<NuqsAdapter>
|
20
|
+
<ServerConfigStoreProvider>
|
21
|
+
<GlobalLayout appearance={'auto'} isMobile={false} locale={''}>
|
22
|
+
{children}
|
23
|
+
</GlobalLayout>
|
24
|
+
</ServerConfigStoreProvider>
|
25
|
+
</NuqsAdapter>
|
26
|
+
</body>
|
27
|
+
</html>
|
28
|
+
);
|
29
|
+
};
|
30
|
+
|
31
|
+
export default RootLayout;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { ActionIcon } from '@lobehub/ui';
|
2
|
+
import { Eye } from 'lucide-react';
|
3
|
+
import { memo, useState } from 'react';
|
4
|
+
import { useTranslation } from 'react-i18next';
|
5
|
+
|
6
|
+
import HtmlPreviewDrawer from './PreviewDrawer';
|
7
|
+
|
8
|
+
interface HtmlPreviewActionProps {
|
9
|
+
content: string;
|
10
|
+
size?: number;
|
11
|
+
}
|
12
|
+
|
13
|
+
const HtmlPreviewAction = memo<HtmlPreviewActionProps>(({ content, size }) => {
|
14
|
+
const { t } = useTranslation('components');
|
15
|
+
const [open, setOpen] = useState(false);
|
16
|
+
|
17
|
+
return (
|
18
|
+
<>
|
19
|
+
<ActionIcon
|
20
|
+
icon={Eye}
|
21
|
+
onClick={() => setOpen(true)}
|
22
|
+
size={size}
|
23
|
+
title={t('HtmlPreview.actions.preview')}
|
24
|
+
/>
|
25
|
+
<HtmlPreviewDrawer content={content} onClose={() => setOpen(false)} open={open} />
|
26
|
+
</>
|
27
|
+
);
|
28
|
+
});
|
29
|
+
|
30
|
+
HtmlPreviewAction.displayName = 'HtmlPreviewAction';
|
31
|
+
|
32
|
+
export default HtmlPreviewAction;
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import { exportFile } from '@lobechat/utils/client';
|
2
|
+
import { Block, Button, Highlighter, Segmented } from '@lobehub/ui';
|
3
|
+
import { Drawer } from 'antd';
|
4
|
+
import { createStyles } from 'antd-style';
|
5
|
+
import { Code2, Download, Eye } from 'lucide-react';
|
6
|
+
import { memo, useCallback, useState } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
|
10
|
+
import { isDesktop } from '@/const/version';
|
11
|
+
import { TITLE_BAR_HEIGHT } from '@/features/ElectronTitlebar';
|
12
|
+
|
13
|
+
const useStyles = createStyles(({ css }) => ({
|
14
|
+
container: css`
|
15
|
+
height: 100%;
|
16
|
+
`,
|
17
|
+
iframe: css`
|
18
|
+
width: 100%;
|
19
|
+
height: 100%;
|
20
|
+
border: none;
|
21
|
+
`,
|
22
|
+
}));
|
23
|
+
|
24
|
+
interface HtmlPreviewDrawerProps {
|
25
|
+
content: string;
|
26
|
+
onClose: () => void;
|
27
|
+
open: boolean;
|
28
|
+
}
|
29
|
+
|
30
|
+
const HtmlPreviewDrawer = memo<HtmlPreviewDrawerProps>(({ content, open, onClose }) => {
|
31
|
+
const { styles } = useStyles();
|
32
|
+
const { t } = useTranslation('components');
|
33
|
+
const [mode, setMode] = useState<'preview' | 'code'>('preview');
|
34
|
+
|
35
|
+
const htmlContent = content;
|
36
|
+
|
37
|
+
const extractTitle = useCallback(() => {
|
38
|
+
const m = htmlContent.match(/<title>([\S\s]*?)<\/title>/i);
|
39
|
+
return m ? m[1].trim() : undefined;
|
40
|
+
}, [htmlContent]);
|
41
|
+
|
42
|
+
const sanitizeFileName = useCallback((name: string) => {
|
43
|
+
return name
|
44
|
+
.replaceAll(/["*/:<>?\\|]/g, '-')
|
45
|
+
.replaceAll(/\s+/g, ' ')
|
46
|
+
.trim()
|
47
|
+
.slice(0, 100);
|
48
|
+
}, []);
|
49
|
+
|
50
|
+
const onDownload = useCallback(() => {
|
51
|
+
const title = extractTitle();
|
52
|
+
const base = title ? sanitizeFileName(title) : `chat-html-preview-${Date.now()}`;
|
53
|
+
exportFile(content, `${base}.html`);
|
54
|
+
}, [content, extractTitle, sanitizeFileName]);
|
55
|
+
|
56
|
+
const Title = (
|
57
|
+
<Flexbox align={'center'} horizontal justify={'space-between'} style={{ width: '100%' }}>
|
58
|
+
{t('HtmlPreview.title')}
|
59
|
+
<Segmented
|
60
|
+
onChange={(v) => setMode(v as 'preview' | 'code')}
|
61
|
+
options={[
|
62
|
+
{
|
63
|
+
label: (
|
64
|
+
<Flexbox align={'center'} gap={6} horizontal>
|
65
|
+
<Eye size={16} />
|
66
|
+
{t('HtmlPreview.mode.preview')}
|
67
|
+
</Flexbox>
|
68
|
+
),
|
69
|
+
value: 'preview',
|
70
|
+
},
|
71
|
+
{
|
72
|
+
label: (
|
73
|
+
<Flexbox align={'center'} gap={6} horizontal>
|
74
|
+
<Code2 size={16} />
|
75
|
+
{t('HtmlPreview.mode.code')}
|
76
|
+
</Flexbox>
|
77
|
+
),
|
78
|
+
value: 'code',
|
79
|
+
},
|
80
|
+
]}
|
81
|
+
value={mode}
|
82
|
+
/>
|
83
|
+
<Button
|
84
|
+
color={'default'}
|
85
|
+
icon={<Download size={16} />}
|
86
|
+
onClick={onDownload}
|
87
|
+
variant={'filled'}
|
88
|
+
>
|
89
|
+
{t('HtmlPreview.actions.download')}
|
90
|
+
</Button>
|
91
|
+
</Flexbox>
|
92
|
+
);
|
93
|
+
|
94
|
+
return (
|
95
|
+
<Drawer
|
96
|
+
destroyOnHidden
|
97
|
+
height={isDesktop ? `calc(100vh - ${TITLE_BAR_HEIGHT}px)` : '100vh'}
|
98
|
+
onClose={onClose}
|
99
|
+
open={open}
|
100
|
+
placement="bottom"
|
101
|
+
styles={{
|
102
|
+
body: { height: '100%', padding: 0 },
|
103
|
+
header: { paddingBlock: 8, paddingInline: 12 },
|
104
|
+
}}
|
105
|
+
title={Title}
|
106
|
+
>
|
107
|
+
{mode === 'preview' ? (
|
108
|
+
<Block className={styles.container}>
|
109
|
+
<iframe
|
110
|
+
className={styles.iframe}
|
111
|
+
sandbox="allow-scripts allow-same-origin"
|
112
|
+
srcDoc={content}
|
113
|
+
title={t('HtmlPreview.iframeTitle')}
|
114
|
+
/>
|
115
|
+
</Block>
|
116
|
+
) : (
|
117
|
+
<Block className={styles.container}>
|
118
|
+
<Highlighter
|
119
|
+
language={'html'}
|
120
|
+
showLanguage={false}
|
121
|
+
style={{ height: '100%', overflow: 'auto' }}
|
122
|
+
>
|
123
|
+
{htmlContent}
|
124
|
+
</Highlighter>
|
125
|
+
</Block>
|
126
|
+
)}
|
127
|
+
</Drawer>
|
128
|
+
);
|
129
|
+
});
|
130
|
+
|
131
|
+
HtmlPreviewDrawer.displayName = 'HtmlPreviewDrawer';
|
132
|
+
|
133
|
+
export default HtmlPreviewDrawer;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { exportFile } from '@lobechat/utils/client';
|
1
2
|
import { Button, copyToClipboard } from '@lobehub/ui';
|
2
3
|
import { App } from 'antd';
|
3
4
|
import isEqual from 'fast-deep-equal';
|
@@ -10,7 +11,6 @@ import { useIsMobile } from '@/hooks/useIsMobile';
|
|
10
11
|
import { useChatStore } from '@/store/chat';
|
11
12
|
import { topicSelectors } from '@/store/chat/selectors';
|
12
13
|
import { ChatMessage } from '@/types/message';
|
13
|
-
import { exportFile } from '@/utils/client/exportFile';
|
14
14
|
|
15
15
|
import { useStyles } from '../style';
|
16
16
|
import Preview from './Preview';
|
@@ -6,6 +6,7 @@ import { MouseEventHandler, ReactNode, memo, use, useCallback, useMemo } from 'r
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
8
8
|
|
9
|
+
import { HtmlPreviewAction } from '@/components/HtmlPreview';
|
9
10
|
import { isDesktop } from '@/const/version';
|
10
11
|
import ChatItem from '@/features/ChatItem';
|
11
12
|
import { VirtuosoContext } from '@/features/Conversation/components/VirtualizedList/VirtuosoContext';
|
@@ -33,6 +34,14 @@ import { normalizeThinkTags, processWithArtifact } from './utils';
|
|
33
34
|
const rehypePlugins = markdownElements.map((element) => element.rehypePlugin).filter(Boolean);
|
34
35
|
const remarkPlugins = markdownElements.map((element) => element.remarkPlugin).filter(Boolean);
|
35
36
|
|
37
|
+
const isHtmlCode = (content: string, language: string) => {
|
38
|
+
return (
|
39
|
+
language === 'html' ||
|
40
|
+
(language === '' && content.includes('<html>')) ||
|
41
|
+
(language === '' && content.includes('<!DOCTYPE html>'))
|
42
|
+
);
|
43
|
+
};
|
44
|
+
|
36
45
|
const useStyles = createStyles(({ css, prefixCls }) => ({
|
37
46
|
loading: css`
|
38
47
|
opacity: 0.6;
|
@@ -175,6 +184,20 @@ const Item = memo<ChatListItemProps>(
|
|
175
184
|
() => ({
|
176
185
|
animated,
|
177
186
|
citations: item?.role === 'user' ? undefined : item?.search?.citations,
|
187
|
+
componentProps: {
|
188
|
+
highlight: {
|
189
|
+
actionsRender: ({ content, actionIconSize, language, originalNode }: any) => {
|
190
|
+
const showHtmlPreview = isHtmlCode(content, language);
|
191
|
+
|
192
|
+
return (
|
193
|
+
<>
|
194
|
+
{showHtmlPreview && <HtmlPreviewAction content={content} size={actionIconSize} />}
|
195
|
+
{originalNode}
|
196
|
+
</>
|
197
|
+
);
|
198
|
+
},
|
199
|
+
},
|
200
|
+
},
|
178
201
|
components,
|
179
202
|
customRender: markdownCustomRender,
|
180
203
|
enableCustomFootnotes: item?.role === 'assistant',
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { FORM_STYLE } from '@lobechat/const';
|
2
|
+
import { exportFile } from '@lobechat/utils/client';
|
1
3
|
import { Button, Form, type FormItemProps, copyToClipboard } from '@lobehub/ui';
|
2
4
|
import { App, Switch } from 'antd';
|
3
5
|
import isEqual from 'fast-deep-equal';
|
@@ -6,13 +8,11 @@ import { memo, useState } from 'react';
|
|
6
8
|
import { useTranslation } from 'react-i18next';
|
7
9
|
import { Flexbox } from 'react-layout-kit';
|
8
10
|
|
9
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
10
11
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
11
12
|
import { useAgentStore } from '@/store/agent';
|
12
13
|
import { agentSelectors } from '@/store/agent/selectors';
|
13
14
|
import { useChatStore } from '@/store/chat';
|
14
15
|
import { chatSelectors, topicSelectors } from '@/store/chat/selectors';
|
15
|
-
import { exportFile } from '@/utils/client/exportFile';
|
16
16
|
|
17
17
|
import { useStyles } from '../style';
|
18
18
|
import Preview from './Preview';
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { exportFile } from '@lobechat/utils/client';
|
1
2
|
import { Button, Form, type FormItemProps, copyToClipboard } from '@lobehub/ui';
|
2
3
|
import { App, Switch } from 'antd';
|
3
4
|
import isEqual from 'fast-deep-equal';
|
@@ -12,7 +13,6 @@ import { useAgentStore } from '@/store/agent';
|
|
12
13
|
import { agentSelectors } from '@/store/agent/selectors';
|
13
14
|
import { useChatStore } from '@/store/chat';
|
14
15
|
import { chatSelectors, topicSelectors } from '@/store/chat/selectors';
|
15
|
-
import { exportFile } from '@/utils/client/exportFile';
|
16
16
|
|
17
17
|
import { useStyles } from '../style';
|
18
18
|
import Preview from './Preview';
|
@@ -164,7 +164,7 @@ class OIDCAdapter {
|
|
164
164
|
log('[%s] Setting userId: %s', this.name, payload.accountId);
|
165
165
|
} else {
|
166
166
|
try {
|
167
|
-
const { getUserAuth } = await import('
|
167
|
+
const { getUserAuth } = await import('@lobechat/utils/server');
|
168
168
|
try {
|
169
169
|
const { userId } = await getUserAuth();
|
170
170
|
if (userId) {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// @vitest-environment node
|
2
|
+
import * as utils from '@lobechat/utils/server';
|
2
3
|
import { TRPCError } from '@trpc/server';
|
3
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
4
5
|
|
5
6
|
import { createCallerFactory } from '@/libs/trpc/edge';
|
6
7
|
import { AuthContext, createContextInner } from '@/libs/trpc/edge/context';
|
7
8
|
import { edgeTrpc as trpc } from '@/libs/trpc/edge/init';
|
8
|
-
import * as utils from '@/utils/server/xor';
|
9
9
|
|
10
10
|
import { jwtPayloadChecker } from './jwtPayload';
|
11
11
|
|
@@ -1,7 +1,6 @@
|
|
1
|
+
import { getXorPayload } from '@lobechat/utils/server';
|
1
2
|
import { TRPCError } from '@trpc/server';
|
2
3
|
|
3
|
-
import { getXorPayload } from '@/utils/server/xor';
|
4
|
-
|
5
4
|
import { edgeTrpc } from '../init';
|
6
5
|
|
7
6
|
export const jwtPayloadChecker = edgeTrpc.middleware(async (opts) => {
|
@@ -75,6 +75,18 @@ export default {
|
|
75
75
|
GoBack: {
|
76
76
|
back: '返回',
|
77
77
|
},
|
78
|
+
HtmlPreview: {
|
79
|
+
actions: {
|
80
|
+
download: '下载',
|
81
|
+
preview: '预览',
|
82
|
+
},
|
83
|
+
iframeTitle: 'HTML 预览',
|
84
|
+
mode: {
|
85
|
+
code: '代码',
|
86
|
+
preview: '预览',
|
87
|
+
},
|
88
|
+
title: 'HTML 预览',
|
89
|
+
},
|
78
90
|
ImageUpload: {
|
79
91
|
actions: {
|
80
92
|
changeImage: '点击更换图片',
|
package/src/middleware.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
|
2
|
+
import { parseDefaultThemeFromCountry } from '@lobechat/utils/server';
|
2
3
|
import debug from 'debug';
|
3
4
|
import { NextRequest, NextResponse } from 'next/server';
|
4
5
|
import { UAParser } from 'ua-parser-js';
|
@@ -11,11 +12,10 @@ import { LOBE_THEME_APPEARANCE } from '@/const/theme';
|
|
11
12
|
import { appEnv } from '@/envs/app';
|
12
13
|
import NextAuthEdge from '@/libs/next-auth/edge';
|
13
14
|
import { Locales } from '@/locales/resources';
|
14
|
-
import { parseBrowserLanguage } from '@/utils/locale';
|
15
|
-
import { parseDefaultThemeFromCountry } from '@/utils/server/geo';
|
16
|
-
import { RouteVariants } from '@/utils/server/routeVariants';
|
17
15
|
|
18
16
|
import { oidcEnv } from './envs/oidc';
|
17
|
+
import { parseBrowserLanguage } from './utils/locale';
|
18
|
+
import { RouteVariants } from './utils/server/routeVariants';
|
19
19
|
|
20
20
|
// Create debug logger instances
|
21
21
|
const logDefault = debug('middleware:default');
|
@@ -9,7 +9,7 @@ import { SEARCH_SEARXNG_NOT_CONFIG } from '@/types/tool/search';
|
|
9
9
|
import { searchRouter } from './search';
|
10
10
|
|
11
11
|
// Mock JWT verification
|
12
|
-
vi.mock('
|
12
|
+
vi.mock('@lobechat/utils/server', () => ({
|
13
13
|
getXorPayload: vi.fn().mockReturnValue({ userId: '1' }),
|
14
14
|
}));
|
15
15
|
|
package/src/services/config.ts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
+
import { BRANDING_NAME, isDeprecatedEdition, isServerMode } from '@lobechat/const';
|
2
|
+
import { downloadFile, exportJSONFile } from '@lobechat/utils/client';
|
1
3
|
import dayjs from 'dayjs';
|
2
4
|
|
3
|
-
import { BRANDING_NAME } from '@/const/branding';
|
4
|
-
import { isDeprecatedEdition, isServerMode } from '@/const/version';
|
5
5
|
import { CURRENT_CONFIG_VERSION } from '@/migrations';
|
6
6
|
import { ImportPgDataStructure } from '@/types/export';
|
7
|
-
import { downloadFile } from '@/utils/client/downloadFile';
|
8
|
-
import { exportJSONFile } from '@/utils/client/exportFile';
|
9
7
|
|
10
8
|
import { exportService } from './export';
|
11
9
|
import { configService as deprecatedExportService } from './export/_deprecated';
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { LOBE_LOCALE_COOKIE } from '@lobechat/const';
|
2
1
|
import { setCookie } from '@lobechat/utils';
|
3
2
|
import { changeLanguage } from 'i18next';
|
4
3
|
|
4
|
+
import { LOBE_LOCALE_COOKIE } from '@/const/locale';
|
5
5
|
import { LocaleMode } from '@/types/locale';
|
6
6
|
|
7
7
|
export const switchLang = (locale: LocaleMode) => {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { translation } from '@/server/translation';
|
2
2
|
import { DynamicLayoutProps } from '@/types/next';
|
3
|
-
|
3
|
+
|
4
|
+
import { RouteVariants } from './routeVariants';
|
4
5
|
|
5
6
|
export const parsePageMetaProps = async (props: DynamicLayoutProps) => {
|
6
7
|
const { locale: hl, isMobile } = await RouteVariants.getVariantsFromProps(props);
|
package/tsconfig.json
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
"@/libs/model-runtime": ["./packages/model-runtime/src/index.ts"],
|
22
22
|
"@/libs/model-runtime/*": ["./packages/model-runtime/src/*"],
|
23
23
|
"@/database/*": ["./packages/database/src/*", "./src/database/*"],
|
24
|
-
"@/const/*": ["./packages/const/src/*"],
|
24
|
+
"@/const/*": ["./packages/const/src/*", "./src/const/*"],
|
25
25
|
"@/utils/*": ["./packages/utils/src/*", "./src/utils/*"],
|
26
26
|
"@/types/*": ["./packages/types/src/*", "./src/types/*"],
|
27
27
|
"@/*": ["./src/*"],
|
package/vitest.config.mts
CHANGED
@@ -13,6 +13,7 @@ export default defineConfig({
|
|
13
13
|
'@/database/_deprecated': resolve(__dirname, './src/database/_deprecated'),
|
14
14
|
'@/database': resolve(__dirname, './packages/database/src'),
|
15
15
|
'@/utils/client/switchLang': resolve(__dirname, './src/utils/client/switchLang'),
|
16
|
+
'@/const/locale': resolve(__dirname, './src/const/locale'),
|
16
17
|
// TODO: after refactor the errorResponse, we can remove it
|
17
18
|
'@/utils/errorResponse': resolve(__dirname, './src/utils/errorResponse'),
|
18
19
|
'@/utils': resolve(__dirname, './packages/utils/src'),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|