@lobehub/chat 1.14.11 → 1.14.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/locales/ar/file.json +2 -1
  3. package/locales/bg-BG/file.json +2 -1
  4. package/locales/de-DE/file.json +2 -1
  5. package/locales/en-US/file.json +2 -1
  6. package/locales/es-ES/file.json +2 -1
  7. package/locales/fr-FR/file.json +2 -1
  8. package/locales/it-IT/file.json +2 -1
  9. package/locales/ja-JP/file.json +2 -1
  10. package/locales/ko-KR/file.json +2 -1
  11. package/locales/nl-NL/file.json +2 -1
  12. package/locales/pl-PL/file.json +2 -1
  13. package/locales/pt-BR/file.json +2 -1
  14. package/locales/ru-RU/file.json +2 -1
  15. package/locales/tr-TR/file.json +2 -1
  16. package/locales/vi-VN/file.json +2 -1
  17. package/locales/zh-CN/file.json +2 -1
  18. package/locales/zh-TW/file.json +2 -1
  19. package/package.json +1 -1
  20. package/src/components/FileParsingStatus/index.tsx +0 -2
  21. package/src/config/modelProviders/moonshot.ts +6 -6
  22. package/src/config/modelProviders/zeroone.ts +30 -29
  23. package/src/config/modelProviders/zhipu.ts +8 -8
  24. package/src/const/url.ts +3 -0
  25. package/src/features/FileViewer/NotSupport/index.tsx +15 -4
  26. package/src/features/FileViewer/Renderer/MSDoc/index.tsx +65 -0
  27. package/src/features/FileViewer/Renderer/index.ts +4 -0
  28. package/src/features/FileViewer/index.tsx +5 -5
  29. package/src/locales/default/file.ts +2 -1
  30. /package/src/features/FileViewer/{PDFViewer → Renderer/PDF}/HighlightLayer.tsx +0 -0
  31. /package/src/features/FileViewer/{PDFViewer → Renderer/PDF}/index.tsx +0 -0
  32. /package/src/features/FileViewer/{PDFViewer → Renderer/PDF}/style.ts +0 -0
  33. /package/src/features/FileViewer/{PDFViewer → Renderer/PDF}/useResizeObserver.ts +0 -0
  34. /package/src/features/FileViewer/{TXTViewer → Renderer/TXT}/index.tsx +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.14.12](https://github.com/lobehub/lobe-chat/compare/v1.14.11...v1.14.12)
6
+
7
+ <sup>Released on **2024-08-30**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: Fix ms doc file preview, Update the sorting of each provider model.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: Fix ms doc file preview, closes [#3686](https://github.com/lobehub/lobe-chat/issues/3686) ([2cd78cf](https://github.com/lobehub/lobe-chat/commit/2cd78cf))
21
+ - **misc**: Update the sorting of each provider model, closes [#3688](https://github.com/lobehub/lobe-chat/issues/3688) ([2630bbc](https://github.com/lobehub/lobe-chat/commit/2630bbc))
22
+
23
+ </details>
24
+
25
+ <div align="right">
26
+
27
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
28
+
29
+ </div>
30
+
5
31
  ### [Version 1.14.11](https://github.com/lobehub/lobe-chat/compare/v1.14.10...v1.14.11)
6
32
 
7
33
  <sup>Released on **2024-08-30**</sup>
@@ -56,7 +56,8 @@
56
56
  "title": "الوضع الحالي للنشر لا يدعم إدارة الملفات"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "هذا التنسيق غير مدعوم للمعاينة عبر الإنترنت"
59
+ "downloadFile": "تحميل الملف",
60
+ "unsupportedFileAndContact": "هذا التنسيق من الملفات غير مدعوم للمعاينة عبر الإنترنت، إذا كان لديك طلب للمعاينة، فلا تتردد في <1>إبلاغنا</1>"
60
61
  },
61
62
  "searchFilePlaceholder": "بحث عن ملف",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Текущият режим на инсталация не поддържа управление на файлове"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Този файлов формат не поддържа онлайн преглед"
59
+ "downloadFile": "Изтеглете файла",
60
+ "unsupportedFileAndContact": "Този формат на файла не поддържа онлайн преглед. Ако имате нужда от преглед, моля, <1>свържете се с нас</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Търсене на файл",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Der aktuelle Bereitstellungsmodus unterstützt keine Dateiverwaltung"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Dieses Dateiformat wird nicht für die Online-Vorschau unterstützt"
59
+ "downloadFile": "Datei herunterladen",
60
+ "unsupportedFileAndContact": "Dieses Dateiformat wird derzeit nicht für die Online-Vorschau unterstützt. Wenn Sie eine Vorschau wünschen, können Sie uns gerne <1>Feedback geben</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Datei suchen",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "The current deployment mode does not support file management"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "This file format does not support online preview"
59
+ "downloadFile": "Download File",
60
+ "unsupportedFileAndContact": "This file format is not currently supported for online preview. If you have a request for previewing, feel free to <1>contact us</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Search Files",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "El modo de despliegue actual no soporta la gestión de archivos"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Este formato de archivo no es compatible con la vista previa en línea"
59
+ "downloadFile": "Descargar archivo",
60
+ "unsupportedFileAndContact": "Este formato de archivo no es compatible con la vista previa en línea. Si desea solicitar una vista previa, no dude en <1>contactarnos</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Buscar archivo",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Le mode de déploiement actuel ne prend pas en charge la gestion des fichiers"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Ce format de fichier ne prend pas en charge l'aperçu en ligne"
59
+ "downloadFile": "Télécharger le fichier",
60
+ "unsupportedFileAndContact": "Ce format de fichier n'est pas encore pris en charge pour l'aperçu en ligne. Si vous souhaitez un aperçu, n'hésitez pas à <1>nous contacter</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Rechercher un fichier",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "La modalità di distribuzione attuale non supporta la gestione dei file"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Questo formato di file non supporta l'anteprima online"
59
+ "downloadFile": "Scarica file",
60
+ "unsupportedFileAndContact": "Questo formato di file non è attualmente supportato per la visualizzazione online. Se hai bisogno di una visualizzazione, ti preghiamo di <1>contattarci</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Cerca file",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "現在のデプロイメントモードはファイル管理をサポートしていません"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "このファイル形式はオンラインプレビューをサポートしていません"
59
+ "downloadFile": "ファイルをダウンロード",
60
+ "unsupportedFileAndContact": "このファイル形式はオンラインプレビューをサポートしていません。プレビューのリクエストがある場合は、ぜひ<1>ご連絡ください</1>。"
60
61
  },
61
62
  "searchFilePlaceholder": "ファイルを検索",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "현재 배포 모드는 파일 관리를 지원하지 않습니다."
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "파일 형식은 온라인 미리보기를 지원하지 않습니다."
59
+ "downloadFile": "파일 다운로드",
60
+ "unsupportedFileAndContact": "이 파일 형식은 온라인 미리보기를 지원하지 않습니다. 미리보기가 필요하신 경우, <1>저희에게 피드백을 주시기 바랍니다</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "파일 검색",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "De huidige implementatiemodus ondersteunt geen bestandsbeheer"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Dit bestandsformaat wordt niet ondersteund voor online preview"
59
+ "downloadFile": "Bestand downloaden",
60
+ "unsupportedFileAndContact": "Dit bestandsformaat wordt momenteel niet ondersteund voor online preview. Als u een preview wilt, neem dan gerust <1>contact met ons op</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Zoek bestand",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Obecny tryb wdrożenia nie obsługuje zarządzania plikami"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Ten format pliku nie jest obsługiwany w podglądzie online"
59
+ "downloadFile": "Pobierz plik",
60
+ "unsupportedFileAndContact": "Ten format pliku nie jest obecnie obsługiwany w podglądzie online. Jeśli chcesz uzyskać podgląd, zachęcamy do <1>skontaktowania się z nami</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Szukaj pliku",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "O modo de implantação atual não suporta gerenciamento de arquivos"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Este formato de arquivo não suporta visualização online"
59
+ "downloadFile": "Baixar arquivo",
60
+ "unsupportedFileAndContact": "Este formato de arquivo não é suportado para visualização online. Se você tiver interesse em visualizar, sinta-se à vontade para <1>nos enviar um feedback</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Pesquisar arquivo",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Текущий режим развертывания не поддерживает управление файлами"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Этот формат файла не поддерживает онлайн-просмотр"
59
+ "downloadFile": "Скачать файл",
60
+ "unsupportedFileAndContact": "Этот формат файла в настоящее время не поддерживает онлайн-просмотр. Если у вас есть запрос на просмотр, пожалуйста, <1>сообщите нам</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Поиск файла",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Mevcut dağıtım modu dosya yönetimini desteklemiyor"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Bu dosya formatı çevrimiçi önizleme desteklenmiyor"
59
+ "downloadFile": "Dosyayı İndir",
60
+ "unsupportedFileAndContact": "Bu dosya formatı çevrimiçi önizleme için desteklenmiyor. Önizleme talebiniz varsa, lütfen <1>bize geri bildirimde bulunun</1>."
60
61
  },
