@lobehub/chat 1.81.7 → 1.81.9

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 (55) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/locales/ar/chat.json +10 -0
  4. package/locales/bg-BG/chat.json +10 -0
  5. package/locales/de-DE/chat.json +10 -0
  6. package/locales/en-US/chat.json +10 -0
  7. package/locales/es-ES/chat.json +10 -0
  8. package/locales/fa-IR/chat.json +10 -0
  9. package/locales/fr-FR/chat.json +10 -0
  10. package/locales/it-IT/chat.json +10 -0
  11. package/locales/ja-JP/chat.json +10 -0
  12. package/locales/ko-KR/chat.json +10 -0
  13. package/locales/nl-NL/chat.json +10 -0
  14. package/locales/pl-PL/chat.json +10 -0
  15. package/locales/pt-BR/chat.json +10 -0
  16. package/locales/ru-RU/chat.json +10 -0
  17. package/locales/tr-TR/chat.json +10 -0
  18. package/locales/vi-VN/chat.json +10 -0
  19. package/locales/zh-CN/chat.json +10 -0
  20. package/locales/zh-TW/chat.json +10 -0
  21. package/package.json +1 -1
  22. package/packages/electron-client-ipc/src/events/localFile.ts +8 -2
  23. package/packages/electron-client-ipc/src/events/system.ts +3 -0
  24. package/packages/electron-client-ipc/src/types/index.ts +1 -0
  25. package/packages/electron-client-ipc/src/types/localFile.ts +46 -0
  26. package/packages/electron-client-ipc/src/types/system.ts +24 -0
  27. package/packages/file-loaders/src/blackList.ts +9 -0
  28. package/packages/file-loaders/src/index.ts +1 -0
  29. package/packages/file-loaders/src/loaders/pdf/index.test.ts +1 -0
  30. package/packages/file-loaders/src/loaders/pdf/index.ts +1 -7
  31. package/src/components/FileIcon/index.tsx +7 -3
  32. package/src/features/Conversation/Extras/Usage/UsageDetail/index.tsx +31 -4
  33. package/src/features/Conversation/Extras/Usage/index.tsx +1 -1
  34. package/src/libs/agent-runtime/anthropic/index.ts +7 -3
  35. package/src/libs/agent-runtime/perplexity/index.test.ts +4 -1
  36. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +17 -8
  37. package/src/libs/agent-runtime/utils/streams/anthropic.test.ts +11 -5
  38. package/src/libs/agent-runtime/utils/streams/anthropic.ts +11 -2
  39. package/src/libs/agent-runtime/utils/streams/openai.ts +5 -2
  40. package/src/libs/agent-runtime/utils/streams/protocol.test.ts +67 -1
  41. package/src/libs/agent-runtime/utils/streams/protocol.ts +46 -1
  42. package/src/locales/default/chat.ts +11 -0
  43. package/src/services/electron/localFileService.ts +19 -0
  44. package/src/services/electron/system.ts +21 -0
  45. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +2 -2
  46. package/src/store/chat/slices/builtinTool/actions/search.ts +0 -3
  47. package/src/tools/local-files/Render/ListFiles/index.tsx +24 -17
  48. package/src/tools/local-files/Render/ReadLocalFile/ReadFileView.tsx +28 -28
  49. package/src/tools/local-files/components/FileItem.tsx +9 -11
  50. package/src/tools/local-files/index.ts +60 -2
  51. package/src/tools/local-files/systemRole.ts +53 -13
  52. package/src/tools/local-files/type.ts +19 -1
  53. package/src/tools/web-browsing/systemRole.ts +40 -38
  54. package/src/types/message/base.ts +8 -0
  55. package/src/utils/fetch/fetchSSE.ts +17 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.81.9](https://github.com/lobehub/lobe-chat/compare/v1.81.8...v1.81.9)
6
+
7
+ <sup>Released on **2025-04-21**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix search prompt.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix search prompt, closes [#7507](https://github.com/lobehub/lobe-chat/issues/7507) ([f55b7de](https://github.com/lobehub/lobe-chat/commit/f55b7de))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.81.8](https://github.com/lobehub/lobe-chat/compare/v1.81.7...v1.81.8)
31
+
32
+ <sup>Released on **2025-04-21**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Show token generate performance.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Show token generate performance, closes [#6959](https://github.com/lobehub/lobe-chat/issues/6959) ([33c3fe7](https://github.com/lobehub/lobe-chat/commit/33c3fe7))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 1.81.7](https://github.com/lobehub/lobe-chat/compare/v1.81.6...v1.81.7)
6
56
 
7
57
  <sup>Released on **2025-04-21**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix search prompt."
6
+ ]
7
+ },
8
+ "date": "2025-04-21",
9
+ "version": "1.81.9"
10
+ },
11
+ {
12
+ "children": {
13
+ "improvements": [
14
+ "Show token generate performance."
15
+ ]
16
+ },
17
+ "date": "2025-04-21",
18
+ "version": "1.81.8"
19
+ },
2
20
  {
3
21
  "children": {
4
22
  "fixes": [
@@ -119,6 +119,16 @@
119
119
  "outputText": "مخرجات نصية",
120
120
  "outputTitle": "تفاصيل المخرجات",
121
121
  "reasoning": "تفكير عميق",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "عدد الرموز في الثانية، TPS. يشير إلى متوسط سرعة توليد المحتوى بواسطة الذكاء الاصطناعي (رمز/ثانية)، ويبدأ الحساب عند استلام أول رمز."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "الوقت حتى أول رمز، TTFT. يشير إلى الفارق الزمني من لحظة إرسال الرسالة حتى استلام أول رمز في العميل."
130
+ }
131
+ },
122
132
  "title": "تفاصيل التوليد",
123
133
  "total": "الإجمالي المستهلك"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Текстов изход",
120
120
  "outputTitle": "Детайли за изхода",
121
121
  "reasoning": "Дълбочинно разсъждение",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Токени на секунда, TPS. Отнася се до средната скорост на генериране на съдържание от AI (Токен/секунда), започвайки да се изчислява след получаване на първия токен."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Време до първия токен, TTFT. Отнася се до времевия интервал от изпращането на съобщението до получаването на първия токен от клиента."
130
+ }
131
+ },
122
132
  "title": "Детайли за генериране",
