mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 19:50:09 +00:00
Compare commits
79 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8b1ab6616 | |||
| 3891015a3d | |||
| 5babb7d826 | |||
| a7504b696a | |||
| 9dc4308942 | |||
| 082117998d | |||
| 9a74d6c045 | |||
| b1a4f24dc9 | |||
| c47551775b | |||
| 2d83300795 | |||
| 0915538da8 | |||
| b76e3c85b9 | |||
| 29ce0225b2 | |||
| 06878829c9 | |||
| ae613c7c35 | |||
| 8184f9d097 | |||
| 7fac37b983 | |||
| d3570879da | |||
| 1ad80809cf | |||
| 2c97a9e920 | |||
| 246cce28db | |||
| 9ffb6891e4 | |||
| 766ca942b3 | |||
| 53fc0642e0 | |||
| a8c725abd5 | |||
| b8a7f6e9eb | |||
| bb594f87e2 | |||
| b0ee9b434e | |||
| cf2c5a1d37 | |||
| 0511e43a48 | |||
| 1f128f407f | |||
| f258a2e042 | |||
| 7996e1c431 | |||
| 93dddfc2e5 | |||
| 5e4186559b | |||
| 9bfd9bb4a5 | |||
| 9ca54135b5 | |||
| f162556607 | |||
| 3292ed83f9 | |||
| 561a38f788 | |||
| 71aaf0fac5 | |||
| 287601f8ec | |||
| b36f8781e6 | |||
| 705450a571 | |||
| 5272c7373f | |||
| fb24b6f1b7 | |||
| 2fd65fe8a3 | |||
| 35d5a2c937 | |||
| 42f40d2717 | |||
| ef8a644d8c | |||
| 81c84348bc | |||
| 8d7a0467db | |||
| e9522729c5 | |||
| cf01894077 | |||
| b5d945b1fd | |||
| cbee964582 | |||
| 87a38ad0c4 | |||
| f2d4745ad3 | |||
| 0167ac8e28 | |||
| b480227fd0 | |||
| 97ff98cada | |||
| 845d3ef58a | |||
| 906917362f | |||
| c69049d6da | |||
| 4f7356ffab | |||
| d20c82c115 | |||
| d617a6cd97 | |||
| 408391eeb6 | |||
| 4a2e671f55 | |||
| 695a261df1 | |||
| 39b723eff4 | |||
| 68937d842c | |||
| b66bc66260 | |||
| 4d06279abd | |||
| 1a8d33fbf4 | |||
| 2c086373cc | |||
| c7d49258f8 | |||
| 2280fd6ff9 | |||
| 8eb901c401 |
@@ -2,6 +2,81 @@
|
||||
|
||||
# Changelog
|
||||
|
||||
## [Version 2.0.0-next.69](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.68...v2.0.0-next.69)
|
||||
|
||||
<sup>Released on **2025-11-17**</sup>
|
||||
|
||||
#### ♻ Code Refactoring
|
||||
|
||||
- **misc**: Remove `language_model_settings` and remove isDeprecatedEdition.
|
||||
|
||||
<br/>
|
||||
|
||||
<details>
|
||||
<summary><kbd>Improvements and Fixes</kbd></summary>
|
||||
|
||||
#### Code refactoring
|
||||
|
||||
- **misc**: Remove `language_model_settings` and remove isDeprecatedEdition, closes [#10264](https://github.com/lobehub/lobe-chat/issues/10264) ([ae613c7](https://github.com/lobehub/lobe-chat/commit/ae613c7))
|
||||
|
||||
</details>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## [Version 2.0.0-next.68](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.67...v2.0.0-next.68)
|
||||
|
||||
<sup>Released on **2025-11-16**</sup>
|
||||
|
||||
#### 🐛 Bug Fixes
|
||||
|
||||
- **misc**: The tool to fail execution on ollama when a message contains b….
|
||||
|
||||
<br/>
|
||||
|
||||
<details>
|
||||
<summary><kbd>Improvements and Fixes</kbd></summary>
|
||||
|
||||
#### What's fixed
|
||||
|
||||
- **misc**: The tool to fail execution on ollama when a message contains b…, closes [#10259](https://github.com/lobehub/lobe-chat/issues/10259) ([1ad8080](https://github.com/lobehub/lobe-chat/commit/1ad8080))
|
||||
|
||||
</details>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## [Version 2.0.0-next.67](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.66...v2.0.0-next.67)
|
||||
|
||||
<sup>Released on **2025-11-16**</sup>
|
||||
|
||||
#### ♻ Code Refactoring
|
||||
|
||||
- **misc**: Refactor to virtua.
|
||||
|
||||
<br/>
|
||||
|
||||
<details>
|
||||
<summary><kbd>Improvements and Fixes</kbd></summary>
|
||||
|
||||
#### Code refactoring
|
||||
|
||||
- **misc**: Refactor to virtua, closes [#10151](https://github.com/lobehub/lobe-chat/issues/10151) ([9ffb689](https://github.com/lobehub/lobe-chat/commit/9ffb689))
|
||||
|
||||
</details>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## [Version 2.0.0-next.66](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.65...v2.0.0-next.66)
|
||||
|
||||
<sup>Released on **2025-11-16**</sup>
|
||||
|
||||
+18
-18
@@ -32,33 +32,33 @@
|
||||
"electron-updater": "^6.6.2",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"fetch-socks": "^1.3.2",
|
||||
"get-port-please": "^3.1.2",
|
||||
"get-port-please": "^3.2.0",
|
||||
"pdfjs-dist": "4.10.38"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
|
||||
"@electron-toolkit/eslint-config-ts": "^3.0.0",
|
||||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/eslint-config-ts": "^3.1.0",
|
||||
"@electron-toolkit/preload": "^3.0.2",
|
||||
"@electron-toolkit/tsconfig": "^2.0.0",
|
||||
"@electron-toolkit/utils": "^4.0.0",
|
||||
"@lobechat/electron-client-ipc": "workspace:*",
|
||||
"@lobechat/electron-server-ipc": "workspace:*",
|
||||
"@lobechat/file-loaders": "workspace:*",
|
||||
"@lobehub/i18n-cli": "^1.20.3",
|
||||
"@types/lodash": "^4.17.0",
|
||||
"@lobehub/i18n-cli": "^1.25.1",
|
||||
"@types/lodash": "^4.17.20",
|
||||
"@types/resolve": "^1.20.6",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@types/set-cookie-parser": "^2.4.10",
|
||||
"@typescript/native-preview": "7.0.0-dev.20250711.1",
|
||||
"consola": "^3.1.0",
|
||||
"consola": "^3.4.2",
|
||||
"cookie": "^1.0.2",
|
||||
"electron": "^38.6.0",
|
||||
"electron": "^38.7.0",
|
||||
"electron-builder": "^26.0.12",
|
||||
"electron-is": "^3.0.0",
|
||||
"electron-log": "^5.3.3",
|
||||
"electron-log": "^5.4.3",
|
||||
"electron-store": "^8.2.0",
|
||||
"electron-vite": "^3.0.0",
|
||||
"execa": "^9.5.2",
|
||||
"electron-vite": "^3.1.0",
|
||||
"execa": "^9.6.0",
|
||||
"fast-glob": "^3.3.3",
|
||||
"fix-path": "^5.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
@@ -66,13 +66,13 @@
|
||||
"just-diff": "^6.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"resolve": "^1.22.8",
|
||||
"semver": "^7.5.4",
|
||||
"set-cookie-parser": "^2.7.1",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.7.3",
|
||||
"undici": "^7.9.0",
|
||||
"vite": "^6.3.5",
|
||||
"resolve": "^1.22.11",
|
||||
"semver": "^7.7.3",
|
||||
"set-cookie-parser": "^2.7.2",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3",
|
||||
"undici": "^7.16.0",
|
||||
"vite": "^6.4.1",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"pnpm": {
|
||||
|
||||
@@ -1,4 +1,32 @@
|
||||
[
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Remove language_model_settings and remove isDeprecatedEdition."]
|
||||
},
|
||||
"date": "2025-11-17",
|
||||
"version": "2.0.0-next.69"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["The tool to fail execution on ollama when a message contains b…."]
|
||||
},
|
||||
"date": "2025-11-16",
|
||||
"version": "2.0.0-next.68"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor to virtua."]
|
||||
},
|
||||
"date": "2025-11-16",
|
||||
"version": "2.0.0-next.67"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Support to collapse message."]
|
||||
},
|
||||
"date": "2025-11-16",
|
||||
"version": "2.0.0-next.66"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@
|
||||
"playwright": "^1.56.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/node": "^22.19.1",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.7.3"
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -249,11 +249,11 @@ const nextConfig: NextConfig = {
|
||||
// permanent: true,
|
||||
// source: '/settings',
|
||||
// },
|
||||
{
|
||||
destination: '/chat',
|
||||
permanent: false,
|
||||
source: '/',
|
||||
},
|
||||
// {
|
||||
// destination: '/chat',
|
||||
// permanent: false,
|
||||
// source: '/',
|
||||
// },
|
||||
{
|
||||
destination: '/chat',
|
||||
permanent: true,
|
||||
|
||||
+19
-24
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lobehub/lobehub",
|
||||
"version": "2.0.0-next.66",
|
||||
"version": "2.0.0-next.69",
|
||||
"description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
||||
"keywords": [
|
||||
"framework",
|
||||
@@ -122,9 +122,6 @@
|
||||
"eslint --fix"
|
||||
]
|
||||
},
|
||||
"overrides": {
|
||||
"eta": "4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.6.1",
|
||||
"@ant-design/pro-components": "^2.8.10",
|
||||
@@ -135,17 +132,17 @@
|
||||
"@azure-rest/ai-inference": "1.0.0-beta.5",
|
||||
"@azure/core-auth": "^1.10.1",
|
||||
"@cfworker/json-schema": "^4.1.1",
|
||||
"@clerk/localizations": "^3.27.2",
|
||||
"@clerk/nextjs": "^6.35.0",
|
||||
"@clerk/themes": "^2.4.35",
|
||||
"@clerk/localizations": "^3.28.0",
|
||||
"@clerk/nextjs": "^6.35.1",
|
||||
"@clerk/themes": "^2.4.36",
|
||||
"@codesandbox/sandpack-react": "^2.20.0",
|
||||
"@cyntler/react-doc-viewer": "^1.17.1",
|
||||
"@electric-sql/pglite": "0.2.17",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@fal-ai/client": "^1.7.2",
|
||||
"@formkit/auto-animate": "^0.9.0",
|
||||
"@google/genai": "^1.29.0",
|
||||
"@huggingface/inference": "^4.13.2",
|
||||
"@google/genai": "^1.29.1",
|
||||
"@huggingface/inference": "^4.13.3",
|
||||
"@icons-pack/react-simple-icons": "^13.8.0",
|
||||
"@khmyznikov/pwa-install": "0.3.9",
|
||||
"@langchain/community": "^0.3.57",
|
||||
@@ -168,14 +165,14 @@
|
||||
"@lobehub/charts": "^2.1.2",
|
||||
"@lobehub/chat-plugin-sdk": "^1.32.4",
|
||||
"@lobehub/chat-plugins-gateway": "^1.9.0",
|
||||
"@lobehub/editor": "^1.22.0",
|
||||
"@lobehub/editor": "^1.23.1",
|
||||
"@lobehub/icons": "^2.43.1",
|
||||
"@lobehub/market-sdk": "^0.23.0",
|
||||
"@lobehub/tts": "^2.0.1",
|
||||
"@lobehub/ui": "^2.13.8",
|
||||
"@lobehub/ui": "^2.16.2",
|
||||
"@modelcontextprotocol/sdk": "^1.22.0",
|
||||
"@neondatabase/serverless": "^1.0.2",
|
||||
"@next/third-parties": "^16.0.1",
|
||||
"@next/third-parties": "^16.0.3",
|
||||
"@opentelemetry/exporter-jaeger": "^2.2.0",
|
||||
"@opentelemetry/winston-transport": "^0.18.0",
|
||||
"@react-pdf/renderer": "^4.3.1",
|
||||
@@ -183,14 +180,14 @@
|
||||
"@saintno/comfyui-sdk": "^0.2.49",
|
||||
"@serwist/next": "^9.2.1",
|
||||
"@t3-oss/env-nextjs": "^0.13.8",
|
||||
"@tanstack/react-query": "^5.90.7",
|
||||
"@tanstack/react-query": "^5.90.10",
|
||||
"@trpc/client": "^11.7.1",
|
||||
"@trpc/next": "^11.7.1",
|
||||
"@trpc/react-query": "^11.7.1",
|
||||
"@trpc/server": "^11.7.1",
|
||||
"@vercel/analytics": "^1.5.0",
|
||||
"@vercel/edge-config": "^1.4.3",
|
||||
"@vercel/functions": "^3.3.0",
|
||||
"@vercel/functions": "^3.3.2",
|
||||
"@vercel/speed-insights": "^1.2.0",
|
||||
"@virtuoso.dev/masonry": "^1.3.5",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
@@ -233,7 +230,7 @@
|
||||
"model-bank": "workspace:*",
|
||||
"modern-screenshot": "^4.6.6",
|
||||
"nanoid": "^5.1.6",
|
||||
"next": "^16.0.1",
|
||||
"next": "^16.0.3",
|
||||
"next-auth": "5.0.0-beta.30",
|
||||
"next-mdx-remote": "^5.0.0",
|
||||
"nextjs-toploader": "^3.9.17",
|
||||
@@ -265,19 +262,19 @@
|
||||
"react-fast-marquee": "^1.6.5",
|
||||
"react-hotkeys-hook": "^5.2.1",
|
||||
"react-i18next": "^15.7.4",
|
||||
"react-layout-kit": "^2.0.0",
|
||||
"react-layout-kit": "^2.0.1",
|
||||
"react-lazy-load": "^4.0.1",
|
||||
"react-pdf": "^9.2.1",
|
||||
"react-responsive": "^10.0.1",
|
||||
"react-rnd": "^10.5.2",
|
||||
"react-router-dom": "^7.9.5",
|
||||
"react-router-dom": "^7.9.6",
|
||||
"react-scan": "^0.4.3",
|
||||
"react-virtuoso": "^4.14.1",
|
||||
"react-wrap-balancer": "^1.1.1",
|
||||
"remark": "^15.0.1",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-html": "^16.0.1",
|
||||
"resolve-accept-language": "^3.1.13",
|
||||
"resolve-accept-language": "^3.1.14",
|
||||
"rtl-detect": "^1.1.2",
|
||||
"semver": "^7.7.3",
|
||||
"sharp": "^0.34.5",
|
||||
@@ -295,6 +292,7 @@
|
||||
"url-join": "^5.0.0",
|
||||
"use-merge-value": "^1.2.0",
|
||||
"uuid": "^11.1.0",
|
||||
"virtua": "^0.47.0",
|
||||
"word-extractor": "^1.0.4",
|
||||
"ws": "^8.18.3",
|
||||
"yaml": "^2.8.1",
|
||||
@@ -311,7 +309,7 @@
|
||||
"@lobehub/lint": "^1.26.2",
|
||||
"@lobehub/market-types": "^1.11.4",
|
||||
"@lobehub/seo-cli": "^1.7.0",
|
||||
"@next/bundle-analyzer": "^16.0.1",
|
||||
"@next/bundle-analyzer": "^16.0.3",
|
||||
"@next/eslint-plugin-next": "^15.5.6",
|
||||
"@peculiar/webcrypto": "^1.5.0",
|
||||
"@playwright/test": "^1.56.1",
|
||||
@@ -397,9 +395,6 @@
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@vercel/speed-insights"
|
||||
],
|
||||
"overrides": {
|
||||
"eta": "4.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,6 @@
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"openai": "^4.0.0"
|
||||
"openai": "^4.104.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"main": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"model-bank": "workspace:*",
|
||||
"query-string": "^9.2.2",
|
||||
"query-string": "^9.3.1",
|
||||
"url-join": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,8 @@ import { BRANDING_NAME, ORG_NAME } from './branding';
|
||||
|
||||
export const CURRENT_VERSION = pkg.version;
|
||||
|
||||
export const isServerMode = true;
|
||||
export const isUsePgliteDB = false;
|
||||
|
||||
export const isDesktop = process.env.NEXT_PUBLIC_IS_DESKTOP_APP === '1';
|
||||
|
||||
export const isDeprecatedEdition = false;
|
||||
|
||||
// @ts-ignore
|
||||
export const isCustomBranding = BRANDING_NAME !== 'LobeHub';
|
||||
// @ts-ignore
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
"@lobechat/prompts": "workspace:*",
|
||||
"@lobechat/types": "workspace:*",
|
||||
"@lobechat/utils": "workspace:*",
|
||||
"debug": "^4.3.4",
|
||||
"immer": "^10.0.3",
|
||||
"debug": "^4.4.3",
|
||||
"immer": "^10.2.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"ts-md5": "^2.0.1"
|
||||
},
|
||||
|
||||
@@ -287,6 +287,44 @@ describe('ChunkModel', () => {
|
||||
expect(result[1].index).toBe(1);
|
||||
expect(result[2].index).toBe(2);
|
||||
});
|
||||
|
||||
it('should handle chunks with null metadata and return undefined pageNumber', async () => {
|
||||
const fileId = '1';
|
||||
const [chunk] = await serverDB
|
||||
.insert(chunks)
|
||||
.values([{ text: 'Chunk with null metadata', userId, index: 0, metadata: null }])
|
||||
.returning();
|
||||
|
||||
await serverDB.insert(fileChunks).values([{ fileId, chunkId: chunk.id, userId }]);
|
||||
|
||||
const result = await chunkModel.findByFileId(fileId, 0);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].metadata).toBeNull();
|
||||
expect(result[0].pageNumber).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle chunks with metadata containing pageNumber', async () => {
|
||||
const fileId = '1';
|
||||
const [chunk] = await serverDB
|
||||
.insert(chunks)
|
||||
.values([
|
||||
{
|
||||
text: 'Chunk with pageNumber',
|
||||
userId,
|
||||
index: 0,
|
||||
metadata: { pageNumber: 5 } as any,
|
||||
},
|
||||
])
|
||||
.returning();
|
||||
|
||||
await serverDB.insert(fileChunks).values([{ fileId, chunkId: chunk.id, userId }]);
|
||||
|
||||
const result = await chunkModel.findByFileId(fileId, 0);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].pageNumber).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getChunksTextByFileId', () => {
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"peerDependencies": {
|
||||
"react": "^19"
|
||||
"react": "^19.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
"test:coverage": "vitest --coverage --silent='passed-only'"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.7"
|
||||
"@types/debug": "^4.1.12"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
"@lobechat/model-runtime": "workspace:*",
|
||||
"@lobechat/types": "workspace:*",
|
||||
"@lobechat/utils": "workspace:*",
|
||||
"i18next": "^24.2.1"
|
||||
"i18next": "^24.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
"@napi-rs/canvas": "^0.1.70",
|
||||
"@xmldom/xmldom": "^0.9.8",
|
||||
"concat-stream": "^2.0.0",
|
||||
"debug": "^4.3.4",
|
||||
"mammoth": "^1.8.0",
|
||||
"debug": "^4.4.3",
|
||||
"mammoth": "^1.11.0",
|
||||
"officeparser": "5.1.1",
|
||||
"pdfjs-dist": "4.10.38",
|
||||
"word-extractor": "^1.0.4",
|
||||
@@ -39,7 +39,7 @@
|
||||
"devDependencies": {
|
||||
"@types/concat-stream": "^2.0.3",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"typescript": "^5"
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5"
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
"ora": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsx": "^4.19.2"
|
||||
"tsx": "^4.20.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3"
|
||||
"zod": "^3.25.76"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
"test:update": "vitest -u"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.862.0",
|
||||
"@huggingface/inference": "^4.11.3",
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.932.0",
|
||||
"@huggingface/inference": "^4.13.3",
|
||||
"@lobechat/const": "workspace:*",
|
||||
"@lobechat/types": "workspace:*",
|
||||
"@lobechat/utils": "workspace:*",
|
||||
"debug": "^4.4.1",
|
||||
"debug": "^4.4.3",
|
||||
"model-bank": "workspace:*",
|
||||
"openai": "^4.104.0"
|
||||
}
|
||||
|
||||
@@ -235,6 +235,73 @@ describe('OllamaStream', () => {
|
||||
expect(onToolCall).toHaveBeenCalledTimes(1);
|
||||
expect(onCompletionMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('tools use with a done', async () => {
|
||||
vi.spyOn(uuidModule, 'nanoid').mockReturnValueOnce('1').mockReturnValueOnce('abcd1234');
|
||||
|
||||
const mockOllamaStream = new ReadableStream<ChatResponse>({
|
||||
start(controller) {
|
||||
controller.enqueue({
|
||||
model: 'qwen2.5',
|
||||
created_at: new Date('2024-12-01T03:34:55.166692Z'),
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
tool_calls: [
|
||||
{
|
||||
function: {
|
||||
name: 'realtime-weather____fetchCurrentWeather',
|
||||
arguments: { city: '杭州' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
done_reason: 'stop',
|
||||
done: true,
|
||||
total_duration: 1122415333,
|
||||
load_duration: 26178333,
|
||||
prompt_eval_count: 221,
|
||||
prompt_eval_duration: 507000000,
|
||||
eval_count: 26,
|
||||
eval_duration: 583000000,
|
||||
} as unknown as ChatResponse);
|
||||
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
const onStartMock = vi.fn();
|
||||
const onTextMock = vi.fn();
|
||||
const onToolCall = vi.fn();
|
||||
const onCompletionMock = vi.fn();
|
||||
|
||||
const protocolStream = OllamaStream(mockOllamaStream, {
|
||||
onStart: onStartMock,
|
||||
onText: onTextMock,
|
||||
onCompletion: onCompletionMock,
|
||||
onToolsCalling: onToolCall,
|
||||
});
|
||||
|
||||
const decoder = new TextDecoder();
|
||||
const chunks = [];
|
||||
|
||||
// @ts-ignore
|
||||
for await (const chunk of protocolStream) {
|
||||
chunks.push(decoder.decode(chunk, { stream: true }));
|
||||
}
|
||||
|
||||
expect(chunks).toEqual(
|
||||
[
|
||||
'id: chat_1',
|
||||
'event: tool_calls',
|
||||
`data: [{"function":{"arguments":"{\\"city\\":\\"杭州\\"}","name":"realtime-weather____fetchCurrentWeather"},"id":"realtime-weather____fetchCurrentWeather_0_abcd1234","index":0,"type":"function"}]\n`,
|
||||
].map((i) => `${i}\n`),
|
||||
);
|
||||
|
||||
expect(onTextMock).toHaveBeenCalledTimes(0);
|
||||
expect(onStartMock).toHaveBeenCalledTimes(1);
|
||||
expect(onToolCall).toHaveBeenCalledTimes(1);
|
||||
expect(onCompletionMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle empty stream', async () => {
|
||||
|
||||
@@ -11,11 +11,6 @@ import {
|
||||
} from './protocol';
|
||||
|
||||
const transformOllamaStream = (chunk: ChatResponse, stack: StreamContext): StreamProtocolChunk => {
|
||||
// maybe need another structure to add support for multiple choices
|
||||
if (chunk.done && !chunk.message.content) {
|
||||
return { data: 'finished', id: stack.id, type: 'stop' };
|
||||
}
|
||||
|
||||
if (chunk.message.thinking) {
|
||||
return { data: chunk.message.thinking, id: stack.id, type: 'reasoning' };
|
||||
}
|
||||
@@ -36,6 +31,11 @@ const transformOllamaStream = (chunk: ChatResponse, stack: StreamContext): Strea
|
||||
};
|
||||
}
|
||||
|
||||
// maybe need another structure to add support for multiple choices
|
||||
if (chunk.done && !chunk.message.content) {
|
||||
return { data: 'finished', id: stack.id, type: 'stop' };
|
||||
}
|
||||
|
||||
// 判断是否有 <think> 或 </think> 标签,更新 thinkingInContent 状态
|
||||
if (chunk.message.content.includes('<think>')) {
|
||||
stack.thinkingInContent = true;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
"@opentelemetry/instrumentation": "^0.207.0",
|
||||
"@opentelemetry/instrumentation-http": "^0.207.0",
|
||||
"@opentelemetry/instrumentation-pg": "^0.60.0",
|
||||
"@opentelemetry/resources": "^2.0.1",
|
||||
"@opentelemetry/sdk-metrics": "^2.0.1",
|
||||
"@opentelemetry/resources": "^2.2.0",
|
||||
"@opentelemetry/sdk-metrics": "^2.2.0",
|
||||
"@opentelemetry/sdk-node": "^0.207.0",
|
||||
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
||||
"@opentelemetry/semantic-conventions": "^1.36.0",
|
||||
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
||||
"@opentelemetry/semantic-conventions": "^1.38.0",
|
||||
"@vercel/otel": "^2.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"promptfoo": "^0.118.17",
|
||||
"tsx": "^4.20.4"
|
||||
"tsx": "^4.20.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^3.3.2",
|
||||
"request-filtering-agent": "^3"
|
||||
"request-filtering-agent": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest": "^3.2.4"
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
"dependencies": {
|
||||
"@lobechat/const": "workspace:*",
|
||||
"@lobechat/types": "workspace:*",
|
||||
"dayjs": "^1.11.18",
|
||||
"dompurify": "^3.2.7"
|
||||
"dayjs": "^1.11.19",
|
||||
"dompurify": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest-canvas-mock": "^0.3.3"
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"happy-dom": "^20.0.0",
|
||||
"happy-dom": "^20.0.10",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
"ssrf-safe-fetch": "workspace:*",
|
||||
"query-string": "^9.1.1",
|
||||
"query-string": "^9.3.1",
|
||||
"url-join": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const partialBuildPages = [
|
||||
{
|
||||
name: 'changelog',
|
||||
disabled: isDesktop,
|
||||
paths: ['src/app/[variants]/@modal/(.)changelog', 'src/app/[variants]/(main)/changelog'],
|
||||
paths: ['src/app/[variants]/(main)/changelog'],
|
||||
},
|
||||
{
|
||||
name: 'auth',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { isServerMode } from '@/const/version';
|
||||
import { serverDB } from '@/database/server';
|
||||
import { authEnv } from '@/envs/auth';
|
||||
import { pino } from '@/libs/logger';
|
||||
@@ -8,7 +7,7 @@ import { UserService } from '@/server/services/user';
|
||||
|
||||
import { validateRequest } from './validateRequest';
|
||||
|
||||
if (authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH && isServerMode && !authEnv.CLERK_WEBHOOK_SECRET) {
|
||||
if (authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH && !authEnv.CLERK_WEBHOOK_SECRET) {
|
||||
throw new Error('`CLERK_WEBHOOK_SECRET` environment variable is missing');
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ const handler = (req: NextRequest) => {
|
||||
*/
|
||||
createContext: () => createLambdaContext(req),
|
||||
|
||||
endpoint: '/trpc/desktop',
|
||||
endpoint: '/trpc/desktop',
|
||||
|
||||
onError: ({ error, path, type }) => {
|
||||
pino.info(`Error in tRPC handler (desktop) on path: ${path}, type: ${type}`);
|
||||
console.error(error);
|
||||
},
|
||||
onError: ({ error, path, type }) => {
|
||||
pino.info(`Error in tRPC handler (desktop) on path: ${path}, type: ${type}`);
|
||||
console.error(error);
|
||||
},
|
||||
|
||||
req: preparedReq,
|
||||
responseMeta({ ctx }) {
|
||||
@@ -34,4 +34,4 @@ const handler = (req: NextRequest) => {
|
||||
});
|
||||
};
|
||||
|
||||
export { handler as GET, handler as POST };
|
||||
export { handler as GET, handler as POST };
|
||||
@@ -6,10 +6,12 @@ import { useUserStore } from '@/store/user';
|
||||
import UserBanner from '../features/UserBanner';
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('next/navigation', () => ({
|
||||
useRouter: vi.fn(() => ({
|
||||
push: vi.fn(),
|
||||
})),
|
||||
const mockNavigate = vi.fn();
|
||||
vi.mock('react-router-dom', () => ({
|
||||
Link: ({ to, children }: { to: string; children: React.ReactNode }) => (
|
||||
<a href={to}>{children}</a>
|
||||
),
|
||||
useNavigate: () => mockNavigate,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/User/UserInfo', () => ({
|
||||
@@ -45,6 +47,7 @@ vi.mock('@/const/auth', () => ({
|
||||
|
||||
afterEach(() => {
|
||||
enableAuth = true;
|
||||
mockNavigate.mockReset();
|
||||
});
|
||||
|
||||
describe('UserBanner', () => {
|
||||
|
||||
@@ -11,10 +11,9 @@ const wrapper: React.JSXElementConstructor<{ children: React.ReactNode }> = ({ c
|
||||
);
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('next/navigation', () => ({
|
||||
useRouter: vi.fn(() => ({
|
||||
push: vi.fn(),
|
||||
})),
|
||||
const mockNavigate = vi.fn();
|
||||
vi.mock('react-router-dom', () => ({
|
||||
useNavigate: () => mockNavigate,
|
||||
}));
|
||||
|
||||
vi.mock('react-i18next', () => ({
|
||||
@@ -23,10 +22,6 @@ vi.mock('react-i18next', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock('../../settings/features/useCategory', () => ({
|
||||
useCategory: vi.fn(() => [{ key: 'extraSetting', label: 'Extra Setting' }]),
|
||||
}));
|
||||
|
||||
// 定义一个变量来存储 enableAuth 的值
|
||||
let enableAuth = true;
|
||||
let enableClerk = true;
|
||||
@@ -52,6 +47,7 @@ vi.mock('@/const/version', async (importOriginal) => {
|
||||
afterEach(() => {
|
||||
enableAuth = true;
|
||||
enableClerk = true;
|
||||
mockNavigate.mockReset();
|
||||
});
|
||||
|
||||
describe('useCategory', () => {
|
||||
@@ -68,7 +64,6 @@ describe('useCategory', () => {
|
||||
const items = result.current;
|
||||
expect(items.some((item) => item.key === 'profile')).toBe(true);
|
||||
expect(items.some((item) => item.key === 'setting')).toBe(true);
|
||||
expect(items.some((item) => item.key === 'data')).toBe(true);
|
||||
expect(items.some((item) => item.key === 'docs')).toBe(true);
|
||||
expect(items.some((item) => item.key === 'feedback')).toBe(true);
|
||||
expect(items.some((item) => item.key === 'changelog')).toBe(true);
|
||||
@@ -93,19 +88,4 @@ describe('useCategory', () => {
|
||||
expect(items.some((item) => item.key === 'changelog')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle settings for non-authenticated users', () => {
|
||||
act(() => {
|
||||
useUserStore.setState({ isSignedIn: false });
|
||||
});
|
||||
enableClerk = false;
|
||||
enableAuth = false;
|
||||
|
||||
const { result } = renderHook(() => useCategory(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
const items = result.current;
|
||||
expect(items.some((item) => item.key === 'extraSetting')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { enableAuth, enableNextAuth } from '@/const/auth';
|
||||
@@ -13,7 +12,7 @@ import { useUserStore } from '@/store/user';
|
||||
import { authSelectors } from '@/store/user/selectors';
|
||||
|
||||
const UserBanner = memo(() => {
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const isLoginWithAuth = useUserStore(authSelectors.isLoginWithAuth);
|
||||
const [signIn] = useUserStore((s) => [s.openLogin]);
|
||||
|
||||
@@ -21,10 +20,10 @@ const UserBanner = memo(() => {
|
||||
<Flexbox gap={12} paddingBlock={8}>
|
||||
{!enableAuth || (enableAuth && isLoginWithAuth) ? (
|
||||
<>
|
||||
<Link href={'/profile'} style={{ color: 'inherit' }}>
|
||||
<Link style={{ color: 'inherit' }} to="/profile">
|
||||
<UserInfo />
|
||||
</Link>
|
||||
<Link href={'/profile/stats'} style={{ color: 'inherit' }}>
|
||||
<Link style={{ color: 'inherit' }} to="/profile/stats">
|
||||
<DataStatistics paddingInline={12} />
|
||||
</Link>
|
||||
</>
|
||||
@@ -36,7 +35,7 @@ const UserBanner = memo(() => {
|
||||
signIn();
|
||||
return;
|
||||
}
|
||||
router.push('/login');
|
||||
navigate('/login');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,44 +1,35 @@
|
||||
import { DOCUMENTS, FEEDBACK, LOBE_CHAT_CLOUD, OFFICIAL_URL, UTM_SOURCE } from '@lobechat/const';
|
||||
import {
|
||||
Book,
|
||||
CircleUserRound,
|
||||
Cloudy,
|
||||
Database,
|
||||
Download,
|
||||
Feather,
|
||||
FileClockIcon,
|
||||
Settings2,
|
||||
} from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { CellProps } from '@/components/Cell';
|
||||
import { enableAuth } from '@/const/auth';
|
||||
import { LOBE_CHAT_CLOUD } from '@/const/branding';
|
||||
import { DOCUMENTS, FEEDBACK, OFFICIAL_URL, UTM_SOURCE } from '@/const/url';
|
||||
import { isServerMode } from '@/const/version';
|
||||
import { usePWAInstall } from '@/hooks/usePWAInstall';
|
||||
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { authSelectors } from '@/store/user/selectors';
|
||||
|
||||
import { useCategory as useSettingsCategory } from '../../settings/features/useCategory';
|
||||
|
||||
export const useCategory = () => {
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const { canInstall, install } = usePWAInstall();
|
||||
const { t } = useTranslation(['common', 'setting', 'auth']);
|
||||
const { showCloudPromotion, hideDocs } = useServerConfigStore(featureFlagsSelectors);
|
||||
const [isLogin, isLoginWithAuth] = useUserStore((s) => [
|
||||
authSelectors.isLogin(s),
|
||||
authSelectors.isLoginWithAuth(s),
|
||||
]);
|
||||
const [isLoginWithAuth] = useUserStore((s) => [authSelectors.isLoginWithAuth(s)]);
|
||||
|
||||
const profile: CellProps[] = [
|
||||
{
|
||||
icon: CircleUserRound,
|
||||
key: 'profile',
|
||||
label: t('userPanel.profile'),
|
||||
onClick: () => router.push('/me/profile'),
|
||||
onClick: () => navigate('/me/profile'),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -47,7 +38,7 @@ export const useCategory = () => {
|
||||
icon: Settings2,
|
||||
key: 'setting',
|
||||
label: t('userPanel.setting'),
|
||||
onClick: () => router.push('/me/settings'),
|
||||
onClick: () => navigate('/me/settings'),
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
@@ -66,29 +57,7 @@ export const useCategory = () => {
|
||||
},
|
||||
];
|
||||
|
||||
const settingsWithoutAuth = [
|
||||
...useSettingsCategory(),
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
];
|
||||
|
||||
/* ↓ cloud slot ↓ */
|
||||
|
||||
/* ↑ cloud slot ↑ */
|
||||
|
||||
const data: CellProps[] = [
|
||||
{
|
||||
icon: Database,
|
||||
key: 'data',
|
||||
label: t('userPanel.data'),
|
||||
onClick: () => router.push('/me/data'),
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
];
|
||||
|
||||
const helps: CellProps[] = [
|
||||
showCloudPromotion && {
|
||||
icon: Cloudy,
|
||||
@@ -112,7 +81,7 @@ export const useCategory = () => {
|
||||
icon: FileClockIcon,
|
||||
key: 'changelog',
|
||||
label: t('changelog'),
|
||||
onClick: () => router.push('/changelog'),
|
||||
onClick: () => navigate('/changelog'),
|
||||
},
|
||||
].filter(Boolean) as CellProps[];
|
||||
|
||||
@@ -120,13 +89,12 @@ export const useCategory = () => {
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
...(!enableAuth || (enableAuth && isLoginWithAuth) ? profile : []),
|
||||
...(enableAuth ? (isLoginWithAuth ? settings : []) : settingsWithoutAuth),
|
||||
...(isLoginWithAuth ? profile : []),
|
||||
...(isLoginWithAuth ? settings : []),
|
||||
/* ↓ cloud slot ↓ */
|
||||
|
||||
/* ↑ cloud slot ↑ */
|
||||
...(canInstall ? pwa : []),
|
||||
...(isLogin && !isServerMode ? data : []),
|
||||
...(!hideDocs ? helps : []),
|
||||
].filter(Boolean) as CellProps[];
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
import { Center } from 'react-layout-kit';
|
||||
|
||||
import BrandWatermark from '@/components/BrandWatermark';
|
||||
|
||||
import Category from './features/Category';
|
||||
import UserBanner from './features/UserBanner';
|
||||
|
||||
const MeHomePage = memo(() => {
|
||||
return (
|
||||
<>
|
||||
<UserBanner />
|
||||
<Category />
|
||||
<Center padding={16}>
|
||||
<BrandWatermark />
|
||||
</Center>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
MeHomePage.displayName = 'MeHomePage';
|
||||
|
||||
export default MeHomePage;
|
||||
@@ -1,18 +1,15 @@
|
||||
import { PropsWithChildren, Suspense } from 'react';
|
||||
import MobileContentLayout from "@/components/server/MobileNavLayout";
|
||||
import Loading from "@/components/Loading/BrandTextLoading";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import Header from "./features/Header";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import Loading from '@/components/Loading/BrandTextLoading';
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
|
||||
import Header from './features/Header';
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren) => {
|
||||
return (
|
||||
<MobileContentLayout header={<Header />} withNav>
|
||||
<Suspense fallback={<Loading />}>{children}</Suspense>
|
||||
const Layout = () => {
|
||||
return <MobileContentLayout header={<Header />} withNav>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
</MobileContentLayout>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Layout.displayName = 'MeLayout';
|
||||
|
||||
export default Layout;
|
||||
export default Layout;
|
||||
@@ -1,38 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { Skeleton } from 'antd';
|
||||
import { memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import Divider from '@/components/Cell/Divider';
|
||||
import SkeletonLoading from '@/components/Loading/SkeletonLoading';
|
||||
|
||||
const Loading = memo(() => {
|
||||
return (
|
||||
<>
|
||||
<Flexbox align={'center'} gap={12} horizontal paddingBlock={12} paddingInline={12}>
|
||||
<Skeleton.Avatar active shape={'circle'} size={48} />
|
||||
<Skeleton.Button active block />
|
||||
</Flexbox>
|
||||
<Flexbox gap={4} horizontal paddingBlock={12} paddingInline={16}>
|
||||
<Skeleton.Button active block />
|
||||
<Skeleton.Button active block />
|
||||
<Skeleton.Button active block />
|
||||
</Flexbox>
|
||||
<Divider />
|
||||
<SkeletonLoading
|
||||
active
|
||||
paragraph={{ rows: 6, style: { marginBottom: 0 }, width: '100%' }}
|
||||
title={false}
|
||||
/>
|
||||
<Divider />
|
||||
<SkeletonLoading
|
||||
active
|
||||
paragraph={{ rows: 3, style: { marginBottom: 0 }, width: '100%' }}
|
||||
title={false}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
export default Loading;
|
||||
@@ -1,40 +0,0 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
import { Center } from 'react-layout-kit';
|
||||
|
||||
import BrandWatermark from '@/components/BrandWatermark';
|
||||
import { metadataModule } from '@/server/metadata';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DynamicLayoutProps } from '@/types/next';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import Category from './features/Category';
|
||||
import UserBanner from './features/UserBanner';
|
||||
|
||||
export const generateMetadata = async (props: DynamicLayoutProps) => {
|
||||
const locale = await RouteVariants.getLocale(props);
|
||||
const { t } = await translation('common', locale);
|
||||
return metadataModule.generate({
|
||||
title: t('tab.me'),
|
||||
url: '/me',
|
||||
});
|
||||
};
|
||||
|
||||
const Page = async (props: DynamicLayoutProps) => {
|
||||
const isMobile = await RouteVariants.getIsMobile(props);
|
||||
|
||||
if (!isMobile) return redirect('/chat');
|
||||
|
||||
return (
|
||||
<>
|
||||
<UserBanner />
|
||||
<Category />
|
||||
<Center padding={16}>
|
||||
<BrandWatermark />
|
||||
</Center>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Page.displayName = 'Me';
|
||||
|
||||
export default Page;
|
||||
@@ -1,13 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { ChartColumnBigIcon, LogOut, ShieldCheck, UserCircle } from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import Cell, { CellProps } from '@/components/Cell';
|
||||
import { enableAuth } from '@/const/auth';
|
||||
import { isDeprecatedEdition } from '@/const/version';
|
||||
import { ProfileTabs } from '@/store/global/initialState';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { authSelectors } from '@/store/user/selectors';
|
||||
@@ -18,42 +16,39 @@ const Category = memo(() => {
|
||||
authSelectors.isLoginWithClerk(s),
|
||||
s.logout,
|
||||
]);
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation('auth');
|
||||
const items: CellProps[] = [
|
||||
{
|
||||
icon: UserCircle,
|
||||
key: ProfileTabs.Profile,
|
||||
label: t('tab.profile'),
|
||||
onClick: () => router.push('/profile'),
|
||||
onClick: () => navigate('/profile'),
|
||||
},
|
||||
enableAuth &&
|
||||
isLoginWithClerk && {
|
||||
icon: ShieldCheck,
|
||||
key: ProfileTabs.Security,
|
||||
label: t('tab.security'),
|
||||
onClick: () => router.push('/profile/security'),
|
||||
},
|
||||
!isDeprecatedEdition && {
|
||||
isLoginWithClerk && {
|
||||
icon: ShieldCheck,
|
||||
key: ProfileTabs.Security,
|
||||
label: t('tab.security'),
|
||||
onClick: () => navigate('/profile/security'),
|
||||
},
|
||||
{
|
||||
icon: ChartColumnBigIcon,
|
||||
key: ProfileTabs.Stats,
|
||||
label: t('tab.stats'),
|
||||
onClick: () => router.push('/profile/stats'),
|
||||
onClick: () => navigate('/profile/stats'),
|
||||
},
|
||||
enableAuth &&
|
||||
isLogin && {
|
||||
type: 'divider',
|
||||
},
|
||||
enableAuth &&
|
||||
isLogin && {
|
||||
icon: LogOut,
|
||||
key: 'logout',
|
||||
label: t('signout', { ns: 'auth' }),
|
||||
onClick: () => {
|
||||
signOut();
|
||||
router.push('/login');
|
||||
},
|
||||
isLogin && {
|
||||
type: 'divider',
|
||||
},
|
||||
isLogin && {
|
||||
icon: LogOut,
|
||||
key: 'logout',
|
||||
label: t('signout', { ns: 'auth' }),
|
||||
onClick: () => {
|
||||
signOut();
|
||||
navigate('/login');
|
||||
},
|
||||
},
|
||||
].filter(Boolean) as CellProps[];
|
||||
|
||||
return items?.map(({ key, ...item }, index) => <Cell key={key || index} {...item} />);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { ChatHeader } from '@lobehub/ui/mobile';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
@@ -11,7 +11,7 @@ import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('common');
|
||||
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<ChatHeader
|
||||
center={
|
||||
@@ -23,7 +23,7 @@ const Header = memo(() => {
|
||||
}
|
||||
/>
|
||||
}
|
||||
onBackClick={() => router.push('/me')}
|
||||
onBackClick={() => navigate('/me')}
|
||||
showBackButton
|
||||
style={mobileHeaderSticky}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
|
||||
|
||||
import Category from './features/Category';
|
||||
|
||||
const MeProfilePage = memo(() => {
|
||||
return (
|
||||
<Category />
|
||||
);
|
||||
});
|
||||
|
||||
MeProfilePage.displayName = 'MeProfilePage';
|
||||
|
||||
export default MeProfilePage;
|
||||
@@ -1,13 +1,11 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
import MobileContentLayout from "@/components/server/MobileNavLayout";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import Header from "./features/Header";
|
||||
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
const Layout = () => {
|
||||
return <MobileContentLayout header={<Header />}>
|
||||
<Outlet />
|
||||
</MobileContentLayout>
|
||||
}
|
||||
|
||||
import Header from './features/Header';
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren) => {
|
||||
return <MobileContentLayout header={<Header />}>{children}</MobileContentLayout>;
|
||||
};
|
||||
|
||||
Layout.displayName = 'MeProfileLayout';
|
||||
|
||||
export default Layout;
|
||||
export default Layout;
|
||||
@@ -1,5 +0,0 @@
|
||||
import SkeletonLoading from '@/components/Loading/SkeletonLoading';
|
||||
|
||||
export default () => {
|
||||
return <SkeletonLoading paragraph={{ rows: 8 }} />;
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { metadataModule } from '@/server/metadata';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DynamicLayoutProps } from '@/types/next';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import Category from './features/Category';
|
||||
|
||||
export const generateMetadata = async (props: DynamicLayoutProps) => {
|
||||
const locale = await RouteVariants.getLocale(props);
|
||||
const { t } = await translation('auth', locale);
|
||||
return metadataModule.generate({
|
||||
description: t('header.desc'),
|
||||
title: t('header.title'),
|
||||
url: '/me/profile',
|
||||
});
|
||||
};
|
||||
|
||||
const Page = async (props: DynamicLayoutProps) => {
|
||||
const isMobile = await RouteVariants.getIsMobile(props);
|
||||
|
||||
if (!isMobile) return redirect('/profile');
|
||||
|
||||
return <Category />;
|
||||
};
|
||||
|
||||
Page.displayName = 'MeProfile';
|
||||
|
||||
export default Page;
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { ChatHeader } from '@lobehub/ui/mobile';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
@@ -11,7 +11,7 @@ import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('common');
|
||||
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<ChatHeader
|
||||
center={
|
||||
@@ -23,7 +23,7 @@ const Header = memo(() => {
|
||||
}
|
||||
/>
|
||||
}
|
||||
onBackClick={() => router.push('/me')}
|
||||
onBackClick={() => navigate('/me')}
|
||||
showBackButton
|
||||
style={mobileHeaderSticky}
|
||||
/>
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { Bot, Brain, Info, Mic2, Settings2, Sparkles } from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { CellProps } from '@/components/Cell';
|
||||
import { isDeprecatedEdition } from '@/const/version';
|
||||
import { SettingsTabs } from '@/store/global/initialState';
|
||||
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
||||
|
||||
export const useCategory = () => {
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation('setting');
|
||||
const { showLLM } = useServerConfigStore(featureFlagsSelectors);
|
||||
|
||||
const items: CellProps[] = [
|
||||
{
|
||||
@@ -23,18 +19,11 @@ export const useCategory = () => {
|
||||
key: SettingsTabs.SystemAgent,
|
||||
label: t('tab.system-agent'),
|
||||
},
|
||||
showLLM &&
|
||||
(isDeprecatedEdition
|
||||
? {
|
||||
icon: Brain,
|
||||
key: SettingsTabs.LLM,
|
||||
label: t('tab.llm'),
|
||||
}
|
||||
: {
|
||||
icon: Brain,
|
||||
key: SettingsTabs.Provider,
|
||||
label: t('tab.provider'),
|
||||
}),
|
||||
{
|
||||
icon: Brain,
|
||||
key: SettingsTabs.Provider,
|
||||
label: t('tab.provider'),
|
||||
},
|
||||
{ icon: Mic2, key: SettingsTabs.TTS, label: t('tab.tts') },
|
||||
{
|
||||
icon: Bot,
|
||||
@@ -50,6 +39,6 @@ export const useCategory = () => {
|
||||
|
||||
return items.map((item) => ({
|
||||
...item,
|
||||
onClick: () => router.push(`/settings?active=${item.key}`),
|
||||
onClick: () => navigate(`/settings?active=${item.key}`),
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
|
||||
|
||||
import Category from './features/Category';
|
||||
|
||||
const MeSettingsPage = memo(() => {
|
||||
return (
|
||||
<Category />
|
||||
);
|
||||
});
|
||||
|
||||
MeSettingsPage.displayName = 'MeSettingsPage';
|
||||
|
||||
export default MeSettingsPage;
|
||||
@@ -1,13 +1,15 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
import MobileContentLayout from "@/components/server/MobileNavLayout";
|
||||
import Loading from "@/components/Loading/BrandTextLoading";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import Header from "./features/Header";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
const Layout = () => {
|
||||
return <MobileContentLayout header={<Header />} withNav>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
</MobileContentLayout>
|
||||
}
|
||||
|
||||
import Header from './features/Header';
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren) => {
|
||||
return <MobileContentLayout header={<Header />}>{children}</MobileContentLayout>;
|
||||
};
|
||||
|
||||
Layout.displayName = 'MeSettingsLayout';
|
||||
|
||||
export default Layout;
|
||||
export default Layout;
|
||||
@@ -1,5 +0,0 @@
|
||||
import SkeletonLoading from '@/components/Loading/SkeletonLoading';
|
||||
|
||||
export default () => {
|
||||
return <SkeletonLoading paragraph={{ rows: 8 }} />;
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { metadataModule } from '@/server/metadata';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DynamicLayoutProps } from '@/types/next';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import Category from './features/Category';
|
||||
|
||||
export const generateMetadata = async (props: DynamicLayoutProps) => {
|
||||
const locale = await RouteVariants.getLocale(props);
|
||||
const { t } = await translation('setting', locale);
|
||||
return metadataModule.generate({
|
||||
description: t('header.desc'),
|
||||
title: t('header.title'),
|
||||
url: '/me/settings',
|
||||
});
|
||||
};
|
||||
|
||||
const Page = async (props: DynamicLayoutProps) => {
|
||||
const isMobile = await RouteVariants.getIsMobile(props);
|
||||
|
||||
if (!isMobile) return redirect('/settings');
|
||||
|
||||
return <Category />;
|
||||
};
|
||||
|
||||
Page.displayName = 'MeSettings';
|
||||
|
||||
export default Page;
|
||||
@@ -1,106 +0,0 @@
|
||||
import { ActionIcon, ActionIconProps, Hotkey } from '@lobehub/ui';
|
||||
import { Compass, FolderClosed, MessageSquare, Palette } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { SidebarTabKey } from '@/store/global/initialState';
|
||||
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { settingsSelectors } from '@/store/user/selectors';
|
||||
import { HotkeyEnum } from '@/types/hotkey';
|
||||
|
||||
const ICON_SIZE: ActionIconProps['size'] = {
|
||||
blockSize: 40,
|
||||
size: 24,
|
||||
strokeWidth: 2,
|
||||
};
|
||||
|
||||
export interface TopActionProps {
|
||||
isPinned?: boolean | null;
|
||||
tab?: SidebarTabKey;
|
||||
}
|
||||
|
||||
// TODO Change icons
|
||||
const TopActions = memo<TopActionProps>(({ tab, isPinned }) => {
|
||||
const { t } = useTranslation('common');
|
||||
const switchBackToChat = useGlobalStore((s) => s.switchBackToChat);
|
||||
const { showMarket, enableKnowledgeBase, showAiImage } =
|
||||
useServerConfigStore(featureFlagsSelectors);
|
||||
const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.NavigateToChat));
|
||||
|
||||
const isChatActive = tab === SidebarTabKey.Chat && !isPinned;
|
||||
const isFilesActive = tab === SidebarTabKey.Files;
|
||||
const isDiscoverActive = tab === SidebarTabKey.Discover;
|
||||
const isImageActive = tab === SidebarTabKey.Image;
|
||||
|
||||
return (
|
||||
<Flexbox gap={8}>
|
||||
<Link
|
||||
aria-label={t('tab.chat')}
|
||||
href={'/chat'}
|
||||
onClick={(e) => {
|
||||
// If Cmd key is pressed, let the default link behavior happen (open in new tab)
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, prevent default and switch session within the current tab
|
||||
e.preventDefault();
|
||||
switchBackToChat(useSessionStore.getState().activeId);
|
||||
}}
|
||||
>
|
||||
<ActionIcon
|
||||
active={isChatActive}
|
||||
icon={MessageSquare}
|
||||
size={ICON_SIZE}
|
||||
title={
|
||||
<Flexbox align={'center'} gap={8} horizontal justify={'space-between'}>
|
||||
<span>{t('tab.chat')}</span>
|
||||
<Hotkey inverseTheme keys={hotkey} />
|
||||
</Flexbox>
|
||||
}
|
||||
tooltipProps={{ placement: 'right' }}
|
||||
/>
|
||||
</Link>
|
||||
{enableKnowledgeBase && (
|
||||
<Link aria-label={t('tab.knowledgeBase')} href={'/knowledge'}>
|
||||
<ActionIcon
|
||||
active={isFilesActive}
|
||||
icon={FolderClosed}
|
||||
size={ICON_SIZE}
|
||||
title={t('tab.knowledgeBase')}
|
||||
tooltipProps={{ placement: 'right' }}
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
{showAiImage && (
|
||||
<Link aria-label={t('tab.aiImage')} href={'/image'}>
|
||||
<ActionIcon
|
||||
active={isImageActive}
|
||||
icon={Palette}
|
||||
size={ICON_SIZE}
|
||||
title={t('tab.aiImage')}
|
||||
tooltipProps={{ placement: 'right' }}
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
{showMarket && (
|
||||
<Link aria-label={t('tab.discover')} href={'/discover'}>
|
||||
<ActionIcon
|
||||
active={isDiscoverActive}
|
||||
icon={Compass}
|
||||
size={ICON_SIZE}
|
||||
title={t('tab.discover')}
|
||||
tooltipProps={{ placement: 'right' }}
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
</Flexbox>
|
||||
);
|
||||
});
|
||||
|
||||
export default TopActions;
|
||||
@@ -1,15 +1,16 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import { Locales } from '@/locales/resources';
|
||||
|
||||
import Hero from '../../features/Hero';
|
||||
import Container from './Container';
|
||||
|
||||
type Props = { children: ReactNode };
|
||||
|
||||
const Layout = ({ children }: Props) => {
|
||||
const Layout = (props: { locale: Locales }) => {
|
||||
const { locale } = props;
|
||||
return (
|
||||
<Container>
|
||||
<Hero />
|
||||
{children}
|
||||
<Outlet context={{ locale }} />
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
'use client';
|
||||
|
||||
import { ChatHeader } from '@lobehub/ui/mobile';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('changelog');
|
||||
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<ChatHeader
|
||||
center={
|
||||
@@ -23,7 +23,7 @@ const Header = memo(() => {
|
||||
}
|
||||
/>
|
||||
}
|
||||
onBackClick={() => router.back()}
|
||||
onBackClick={() => navigate(-1)}
|
||||
showBackButton
|
||||
style={mobileHeaderSticky}
|
||||
/>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
import { Locales } from '@/locales/resources';
|
||||
|
||||
import Hero from '../../features/Hero';
|
||||
import Header from './Header';
|
||||
|
||||
type Props = { children: ReactNode };
|
||||
|
||||
const Layout = ({ children }: Props) => {
|
||||
const Layout = (props: { locale: Locales }) => {
|
||||
const { locale } = props;
|
||||
return (
|
||||
<MobileContentLayout header={<Header />} padding={16}>
|
||||
<Hero />
|
||||
{children}
|
||||
<Outlet context={{ locale }} />
|
||||
</MobileContentLayout>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Typography } from '@lobehub/ui';
|
||||
import { Image } from '@lobehub/ui/mdx';
|
||||
import { Divider } from 'antd';
|
||||
import Link from 'next/link';
|
||||
import useSWR from 'swr';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import { CustomMDX } from '@/components/mdx';
|
||||
import Image from '@/components/mdx/Image';
|
||||
import { OFFICIAL_SITE } from '@/const/url';
|
||||
import { Locales } from '@/locales/resources';
|
||||
import { ChangelogService } from '@/server/services/changelog';
|
||||
@@ -14,14 +15,16 @@ import GridLayout from './GridLayout';
|
||||
import PublishedTime from './PublishedTime';
|
||||
import VersionTag from './VersionTag';
|
||||
|
||||
const Post = async ({
|
||||
const Post = ({
|
||||
id,
|
||||
mobile,
|
||||
versionRange,
|
||||
locale,
|
||||
}: ChangelogIndexItem & { branch?: string; locale: Locales; mobile?: boolean }) => {
|
||||
const changelogService = new ChangelogService();
|
||||
const data = await changelogService.getPostById(id, { locale });
|
||||
const { data } = useSWR([`changelog-post-${id}`, locale], async () => {
|
||||
const changelogService = new ChangelogService();
|
||||
return await changelogService.getPostById(id, { locale });
|
||||
});
|
||||
|
||||
if (!data || !data.title) return null;
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { Fragment } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
import { useOutletContext } from 'react-router-dom';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import NotFound from '@/components/404';
|
||||
import { Locales } from '@/locales/resources';
|
||||
import { ChangelogService } from '@/server/services/changelog';
|
||||
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
||||
|
||||
import GridLayout from './features/GridLayout';
|
||||
import Pagination from './features/Pagination';
|
||||
import Post from './features/Post';
|
||||
import UpdateChangelogStatus from './features/UpdateChangelogStatus';
|
||||
|
||||
const Page = (props: { isMobile: boolean }) => {
|
||||
const { locale } = useOutletContext<{ locale: Locales }>();
|
||||
const { isMobile } = props;
|
||||
const { hideDocs } = useServerConfigStore(featureFlagsSelectors);
|
||||
|
||||
const { data } = useSWR('changelog-index', async () => {
|
||||
const changelogService = new ChangelogService();
|
||||
return await changelogService.getChangelogIndex();
|
||||
});
|
||||
|
||||
if (hideDocs) return <NotFound />;
|
||||
|
||||
if (!data) return <NotFound />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flexbox gap={isMobile ? 16 : 48}>
|
||||
{data?.map((item) => (
|
||||
<Fragment key={item.id}>
|
||||
<Post locale={locale} mobile={isMobile} {...item} />
|
||||
</Fragment>
|
||||
))}
|
||||
</Flexbox>
|
||||
<GridLayout>
|
||||
<Pagination />
|
||||
</GridLayout>
|
||||
<UpdateChangelogStatus currentId={data[0]?.id} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const DesktopPage = () => {
|
||||
return <Page isMobile={false} />;
|
||||
};
|
||||
|
||||
const MobilePage = () => {
|
||||
return <Page isMobile={true} />;
|
||||
};
|
||||
|
||||
export { DesktopPage, MobilePage };
|
||||
@@ -1,10 +0,0 @@
|
||||
import ServerLayout from '@/components/server/ServerLayout';
|
||||
|
||||
import Desktop from './_layout/Desktop';
|
||||
import Mobile from './_layout/Mobile';
|
||||
|
||||
const MainLayout = ServerLayout({ Desktop, Mobile });
|
||||
|
||||
MainLayout.displayName = 'ChangelogLayout';
|
||||
|
||||
export default MainLayout;
|
||||
@@ -1,23 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
||||
|
||||
/**
|
||||
* @description: Changelog Modal (intercepting routes fallback when hard refresh)
|
||||
* @example: /changelog/modal => /changelog
|
||||
* @refs: https://github.com/lobehub/lobe-chat/discussions/2295#discussioncomment-9290942
|
||||
*/
|
||||
|
||||
const ChangelogModal = () => {
|
||||
const router = useQueryRoute();
|
||||
|
||||
useEffect(() => {
|
||||
router.replace('/changelog');
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default ChangelogModal;
|
||||
@@ -1,78 +0,0 @@
|
||||
import { Divider, Skeleton } from 'antd';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { Fragment, Suspense } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import Pagination from '@/app/[variants]/@modal/(.)changelog/modal/features/Pagination';
|
||||
import UpdateChangelogStatus from '@/app/[variants]/@modal/(.)changelog/modal/features/UpdateChangelogStatus';
|
||||
import StructuredData from '@/components/StructuredData';
|
||||
import { serverFeatureFlags } from '@/config/featureFlags';
|
||||
import { BRANDING_NAME } from '@/const/branding';
|
||||
import { OFFICIAL_SITE } from '@/const/url';
|
||||
import { ldModule } from '@/server/ld';
|
||||
import { metadataModule } from '@/server/metadata';
|
||||
import { ChangelogService } from '@/server/services/changelog';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DynamicLayoutProps } from '@/types/next';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import GridLayout from './features/GridLayout';
|
||||
import Post from './features/Post';
|
||||
|
||||
export const generateMetadata = async (props: DynamicLayoutProps) => {
|
||||
const locale = await RouteVariants.getLocale(props);
|
||||
const { t } = await translation('metadata', locale);
|
||||
return metadataModule.generate({
|
||||
canonical: urlJoin(OFFICIAL_SITE, 'changelog'),
|
||||
description: t('changelog.description', { appName: BRANDING_NAME }),
|
||||
title: t('changelog.title'),
|
||||
url: '/changelog',
|
||||
});
|
||||
};
|
||||
|
||||
const Page = async (props: DynamicLayoutProps) => {
|
||||
const hideDocs = serverFeatureFlags().hideDocs;
|
||||
if (hideDocs) return notFound();
|
||||
|
||||
const { isMobile, locale } = await RouteVariants.getVariantsFromProps(props);
|
||||
const { t } = await translation('metadata', locale);
|
||||
const changelogService = new ChangelogService();
|
||||
const data = await changelogService.getChangelogIndex();
|
||||
|
||||
if (!data) return notFound();
|
||||
|
||||
const ld = ldModule.generate({
|
||||
description: t('changelog.description', { appName: BRANDING_NAME }),
|
||||
title: t('changelog.title', { appName: BRANDING_NAME }),
|
||||
url: '/changelog',
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<StructuredData ld={ld} />
|
||||
<Flexbox gap={isMobile ? 16 : 48}>
|
||||
{data?.map((item) => (
|
||||
<Fragment key={item.id}>
|
||||
<Suspense
|
||||
fallback={
|
||||
<GridLayout>
|
||||
<Divider />
|
||||
<Skeleton active paragraph={{ rows: 5 }} />
|
||||
</GridLayout>
|
||||
}
|
||||
>
|
||||
<Post locale={locale} mobile={isMobile} {...item} />
|
||||
</Suspense>
|
||||
</Fragment>
|
||||
))}
|
||||
</Flexbox>
|
||||
<GridLayout>
|
||||
<Pagination />
|
||||
</GridLayout>
|
||||
<UpdateChangelogStatus currentId={data[0]?.id} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,83 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { memo, useEffect } from 'react';
|
||||
import { useMediaQuery } from 'react-responsive';
|
||||
import { MemoryRouter, Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
||||
|
||||
import MainChatPage from './components/MainChatPage';
|
||||
import SettingsPage from './components/SettingsPage';
|
||||
|
||||
// Get initial path from URL
|
||||
const getInitialPath = () => {
|
||||
if (typeof window === 'undefined') return '/';
|
||||
const fullPath = window.location.pathname;
|
||||
const searchParams = window.location.search;
|
||||
const chatIndex = fullPath.indexOf('/chat');
|
||||
|
||||
if (chatIndex !== -1) {
|
||||
const pathAfterChat = fullPath.slice(chatIndex + '/chat'.length) || '/';
|
||||
return pathAfterChat + searchParams;
|
||||
}
|
||||
return '/';
|
||||
};
|
||||
|
||||
// Helper component to sync URL with MemoryRouter
|
||||
const UrlSynchronizer = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Sync initial URL
|
||||
useEffect(() => {
|
||||
const fullPath = window.location.pathname;
|
||||
const searchParams = window.location.search;
|
||||
const chatIndex = fullPath.indexOf('/chat');
|
||||
|
||||
if (chatIndex !== -1) {
|
||||
const pathAfterChat = fullPath.slice(chatIndex + '/chat'.length) || '/';
|
||||
const targetPath = pathAfterChat + searchParams;
|
||||
|
||||
if (location.pathname + location.search !== targetPath) {
|
||||
navigate(targetPath, { replace: true });
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Update browser URL when location changes
|
||||
useEffect(() => {
|
||||
const normalizedPath = location.pathname === '/' ? '' : location.pathname;
|
||||
const newUrl = `/chat${normalizedPath}${location.search}`;
|
||||
if (window.location.pathname + window.location.search !== newUrl) {
|
||||
window.history.replaceState({}, '', newUrl);
|
||||
}
|
||||
}, [location.pathname, location.search]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const ChatRouter = memo(() => {
|
||||
const mobile = useMediaQuery({ maxWidth: 768 });
|
||||
const routes = (
|
||||
<Routes>
|
||||
<Route element={<MainChatPage mobile={true} />} path="/" />
|
||||
<Route element={<SettingsPage mobile={true} />} path="/settings" />
|
||||
<Route element={<Navigate replace to="/" />} path="*" />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
return (
|
||||
<MemoryRouter initialEntries={[getInitialPath()]} initialIndex={0}>
|
||||
<UrlSynchronizer />
|
||||
{mobile ? (
|
||||
// Mobile Layout
|
||||
routes
|
||||
) : (
|
||||
// Desktop Layout
|
||||
<MainChatPage mobile={false} />
|
||||
)}
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
ChatRouter.displayName = 'ChatRouter';
|
||||
|
||||
export default ChatRouter;
|
||||
@@ -1,22 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { PropsWithChildren, memo } from 'react';
|
||||
|
||||
import Desktop from './Desktop';
|
||||
import Mobile from './Mobile';
|
||||
|
||||
interface ChatLayoutProps extends PropsWithChildren {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const ChatLayout = memo<ChatLayoutProps>(({ children, mobile }) => {
|
||||
if (mobile) {
|
||||
return <Mobile>{children}</Mobile>;
|
||||
}
|
||||
|
||||
return <Desktop>{children}</Desktop>;
|
||||
});
|
||||
|
||||
ChatLayout.displayName = 'ChatLayout';
|
||||
|
||||
export default ChatLayout;
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Suspense } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import { isDesktop } from '@/const/version';
|
||||
import ProtocolUrlHandler from '@/features/ProtocolUrlHandler';
|
||||
|
||||
import { LayoutProps } from '../type';
|
||||
import RegisterHotkeys from './RegisterHotkeys';
|
||||
import SessionPanel from './SessionPanel';
|
||||
import Workspace from './Workspace';
|
||||
|
||||
const Layout = ({ children }: LayoutProps) => {
|
||||
const Layout = () => {
|
||||
return (
|
||||
<>
|
||||
<Flexbox
|
||||
@@ -19,14 +18,14 @@ const Layout = ({ children }: LayoutProps) => {
|
||||
width={'100%'}
|
||||
>
|
||||
<SessionPanel />
|
||||
<Workspace>{children}</Workspace>
|
||||
<Workspace>
|
||||
<Outlet />
|
||||
</Workspace>
|
||||
</Flexbox>
|
||||
{/* ↓ cloud slot ↓ */}
|
||||
|
||||
{/* ↑ cloud slot ↑ */}
|
||||
<Suspense>
|
||||
<RegisterHotkeys />
|
||||
</Suspense>
|
||||
<RegisterHotkeys />
|
||||
{isDesktop && <ProtocolUrlHandler />}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { withSuspense } from '@/components/withSuspense';
|
||||
import { useShowMobileWorkspace } from '@/hooks/useShowMobileWorkspace';
|
||||
|
||||
import SessionPanelContent from '../components/SessionPanel';
|
||||
import { LayoutProps } from './type';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
const useStyles = createStyles(({ css, token }) => ({
|
||||
main: css`
|
||||
@@ -18,7 +18,7 @@ const useStyles = createStyles(({ css, token }) => ({
|
||||
`,
|
||||
}));
|
||||
|
||||
const Layout = memo<LayoutProps>(({ children }) => {
|
||||
const Layout = memo(( ) => {
|
||||
const showMobileWorkspace = useShowMobileWorkspace();
|
||||
const { styles } = useStyles();
|
||||
|
||||
@@ -38,7 +38,7 @@ const Layout = memo<LayoutProps>(({ children }) => {
|
||||
style={showMobileWorkspace ? undefined : { display: 'none' }}
|
||||
width="100%"
|
||||
>
|
||||
{children}
|
||||
<Outlet />
|
||||
</Flexbox>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
|
||||
import TelemetryNotification from '../components/features/TelemetryNotification';
|
||||
import PageTitle from '../features/PageTitle';
|
||||
import WorkspaceLayout from './WorkspaceLayout';
|
||||
|
||||
interface MainChatPageProps {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const MainChatPage = memo<MainChatPageProps>(({ mobile }) => {
|
||||
return (
|
||||
<>
|
||||
<PageTitle />
|
||||
<WorkspaceLayout mobile={mobile} />
|
||||
<TelemetryNotification mobile={mobile} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
MainChatPage.displayName = 'MainChatPage';
|
||||
|
||||
export default MainChatPage;
|
||||
@@ -14,9 +14,6 @@ import ConversationArea from './ConversationArea';
|
||||
import PortalPanel from './PortalPanel';
|
||||
import TopicSidebar from './TopicSidebar';
|
||||
|
||||
interface WorkspaceLayoutProps {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const DesktopWorkspace = memo(() => (
|
||||
<>
|
||||
@@ -60,14 +57,4 @@ const MobileWorkspace = memo(() => (
|
||||
|
||||
MobileWorkspace.displayName = 'MobileWorkspace';
|
||||
|
||||
const WorkspaceLayout = memo<WorkspaceLayoutProps>(({ mobile }) => {
|
||||
if (mobile) {
|
||||
return <MobileWorkspace />;
|
||||
}
|
||||
|
||||
return <DesktopWorkspace />;
|
||||
});
|
||||
|
||||
WorkspaceLayout.displayName = 'WorkspaceLayout';
|
||||
|
||||
export default WorkspaceLayout;
|
||||
export { DesktopWorkspace, MobileWorkspace };
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { useQueryState } from 'nuqs';
|
||||
import { memo, useLayoutEffect } from 'react';
|
||||
import { createStoreUpdater } from 'zustand-utils';
|
||||
|
||||
import { useQueryState } from '@/hooks/useQueryParam';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
|
||||
// sync outside state to useChatStore
|
||||
@@ -34,7 +34,7 @@ const ChatHydration = memo(() => {
|
||||
unsubscribeTopic();
|
||||
unsubscribeThread();
|
||||
};
|
||||
}, []);
|
||||
}, [setTopic, setThread]); // ✅ 现在 setValue 是稳定的,可以安全地添加到依赖数组
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
+10
-12
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
import { useChatStore } from '@/store/chat';
|
||||
|
||||
@@ -10,21 +10,19 @@ import { useSend } from '../useSend';
|
||||
const MessageFromUrl = () => {
|
||||
const updateMessageInput = useChatStore((s) => s.updateMessageInput);
|
||||
const { send: sendMessage } = useSend();
|
||||
const searchParams = useSearchParams();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
const message = searchParams.get('message');
|
||||
if (message) {
|
||||
// Remove message from URL
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.delete('message');
|
||||
const newUrl = `${window.location.pathname}?${params.toString()}`;
|
||||
window.history.replaceState({}, '', newUrl);
|
||||
if (!message) return;
|
||||
|
||||
updateMessageInput(message);
|
||||
sendMessage();
|
||||
}
|
||||
}, [searchParams, updateMessageInput, sendMessage]);
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.delete('message');
|
||||
setSearchParams(params, { replace: true });
|
||||
|
||||
updateMessageInput(message);
|
||||
sendMessage();
|
||||
}, [searchParams, setSearchParams, updateMessageInput, sendMessage]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ import GroupChatInput from './GroupChat';
|
||||
|
||||
const Desktop = memo((props: { targetMemberId?: string }) => {
|
||||
const isGroupSession = useSessionStore(sessionSelectors.isCurrentSessionGroupSession);
|
||||
|
||||
return isGroupSession ? <GroupChatInput {...props} /> : <ClassicChatInput />;
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -75,6 +75,7 @@ const MainChatItem = memo<ThreadChatItemProps>(({ id, index }) => {
|
||||
endRender={showThread && <Thread id={id} placement={placement} />}
|
||||
id={id}
|
||||
index={index}
|
||||
isLatestItem={isLatestItem}
|
||||
/>
|
||||
{isLatestItem && <SupervisorThinkingTag />}
|
||||
</>
|
||||
|
||||
+21
-28
@@ -4,6 +4,7 @@ import { Icon } from '@lobehub/ui';
|
||||
import { Popover, Tooltip } from 'antd';
|
||||
import { createStyles, useTheme } from 'antd-style';
|
||||
import debug from 'debug';
|
||||
import isEqual from 'fast-deep-equal';
|
||||
import { ChevronDown, ChevronUp } from 'lucide-react';
|
||||
import { markdownToTxt } from 'markdown-to-txt';
|
||||
import { memo, useCallback, useMemo, useState, useSyncExternalStore } from 'react';
|
||||
@@ -11,13 +12,13 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import {
|
||||
getVirtuosoActiveIndex,
|
||||
getVirtuosoGlobalRef,
|
||||
subscribeVirtuosoActiveIndex,
|
||||
subscribeVirtuosoGlobalRef,
|
||||
getVirtuaActiveIndex,
|
||||
getVirtuaGlobalRef,
|
||||
subscribeVirtuaActiveIndex,
|
||||
subscribeVirtuaGlobalRef,
|
||||
} from '@/features/Conversation/components/VirtualizedList/VirtuosoContext';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
import { chatSelectors } from '@/store/chat/selectors';
|
||||
import { displayMessageSelectors } from '@/store/chat/selectors';
|
||||
|
||||
const log = debug('lobe-react:chat-minimap');
|
||||
|
||||
@@ -194,21 +195,17 @@ interface MinimapIndicator {
|
||||
width: number;
|
||||
}
|
||||
|
||||
const ChatMinimap = () => {
|
||||
const ChatMinimap = memo(() => {
|
||||
const { t } = useTranslation('chat');
|
||||
const { styles, cx } = useStyles();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const virtuosoRef = useSyncExternalStore(
|
||||
subscribeVirtuosoGlobalRef,
|
||||
getVirtuosoGlobalRef,
|
||||
() => null,
|
||||
);
|
||||
const virtuaRef = useSyncExternalStore(subscribeVirtuaGlobalRef, getVirtuaGlobalRef, () => null);
|
||||
const activeIndex = useSyncExternalStore(
|
||||
subscribeVirtuosoActiveIndex,
|
||||
getVirtuosoActiveIndex,
|
||||
subscribeVirtuaActiveIndex,
|
||||
getVirtuaActiveIndex,
|
||||
() => null,
|
||||
);
|
||||
const messages = useChatStore(chatSelectors.mainDisplayChats);
|
||||
const messages = useChatStore(displayMessageSelectors.mainAIChats, isEqual);
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
@@ -247,20 +244,19 @@ const ChatMinimap = () => {
|
||||
|
||||
const handleJump = useCallback(
|
||||
(virtIndex: number) => {
|
||||
virtuosoRef?.current?.scrollToIndex({
|
||||
virtuaRef?.current?.scrollToIndex(virtIndex, {
|
||||
align: 'start',
|
||||
behavior: 'smooth',
|
||||
index: virtIndex,
|
||||
// The current index detection will be off by 1, so we need to add 1 here
|
||||
offset: 6,
|
||||
smooth: true,
|
||||
});
|
||||
},
|
||||
[virtuosoRef],
|
||||
[virtuaRef],
|
||||
);
|
||||
|
||||
const handleStep = useCallback(
|
||||
(direction: 'prev' | 'next') => {
|
||||
const ref = virtuosoRef?.current;
|
||||
const ref = virtuaRef?.current;
|
||||
if (!ref || indicators.length === 0) return;
|
||||
|
||||
let targetPosition: number;
|
||||
@@ -303,14 +299,13 @@ const ChatMinimap = () => {
|
||||
|
||||
if (!targetIndicator) return;
|
||||
|
||||
ref.scrollToIndex({
|
||||
ref.scrollToIndex(targetIndicator.virtuosoIndex, {
|
||||
align: 'start',
|
||||
behavior: 'smooth',
|
||||
index: targetIndicator.virtuosoIndex,
|
||||
offset: 6,
|
||||
smooth: true,
|
||||
});
|
||||
},
|
||||
[activeIndex, activeIndicatorPosition, indicators, virtuosoRef],
|
||||
[activeIndex, activeIndicatorPosition, indicators, virtuaRef],
|
||||
);
|
||||
|
||||
if (indicators.length <= MIN_MESSAGES) return null;
|
||||
@@ -353,9 +348,7 @@ const ChatMinimap = () => {
|
||||
aria-label={t('minimap.jumpToMessage', { index: position + 1 })}
|
||||
className={styles.indicator}
|
||||
onClick={() => handleJump(virtuosoIndex)}
|
||||
style={{
|
||||
width,
|
||||
}}
|
||||
style={{ width }}
|
||||
type={'button'}
|
||||
>
|
||||
<div
|
||||
@@ -382,6 +375,6 @@ const ChatMinimap = () => {
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
export default memo(ChatMinimap);
|
||||
export default ChatMinimap;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { useQueryState } from 'nuqs';
|
||||
import { memo, useEffect, useLayoutEffect } from 'react';
|
||||
import { createStoreUpdater } from 'zustand-utils';
|
||||
|
||||
import { useFetchThreads } from '@/hooks/useFetchThreads';
|
||||
import { useQueryState } from '@/hooks/useQueryParam';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
|
||||
// sync outside state to useChatStore
|
||||
@@ -26,7 +26,7 @@ const ThreadHydration = memo(() => {
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
}, [setThread]); // ✅ 现在 setValue 是稳定的,可以安全地添加到依赖数组
|
||||
|
||||
// should open portal automatically when portalThread is set
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
'use client';
|
||||
|
||||
export { default } from '@/components/Error';
|
||||
@@ -3,7 +3,6 @@
|
||||
import { memo } from 'react';
|
||||
|
||||
import PageTitle from '@/components/PageTitle';
|
||||
import { withSuspense } from '@/components/withSuspense';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
import { topicSelectors } from '@/store/chat/selectors';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
@@ -16,4 +15,4 @@ const Title = memo(() => {
|
||||
return <PageTitle title={[topicTitle, agentTitle].filter(Boolean).join(' · ')} />;
|
||||
});
|
||||
|
||||
export default withSuspense(Title);
|
||||
export default Title;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
|
||||
import { DesktopWorkspace, MobileWorkspace } from './components/WorkspaceLayout';
|
||||
import TelemetryNotification from './components/features/TelemetryNotification';
|
||||
import PageTitle from './features/PageTitle';
|
||||
|
||||
const MobileChatPage = memo(() => {
|
||||
return (
|
||||
<>
|
||||
<PageTitle />
|
||||
<MobileWorkspace />
|
||||
<TelemetryNotification mobile={true} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
const DesktopChatPage = memo(() => {
|
||||
return (
|
||||
<>
|
||||
<PageTitle />
|
||||
<DesktopWorkspace />
|
||||
<TelemetryNotification mobile={false} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
export { DesktopChatPage, MobileChatPage };
|
||||
@@ -1,10 +0,0 @@
|
||||
import ServerLayout from '@/components/server/ServerLayout';
|
||||
import Desktop from './_layout/Desktop';
|
||||
import Mobile from './_layout/Mobile';
|
||||
import { LayoutProps } from './_layout/type';
|
||||
|
||||
const Layout = ServerLayout<LayoutProps>({ Desktop, Mobile });
|
||||
|
||||
Layout.displayName = 'ChatLayout';
|
||||
|
||||
export default Layout;
|
||||
@@ -1,3 +0,0 @@
|
||||
import Loading from '@/components/Loading/BrandTextLoading';
|
||||
|
||||
export default () => <Loading />;
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from '@/components/404';
|
||||
@@ -1,12 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
import { BrandTextLoading } from '@/components/Loading';
|
||||
|
||||
const ChatRouter = dynamic(() => import('./ChatRouter'), {
|
||||
loading: BrandTextLoading,
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
export default ChatRouter;
|
||||
@@ -1,14 +1,15 @@
|
||||
'use client';
|
||||
|
||||
import { useQueryState } from 'nuqs';
|
||||
import { parseAsString } from 'nuqs/server';
|
||||
import { memo, useEffect } from 'react';
|
||||
import { createStoreUpdater } from 'zustand-utils';
|
||||
|
||||
import { parseAsString, useQueryParam } from '@/hooks/useQueryParam';
|
||||
import { useAgentStore } from '@/store/agent';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
|
||||
const THROTTLE_DELAY = 50;
|
||||
|
||||
// sync outside state to useSessionStore
|
||||
const SessionHydration = memo(() => {
|
||||
const useStoreUpdater = createStoreUpdater(useSessionStore);
|
||||
@@ -17,10 +18,11 @@ const SessionHydration = memo(() => {
|
||||
const [switchTopic] = useChatStore((s) => [s.switchTopic]);
|
||||
|
||||
// two-way bindings the url and session store
|
||||
const [session, setSession] = useQueryState(
|
||||
'session',
|
||||
parseAsString.withDefault('inbox').withOptions({ history: 'replace', throttleMs: 50 }),
|
||||
);
|
||||
const [session, setSession] = useQueryParam('session', parseAsString.withDefault('inbox'), {
|
||||
history: 'replace',
|
||||
throttleMs: THROTTLE_DELAY,
|
||||
});
|
||||
|
||||
useStoreUpdater('activeId', session);
|
||||
useAgentStoreUpdater('activeId', session);
|
||||
useChatStoreUpdater('activeId', session);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Link from 'next/link';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
|
||||
import { INBOX_SESSION_ID } from '@/const/session';
|
||||
@@ -24,15 +24,12 @@ const Inbox = memo(() => {
|
||||
return (
|
||||
<Link
|
||||
aria-label={t('inbox.title')}
|
||||
href={SESSION_CHAT_URL(INBOX_SESSION_ID, mobile)}
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (activeId === INBOX_SESSION_ID && !mobile) {
|
||||
// If user tap the inbox again, open a new topic.
|
||||
// Only for desktop.
|
||||
const inboxMessages = chatSelectors.inboxActiveTopicMessages(getChatStoreState());
|
||||
|
||||
if (inboxMessages.length > 0) {
|
||||
await openNewTopicOrSaveTopic();
|
||||
}
|
||||
@@ -40,6 +37,7 @@ const Inbox = memo(() => {
|
||||
switchSession(INBOX_SESSION_ID);
|
||||
}
|
||||
}}
|
||||
to={SESSION_CHAT_URL(INBOX_SESSION_ID, mobile)}
|
||||
>
|
||||
<ListItem
|
||||
active={activeId === INBOX_SESSION_ID}
|
||||
|
||||
@@ -9,8 +9,8 @@ import LazyLoad from 'react-lazy-load';
|
||||
|
||||
import { SESSION_CHAT_URL } from '@/const/url';
|
||||
import { useSwitchSession } from '@/hooks/useSwitchSession';
|
||||
import { useSessionStore, getSessionStoreState } from '@/store/session';
|
||||
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
||||
import { getSessionStoreState, useSessionStore } from '@/store/session';
|
||||
import { sessionGroupSelectors, sessionSelectors } from '@/store/session/selectors';
|
||||
import { getUserStoreState } from '@/store/user';
|
||||
import { userProfileSelectors } from '@/store/user/selectors';
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { ActionIcon } from '@lobehub/ui';
|
||||
import { ChatHeader } from '@lobehub/ui/mobile';
|
||||
import { MessageSquarePlus } from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { ProductLogo } from '@/components/Branding';
|
||||
@@ -16,14 +16,14 @@ import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
|
||||
const Header = memo(() => {
|
||||
const [createSession] = useSessionStore((s) => [s.createSession]);
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const { showCreateSession } = useServerConfigStore(featureFlagsSelectors);
|
||||
|
||||
return (
|
||||
<ChatHeader
|
||||
left={
|
||||
<Flexbox align={'center'} gap={8} horizontal style={{ marginLeft: 8 }}>
|
||||
<UserAvatar onClick={() => router.push('/me')} size={32} />
|
||||
<UserAvatar onClick={() => navigate('/me')} size={32} />
|
||||
<ProductLogo type={'text'} />
|
||||
</Flexbox>
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { ChatHeader, ChatHeaderTitle } from '@lobehub/ui/chat';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { pathString } from '@/utils/url';
|
||||
|
||||
@@ -11,12 +11,12 @@ import HeaderContent from '../../features/HeaderContent';
|
||||
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('setting');
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<ChatHeader
|
||||
left={<ChatHeaderTitle title={t('header.session')} />}
|
||||
onBackClick={() => router.push(pathString('/chat', { search: location.search }))}
|
||||
onBackClick={() => navigate(pathString('/chat', { search: location.search }))}
|
||||
right={<HeaderContent />}
|
||||
showBackButton
|
||||
/>
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
import { ChatHeader } from '@lobehub/ui/mobile';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
||||
import { mobileHeaderSticky } from '@/styles/mobileHeader';
|
||||
|
||||
import HeaderContent from '../../features/HeaderContent';
|
||||
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('setting');
|
||||
const router = useQueryRoute();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<ChatHeader
|
||||
center={<ChatHeader.Title title={t('header.session')} />}
|
||||
onBackClick={() => router.push('/chat')}
|
||||
onBackClick={() => navigate(-1)}
|
||||
right={<HeaderContent />}
|
||||
showBackButton
|
||||
style={mobileHeaderSticky}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
'use client';
|
||||
|
||||
export { default } from '@/components/Error';
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
import { CheckCircleOutlined } from '@ant-design/icons';
|
||||
import { Button, Modal, Space } from 'antd';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
interface PublishResultModalProps {
|
||||
identifier?: string;
|
||||
@@ -13,13 +13,13 @@ interface PublishResultModalProps {
|
||||
}
|
||||
|
||||
const PublishResultModal = memo<PublishResultModalProps>(({ identifier, onCancel, open }) => {
|
||||
const router = useRouter();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation('setting');
|
||||
const { t: tCommon } = useTranslation('common');
|
||||
|
||||
const handleGoToMarket = () => {
|
||||
if (identifier) {
|
||||
router.push(`/discover/assistant/${identifier}`);
|
||||
navigate(`/discover/assistant/${identifier}`);
|
||||
}
|
||||
onCancel();
|
||||
};
|
||||
|
||||
+6
-35
@@ -8,12 +8,9 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
import PageTitle from '@/components/PageTitle';
|
||||
import SafeSpacing from '@/components/SafeSpacing';
|
||||
import { HEADER_HEIGHT } from '@/const/layoutTokens';
|
||||
import { useCategory } from '@/features/AgentSetting/AgentCategory/useCategory';
|
||||
import AgentSettings from '@/features/AgentSetting/AgentSettings';
|
||||
import Footer from '@/features/Setting/Footer';
|
||||
import SettingContainer from '@/features/Setting/SettingContainer';
|
||||
import { useInitAgentConfig } from '@/hooks/useInitAgentConfig';
|
||||
import { useAgentStore } from '@/store/agent';
|
||||
import { agentSelectors } from '@/store/agent/selectors';
|
||||
@@ -21,14 +18,9 @@ import { ChatSettingsTabs } from '@/store/global/initialState';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
import { sessionMetaSelectors } from '@/store/session/selectors';
|
||||
|
||||
import DesktopHeader from '../settings/_layout/Desktop/Header';
|
||||
import MobileHeader from '../settings/_layout/Mobile/Header';
|
||||
import MobileHeader from './_layout/Mobile/Header';
|
||||
|
||||
interface SettingsPageProps {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const SettingsPage = memo<SettingsPageProps>(({ mobile = false }) => {
|
||||
export default memo(() => {
|
||||
const { t } = useTranslation('setting');
|
||||
const [tab, setTab] = useState(ChatSettingsTabs.Prompt);
|
||||
const theme = useTheme();
|
||||
@@ -46,8 +38,8 @@ const SettingsPage = memo<SettingsPageProps>(({ mobile = false }) => {
|
||||
|
||||
const { isLoading } = useInitAgentConfig();
|
||||
|
||||
const content = (
|
||||
<>
|
||||
return (
|
||||
<MobileContentLayout header={<MobileHeader />}>
|
||||
<PageTitle title={t('header.sessionWithName', { name: title })} />
|
||||
<Tabs
|
||||
activeKey={tab}
|
||||
@@ -67,28 +59,7 @@ const SettingsPage = memo<SettingsPageProps>(({ mobile = false }) => {
|
||||
onMetaChange={updateAgentMeta}
|
||||
tab={tab}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
if (mobile) {
|
||||
return (
|
||||
<MobileContentLayout header={<MobileHeader />}>
|
||||
{content}
|
||||
<Footer />
|
||||
</MobileContentLayout>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<DesktopHeader />
|
||||
<SettingContainer addonAfter={<Footer />} addonBefore={<SafeSpacing height={HEADER_HEIGHT} />}>
|
||||
{content}
|
||||
</SettingContainer>
|
||||
</>
|
||||
<Footer />
|
||||
</MobileContentLayout>
|
||||
);
|
||||
});
|
||||
|
||||
SettingsPage.displayName = 'SettingsPage';
|
||||
|
||||
export default SettingsPage;
|
||||
@@ -1,3 +0,0 @@
|
||||
import SkeletonLoading from '@/components/Loading/SkeletonLoading';
|
||||
|
||||
export default () => <SkeletonLoading paragraph={{ rows: 8 }} />;
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from '@/components/404';
|
||||
@@ -0,0 +1,21 @@
|
||||
import React, { memo } from 'react';
|
||||
import { Link as ReactRouterLink, LinkProps as ReactRouterLinkProps } from 'react-router-dom';
|
||||
|
||||
interface LinkProps extends Omit<ReactRouterLinkProps, 'to'> {
|
||||
children?: React.ReactNode;
|
||||
href?: string;
|
||||
to?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link component for React Router
|
||||
* Provides a Next.js-like API (href prop) while using React Router internally
|
||||
*/
|
||||
const Link = memo<LinkProps>(({ href, to, ...props }) => {
|
||||
const linkTo = href || to || '/';
|
||||
return <ReactRouterLink {...props} to={linkTo} />;
|
||||
});
|
||||
|
||||
Link.displayName = 'Link';
|
||||
|
||||
export default Link;
|
||||
+15
-7
@@ -1,12 +1,19 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { SCROLL_PARENT_ID } from '@/app/[variants]/(main)/discover/features/const';
|
||||
import { SCROLL_PARENT_ID } from '../../../features/const';
|
||||
import Footer from '@/features/Setting/Footer';
|
||||
|
||||
const MAX_WIDTH = 1440;
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren) => {
|
||||
/**
|
||||
* Desktop Discover Detail Layout
|
||||
* Layout for detail pages (assistant, model, provider, mcp details)
|
||||
*/
|
||||
const DesktopDiscoverDetailLayout = memo(() => {
|
||||
return (
|
||||
<Flexbox
|
||||
align={'center'}
|
||||
@@ -17,14 +24,15 @@ const Layout = ({ children }: PropsWithChildren) => {
|
||||
width={'100%'}
|
||||
>
|
||||
<Flexbox gap={24} style={{ maxWidth: MAX_WIDTH, minHeight: '100%' }} width={'100%'}>
|
||||
{children}
|
||||
<Outlet />
|
||||
<div />
|
||||
<Footer />
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
Layout.displayName = 'DesktopDiscoverDetailLayout';
|
||||
DesktopDiscoverDetailLayout.displayName = 'DesktopDiscoverDetailLayout';
|
||||
|
||||
export default Layout;
|
||||
|
||||
export default DesktopDiscoverDetailLayout;
|
||||
@@ -1,22 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { PropsWithChildren, memo } from 'react';
|
||||
|
||||
import Desktop from './Desktop';
|
||||
import Mobile from './Mobile';
|
||||
|
||||
interface DetailLayoutProps extends PropsWithChildren {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const DetailLayout = memo<DetailLayoutProps>(({ children, mobile }) => {
|
||||
if (mobile) {
|
||||
return <Mobile>{children}</Mobile>;
|
||||
}
|
||||
|
||||
return <Desktop>{children}</Desktop>;
|
||||
});
|
||||
|
||||
DetailLayout.displayName = 'DetailLayout';
|
||||
|
||||
export default DetailLayout;
|
||||
@@ -1,15 +1,15 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { SCROLL_PARENT_ID } from '@/app/[variants]/(main)/discover/features/const';
|
||||
import MobileContentLayout from '@/components/server/MobileNavLayout';
|
||||
import Footer from '@/features/Setting/Footer';
|
||||
|
||||
import Header from './Header';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren) => {
|
||||
const Layout = () => {
|
||||
return (
|
||||
<MobileContentLayout gap={16} header={<Header />} id={SCROLL_PARENT_ID} padding={16}>
|
||||
{children}
|
||||
<Outlet />
|
||||
<div />
|
||||
<Footer />
|
||||
</MobileContentLayout>
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
import { memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import { withSuspense } from '@/components/withSuspense';
|
||||
import { useQuery } from '@/hooks/useQuery';
|
||||
import { useDiscoverStore } from '@/store/discover';
|
||||
import { AssistantMarketSource } from '@/types/discover';
|
||||
|
||||
import { TocProvider } from '../../features/Toc/useToc';
|
||||
import { DetailProvider } from './features/DetailProvider';
|
||||
import Details from './features/Details';
|
||||
import Header from './features/Header';
|
||||
import StatusPage from './features/StatusPage';
|
||||
import Loading from './loading';
|
||||
|
||||
interface ClientProps {
|
||||
identifier: string;
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const Client = memo<ClientProps>(({ identifier, mobile }) => {
|
||||
const { version, source } = useQuery() as { source?: AssistantMarketSource; version?: string };
|
||||
const marketSource = source as AssistantMarketSource | undefined;
|
||||
const useAssistantDetail = useDiscoverStore((s) => s.useAssistantDetail);
|
||||
const { data, isLoading } = useAssistantDetail({ identifier, source: marketSource, version });
|
||||
|
||||
if (isLoading) return <Loading />;
|
||||
if (!data) return notFound();
|
||||
|
||||
// 检查助手状态
|
||||
const status = (data as any)?.status;
|
||||
if (status === 'unpublished' || status === 'archived' || status === 'deprecated') {
|
||||
return <StatusPage status={status} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<TocProvider>
|
||||
<DetailProvider config={data}>
|
||||
<Flexbox gap={16}>
|
||||
<Header mobile={mobile} />
|
||||
<Details mobile={mobile} />
|
||||
</Flexbox>
|
||||
</DetailProvider>
|
||||
</TocProvider>
|
||||
);
|
||||
});
|
||||
|
||||
export default withSuspense(Client);
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { Tag } from '@lobehub/ui';
|
||||
import { ReactNode, memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import Title from '../../../../../../features/Title';
|
||||
import Title from '../../../../../features/Title';
|
||||
|
||||
interface BlockProps {
|
||||
children?: ReactNode;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user