61
62
  "searchFilePlaceholder": "Dosya Ara",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "Chế độ triển khai hiện tại không hỗ trợ quản lý tệp"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "Định dạng tệp này không hỗ trợ xem trước trực tuyến"
59
+ "downloadFile": "Tải tệp",
60
+ "unsupportedFileAndContact": "Định dạng tệp này hiện không hỗ trợ xem trước trực tuyến. Nếu bạn có yêu cầu xem trước, vui lòng <1>phản hồi cho chúng tôi</1>"
60
61
  },
61
62
  "searchFilePlaceholder": "Tìm kiếm tệp",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "当前部署模式不支持文件管理"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "此文件格式不支持在线预览"
59
+ "downloadFile": "下载文件",
60
+ "unsupportedFileAndContact": "此文件格式暂不支持在线预览,如有预览诉求,欢迎<1>反馈给我们</1>"
60
61
  },
61
62
  "searchFilePlaceholder": "搜索文件",
62
63
  "tab": {
@@ -56,7 +56,8 @@
56
56
  "title": "當前部署模式不支持檔案管理"
57
57
  },
58
58
  "preview": {
59
- "unsupportedFile": "此檔案格式不支持在線預覽"
59
+ "downloadFile": "下載檔案",
60
+ "unsupportedFileAndContact": "此檔案格式暫不支援線上預覽,如有預覽需求,歡迎<1>反饋給我們</1>"
60
61
  },