123
133
  "total": "Общо разходи"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Text-Ausgabe",
120
120
  "outputTitle": "Ausgabedetails",
121
121
  "reasoning": "Tiefes Denken",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens pro Sekunde, TPS. Bezieht sich auf die durchschnittliche Geschwindigkeit, mit der AI-Inhalte generiert werden (Token/Sekunde), und beginnt mit der Berechnung, nachdem das erste Token empfangen wurde."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Zeit bis zum ersten Token, TTFT. Bezieht sich auf das Zeitintervall von dem Moment, in dem Sie eine Nachricht senden, bis der Client das erste Token erhält."
130
+ }
131
+ },
122
132
  "title": "Generierungsdetails",
123
133
  "total": "Gesamter Verbrauch"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Text Output",
120
120
  "outputTitle": "Output Details",
121
121
  "reasoning": "Deep Thinking",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Per Second (TPS). This indicates the average speed of AI-generated content (Tokens/second), calculated from the moment the first Token is received."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Time To First Token (TTFT). This refers to the time interval from when you send a message to when the client receives the first Token."
130
+ }
131
+ },
122
132
  "title": "Generation Details",
123
133
  "total": "Total Consumption"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Salida de texto",
120
120
  "outputTitle": "Detalles de salida",
121
121
  "reasoning": "Razonamiento profundo",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Por Segundo, TPS. Se refiere a la velocidad promedio de generación de contenido por la IA (Token/segundo), comenzando a contar desde que se recibe el primer Token."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Tiempo Hasta el Primer Token, TTFT. Se refiere al intervalo de tiempo desde que envía un mensaje hasta que el cliente recibe el primer Token."
130
+ }
131
+ },
122
132
  "title": "Detalles de generación",
123
133
  "total": "Total consumido"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "خروجی متنی",
120
120
  "outputTitle": "جزئیات خروجی",
121
121
  "reasoning": "تفکر عمیق",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "تعداد توکن در ثانیه، TPS. به میانگین سرعت تولید محتوای AI اشاره دارد (توکن/ثانیه) و از زمان دریافت اولین توکن شروع به محاسبه می‌شود."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "زمان تا اولین توکن، TTFT. به فاصله زمانی بین ارسال پیام شما و دریافت اولین توکن توسط کلاینت اشاره دارد."
130
+ }
131
+ },
122
132
  "title": "جزئیات تولید",
123
133
  "total": "مجموع مصرف"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Sortie texte",
120
120
  "outputTitle": "Détails de la sortie",
121
121
  "reasoning": "Raisonnement approfondi",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Par Seconde, TPS. Indique la vitesse moyenne de génération de contenu par l'IA (Token/seconde), calculée à partir de la réception du premier Token."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Temps Jusqu'au Premier Token, TTFT. Indique l'intervalle de temps entre l'envoi de votre message et la réception du premier Token par le client."
130
+ }
131
+ },
122
132
  "title": "Détails de génération",
123
133
  "total": "Total consommé"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Output testo",
120
120
  "outputTitle": "Dettagli output",
121
121
  "reasoning": "Ragionamento profondo",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Token Per Second, TPS. Indica la velocità media di generazione dei contenuti da parte dell'AI (Token/secondo), calcolata a partire dalla ricezione del primo Token."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Time To First Token, TTFT. Indica l'intervallo di tempo che intercorre tra l'invio del messaggio e la ricezione del primo Token da parte del client."
130
+ }
131
+ },
122
132
  "title": "Dettagli generati",
123
133
  "total": "Totale consumato"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "テキスト出力",
120
120
  "outputTitle": "出力の詳細",
121
121
  "reasoning": "深い思考",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "トークン毎秒(TPS)。AIが生成するコンテンツの平均速度(トークン/秒)を示し、最初のトークンを受信した時点から計算が始まります。"
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "最初のトークンまでの時間(TTFT)。メッセージを送信してからクライアントが最初のトークンを受信するまでの時間間隔を示します。"
130
+ }
131
+ },
122
132
  "title": "生成の詳細",
123
133
  "total": "合計消費"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "텍스트 출력",
120
120
  "outputTitle": "출력 세부사항",
121
121
  "reasoning": "심층 사고",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "초당 토큰 수(TPS). AI가 생성한 콘텐츠의 평균 속도(토큰/초)를 나타내며, 첫 번째 토큰을 수신한 후부터 계산됩니다."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "첫 번째 토큰까지의 시간(Time To First Token, TTFT). 메시지를 전송한 시점부터 클라이언트가 첫 번째 토큰을 수신할 때까지의 시간 간격을 나타냅니다."
130
+ }
131
+ },
122
132
  "title": "생성 세부사항",
123
133
  "total": "총 소모"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Tekstuitvoer",
120
120
  "outputTitle": "Uitvoerdetails",
121
121
  "reasoning": "Diep nadenken",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Per Second, TPS. Dit verwijst naar de gemiddelde snelheid van AI-gegenereerde inhoud (Token/seconde), die begint te tellen vanaf het moment dat het eerste Token is ontvangen."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Time To First Token, TTFT. Dit verwijst naar de tijdsduur van het moment dat u een bericht verzendt tot het moment dat de client het eerste Token ontvangt."
130
+ }
131
+ },
122
132
  "title": "Genereren van details",
123
133
  "total": "Totaal verbruik"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Wyjście tekstowe",
120
120
  "outputTitle": "Szczegóły wyjścia",
121
121
  "reasoning": "Głębokie myślenie",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokeny na sekundę, TPS. Oznacza średnią prędkość generowania treści przez AI (Tokeny/sekundę), obliczaną od momentu otrzymania pierwszego Tokena."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Czas do pierwszego tokena, TTFT. Oznacza czas od momentu wysłania wiadomości do momentu, w którym klient otrzymuje pierwszy Token."