61
62
  "searchFilePlaceholder": "搜索檔案",
62
63
  "tab": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.14.11",
3
+ "version": "1.14.12",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -104,8 +104,6 @@ const FileParsingStatus = memo<FileParsingStatusProps>(
104
104
  }
105
105
 
106
106
  case AsyncTaskStatus.Success: {
107
- console.log(embeddingStatus);
108
-
109
107
  // if no embedding status, it means that the embedding is not started
110
108
  if (!embeddingStatus || preparingEmbedding)
111
109
  return (
@@ -4,11 +4,11 @@ import { ModelProviderCard } from '@/types/llm';
4
4
  const Moonshot: ModelProviderCard = {
5
5
  chatModels: [
6
6
  {
7
- displayName: 'Moonshot V1 8K',
7
+ displayName: 'Moonshot V1 128K',
8
8
  enabled: true,
9
9
  functionCall: true,
10
- id: 'moonshot-v1-8k',
11
- tokens: 8192,
10
+ id: 'moonshot-v1-128k',
11
+ tokens: 128_000,
12
12
  },
13
13
  {
14
14
  displayName: 'Moonshot V1 32K',
@@ -18,11 +18,11 @@ const Moonshot: ModelProviderCard = {
18
18
  tokens: 32_768,
19
19
  },
20
20
  {
21
- displayName: 'Moonshot V1 128K',
21
+ displayName: 'Moonshot V1 8K',
22
22
  enabled: true,
23
23
  functionCall: true,
24
- id: 'moonshot-v1-128k',
25
- tokens: 128_000,
24
+ id: 'moonshot-v1-8k',
25
+ tokens: 8192,
26
26
  },
27
27
  ],
28
28
  checkModel: 'moonshot-v1-8k',
@@ -11,23 +11,39 @@ const ZeroOne: ModelProviderCard = {
11
11
  tokens: 32_768,
12
12
  },
13
13
  {
14
- description: '中型尺寸模型升级微调,能力均衡,性价比高。深度优化指令遵循能力。',
15
- displayName: 'Yi Medium',
14
+ description:
15
+ ' yi-large 模型的基础上支持并强化了工具调用的能力,适用于各种需要搭建 agent 或 workflow 的业务场景。',
16
+ displayName: 'Yi Large FC',
16
17
  enabled: true,
17
- id: 'yi-medium',
18
+ functionCall: true,
19
+ id: 'yi-large-fc',
20
+ tokens: 32_768,
21
+ },
22
+ {
23
+ description:
24
+ '基于 yi-large 超强模型的高阶服务,结合检索与生成技术提供精准答案,实时全网检索信息服务。',
25
+ displayName: 'Yi Large RAG',
26
+ enabled: true,
27
+ id: 'yi-large-rag',
18
28
  tokens: 16_384,
19
29
  },
20
30
  {
21
- description: '复杂视觉任务模型,提供高性能图片理解、分析能力。',
22
- displayName: 'Yi Vision',
31
+ description: '超高性价比、卓越性能。根据性能和推理速度、成本,进行平衡性高精度调优。',
32
+ displayName: 'Yi Large Turbo',
23
33
  enabled: true,
24
- id: 'yi-vision',
34
+ id: 'yi-large-turbo',
35
+ tokens: 16_384,
36
+ },
37
+ {
38
+ description: '中型尺寸模型升级微调,能力均衡,性价比高。深度优化指令遵循能力。',
39
+ displayName: 'Yi Medium',
40
+ enabled: true,
41
+ id: 'yi-medium',
25
42
  tokens: 16_384,
26
- vision: true,
27
43
  },
28
44
  {
29
45
  description: '200K 超长上下文窗口,提供长文本深度理解和生成能力。',
30
- displayName: 'Yi 200K',
46
+ displayName: 'Yi Medium 200K',
31
47
  enabled: true,
32
48
  id: 'yi-medium-200k',
33
49
  tokens: 200_000,
@@ -35,32 +51,17 @@ const ZeroOne: ModelProviderCard = {
35
51
  {
36
52
  description: '小而精悍,轻量极速模型。提供强化数学运算和代码编写能力。',
37
53
  displayName: 'Yi Spark',
38
- id: 'yi-spark',
39
- tokens: 16_384,
40
- },
41
- {
42
- description:
43
- '基于 yi-large 超强模型的高阶服务,结合检索与生成技术提供精准答案,实时全网检索信息服务。',
44
- displayName: 'Yi Large RAG',
45
54
  enabled: true,
46
- id: 'yi-large-rag',
55
+ id: 'yi-spark',
47
56
  tokens: 16_384,
48
57
  },
49
58
  {
50
- description:
51
- ' yi-large 模型的基础上支持并强化了工具调用的能力,适用于各种需要搭建 agent 或 workflow 的业务场景。',
52
- displayName: 'Yi Large FC',
53
- enabled: true,
54
- functionCall: true,
55
- id: 'yi-large-fc',
56
- tokens: 32_768,
57
- },
58
- {
59
- description: '超高性价比、卓越性能。根据性能和推理速度、成本,进行平衡性高精度调优。',
60
- displayName: 'Yi Large Turbo',
59
+ description: '复杂视觉任务模型,提供高性能图片理解、分析能力。',
60
+ displayName: 'Yi Vision',
61
61
  enabled: true,
62
- id: 'yi-large-turbo',
62
+ id: 'yi-vision',
63
63
  tokens: 16_384,
64
+ vision: true,
64
65
  },
65
66
  {
66
67
  description: '初期版本,推荐使用 yi-large(新版本)',
@@ -69,7 +70,7 @@ const ZeroOne: ModelProviderCard = {
69
70
  tokens: 16_384,
70
71
  },
71
72
  ],
72
- checkModel: 'yi-large',
73
+ checkModel: 'yi-spark',
73
74
  id: 'zeroone',
74
75
  name: '01.AI',
75
76
  };
@@ -5,14 +5,6 @@ import { ModelProviderCard } from '@/types/llm';
5
5
  // ref https://open.bigmodel.cn/modelcenter/square
6
6
  const ZhiPu: ModelProviderCard = {
7
7
  chatModels: [
8
- {
9
- description: '超长输入:专为处理超长文本和记忆型任务设计',
10
- displayName: 'GLM-4-Long',
11
- enabled: true,
12
- functionCall: true,
13
- id: 'glm-4-long',
14
- tokens: 1_024_000,
15
- },
16
8
  {
17
9
  description:
18
10
  'GLM-4-AllTools 是专门为支持智能体和相关任务而进一步优化的模型版本。它能够自主理解用户的意图,规划复杂的指令,并能够调用一个或多个工具(例如网络浏览器、代码解释器和文本生图像)以完成复杂的任务。',
@@ -60,6 +52,14 @@ const ZhiPu: ModelProviderCard = {
60
52
  id: 'glm-4-airx',
61
53
  tokens: 8192,
62
54
  },
55
+ {
56
+ description: '超长输入:专为处理超长文本和记忆型任务设计',
57
+ displayName: 'GLM-4-Long',
58
+ enabled: true,
59
+ functionCall: true,
60
+ id: 'glm-4-long',
61
+ tokens: 1_024_000,
62
+ },
63
63
  {
64
64
  description: '适用简单任务,速度最快,价格最实惠的版本',
65
65
  displayName: 'GLM-4-Flash',
package/src/const/url.ts CHANGED
@@ -47,6 +47,9 @@ export const PLUGINS_INDEX_URL = 'https://chat-plugins.lobehub.com';
47
47
  export const MORE_MODEL_PROVIDER_REQUEST_URL =
48
48
  'https://github.com/lobehub/lobe-chat/discussions/1284';
49
49
 
50
+ export const MORE_FILE_PREVIEW_REQUEST_URL =
51
+ 'https://github.com/lobehub/lobe-chat/discussions/3684';
52
+
50
53
  export const AGENTS_INDEX_GITHUB = 'https://github.com/lobehub/lobe-chat-agents';
51
54
  export const AGENTS_INDEX_GITHUB_ISSUE = urlJoin(AGENTS_INDEX_GITHUB, 'issues/new');
52
55
 
@@ -1,10 +1,13 @@
1
1
  import { IDocument } from '@cyntler/react-doc-viewer';
2
+ import { FluentEmoji } from '@lobehub/ui';
2
3
  import { Button } from 'antd';
3
4
  import { createStyles } from 'antd-style';
5
+ import Link from 'next/link';
4
6
  import React, { ComponentType, useState } from 'react';
5
- import { useTranslation } from 'react-i18next';
7
+ import { Trans, useTranslation } from 'react-i18next';
6
8
  import { Center, Flexbox } from 'react-layout-kit';
7
9
 
10
+ import { MORE_FILE_PREVIEW_REQUEST_URL } from '@/const/url';
8
11
  import { downloadFile } from '@/utils/client/downloadFile';
9
12
 
10
13
  const useStyles = createStyles(({ css, token }) => ({
@@ -25,7 +28,7 @@ const NotSupport: ComponentType<{
25
28
  }> = ({ fileName, document: doc }) => {
26
29
  const { styles } = useStyles();
27
30
 
28
- const { t } = useTranslation(['file', 'common']);
31
+ const { t } = useTranslation('file');
29
32
 
30
33
  const [loading, setLoading] = useState(false);
31
34
 
@@ -33,7 +36,15 @@ const NotSupport: ComponentType<{
33
36
  <Flexbox className={styles.page} id="txt-renderer">
34
37
  <Center height={'100%'}>
35
38
  <Flexbox align={'center'} gap={12}>
36
- {t('preview.unsupportedFile')}
39
+ <FluentEmoji emoji={'👀'} size={64} />
40
+ <Flexbox style={{ textAlign: 'center' }}>
41
+ <Trans i18nKey="preview.unsupportedFileAndContact" ns={'file'}>
42
+ 此文件格式暂不支持在线预览,如有预览诉求,欢迎
43
+ <Link aria-label={'todo'} href={MORE_FILE_PREVIEW_REQUEST_URL} target="_blank">
44
+ 反馈给我们
45
+ </Link>
46
+ </Trans>
47
+ </Flexbox>
37
48
  <Button
38
49
  loading={loading}
39
50
  onClick={async () => {
@@ -43,7 +54,7 @@ const NotSupport: ComponentType<{
43
54
  setLoading(false);
44
55
  }}
45
56
  >
46
- {t('download', { ns: 'common' })}
57
+ {t('preview.downloadFile')}
47
58
  </Button>
48
59
  </Flexbox>
49
60
  </Center>
@@ -0,0 +1,65 @@
1
+ import { DocRenderer } from '@cyntler/react-doc-viewer';
2
+ import { css, cx } from 'antd-style';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ const container = css`
6
+ position: relative;
7
+ overflow: hidden;
8
+ border-radius: 4px;
9
+ `;
10
+
11
+ const content = css`
12
+ position: absolute;
13
+ inset-block: -1px -1px;
14
+ inset-inline-start: -1px;
15
+
16
+ width: calc(100% + 2px);
17
+ height: calc(100% + 2px);
18
+
19
+ border: 0;
20
+ `;
21
+
22
+ const MSDocRenderer: DocRenderer = ({ mainState: { currentDocument } }) => {
23
+ if (!currentDocument) return null;
24
+
25
+ return (
26
+ <Flexbox className={cx(container)} height={'100%'} id="msdoc-renderer" width={'100%'}>
27
+ <iframe
28
+ className={cx(content)}
29
+ id="msdoc-iframe"
30
+ src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(
31
+ currentDocument.uri,
32
+ )}`}
33
+ title="msdoc-iframe"
34
+ />
35
+ </Flexbox>
36
+ );
37
+ };
38
+
39
+ export default MSDocRenderer;
40
+
41
+ const MSDocFTMaps = {
42
+ doc: ['doc', 'application/msword'],
43
+ docx: [
44
+ 'docx',
45
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
46
+ 'application/octet-stream',
47
+ ],
48
+ odt: ['odt', 'application/vnd.oasis.opendocument.text'],
49
+ ppt: ['ppt', 'application/vnd.ms-powerpoint'],
50
+ pptx: ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
51
+ xls: ['xls', 'application/vnd.ms-excel'],
52
+ xlsx: ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
53
+ };
54
+
55
+ MSDocRenderer.fileTypes = [
56
+ ...MSDocFTMaps.odt,
57
+ ...MSDocFTMaps.doc,
58
+ ...MSDocFTMaps.docx,
59
+ ...MSDocFTMaps.xls,
60
+ ...MSDocFTMaps.xlsx,
61
+ ...MSDocFTMaps.ppt,
62
+ ...MSDocFTMaps.pptx,
63
+ ];
64
+ MSDocRenderer.weight = 0;
65
+ MSDocRenderer.fileLoader = ({ fileLoaderComplete }) => fileLoaderComplete();
@@ -0,0 +1,4 @@
1
+ import MSDocRenderer from './MSDoc';
2
+ import TXTRenderer from './TXT';
3
+
4
+ export const FileViewRenderers = [TXTRenderer, MSDocRenderer];
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
 
3
- import DocViewer, { MSDocRenderer } from '@cyntler/react-doc-viewer';
3
+ import DocViewer from '@cyntler/react-doc-viewer';
4
4
  import { createStyles } from 'antd-style';
5
5
  import { CSSProperties, memo } from 'react';
6
6
 
7
7
  import { FileListItem } from '@/types/files';
8
8
 
9
9
  import NotSupport from './NotSupport';
10
- import PDFViewer from './PDFViewer';
11
- import TXTViewer from './TXTViewer';
10
+ import { FileViewRenderers } from './Renderer';
11
+ import PDFRenderer from './Renderer/PDF';
12
12
 
13
13
  const useStyles = createStyles(({ css, token }) => ({
14
14
  container: css`
@@ -25,7 +25,7 @@ interface FileViewerProps extends FileListItem {
25
25
  const FileViewer = memo<FileViewerProps>(({ id, style, fileType, url, name }) => {
26
26
  const { styles } = useStyles();
27
27
  if (fileType === 'pdf' || name.endsWith('.pdf')) {
28
- return <PDFViewer fileId={id} url={url} />;
28
+ return <PDFRenderer fileId={id} url={url} />;
29
29
  }
30
30
 
31
31
  return (
@@ -36,7 +36,7 @@ const FileViewer = memo<FileViewerProps>(({ id, style, fileType, url, name }) =>
36
36
  noRenderer: { overrideComponent: NotSupport },
37
37
  }}
38
38
  documents={[{ fileName: name, fileType, uri: url }]}
39
- pluginRenderers={[TXTViewer, MSDocRenderer]}
39
+ pluginRenderers={FileViewRenderers}
40
40
  style={style}
41
41
  />
42
42
  );
@@ -57,7 +57,8 @@ export default {
57
57
  title: '当前部署模式不支持文件管理',
58
58
  },
59
59
  preview: {
60
- unsupportedFile: '此文件格式不支持在线预览',
60
+ downloadFile: '下载文件',
61
+ unsupportedFileAndContact: '此文件格式暂不支持在线预览,如有预览诉求,欢迎<1>反馈给我们</1>',
61
62
  },
62
63
  searchFilePlaceholder: '搜索文件',
63
64
  tab: {