130
+ }
131
+ },
122
132
  "title": "Szczegóły generacji",
123
133
  "total": "Całkowite zużycie"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Saída de texto",
120
120
  "outputTitle": "Detalhes da saída",
121
121
  "reasoning": "Raciocínio profundo",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Por Segundo, TPS. Refere-se à velocidade média de geração de conteúdo pela IA (Token/segundo), começando a contagem após o recebimento do primeiro Token."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Tempo Para o Primeiro Token, TTFT. Refere-se ao intervalo de tempo desde que você envia a mensagem até que o cliente receba o primeiro Token."
130
+ }
131
+ },
122
132
  "title": "Detalhes da geração",
123
133
  "total": "Total consumido"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Текстовый выход",
120
120
  "outputTitle": "Детали выхода",
121
121
  "reasoning": "Глубокое мышление",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Токены в секунду (TPS). Средняя скорость генерации контента ИИ (Токенов/сек), начинается с момента получения первого токена."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Время до первого токена (TTFT). Время, прошедшее с момента отправки вами сообщения до получения первого токена клиентом."
130
+ }
131
+ },
122
132
  "title": "Детали генерации",
123
133
  "total": "Общее потребление"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Metin çıkışı",
120
120
  "outputTitle": "Çıkış detayları",
121
121
  "reasoning": "Derin düşünme",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Token Başına Saniye, TPS. AI tarafından üretilen içeriğin ortalama hızını (Token/saniye) belirtir, ilk Token alındıktan sonra hesaplanmaya başlanır."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "İlk Token'a Kadar Geçen Süre, TTFT. Mesajınızı göndermenizden, istemcinin ilk Token'ı almasına kadar geçen zaman aralığını belirtir."
130
+ }
131
+ },
122
132
  "title": "Üretim detayları",
123
133
  "total": "Toplam tüketim"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "Văn bản xuất",
120
120
  "outputTitle": "Chi tiết xuất",
121
121
  "reasoning": "Suy nghĩ sâu sắc",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Mỗi Giây, TPS. Chỉ tốc độ trung bình của nội dung do AI tạo ra (Token/giây), bắt đầu tính từ khi nhận được Token đầu tiên."
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Thời Gian Đến Token Đầu Tiên, TTFT. Chỉ khoảng thời gian từ khi bạn gửi tin nhắn đến khi khách hàng nhận được Token đầu tiên."
130
+ }
131
+ },
122
132
  "title": "Chi tiết tạo ra",
123
133
  "total": "Tổng tiêu thụ"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "文本输出",
120
120
  "outputTitle": "输出明细",
121
121
  "reasoning": "深度思考",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "Tokens Per Second,TPS。指AI生成内容的平均速度(Token/秒),在接收到首个 Token 后开始计算。"
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "Time To First Token,TTFT。指从您发送消息到客户端接收到首个 Token 的时间间隔。"
130
+ }
131
+ },
122
132
  "title": "生成明细",
123
133
  "total": "总计消耗"
124
134
  }
@@ -119,6 +119,16 @@
119
119
  "outputText": "文本輸出",
120
120
  "outputTitle": "輸出明細",
121
121
  "reasoning": "深度思考",
122
+ "speed": {
123
+ "tps": {
124
+ "title": "TPS",
125
+ "tooltip": "每秒令牌數,TPS。指AI生成內容的平均速度(Token/秒),在接收到首個令牌後開始計算。"
126
+ },
127
+ "ttft": {
128
+ "title": "TTFT",
129
+ "tooltip": "首次令牌時間,TTFT。指從您發送消息到客戶端接收到首個令牌的時間間隔。"
130
+ }
131
+ },
122
132
  "title": "生成明細",
123
133
  "total": "總計消耗"
124
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.81.7",
3
+ "version": "1.81.9",
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",
@@ -1,22 +1,28 @@
1
1
  import {
2
2
  ListLocalFileParams,
3
3
  LocalFileItem,
4
+ LocalMoveFilesResultItem,
4
5
  LocalReadFileParams,
5
6
  LocalReadFileResult,
6
7
  LocalReadFilesParams,
7
8
  LocalSearchFilesParams,
9
+ MoveLocalFilesParams,
8
10
  OpenLocalFileParams,
9
11
  OpenLocalFolderParams,
12
+ RenameLocalFileParams,
13
+ RenameLocalFileResult,
10
14
  } from '../types';
11
15
 
12
16
  export interface LocalFilesDispatchEvents {
13
17
  // Local Files API Events
14
18
  listLocalFiles: (params: ListLocalFileParams) => LocalFileItem[];
15
- // New methods
19
+ moveLocalFiles: (params: MoveLocalFilesParams) => LocalMoveFilesResultItem[];
20
+
16
21
  openLocalFile: (params: OpenLocalFileParams) => void;
17
22
  openLocalFolder: (params: OpenLocalFolderParams) => void;
18
23
  readLocalFile: (params: LocalReadFileParams) => LocalReadFileResult;
19
-
20
24
  readLocalFiles: (params: LocalReadFilesParams) => LocalReadFileResult[];
25
+
26
+ renameLocalFile: (params: RenameLocalFileParams) => RenameLocalFileResult;
21
27
  searchLocalFiles: (params: LocalSearchFilesParams) => LocalFileItem[];
22
28
  }
@@ -1,5 +1,8 @@
1
+ import { ElectronAppState } from '../types';
2
+
1
3
  export interface SystemDispatchEvents {
2
4
  checkSystemAccessibility: () => boolean | undefined;
5
+ getDesktopAppState: () => ElectronAppState;
3
6
  /**
4
7
  * 更新应用语言设置
5
8
  * @param locale 语言设置
@@ -3,5 +3,6 @@ export * from './localFile';
3
3
  export * from './remoteServer';
4
4
  export * from './route';
5
5
  export * from './shortcut';
6
+ export * from './system';
6
7
  export * from './update';
7
8
  export * from './upload';
@@ -19,7 +19,35 @@ export interface ListLocalFileParams {
19
19
  path: string;
20
20
  }
21
21
 
22
+ export interface MoveLocalFileParams {
23
+ newPath: string;
24
+ oldPath: string;
25
+ }
26
+
27
+ export interface MoveLocalFilesParams {
28
+ items: MoveLocalFileParams[];
29
+ }
30
+
31
+ export interface LocalMoveFilesResultItem {
32
+ error?: string; // Error message if this specific item failed
33
+ newPath?: string; // The final path after moving/renaming, if successful
34
+ sourcePath: string; // The original path of the item being moved/renamed
35
+ success: boolean; // Whether the operation for this specific item was successful
36
+ }
37
+
38
+ export interface RenameLocalFileParams {
39
+ newName: string;
40
+ path: string;
41
+ }
42
+
43
+ export interface RenameLocalFileResult {
44
+ error?: any;
45
+ newPath: string;
46
+ success: boolean;
47
+ }
48
+
22
49
  export interface LocalReadFileParams {
50
+ loc?: [number, number];
23
51
  path: string;
24
52
  }
25
53
 
@@ -28,13 +56,31 @@ export interface LocalReadFilesParams {
28
56
  }
29
57
 
30
58
  export interface LocalReadFileResult {
59
+ /**
60
+ * Character count of the content within the specified `loc` range.
61
+ */
31
62
  charCount: number;
63
+ /**
64
+ * Content of the file within the specified `loc` range.
65
+ */
32
66
  content: string;
33
67
  createdTime: Date;
34
68
  fileType: string;
35
69
  filename: string;
70
+ /**
71
+ * Line count of the content within the specified `loc` range.
72
+ */
36
73
  lineCount: number;
74
+ loc: [number, number];
37
75
  modifiedTime: Date;
76
+ /**
77
+ * Total character count of the entire file.
78
+ */
79
+ totalCharCount: number;
80
+ /**
81
+ * Total line count of the entire file.
82
+ */
83
+ totalLineCount: number;
38
84
  }
39
85
 
40
86
  export interface LocalSearchFilesParams {
@@ -0,0 +1,24 @@
1
+ export interface ElectronAppState {
2
+ arch?: string; // e.g., 'x64', 'arm64'
3
+ isLinux?: boolean;
4
+ isMac?: boolean;
5
+ isWindows?: boolean;
6
+ platform?: 'darwin' | 'win32' | 'linux'; // , etc.
7
+ userPath?: UserPathData;
8
+ }
9
+
10
+ /**
11
+ * Defines the structure for user-specific paths obtained from Electron.
12
+ */
13
+ export interface UserPathData {
14
+ desktop: string;
15
+ documents: string;
16
+ downloads?: string;
17
+ // App data directory
18
+ home: string;
19
+ // Optional as not all OS might have it easily accessible or standard
20
+ music?: string;
21
+ pictures?: string;
22
+ userData: string;
23
+ videos?: string; // User's home directory
24
+ }
@@ -0,0 +1,9 @@
1
+ // List of system files/directories to ignore
2
+ export const SYSTEM_FILES_TO_IGNORE = [
3
+ '.DS_Store',
4
+ 'Thumbs.db',
5
+ 'desktop.ini',
6
+ '.localized',
7
+ 'ehthumbs.db',
8
+ 'ehthumbs_vista.db',
9
+ ];
@@ -1,2 +1,3 @@
1
+ export * from './blackList';
1
2
  export * from './loadFile';
2
3
  export * from './types';
@@ -42,6 +42,7 @@ describe('PdfLoader', () => {
42
42
 
43
43
  it('should attach document metadata correctly', async () => {
44
44
  // 首先加载页面以初始化 pdfInstance,尽管此方法不直接使用页面
45
+ await loader.loadPages(testFile);
45
46
  const metadata = await loader.attachDocumentMetadata!(testFile);
46
47
 
47
48
  expect(metadata).toMatchSnapshot();
@@ -11,8 +11,6 @@ export class PdfLoader implements FileLoaderInterface {
11
11
  private pdfInstance: PDFDocumentProxy | null = null;
12
12
 
13
13
  private async getPDFFile(filePath: string) {
14
- if (!!this.pdfInstance) return this.pdfInstance;
15
-
16
14
  const dataBuffer = await readFile(filePath);
17
15
 
18
16
  const loadingTask = pdfjsLib.getDocument({
@@ -22,11 +20,7 @@ export class PdfLoader implements FileLoaderInterface {
22
20
  worker: undefined, // Attempt to use system fonts
23
21
  });
24
22
 
25
- const pdf: PDFDocumentProxy = await loadingTask.promise;
26
-
27
- this.pdfInstance = pdf;
28
-
29
- return pdf;
23
+ return await loadingTask.promise;
30
24
  }
31
25
 
32
26
  async loadPages(filePath: string): Promise<DocumentPage[]> {
@@ -1,16 +1,20 @@
1
1
  import { FileTypeIcon, MaterialFileTypeIcon } from '@lobehub/ui';
2
- import { memo } from 'react';
2
+ import React, { memo } from 'react';
3
3
 
4
4
  import { mimeTypeMap } from './config';
5
5
 
6
6
  interface FileListProps {
7
7
  fileName: string;
8
- fileType: string;
8
+ fileType?: string;
9
+ isDirectory?: boolean;
9
10
  size?: number;
10
11
  variant?: 'pure' | 'file' | 'folder';
11
12
  }
12
13
 
13
- const FileIcon = memo<FileListProps>(({ fileName, size, variant = 'file' }) => {
14
+ const FileIcon = memo<FileListProps>(({ fileName, size, variant = 'file', isDirectory }) => {
15
+ if (isDirectory)
16
+ return <FileTypeIcon color={'gold'} size={size} type={'folder'} variant={'color'} />;
17
+
14
18
  if (Object.keys(mimeTypeMap).some((key) => fileName?.toLowerCase().endsWith(`.${key}`))) {
15
19
  const ext = fileName.split('.').pop()?.toLowerCase() as string;
16
20