Compare commits

...

335 Commits

Author SHA1 Message Date
kangfenmao
94d9b79957 chore(version): 1.0.2 2025-03-01 12:25:33 +08:00
kangfenmao
78a7b2759e fix: Simplify model selection logic in message regeneration
Modify the model selection process to directly use the appropriate model based on the conversation context, removing redundant conditional logic
2025-03-01 11:20:58 +08:00
kangfenmao
27c0edfb79 fix: Improve ModelAvatar and AssistantItem styling for better layout and text handling
- Add min-width and min-height to ModelAvatar to ensure consistent sizing
- Separate AssistantName into a new styled component for better text overflow handling
- Refactor AssistantItem to improve text display and icon alignment
2025-03-01 10:41:24 +08:00
kangfenmao
59b1d8bcc4 style: Refine Segmented component styling with transparent background and rounded corners 2025-03-01 01:44:02 +08:00
kangfenmao
741d84b4d3 feat: Sort model groups alphabetically in provider settings
- Implement alphabetical sorting for model groups
- Use lodash's sortBy and toPairs to order model groups
- Modify rendering to use sorted model groups
2025-03-01 01:00:44 +08:00
suyao
5bacf048f2 fix: The proxy configuration is not correctly passed. 2025-03-01 00:42:56 +08:00
kangfenmao
1d4916c516 feat: Extract ModelEditContent into separate component and refine UI styling
- Create new ModelEditContent component in ProviderSettings
- Separate model editing logic from ProviderSetting
- Adjust styling for AssistantItem and TopicsTab list items
- Refine Segmented component styling with transparent background
- Improve modal layout and interaction for model type configuration
2025-03-01 00:40:55 +08:00
kangfenmao
8e1207c2a2 feat: Add assistant icon display toggle in settings
- Implement new setting to show/hide model icons in assistant list
- Add localization support for new assistant settings
- Update UI to conditionally render model avatar in AssistantItem
- Modify settings store to include showAssistantIcon state
- Enhance display settings with new toggle switch for assistant icon
2025-03-01 00:18:47 +08:00
kangfenmao
ac92f1a783 refactor: Simplify Segmented component styling
- Remove custom Segmented styling from AntdProvider
- Update HomeTabs Segmented component with refined styles
- Consolidate Segmented styling in a single location
- Improve visual consistency with rounded corners and transparent background
2025-02-28 23:25:36 +08:00
kangfenmao
28c59ea436 feat: Enhance UI styling and interaction details
- Update window vibrancy to 'sidebar' for better visual effect
- Refine input bar styling with softer background and rounded corners
- Adjust toolbar button sizes and styling
- Modify topic position selection to use Segmented component
- Tweak light theme background opacity
2025-02-28 23:25:36 +08:00
ousugo
9e808208ab fix: Normal content is misidentified as chain of thought content 2025-02-28 22:06:08 +08:00
Asurada
feefaaf3e3 feat: Added More Settings section with risk warnings in model type configuration (#2560)
* feat: add "More Settings" option in multiple languages and enhance model type selection UI

* feat: add "More Settings" option with warnings and confirmation prompts in multiple languages

* fix: improve modal close handling and reset model type visibility
2025-02-28 22:04:44 +08:00
kangfenmao
31078b8ec5 chore: Update Xirang provider configuration and localization 2025-02-28 18:20:23 +08:00
lbc123456
f3f32cc591 feat: 模型服务添加天翼云模型 (#2238)
* feat: 模型服务添加天翼云模型

* feat:add website

* fix: id is duplicate

---------

Co-authored-by: 李保成 <libaocheng@cndatacom.com>
2025-02-28 17:40:57 +08:00
kangfenmao
f489b034b5 Revert "feat: allow o1 streaming"
This reverts commit d4848faa5a.
2025-02-28 14:20:37 +08:00
ZhuangYumin
3d9d5b6263 feat: let quick assistant follow theme setting 2025-02-28 13:14:45 +08:00
Pres
89440c9c10 feat: add support for GPT 4.5 2025-02-28 13:14:05 +08:00
Pres
4c0f358323 fix:Claude model name typo 2025-02-28 11:53:30 +08:00
kangfenmao
ad01fc43e5 Revert "docs: remove Chinese issue templates for bug reports, feature requests, and questions"
This reverts commit ab5e830ed1.
2025-02-28 10:34:28 +08:00
xiaotianxt
9b17416f9c fix: remove restrictions on mac alt+x shortcuts
Restrictions are introduced in earlier beta versions of MacOS Sequoia.
However, in the public release, Apple revoke this restrictions.

Alt+[Char] shortcut has no restrictions now.
2025-02-28 10:30:47 +08:00
onevcat
cda4edfb7f Remove unused protocol register and open url code 2025-02-28 08:19:04 +08:00
eeee0717
acc803aa43 fix bug: #2474 2025-02-28 08:18:14 +08:00
TW
2ab8f325df feat: Enhance Assistant and Topic components with title attributes for better accessibility 2025-02-28 08:17:01 +08:00
onevcat
a68cbe4438 Switch to @use and module system for scss 2025-02-28 08:16:03 +08:00
onevcat
646d0e4ccb Use the Russian language label
This ensures the language label aligns with others (using its own language name instead of English).
2025-02-27 20:40:52 +08:00
Asurada
a7a82be083 feat: Add model editing functionality to provider settings (#2243) 2025-02-27 17:00:01 +08:00
CherryLover
c0117c25ac feat: 为模型选择弹窗添加键盘导航功能 (#2057)
* feat: 为模型选择弹窗添加键盘导航功能

* fix(SelectModelPopup): 改进键盘导航和项目筛选
2025-02-27 16:58:11 +08:00
SuYao
d51da99b8f fix: some proxy errors in main process (#2294)
* formatter proxy config type

* fix: some proxy errors in main process

* chore: Remove debug logging in ProxyManager
2025-02-27 16:46:05 +08:00
ZhuangYumin
d4848faa5a feat: allow o1 streaming 2025-02-27 16:42:11 +08:00
NJczh
bfeca0b383 fix:修复备份恢复完成后可能无权限清理临时目录 (#2247) 2025-02-27 16:40:47 +08:00
xiaotianxt
79c7c3dc1c feat: Improve settings navigation hotkey behavior
- Add location check to prevent navigating to settings when already on settings page
- Enable hotkey on content editable and form elements
- Use useLocation to track current route
2025-02-27 16:39:52 +08:00
SuYao
b2ebbc1e30 fix: favicon can't load error (#2426)
* feat: Implement robust favicon loading with fallback mechanisms

* refactor: Improve favicon loading state and use Promise Method

* refactor: Extract FallbackFavicon into a separate component

* feat: Add Splitbee favicon service to fallback favicon URLs
2025-02-27 16:38:14 +08:00
Cicada
50e2dd0ec0 docs: Convert Traditional Chinese to Simplified 2025-02-27 16:37:06 +08:00
yeongpin
5e753de71c feat: Add GIF support for avatar uploads without compression 2025-02-27 15:02:02 +08:00
kangfenmao
6bc6dab879 docs: Update README files to mark networking and first official version as completed 2025-02-26 19:30:30 +08:00
kangfenmao
7d794d33dd chore(version): 1.0.1 2025-02-26 17:28:08 +08:00
kangfenmao
aab318e8ca fix: Adjust file upload and navbar styling for cross-platform compatibility
- Update Dragger component to use customRequest for file uploads
- Add Windows-specific padding adjustment for navbar right section
2025-02-26 13:33:21 +08:00
kangfenmao
6554a3817b feat: Add O3 provider and refactor migration logic 2025-02-26 13:33:11 +08:00
icinggslits
7d76db40e8 feat: Add search button to the knowledge base, and adjusted the display for drag-and-drop uploads (#2365)
* feat: Add search button to the knowledge base, and adjusted the display for drag-and-drop uploads

* feat: Add search button to the knowledge base, and adjusted the display for drag-and-drop uploads
2025-02-26 12:06:34 +08:00
ZhuangYumin
186c82e355 feat: add better support for openrouter thinking format 2025-02-26 12:04:47 +08:00
首都爱护动物协会
67311f1cbe add o3 2025-02-26 12:03:08 +08:00
kangfenmao
62d969335e chore: Improve localization formatting for Notion and Yuque error messages
- Standardize spacing and capitalization in Chinese (Simplified and Traditional) locales
- Enhance readability of error and configuration messages
- Consistent formatting for API keys, database IDs, and URLs
2025-02-26 00:21:49 +08:00
kangfenmao
c6eb77ab8b feat: Enhance web search settings with blacklist and result configuration
- Update Tavily description across locales to emphasize AI agent capabilities
- Add blacklist functionality for web search results
- Introduce configurable maximum search results
- Improve localization for web search settings in multiple languages
2025-02-26 00:16:13 +08:00
kangfenmao
7e17987fa3 chore: Reorganize and clean up localization files
This commit involves minor reorganization and cleanup of translation files across multiple languages (en-us, ja-jp, ru-ru, zh-cn, zh-tw). Changes include:

- Reordering of some translation keys
- Removing duplicate entries
- Slight restructuring of nested translation objects
- Minor formatting adjustments
2025-02-26 00:02:03 +08:00
Chen Tao
4bc69b7c5e feat: add web search settings (#2314)
* fix: add time when using web search

* feat: add optional

* chore

* chore

* chore

* clean code

* feat: set search max results

* feat: add manual blacklist

* clean code

* chore

* chore

* clean
2025-02-25 23:46:51 +08:00
ousugo
e08029a6f5 feat: Improve think tag processing with more robust parsing 2025-02-25 23:46:25 +08:00
kangfenmao
93d68102d6 fix: Update favicon service for message citations 2025-02-25 23:43:22 +08:00
kangfenmao
f448d8a8db fix: assistant and agent emoji 2025-02-25 21:00:23 +08:00
kangfenmao
a047048f69 refactor: Extract file drop handling logic to separate utility function 2025-02-25 19:53:04 +08:00
icinggslits
aec14567ee feat: Support more file drag and drop scenarios (#2278)
* feat: Support more file drag and drop scenarios

* feat: Support more file drag and drop scenarios
2025-02-25 19:46:32 +08:00
kangfenmao
bad89e3d28 chore: Remove social media links from About settings 2025-02-25 19:40:52 +08:00
kangfenmao
408f2b16ad fix: Standardize Notion connection error messages across locales 2025-02-25 19:34:15 +08:00
kangfenmao
d6b87ece23 fix: 修复深色模式下气泡样式的用户名样式错误问题
This reverts commit 69513cc76e.
2025-02-25 19:31:19 +08:00
icinggslits
91104e288c fix: Export image in dark mode (#2332)
Co-authored-by: 亢奋猫 <kangfenmao@qq.com>
2025-02-25 19:20:11 +08:00
eeee0717
aeeded2aa1 fix bug: 深色模式对话导出渲染不正确 2025-02-25 19:12:44 +08:00
ousugo
b10198de1f feat: Enhance reference prompt with language matching instruction 2025-02-25 19:09:56 +08:00
Yuankui Li
0789ccedbb feat: 知识库支持更多txt based格式 2025-02-25 19:07:06 +08:00
Aglargil
0a5401174b feat: add export to Yuque 2025-02-25 19:06:37 +08:00
Godcoper
69513cc76e fix: 修复深色模式下气泡样式的用户名样式错误问题 2025-02-25 18:58:10 +08:00
suyao
5a471125db chore: Update Grok app logo and related images 2025-02-25 15:01:01 +08:00
kangfenmao
06b2ca9149 refactor: Move fullscreen notification logic to a separate hook 2025-02-25 13:32:15 +08:00
ousugo
26dd931f70 feat: Add fullscreen mode notification with localized message 2025-02-25 13:28:29 +08:00
kangfenmao
68df5cd211 chore: Remove console logs and clean up code
This commit removes unnecessary console.log statements and makes minor code cleanup in several files:
- PlantUML component
- WebSearchSettings
- WebSearchService
- Store settings

Additionally, it updates the store migration to handle LM Studio provider addition and reverts the store version
2025-02-25 13:27:31 +08:00
Chen Tao
c7071a98f0 fix: 网络搜索添加时间信息 (#2255)
* fix: add time when using web search

* feat: add optional

* chore

* chore

* chore

* clean code
2025-02-25 13:20:53 +08:00
zzsx
ff14dcc559 feat: 添加更多C++文件扩展名支持
在 `textExts` 数组中添加了以下C++文件扩展名:
- `.hpp`: C++ 头文件
- `.cc`: C++ 源文件
- `.cxx`: C++ 源文件
- `.cppm`: C++20 模块接口文件
- `.ipp`: 模板实现文件
- `.ixx`: C++20 模块实现文件
2025-02-25 13:19:32 +08:00
preszzz
bb02ca83dc feat: add new claude 3.7 model support 2025-02-25 13:17:09 +08:00
Alice39s
4d9e842381 feat: Add support for Gemini 2.0 and update Yi model configurations
- Added `gemini-2.0` to `visionAllowedModels`.
- Introduced new Gemini models in `SYSTEM_MODELS`:
  - `gemini-1.5-flash-8b`
  - `gemini-2.0-flash`
- Updated Yi model configurations:
  - Renamed `yi-lightning` to "Yi Lightning".
  - Deprecated `yi-medium`, `yi-large`, and `yi-vision` (replaced by `yi-lightning` per documentation).
  - Added `yi-vision-v2` as a new version of Yi Vision.
2025-02-25 08:29:59 +08:00
ousugo
0165bcdce3 feat: Adapt glmzeropreview thinking chain format, enhance message thought processing with flexible extractors, 2025-02-25 08:29:16 +08:00
自由的世界人
f015c78060 fix: folder spelling change (#2242) 2025-02-25 08:26:25 +08:00
Zicheng Zhang
c233ba0a1c fix: count reasoning content into token estimation (#2276) 2025-02-25 08:24:53 +08:00
eeee0717
88dd75827a fix bug: uniqueIds is null when uploaded directory 2025-02-24 21:40:17 +08:00
kangfenmao
2ab63f2e4c fix: Update Infini provider API URL to include '/maas' path 2025-02-24 18:08:22 +08:00
icinggslits
91bf356c73 feat: add shortcut to home window of mini app 2025-02-24 12:58:40 +08:00
vic123
28c0748001 fix: undesired assistant selection menu popup when no ' ' before '@' 2025-02-24 12:57:26 +08:00
SagoLu
3108a1c0b3 fix:修复在备份和恢复备份时由于无法删除临时目录导致的功能终止 (#2224)
* refactor: Remove chat settings toolbar button from input bar

* fix:修复在备份时,由于临时文件只读导致的备份失败

* fix:修复在恢复备份时,由于临时文件只读导致的备份失败

---------

Co-authored-by: kangfenmao <kangfenmao@qq.com>
2025-02-24 12:56:19 +08:00
Alice39s
6cfa7d0eb6 feat: Improve support for the Codestral and additional Mistral models
- Added new image asset `codestral.png` for Codestral model.
- Updated `embedings.ts` to include the `mistral-embed` embedding model with `max_context: 8000`.
- Updated `models.ts` to:
  - Add support for Codestral model with `codestral-latest` ID.
  - Introduce new Mistral models, including:
    - `ministral-3b-latest`
    - `ministral-8b-latest`
    - `mistral-large-latest`
    - `mistral-small-latest`
    - `mistral-embed`
  - Organize models into appropriate groups (e.g., "Mistral Chat", "Mistral Code").
- Adjusted `getModelLogo` function to include Codestral and Ministral logos.
2025-02-24 12:55:28 +08:00
kangfenmao
da6c80ebc2 refactor: Rename onResend to onResendUserMessage for clarity 2025-02-24 12:50:29 +08:00
Asurada
af1a9868db feat: Add remark function to knowledge url (#2210)
* chore: Update .gitignore to exclude .cursor/rules

* feat: Add remark function to knowledge url
2025-02-24 12:47:47 +08:00
dengshenkk
f87ba144c8 feat: 用户侧消息快捷重试功能 (#2221)
* Update MessageMenubar.tsx

用户发送消息可以重试, 方便在接口错误后进行重试

* Update MessageMenubar.tsx
2025-02-24 12:41:59 +08:00
ousugo
8d61cbcae9 feat: Improve knowledge base creation popup input focus 2025-02-24 12:40:46 +08:00
ousugo
c61dde5085 feat: Enhance knowledge search popup input focus behavior 2025-02-24 12:40:46 +08:00
sijie-chan
3015e90925 fix: 添加多个目录到知识库多个进度之间展示混淆 2025-02-24 12:40:00 +08:00
牡丹凤凰
b3629e83f2 Update README.ja.md 2025-02-24 07:23:23 +08:00
牡丹凤凰
cef9312e7e Update README.zh.md 2025-02-24 07:22:55 +08:00
牡丹凤凰
802622646a Update README.md (#2213) 2025-02-24 07:22:12 +08:00
kangfenmao
ce70c7239c chore(version): 1.0.0 2025-02-23 15:10:24 +08:00
kangfenmao
c354537f30 feat: Add Tavily dark mode logo and improve web search settings UI 2025-02-23 15:10:01 +08:00
kangfenmao
fb6b0b0c97 refactor: Rename AssistantItemComponent to AssistantItem and update imports 2025-02-23 14:30:17 +08:00
wnzzer
fc59144b1d fix:清空话题总是修复当前话题 (#2167) 2025-02-23 14:26:31 +08:00
kangfenmao
cacd0a1387 feat: Improve web search UI and localization 2025-02-23 14:22:09 +08:00
kangfenmao
af9763d142 chore: Update Tavily core package and remove js-tiktoken dependency 2025-02-23 11:01:30 +08:00
kangfenmao
b9402a8370 feat: add web search 2025-02-23 11:01:29 +08:00
kangfenmao
97a08f00a3 chore(version): 0.9.30 2025-02-23 07:02:00 +08:00
kangfenmao
4e20bd1ef8 feat: Enhance assistant emoji and popup UI interactions 2025-02-23 06:45:35 +08:00
George·Dong
5c2d936688 feat: 添加Notion导出自动分页功能 (#2098)
* fix: 长对话Notion导出失败(分页导出)

* feat: 添加Notion导出自动分页设置
2025-02-23 06:45:26 +08:00
ousugo
6b34aac263 feat: Auto-select newly added knowledge base 2025-02-23 00:17:46 +08:00
kangfenmao
f59f6ade69 chore(version): 0.9.29 2025-02-22 22:58:19 +08:00
ousugo
50478c600f fix: Regenerat messages don't use @ specified models 2025-02-22 22:35:02 +08:00
ousugo
bba5cac246 fix: Restore textarea focus after selecting mention model via mouse 2025-02-22 22:34:16 +08:00
shijian
b9b31aed52 fix: 复制聊天信息按钮显示不全 2025-02-22 22:32:30 +08:00
kangfenmao
40203fb721 fix: Remove LM Studio provider from initial state 2025-02-22 22:31:37 +08:00
kangfenmao
b83343a8b9 fix: Remove duplicate empty LM Studio providers 2025-02-22 13:35:14 +08:00
aber0724
7677850547 feat: Add Monica minapp 2025-02-22 11:27:30 +08:00
sijie-chan
d0e233f1b3 fix: 添加目录到知识库任意一个失败界面上会展示失败 2025-02-22 11:26:31 +08:00
kangfenmao
903d0043ba chore(version): 0.9.28 2025-02-21 18:25:30 +08:00
kangfenmao
811815d69d feat: update miniapp logo 2025-02-21 18:25:23 +08:00
kangfenmao
d5b9c35f0a feat: Enhance topic message clearing functionality
关于“清空话题”的Bug反馈 #2107

close #2107
2025-02-21 16:48:04 +08:00
suyao
83c8f06b81 fix: add first message handling in mini home window 2025-02-21 16:32:56 +08:00
kangfenmao
acb2ea30fb feat: add export function to message 2025-02-21 16:27:07 +08:00
kangfenmao
55317b5608 refactor: Remove chat settings toolbar button from input bar 2025-02-21 14:31:05 +08:00
kangfenmao
b42a5c5e63 chore: Upgrade Yarn and TypeScript patch versions 2025-02-21 14:18:16 +08:00
kangfenmao
cc76fe19f9 feat: Synchronize and clean up localization files
This commit involves several improvements to localization files across different languages:
- Reordered and cleaned up translation keys
- Removed redundant entries
- Ensured consistent ordering of keys
- Added missing translations for various features
- Normalized whitespace and formatting
2025-02-21 14:15:36 +08:00
落子
cf2d7ba8b4 feat: add "Copy as" options to topics right click menu (#2095)
* feat: Add copy topic as image and Markdown functionality

* add translation
2025-02-21 13:59:34 +08:00
Avan
1c163c55b8 feat: baidu ai search 2025-02-21 13:58:19 +08:00
kangfenmao
69bb661b5a feat: Add API host formatting utility function 2025-02-21 13:50:24 +08:00
lizhixuan
f062c56de4 refactor: Move abort controller to utils and update imports 2025-02-21 12:50:18 +08:00
lizhixuan
4c9bd02f8e feat: Add message completion abort functionality 2025-02-21 12:50:18 +08:00
kangfenmao
241cb0c0d8 refactor: Simplify translation history clear button configuration 2025-02-21 11:17:41 +08:00
ousugo
6a57973864 feat: Add newline tooltip for translation input 2025-02-21 11:16:02 +08:00
kangfenmao
369f629206 refactor: Simplify embedding model regex pattern 2025-02-21 09:46:26 +08:00
kangfenmao
09a8f83650 refactor: Clean up MinAppsPopover component formatting 2025-02-20 15:35:51 +08:00
kangfenmao
40912eaaf4 refactor: Simplify topic deletion interaction 2025-02-20 15:33:24 +08:00
ousugo
0d236a94ab feat: Add direct topic deletion shortcut 2025-02-20 15:19:32 +08:00
ousugo
3a936e0f26 feat: Add confirmation dialog for topic deletion 2025-02-20 15:19:32 +08:00
Yrom
81a35d129d feat: add developer tools button in MinApp for development mode 2025-02-20 15:19:10 +08:00
ousugo
e2d0c3bbce feat: Add emoji selection for assistant name 2025-02-20 15:17:04 +08:00
kangfenmao
12c9d810a2 feat: Add C and C++ file extensions to supported text files
close #2066
2025-02-20 14:45:11 +08:00
kangfenmao
b18b161094 fix: Update migration config to set default thought auto-collapse 2025-02-20 12:24:24 +08:00
ousugo
32da853f27 feat: Add thought content auto-collapse setting 2025-02-20 12:22:45 +08:00
ousugo
bf51a0b5c6 feat: Add copy functionality to message reasoning content 2025-02-20 12:22:45 +08:00
kangfenmao
ae71a7be9e refactor: Simplify translation page layout and styling 2025-02-20 12:16:38 +08:00
Chen Tao
0fb6795833 feat: add shortcuts to open settings page (#1964)
* feat: add shortcuts to open settings page
* refactor: simplify code
* fix: change to useHotKeys
2025-02-20 12:10:16 +08:00
jtsang4
dd6d228760 feat: Add backspace handling to remove last mentioned model 2025-02-20 12:08:25 +08:00
eeee0717
8c5999dc82 fix: knowledge base status problem 2025-02-20 12:07:05 +08:00
kangfenmao
31b0fbf775 fix: Improve null handling in code block and syntax highlighting 2025-02-20 12:04:29 +08:00
kangfenmao
39fe583030 refactor: Remove default grid settings from migration config 2025-02-20 11:54:21 +08:00
littel_penguin66
5c19695e21 feat: add dify miniapp (#1999)
* add Dify miniapp

* add wpslingxi,lechat,abacus miniapps

* resize pic

* change png to webp

* update 71
2025-02-20 11:52:36 +08:00
FischLu
6e4610e337 fix: fix translation 2025-02-20 11:50:49 +08:00
onlyfeng
eb2439b90c fix(KnowledgeBase): handle JSON parse failure by falling back to text file processing to avoid error display affecting normal progress indication 2025-02-20 11:44:36 +08:00
kangfenmao
a4a0980cd3 fix: Ignore hidden files when traversing directories 2025-02-20 11:43:01 +08:00
FischLu
7d99765589 fix: fix the issue where the menu scrolls back to the top after clicking an option 2025-02-19 21:40:32 +08:00
kangfenmao
5f6cf1bd66 docs: Update README files with comprehensive TODO list and minor formatting improvements 2025-02-19 20:07:10 +08:00
Teo
02930a2793 feat: 添加翻译历史功能 2025-02-19 19:38:59 +08:00
Yrom
b31b1c7908 feat: Support dark theme for PlantUML 2025-02-19 18:37:05 +08:00
Yrom
d0ee764732 feat: Add PlantUML diagram support (via PlantUML official online server) 2025-02-19 18:37:05 +08:00
ousugo
01cd10b364 refactor: Simplify model type detection with utility functions 2025-02-19 18:33:51 +08:00
ousugo
29ba156b9a feat: Add Doubao provider support for model type detection
(cherry picked from commit 008b84e128484c98eb59c75d8f44cbc320509049)
2025-02-19 18:33:51 +08:00
ousugo
e541c7b429 feat: Add model generation check before narrow mode toggle 2025-02-19 18:33:16 +08:00
ousugo
5f4142f0c4 chore: Enhance issue templates with improved guidance and visual context 2025-02-19 17:19:15 +08:00
jiangjiwei
95bbc70c93 feat: 为 Notion 导出添加可配置的页面名称 key 2025-02-19 17:18:45 +08:00
ousugo
4add56ae6a fix: Ensure model is updated when setting default model 2025-02-19 17:13:52 +08:00
Teo
16f87537a2 refactor: 翻译页UI重构 2025-02-19 15:53:52 +08:00
kangfenmao
7f05626a8f chore(version): 0.9.27 2025-02-19 10:21:12 +08:00
kangfenmao
2094e2201a feat: Add web search support for OpenRouter provider 2025-02-19 10:11:49 +08:00
icinggslits
e0fcdf43c5 feature: Adaptive height of textarea on translation page 2025-02-19 09:57:26 +08:00
kangfenmao
affc866c17 feat: Add default API host for DMX provider in migration 2025-02-19 09:45:41 +08:00
kangfenmao
799267049f fix: Safely update topic with existing topic data 2025-02-19 09:35:10 +08:00
kangfenmao
cb8d47a17b fix: Improve knowledge base processing and deletion handling 2025-02-19 09:28:36 +08:00
kangfenmao
c494288f7b refactor: Simplify DragableList styling and remove unnecessary margins 2025-02-19 09:21:10 +08:00
suyao
2c3f89dbde fix: update model identification with provider-specific uniqueness 2025-02-19 09:14:45 +08:00
ousugo
4721a660fa feat: Add German language support to translation options 2025-02-19 08:21:00 +08:00
George·Dong
6aaa3def0d feat: 添加Notion文档按钮Tooltip 2025-02-19 08:20:21 +08:00
George·Dong
045708d9b3 fix: 修改导出到Notion的相关提示 2025-02-19 08:20:21 +08:00
icinggslits
9ffe92d378 fix: Update language options promptly 2025-02-19 08:18:41 +08:00
首都爱护动物协会
7159481217 Updated provider information 2025-02-19 07:10:45 +08:00
kangfenmao
d07e136037 fix: Add top margin to 'Add Assistant' button in AssistantsTab 2025-02-18 21:17:13 +08:00
Yrom
b38a9c954a feat: Enable search capability for Qwen commercial version model 2025-02-18 21:14:43 +08:00
kangfenmao
7139d5093a chore(version): 0.9.26 2025-02-18 20:55:04 +08:00
kangfenmao
9e283d6930 fix: Update agent knowledge base field name and handling 2025-02-18 20:55:04 +08:00
Chen Tao
c9a4e12765 feat: artifacts add open external (#1812)
* feat: artifacts add open external

* fix: remove modal
2025-02-18 19:56:39 +08:00
Teo
7bd644451b fix: 解决生成过程中出现错误内容被清空覆盖问题 2025-02-18 19:46:50 +08:00
美兰十三
5a00bdcbc6 fix: 修复mac下快捷键注册control被替换成command的问题 2025-02-18 19:46:28 +08:00
eeee0717
3c958c3d11 feat: 目录进度可视化 2025-02-18 19:45:47 +08:00
kangfenmao
1d5ace0fb2 feat: Add 'off' option for reasoning effort in assistant settings 2025-02-18 18:16:14 +08:00
ousugo
f8fce871da fix: Recalculate token consumption after modifying the message, resolve #1829 2025-02-18 16:34:52 +08:00
ousugo
de76d3fedc fix: Improve DragableList component styling and placeholder handling 2025-02-18 16:26:34 +08:00
lucifer9
b2c6662192 adjust Notion database ID input width in DataSettings 2025-02-18 16:22:53 +08:00
lucifer9
bf8a7c01b0 Refactor WebDAV i18n and UI for improved flexibility and localization
- i18n Updates:
   - Refactored WebDAV-related translations into nested JSON structures for better organization.
   - Added support for pluralization in time intervals (minutes and hours) across all locales (en-us, ja-jp, ru-ru, zh-cn, zh-tw).

 - UI Enhancements:
   - Updated `DataSettings` and `WebDavSettings` components to use the new i18n keys for time intervals.
   - Improved the `Select` dropdown for sync intervals with dynamic pluralization based on locale.
   - Adjusted input field widths for better alignment and consistency.

 - Code Cleanup:
   - Removed redundant comments and unused code in `WebDavSettings.tsx`.
   - Simplified button and input styling for a cleaner layout.
2025-02-18 16:22:53 +08:00
ousugo
fb8ed35b59 fix: Clicking the taskbar icon while enable the Quick Assistant can't open the main window 2025-02-18 16:01:10 +08:00
ousugo
7c4d81c108 feat: Add kimi-latest model support in vision and model logos 2025-02-18 15:50:01 +08:00
kangfenmao
7199f73e06 style: Adjust horizontal message layout display property 2025-02-18 15:48:13 +08:00
Teo
869e56b53c style: 优化聊天窗口UI (#1881) 2025-02-18 11:43:42 +08:00
MyPrototypeWhat
f99851fb6b feat: Conditionally hide thinking loader for paused messages (#1875)
Co-authored-by: lizhixuan <zhixuan.li@banosuperapp.com>
2025-02-18 11:10:48 +08:00
kangfenmao
c94450db44 chore(version): 0.9.25 2025-02-18 10:41:44 +08:00
kangfenmao
195ef92acc feat: Add size prop to MessageThought Collapse component 2025-02-18 10:12:30 +08:00
kangfenmao
a67370426b fix: Handle undefined provider in model name generation 2025-02-18 09:56:26 +08:00
kangfenmao
9d35205681 feat: Improve system prompt styling with theme-aware background 2025-02-18 09:42:52 +08:00
icinggslits
98087e50db feat: Backspace deletes clipboard text in MiniApp 2025-02-18 08:13:56 +08:00
icinggslits
bedac4f59d fix: init zoom 2025-02-18 08:11:38 +08:00
ousugo
aba3874797 refactor: Improve PromptPopup text area focus and cursor placement 2025-02-18 08:10:58 +08:00
ousugo
3383280726 feat: Improve text edit popup focus and cursor placement 2025-02-18 08:10:58 +08:00
kangfenmao
0c13e708b9 refactor: Extract message group menu bar into a separate component 2025-02-17 23:21:24 +08:00
kangfenmao
bc77c423b3 fix: Adjust paragraph margin when followed by list 2025-02-17 23:08:17 +08:00
kangfenmao
4821756301 fix: Conditionally render message group border based on popover state 2025-02-17 23:02:49 +08:00
Chen Tao
78290ca70e feat: add knowledge base filter (#1822)
* feat: add search filter

* chore
2025-02-17 22:18:10 +08:00
kangfenmao
7feeb07624 refactor: Extract message group settings into a separate component 2025-02-17 22:14:47 +08:00
luwux
93e28ed916 improvement(shortcut): Supports Option + Space on Mac
Supports the Option (⌥) + Space shortcut, as it's the default shortcut for ChatGPT Desktop app to show popup.
2025-02-17 19:04:08 +08:00
ousugo
b4aaf052fe feat: Add page title for Cherry Studio, resolve #1222 2025-02-17 19:02:56 +08:00
rebecca554owen
b37e0389fc fix 2025-02-17 18:38:22 +08:00
kangfenmao
e1ebe069a5 feat: Add grid mode settings for message display 2025-02-17 18:35:36 +08:00
kangfenmao
d73912ee3b feat: Enhance Notion settings with placeholders and help icon 2025-02-17 17:19:24 +08:00
kangfenmao
f81c7c7a6c feat: update knowledge base file upload hint text 2025-02-17 16:50:34 +08:00
FischLu
5a7bcd5997 feat: improve model mention autocomplete behavior under IME 2025-02-17 16:38:44 +08:00
duanyongcheng
09a347cae4 feat: show provider in mesage 2025-02-17 16:38:00 +08:00
Chen Tao
266f909045 feat: allow knowledge base multiple search #1346 (#1773)
* feat: agent can select multiple knowledge bases

* feat: basic search multiple knowledge base

* fix bug: knowledge base is delete, assistants and agents sync delete

* fix bug: assistant and knowledge base button sync

* feat: allow to search multiple knowledge base

* chore: finish rebase to upstream/main
2025-02-17 16:36:25 +08:00
cl1107
bad2f15c1f feat: Add a new grid mode for message display. (#1626)
* chore(version): 0.9.23

* feat(renderer): 新增网格模式的消息展示方式

* feat(message): 新增消息网格展示相关设置

* 根据 gridPopoverTrigger 属性动态设置消息分组的样式

* 在 MessageMenubar 组件中,各个按钮 click 事件阻止事件冒泡,避免打开 popover

* 多模型回答样式添加网格模式并优化消息样式

---------

Co-authored-by: kangfenmao <kangfenmao@qq.com>
2025-02-17 16:36:01 +08:00
shniubobo
e3115d00bf fix: Rendering error with MathJax for Chinese text 2025-02-17 16:24:38 +08:00
首都爱护动物协会
0c0ccf3d11 update provider info 2025-02-17 16:21:09 +08:00
ousugo
2076e6f998 fix: open current webview URL when launching external link 2025-02-17 16:20:12 +08:00
ousugo
b49d80b78d fix: Clicking the help button always opens a new webview
(cherry picked from commit 4939afafabcbfb294f00d21053939cad8238731e)
2025-02-17 16:19:31 +08:00
kangfenmao
ab5e830ed1 docs: remove Chinese issue templates for bug reports, feature requests, and questions 2025-02-17 12:02:07 +08:00
ousugo
e0eca97053 fix: update Baidu API key URL in provider configuration, resolve #1794 2025-02-17 11:55:53 +08:00
George·Dong
d175212d9a fix: 修复切换助手时无法正确切换到助手默认模型的问题 (#1776) 2025-02-17 11:28:17 +08:00
Shelly
642ce160a1 fix: 修复同名模型选择问题 (#1772)
1. 同名模型显示的供应商名称问题
2. 同名模型不同供应商不能被同时选择

Co-authored-by: duanyongcheng <duanyongcheng77@gmail.com>
2025-02-17 09:47:01 +08:00
Wenwei Lin
574d02a8c9 feat: support json and draftsExport file in knowledge base (#1717) 2025-02-17 08:25:07 +08:00
ousugo
7764507d74 feat: Expand reasoning model regex to include 'thinking' keyword 2025-02-17 08:16:47 +08:00
ousugo
fa8bf61532 fix: sidebar navigation and active state handling
- 当固定在侧边栏的小程序被打开时,对应图标显示为被选中
- 修复点击两次主题切换按钮会导致当前 Webview 被错误关闭的问题
- 修复当 Webview 处于打开状态,点击侧边栏按钮无法立即跳转到对应界面的问题
- 修复打开帮助文档,其按钮没有显示为被选中的问题
- 修复在设置界面时打开帮助文档,设置按钮继续显示为被选中的问题
2025-02-17 08:15:03 +08:00
ousugo
30e8cef9cc fix: correction of the capitalization of Perplexity names 2025-02-17 08:13:56 +08:00
ousugo
1a2861e81a fix: Fix the miniapp sorting problem, resolve #1725
- 修复小程序拖动排序不生效的问题
- 修复小程序拖动排序时列表滚动排序不生效的问题
2025-02-17 08:13:56 +08:00
Neal_Tan
653e5d82ed docs: optimize issues (#1790) 2025-02-17 08:12:40 +08:00
kangfenmao
5be0e0ae72 style: Enhance scrollbar appearance in mention models dropdown 2025-02-16 13:56:10 +08:00
FischLu
b92b46f2b0 refine code 2025-02-16 13:54:32 +08:00
FischLu
23686d4926 feat: implement select mode menu autoscroll for long mode lists 2025-02-16 13:54:32 +08:00
kangfenmao
b340b40bcf Revert "fix: Improve the @ model list experience"
This reverts commit c53d63f7af.
2025-02-16 13:54:09 +08:00
bfdyanshe
253fc6f4e1 fix: Separate EPUB files into dedicated book file extension category 2025-02-16 13:46:52 +08:00
bC2y5tal
99aa0d3255 feat: Add EPUB file support to document loader 2025-02-16 13:46:52 +08:00
icinggslits
23a2a6b57c improvement(shortcut): Support more keyboard shortcuts 2025-02-16 13:45:03 +08:00
icinggslits
a869857fc1 add usableEndKeys 2025-02-16 13:45:03 +08:00
kangfenmao
4ecedcb267 feat: Enhance topic handling and message prompt generation 2025-02-16 13:41:31 +08:00
kangfenmao
cbd6a30e14 feat: Improve knowledge base threshold tooltip and input 2025-02-16 12:20:08 +08:00
kangfenmao
5f2cddee09 chore: Update store migration for Coze minapp 2025-02-16 12:14:20 +08:00
Chen Tao
c0e0e924f7 feat: 添加知识库匹配度阈值 (#1634)
* feat: 添加知识库匹配度阈值

* fix: 增加问答时知识库阈值

* feat: 当知识库未检索到数据时使用通用对话逻辑

* fix: add toast
2025-02-16 11:38:00 +08:00
Avan
b6ad7eeb9a style: add bot.n.cn logo 2025-02-16 11:36:58 +08:00
Avan
9cf74317a6 feat: add bot.n.cn 2025-02-16 11:36:58 +08:00
George·Dong
82fcc2292e feat: Add Coze minapp 2025-02-16 10:38:28 +08:00
yangtb2024
4eb0c25682 fix: 窗口较小时,工具显示适配问题 2025-02-16 10:35:45 +08:00
kassadin
9e128d2524 fix: unregister global shortcuts 2025-02-16 10:34:24 +08:00
jyeric
1473cb3123 Fix: Font size and Latex problem, resolve CherryHQ#1034 CherryHQ#1596 (#1723) 2025-02-15 22:55:43 +08:00
Wenwei Lin
2c5fe01fbf fix: add ellipsis in knowledge base item (#1718) 2025-02-15 22:51:07 +08:00
Wenwei Lin
d574a09529 fix: support html file in knowledge base (#1703) 2025-02-15 22:50:05 +08:00
美兰十三
f20bccfd7d feature: add topic prompt (#1696)
* feat: 新增话题补充提示词

* feat: 新增话题补充提示词

* feat: 新增话题补充提示词

* feat: 新增话题补充提示词

* feat: 新增话题补充提示词
2025-02-15 08:21:59 +08:00
icinggslits
5dcc892f31 调整show_app快捷键功能的交互逻辑 2025-02-15 08:17:18 +08:00
kangfenmao
26e3871688 Revert "fix: 网页链接附带中文标点解析错误"
This reverts commit 16feb49e9e.
2025-02-15 01:30:13 +08:00
kangfenmao
9a6aad35b0 fix: Improve handling of 'undefined' values in JSON parsing 2025-02-15 01:25:59 +08:00
eeee0717
16feb49e9e fix: 网页链接附带中文标点解析错误 2025-02-15 01:06:32 +08:00
kangfenmao
30959e2380 feat: Add LM Studio and ModelScope as system LLM providers
- Update llm.ts to include LM Studio and ModelScope in initial system providers
- Modify migrate.ts to add migration logic for adding these new providers
- Ensure providers are added only if they don't already exist in the configuration
2025-02-15 01:03:09 +08:00
kangfenmao
2c17f75f4f fix: Correct migration version configuration 2025-02-15 00:55:07 +08:00
Yihong Wang
2d1a930bfe feat: Add NotebookLM to MinApps solve #1679 2025-02-15 00:52:47 +08:00
eeee0717
320d27059f fix: 分组和非分组逻辑修改 2025-02-15 00:33:39 +08:00
eeee0717
31014aa8a6 fix: Switching model does not work 2025-02-15 00:33:39 +08:00
ousugo
b468ecfce7 feat: Improve textarea cursor positioning on focus 2025-02-15 00:31:36 +08:00
ousugo
c53d63f7af fix: Improve the @ model list experience
- 修复使用方向键上下移动时,列表不随之滚动的问题
- 添加滚动条
2025-02-15 00:29:32 +08:00
ousugo
dabff0a847 feat: Add platform and version fields to all issue templates 2025-02-15 00:26:31 +08:00
Konjac-XZ
26a5ae0086 fix: Translation error when passing empty user messages to certain models.(Refined) 2025-02-15 00:24:17 +08:00
kangfenmao
88e0d293a2 chore(version): 0.9.24 2025-02-14 15:04:59 +08:00
kangfenmao
0c97b52c53 refactor: Improve provider removal logic in LLM store 2025-02-14 14:49:34 +08:00
ousugo
2449a22c69 perf: Add new Infini AI models to system models list 2025-02-14 14:37:57 +08:00
ousugo
028f9d88d9 feat: Add reasoning model filter in EditModelsPopup 2025-02-14 14:30:48 +08:00
kangfenmao
a07c6cdffb refactor: Improve provider settings and menu handling 2025-02-14 13:35:58 +08:00
kangfenmao
5a647b0d61 style: Adjust group menu bar styling 2025-02-14 13:18:16 +08:00
kangfenmao
007e6419ba feat: Add ModelScope provider to LLM providers list 2025-02-14 13:13:32 +08:00
Col0ring
caa473639c feat: add modelscope provider (#1563)
Co-authored-by: 亢奋猫 <kangfenmao@qq.com>
2025-02-14 13:12:46 +08:00
kangfenmao
b6825a6ea2 feat(notion): Add divider to Notion settings page 2025-02-14 13:08:47 +08:00
Trey Dong
710180997f feat(notion): 添加 Notion连接检查功能 (#1620)
- 在 Notion 配置页面添加"检查"按钮
- 实现 Notion 连接检查逻辑
- 添加相关国际化文本
2025-02-14 10:52:16 +08:00
hehua2008
fd4334f331 feat: Add LM Studio support (#1572)
Co-authored-by: hehua2008 <hegan2010@gmail.com>
Co-authored-by: 亢奋猫 <kangfenmao@qq.com>
2025-02-14 10:49:57 +08:00
FischLu
80dedc149a feat: Implement circular selection in model selector 2025-02-14 10:40:03 +08:00
duanyongcheng77
8eacaa281a chore: add ignore for .cursoerules 2025-02-14 10:38:51 +08:00
duanyongcheng77
6e75140939 chore: 🤖 add aider gitignore 2025-02-14 10:38:51 +08:00
Asurada
5a3a97135f feat: Add XiaoYi miniapp, resolve #1591 (#1595)
Co-authored-by: 亢奋猫 <kangfenmao@qq.com>
2025-02-14 10:37:42 +08:00
ousugo
44d42d64ef fix: Solve the problem that eslint always reports line break errors on Windows 2025-02-14 10:36:07 +08:00
ousugo
fad3f67678 feat: Improve model search by adding name-based filtering, resolve #1520
搜索模型时,同时搜索模型的名字和 ID
2025-02-14 10:32:34 +08:00
kangfenmao
65b30b3b0d chore: Update Vite config and remove deprecated migration code
- Exclude additional chunk in Electron Vite configuration
- Remove outdated migration logic for providers and MinApps
2025-02-14 10:31:24 +08:00
首都爱护动物协会
0278228a84 add providers
新增服务商:
1.无问芯穹
2Perplexity
3.DMXAPI

补充部分embedding模型信息
2025-02-14 10:28:52 +08:00
shniubobo
bb0cb1cecc fix: Regression on reasoning time
PR #1253 fixed reasoning time calculation for APIs that return reasoning
content in `delta.content`, but introduced a regression for those
returning it in `delta.reasoning_content`. This commit fixes the
regression.

Fixes #1593
2025-02-14 10:26:54 +08:00
shniubobo
f5cd6ecb50 fix: Remove trailing newline in codeblocks 2025-02-14 10:10:30 +08:00
Xin Rui
76c0ad9985 fix: translation error when passing empty user messages to certain models.. (#1612) 2025-02-14 10:09:47 +08:00
kangfenmao
4c771c6913 chore(version): 0.9.23 2025-02-13 17:49:06 +08:00
kangfenmao
15d50761e7 feat: Enhance file processing and loader configuration
- Remove image loader from dependencies
- Update file loading to skip image, video, and audio files
- Add logging for knowledge base file processing
- Modify common file extensions list
- Add type ignore for LocalPathLoader to resolve TypeScript issues
2025-02-13 17:49:06 +08:00
kangfenmao
1c33c90884 feat: Add file type not supported error message in multiple languages 2025-02-13 16:41:48 +08:00
kangfenmao
53e5a3bf76 fix: Reset MinApp onClose handler when closing the app 2025-02-13 16:10:46 +08:00
kangfenmao
adfea253d7 chore(version): 0.9.22 2025-02-13 14:02:45 +08:00
kangfenmao
6c17fee69e refactor: Remove unused onMaxTokensChange function 2025-02-13 14:02:36 +08:00
kangfenmao
40958ffb2c feat: Add useSidebarIconShow hook to conditionally render sidebar icons 2025-02-13 13:38:46 +08:00
kangfenmao
22d2121dcc feat: Add documentation link to sidebar with multilingual support 2025-02-13 13:27:25 +08:00
kangfenmao
4632f1a92a feat: Improve token limit settings and knowledge base URL handling
- Update OpenAI package to version 4.77.3
- Add confirmation modal for max tokens setting
- Modify max tokens input to use InputNumber instead of Slider
- Update localization strings for max tokens and URL input
- Enhance knowledge base URL input to support multiple URLs
- Improve error handling and input validation
2025-02-13 13:12:51 +08:00
kangfenmao
b9affe3eb8 style: code format 2025-02-13 11:40:55 +08:00
Chen Tao
c6f136caa2 feat: knowledge base support more file types (#1300)
* feat: knowledge base support more file types

* chore: add common document types

* feat: finish basic odloader

* feat: finish open document loader

* feat: support more type from dictionary

* fix: 删除目录时仍能检索到信息

* chore
2025-02-13 11:36:33 +08:00
Wenwei Lin
827959e580 fix: Label text was obscured in create agent page 2025-02-13 11:36:07 +08:00
Chen Tao
8739c49634 feat: add i18n sync script (#1538)
* feat: add i18n sync script

* chore
2025-02-13 11:34:23 +08:00
Asurada
e99f253d48 feat: add google AI Studio minapp, resolve #832 (#1518)
* feat: add google AI Studio minapp, resolve #832

* fix: correct variable name for aistudio in migrateConfig
2025-02-13 11:28:51 +08:00
牡丹凤凰
0cb82bd3bd Update README.zh.md (#1516) 2025-02-12 23:10:50 +08:00
牡丹凤凰
cf89981b64 Update README.ja.md (#1515) 2025-02-12 23:10:10 +08:00
牡丹凤凰
e4133b0054 Update README.zh.md (#1514) 2025-02-12 23:08:59 +08:00
牡丹凤凰
9249ee9094 Update README.md (#1513) 2025-02-12 23:07:46 +08:00
kangfenmao
0a4b360745 feat: update AIHubMix OAuth and release workflow configuration 2025-02-12 18:24:57 +08:00
kangfenmao
59c4d60d6a fix(i18n): use translation for API key error message 2025-02-12 18:24:39 +08:00
kangfenmao
dcdb00eee7 feat: remove auto reset model feature #1435
close #1435
2025-02-12 16:58:33 +08:00
kangfenmao
946129ceb3 feat: expand embedding model regex to include more model identifiers #1481
close  #1481
2025-02-12 16:39:35 +08:00
kangfenmao
ada45b229d feat: switch default math rendering engine to KaTeX #1485 2025-02-12 16:34:24 +08:00
kangfenmao
7934ce473d fix(i18n): model exist error tip 2025-02-12 16:11:01 +08:00
kangfenmao
f749bef2fd fix: openai o1 models not support max_token params
close #1378
close #1378
close #1340
close #1197
close #491
2025-02-12 15:59:42 +08:00
kangfenmao
6b2452422e fix: doubao not support files type 2025-02-12 15:41:24 +08:00
kangfenmao
50438dd612 feat: WebDAV data backup and restore secondary confirmation #1326
close #1326
2025-02-12 15:19:21 +08:00
kangfenmao
38f665e484 fix: update Ollama API endpoint URL 2025-02-12 14:56:59 +08:00
kangfenmao
635e125ef4 chore: update store migration and LLM providers 2025-02-12 14:52:45 +08:00
kangfenmao
1b3ae92854 docs: change knowledge base documents chunk max limit 2025-02-12 14:36:56 +08:00
cnJasonZ
ce66f2e2ea feat: add new model provider PPIO (#1359) 2025-02-12 14:14:56 +08:00
方程
726efe3558 feat: add gitee ai provider (#1473)
* feat: add gitee ai provider

* feat: add gitee ai provider

---------

Co-authored-by: 方程 <fangcheng@oschina.cn>
2025-02-12 14:11:13 +08:00
ousugo
24deb56d00 feat(ISSUE_TEMPLATE): 添加Issue提交检查清单 2025-02-12 14:09:36 +08:00
亢奋猫
5e8d7682f5 feat: 🎸 使用@呼出模型选择列表 #1317 #1324 (#1458)
* feat: 🎸 使用@呼出模型选择列表

输入第一个字符为@符号的时候可以呼出选择模型的列表

* feat: 🎸 Only one can be chosen at a time

一次只能选择一个模型,选择后自动关闭。选择过的模型不在出现在列表,避免删除模型的时候显示异常。

* fix: 🐛 When choosing the model, Enter will send a message

* feat: 🎸 选中的模型显示供应商

* feat: 🎸 pinned module show privoder

* feat: 🎸 only selected modle show provider

* feat: 🎸 删除@符号以后自动关闭

* feat: 🎸 增加模糊搜索

---------

Co-authored-by: duanyongcheng77 <duanyongcheng77@gmail.com>
2025-02-12 14:08:18 +08:00
牡丹凤凰
ceb97e80ff Update embedings.ts 2025-02-12 08:31:00 +08:00
牡丹凤凰
bf1fa5b767 Update zh-tw.json
更正繁体中文当中关于Temperature的描述
2025-02-12 08:30:34 +08:00
airwish
e99f34893e feat: expanded web search models 2025-02-12 08:30:00 +08:00
牡丹凤凰
a49dd6101e Update zh-tw.json (#1433)
助手菜单名称显示不全
2025-02-12 08:25:14 +08:00
kangfenmao
d03b852671 feat: Add image loader to embedjs configuration 2025-02-11 22:55:49 +08:00
kangfenmao
13e48411c1 chore: Update embedjs dependencies to version 0.1.28 2025-02-11 22:36:34 +08:00
linauror
de1976d984 fix:针对思考类模型的返回,总结标题仅截取</think>之后的内容 (#1415) 2025-02-11 18:05:09 +08:00
Trey Dong
220046cc95 feat: add pin topic feature (#1408)
* feat: 新增导出至Notion的选项

* fix:添加多语言支持

* fix:添加提示语的多语言支持,以及防止重复导入的状态

* fix:修复多语言错误及调整UI样式统一

* feat:添加话题固定功能
2025-02-11 16:51:58 +08:00
kangfenmao
bae76f921b fix: upload button tooltip 2025-02-11 16:34:26 +08:00
lucifer9
cb88a48d8b feat: add support for clickable citations in message content (#1381)
* Add support for clickable citations in message content

* update format
2025-02-11 16:21:20 +08:00
kshern
4d13a8d9c2 fix: retain selected model when regenerating message (#1382)
* fix: retain selected model when regenerating message instead of reverting to default model

* fix: use props model

---------

Co-authored-by: Shern <shenkeji@corp.netease.com>
2025-02-11 14:12:56 +08:00
Trey Dong
50cc1c6b5a feat: 增加导出话题至Notion的功能 (#1331)
* feat: 新增导出至Notion的选项

* fix:添加多语言支持

* fix:添加提示语的多语言支持,以及防止重复导入的状态

* fix:修复多语言错误及调整UI样式统一
2025-02-11 11:27:01 +08:00
kangfenmao
1d82552491 Revert "feat: enable local network access on macOS #1178"
This reverts commit 6fb79c17d2.
2025-02-11 11:18:33 +08:00
Chen Tao
5c2129c0c8 fix: 数据库文档个数变为默认6个#1366 #1370 2025-02-11 10:05:34 +08:00
美兰十三
0eead315d8 fix: 快捷键无法绑定空格 2025-02-11 09:25:42 +08:00
Peter Chen
04cfe5019e Update MessageThought.tsx 2025-02-10 16:48:47 +08:00
kangfenmao
a0cfe7df4a fix: store migrate version 2025-02-10 14:40:30 +08:00
Chen Tao
3d8748a61a feat: add translate selection (#1010)
* feat: add translate selection

* chore: add default translate value

* feat: optimize trigger translation shotcut and add TanslateLanguageVarious

* fix

* fix: add database migrate version
2025-02-10 13:19:46 +08:00
郑恩
f3940159b3 feat: 优化思考过程显示的换行效果 2025-02-10 13:17:32 +08:00
Fadouse
81d4accacf fix: correct thinking time calculation for deepseek r1 2025-02-09 21:29:21 +08:00
Wenwei Lin
c900a186b7 feat: 知识库文件支持 html 类型 2025-02-09 21:27:15 +08:00
kangfenmao
72d61ef853 chore(version): 0.9.21 2025-02-09 10:20:03 +08:00
kangfenmao
8c32f51892 fix: Remove local network access switch and add insecure content loading 2025-02-09 10:14:35 +08:00
kangfenmao
0a3ad04f12 fix: max chunk size 2025-02-09 09:32:40 +08:00
牡丹凤凰
555a991a30 Update embedings.ts
embedding models information
2025-02-09 09:31:01 +08:00
230 changed files with 11836 additions and 3633 deletions

View File

@@ -16,6 +16,7 @@ module.exports = {
'react/prop-types': 'off', 'react/prop-types': 'off',
'simple-import-sort/imports': 'error', 'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error', 'simple-import-sort/exports': 'error',
'react/no-is-mounted': 'off' 'react/no-is-mounted': 'off',
'prettier/prettier': ['error', { endOfLine: 'auto' }]
} }
} }

View File

@@ -1,4 +1,4 @@
name: 🐛 错误报告 name: 🐛 错误报告 (中文)
description: 创建一个报告以帮助我们改进 description: 创建一个报告以帮助我们改进
title: '[错误]: ' title: '[错误]: '
labels: ['bug'] labels: ['bug']
@@ -7,6 +7,21 @@ body:
attributes: attributes:
value: | value: |
感谢您花时间填写此错误报告! 感谢您花时间填写此错误报告!
在提交此问题之前,请确保您已经了解了[常见问题](https://docs.cherry-ai.com/question-contact/questions)和[知识科普](https://docs.cherry-ai.com/question-contact/knowledge)
- type: checkboxes
id: checklist
attributes:
label: 提交前检查
description: |
在提交 Issue 前请确保您已经完成了以下所有步骤
options:
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决。
required: true
- label: 我已经查看了置顶 Issue 并搜索了现有的 [开放Issue](https://github.com/CherryHQ/cherry-studio/issues)和[已关闭Issue](https://github.com/CherryHQ/cherry-studio/issues?q=is%3Aissue%20state%3Aclosed%20),没有找到类似的问题。
required: true
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等。
required: true
- type: dropdown - type: dropdown
id: platform id: platform
@@ -33,7 +48,7 @@ body:
id: description id: description
attributes: attributes:
label: 错误描述 label: 错误描述
description: 清晰简洁地描述错误是什么 description: 描述问题时请尽可能详细
placeholder: 告诉我们发生了什么... placeholder: 告诉我们发生了什么...
validations: validations:
required: true required: true
@@ -42,7 +57,7 @@ body:
id: reproduction id: reproduction
attributes: attributes:
label: 重现步骤 label: 重现步骤
description: 重现行为的步骤 description: 提供详细的重现步骤,以便于我们可以准确地重现问题
placeholder: | placeholder: |
1. 转到 '...' 1. 转到 '...'
2. 点击 '....' 2. 点击 '....'
@@ -70,4 +85,4 @@ body:
id: additional id: additional
attributes: attributes:
label: 附加信息 label: 附加信息
description: 在此添加有关问题的任何其他上下文 description: 任何能让我们对你所遇到的问题有更多了解的东西

View File

@@ -1,4 +1,4 @@
name: 💡 功能建议 name: 💡 功能建议 (中文)
description: 为项目提出新的想法 description: 为项目提出新的想法
title: '[功能]: ' title: '[功能]: '
labels: ['enhancement'] labels: ['enhancement']
@@ -7,11 +7,49 @@ body:
attributes: attributes:
value: | value: |
感谢您花时间提出新的功能建议! 感谢您花时间提出新的功能建议!
在提交此问题之前,请确保您已经了解了[项目规划](https://docs.cherry-ai.com/cherrystudio/planning)和[功能介绍](https://docs.cherry-ai.com/cherrystudio/preview)
- type: checkboxes
id: checklist
attributes:
label: 提交前检查
description: |
在提交 Issue 前请确保您已经完成了以下所有步骤
options:
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决。
required: true
- label: 我已经查看了置顶 Issue 并搜索了现有的 [开放Issue](https://github.com/CherryHQ/cherry-studio/issues)和[已关闭Issue](https://github.com/CherryHQ/cherry-studio/issues?q=is%3Aissue%20state%3Aclosed%20),没有找到类似的建议。
required: true
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等。
required: true
- label: 最新的 Cherry Studio 版本没有实现我所提出的功能。
required: true
- type: dropdown
id: platform
attributes:
label: 平台
description: 您正在使用哪个平台?
options:
- Windows
- macOS
- Linux
validations:
required: true
- type: input
id: version
attributes:
label: 版本
description: 您正在运行的 Cherry Studio 版本是什么?
placeholder: 例如 v1.0.0
validations:
required: true
- type: textarea - type: textarea
id: problem id: problem
attributes: attributes:
label: 您的功能建议是否与某个问题相关? label: 您的功能建议是否与某个问题/issue相关?
description: 请简明扼要地描述您遇到的问题 description: 请简明扼要地描述您遇到的问题
placeholder: 我总是感到沮丧,因为... placeholder: 我总是感到沮丧,因为...
validations: validations:

View File

@@ -1,6 +1,6 @@
name: 提问 name: 讨论 & 提问 (中文)
description: 提出一个问题或寻求帮助 description: 寻求帮助、讨论问题、提出疑问等...
title: '[问题]: ' title: '[讨论]: '
labels: ['question'] labels: ['question']
body: body:
- type: markdown - type: markdown
@@ -8,6 +8,39 @@ body:
value: | value: |
感谢您的提问!请尽可能详细地描述您的问题,这样我们才能更好地帮助您。 感谢您的提问!请尽可能详细地描述您的问题,这样我们才能更好地帮助您。
- type: checkboxes
id: checklist
attributes:
label: Issue 检查清单
description: |
在提交 Issue 前请确保您已经完成了以下所有步骤
options:
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决。
required: true
- label: 我确认自己需要的是提出问题并且讨论问题,而不是 Bug 反馈或需求建议。
required: true
- type: dropdown
id: platform
attributes:
label: 平台
description: 您正在使用哪个平台?
options:
- Windows
- macOS
- Linux
validations:
required: true
- type: input
id: version
attributes:
label: 版本
description: 您正在运行的 Cherry Studio 版本是什么?
placeholder: 例如 v1.0.0
validations:
required: true
- type: textarea - type: textarea
id: question id: question
attributes: attributes:

View File

@@ -1,4 +1,4 @@
name: 🐛 Bug Report name: 🐛 Bug Report (English)
description: Create a report to help us improve description: Create a report to help us improve
title: '[Bug]: ' title: '[Bug]: '
labels: ['bug'] labels: ['bug']
@@ -6,7 +6,22 @@ body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
Thanks for taking the time to fill out this bug report! Thank you for taking the time to fill out this bug report!
Before submitting this issue, please make sure that you have understood the [FAQ](https://docs.cherry-ai.com/question-contact/questions) and [Knowledge Science](https://docs.cherry-ai.com/question-contact/knowledge)
- type: checkboxes
id: checklist
attributes:
label: Issue Checklist
description: |
Before submitting an issue, please make sure you have completed the following steps
options:
- label: I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
required: true
- label: I've looked at pinned issues and searched for existing [Open Issues](https://github.com/CherryHQ/cherry-studio/issues), [Closed Issues](https://github.com/CherryHQ/cherry-studio/issues?q=is%3Aissue%20state%3Aclosed), and [Discussions](https://github.com/CherryHQ/cherry-studio/discussions), no similar issue or discussion was found.
required: true
- label: I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.
required: true
- type: dropdown - type: dropdown
id: platform id: platform
@@ -33,8 +48,8 @@ body:
id: description id: description
attributes: attributes:
label: Bug Description label: Bug Description
description: A clear and concise description of what the bug is description: Please be as detailed as possible when describing the problem. Please provide screenshots or screen recordings whenever possible to help us better understand the issue.
placeholder: Tell us what happened... placeholder: Tell us what happened... (Remember to attach screenshots/recordings if applicable)
validations: validations:
required: true required: true
@@ -42,12 +57,14 @@ body:
id: reproduction id: reproduction
attributes: attributes:
label: Steps To Reproduce label: Steps To Reproduce
description: Steps to reproduce the behavior description: Provide detailed steps to reproduce the issue so that our developers can reproduce the issue accurately. Please include screenshots or screen recordings for each step when possible.
placeholder: | placeholder: |
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
4. See error 4. See error
Remember to attach screenshots/recordings for each step when possible!
validations: validations:
required: true required: true
@@ -70,4 +87,4 @@ body:
id: additional id: additional
attributes: attributes:
label: Additional Context label: Additional Context
description: Add any other context about the problem here description: Anything that gives us a better understanding of the problem you're experiencing

View File

@@ -1,4 +1,4 @@
name: 💡 Feature Request name: 💡 Feature Request (English)
description: Suggest an idea for this project description: Suggest an idea for this project
title: '[Feature]: ' title: '[Feature]: '
labels: ['enhancement'] labels: ['enhancement']
@@ -6,33 +6,71 @@ body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
Thanks for taking the time to suggest a new feature! Thank you for taking the time to submit a feature request!
Before submitting this issue, please make sure you have reviewed the [Project Roadmap](https://docs.cherry-ai.com/cherrystudio/planning) and the [Feature Overview](https://docs.cherry-ai.com/cherrystudio/preview).
- type: checkboxes
id: checklist
attributes:
label: Issue Checklist
description: |
Before submitting an issue, please make sure you have completed the following steps
options:
- label: I understand that issues are for reporting problems and requesting features, not for off-topic comments, and I will provide as much detail as possible to help resolve the issue.
required: true
- label: I have checked the pinned issues and searched through the existing [open issues](https://github.com/CherryHQ/cherry-studio/issues), [closed issues](https://github.com/CherryHQ/cherry-studio/issues?q=is%3Aissue%20state%3Aclosed), and [discussions](https://github.com/CherryHQ/cherry-studio/discussions) and did not find a similar suggestion.
required: true
- label: I have provided a short and descriptive title so that developers can quickly understand the issue when browsing the issue list, rather than vague titles like "A suggestion" or "Stuck."
required: true
- label: The latest version of Cherry Studio does not include the feature I am suggesting.
required: true
- type: dropdown
id: platform
attributes:
label: Platform
description: What platform are you using?
options:
- Windows
- macOS
- Linux
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: What version of Cherry Studio are you running?
placeholder: e.g. v1.0.0
validations:
required: true
- type: textarea - type: textarea
id: problem id: problem
attributes: attributes:
label: Is your feature request related to a problem? label: Is your feature request related to an existing issue?
description: A clear and concise description of what the problem is description: Please briefly describe the problem you are experiencing. If possible, include screenshots or recordings to help illustrate the current situation or pain points.
placeholder: I'm always frustrated when... placeholder: I often feel frustrated because... (Remember to attach screenshots/recordings if applicable)
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: solution id: solution
attributes: attributes:
label: Describe the solution you'd like label: Desired Solution
description: A clear and concise description of what you want to happen description: Please briefly describe what you would like to happen. You can include mockups, screenshots, or screen recordings to better illustrate your proposed solution.
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: alternatives id: alternatives
attributes: attributes:
label: Describe alternatives you've considered label: Alternative Solutions
description: A clear and concise description of any alternative solutions or features you've considered description: Please briefly describe any alternative solutions or features you have considered. Feel free to include screenshots or mockups of alternative approaches.
- type: textarea - type: textarea
id: additional id: additional
attributes: attributes:
label: Additional Context label: Additional Information
description: Add any other context or screenshots about the feature request here description: Add any other context, screenshots, mockups or recordings that can help us better understand your feature request.

View File

@@ -1,19 +1,54 @@
name: ❓ Question name: Discussion & Questions
description: Ask a question or seek help description: Seeking help, discussing issues, asking questions, etc...
title: '[Question]: ' title: '[Discussion]: '
labels: ['question'] labels: ['question']
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
Thanks for asking a question! Please provide as much detail as possible so we can better assist you. Thank you for your question! Please describe your issue in as much detail as possible so that we can better assist you.
- type: checkboxes
id: checklist
attributes:
label: Issue Checklist
description: |
Before submitting an issue, please make sure you have completed the following steps
options:
- label: I understand that issues are meant for feedback and problem-solving, not for venting, and I will provide as much detail as possible to help resolve the issue.
required: true
- label: I have checked the pinned issues and searched through the existing [open issues](https://github.com/CherryHQ/cherry-studio/issues), [closed issues](https://github.com/CherryHQ/cherry-studio/issues?q=is%3Aissue%20state%3Aclosed), and [discussions](https://github.com/CherryHQ/cherry-studio/discussions) and did not find a similar suggestion.
required: true
- label: I confirm that I am here to ask questions and discuss issues, not to report bugs or request features.
required: true
- type: dropdown
id: platform
attributes:
label: Platform
description: What platform are you using?
options:
- Windows
- macOS
- Linux
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: What version of Cherry Studio are you running?
placeholder: e.g. v1.0.0
validations:
required: true
- type: textarea - type: textarea
id: question id: question
attributes: attributes:
label: Your Question label: Your Question
description: Please describe your question in detail description: Please describe your issue in detail. Include screenshots or screen recordings whenever possible to help us better understand your question.
placeholder: Please explain your question as clearly as possible... placeholder: Please explain your issue as clearly as possible...(Remember to attach screenshots/recordings if applicable)
validations: validations:
required: true required: true
@@ -21,23 +56,23 @@ body:
id: context id: context
attributes: attributes:
label: Context label: Context
description: Please provide some background information to help us better understand your question description: Please provide some background information to help us better understand your question. Screenshots or recordings of your current setup or situation can be very helpful.
placeholder: "For example: use case, solutions you've tried, etc." placeholder: "For example: use case, solutions you've tried, etc. Don't forget to include relevant screenshots/recordings!"
- type: textarea - type: textarea
id: additional id: additional
attributes: attributes:
label: Additional Information label: Additional Information
description: Any other relevant information, screenshots, or code examples description: Any other relevant information, screenshots, recordings, or code examples that can help us better assist you
render: shell render: shell
- type: dropdown - type: dropdown
id: priority id: priority
attributes: attributes:
label: Priority label: Priority
description: How urgent is this question for you? description: How urgent is this issue for you?
options: options:
- Low (Can wait) - Low (Review when available)
- Medium (Would like a response soon) - Medium (Would like a response soon)
- High (Blocking progress) - High (Blocking progress)
validations: validations:

View File

@@ -70,6 +70,7 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
- name: Build Mac - name: Build Mac
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
@@ -82,6 +83,7 @@ jobs:
APPLE_ID: ${{ vars.APPLE_ID }} APPLE_ID: ${{ vars.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ vars.APPLE_APP_SPECIFIC_PASSWORD }} APPLE_APP_SPECIFIC_PASSWORD: ${{ vars.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Windows - name: Build Windows
@@ -89,6 +91,7 @@ jobs:
run: yarn build:win run: yarn build:win
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
- name: Replace spaces in filenames - name: Replace spaces in filenames
run: node scripts/replace-spaces.js run: node scripts/replace-spaces.js

3
.gitignore vendored
View File

@@ -44,3 +44,6 @@ stats.html
# Local # Local
local local
.aider*
.cursorrules
.cursor/rules

View File

@@ -1,25 +0,0 @@
diff --git a/src/libsql-db.js b/src/libsql-db.js
index 58c42e4910bd0e53bc497ff9b9702b1f7a961266..250bc97c50a9b790e8798441d904d040f2d2af43 100644
--- a/src/libsql-db.js
+++ b/src/libsql-db.js
@@ -41,9 +41,9 @@ export class LibSqlDb {
}
async similaritySearch(query, k) {
const statement = `SELECT id, pageContent, uniqueLoaderId, source, metadata,
- vector_distance_cos(vector, vector32('[${query.join(',')}]'))
+ vector_distance_cos(vector, vector32('[${query.join(',')}]')) as distance
FROM ${this.tableName}
- ORDER BY vector_distance_cos(vector, vector32('[${query.join(',')}]')) ASC
+ ORDER BY distance ASC
LIMIT ${k};`;
this.debug(`Executing statement - ${truncateCenterString(statement, 700)}`);
const results = await this.client.execute(statement);
@@ -52,7 +52,7 @@ export class LibSqlDb {
return {
metadata,
pageContent: result.pageContent.toString(),
- score: 1,
+ score: 1 - result.distance,
};
});
}

View File

@@ -1,16 +1,10 @@
diff --git a/src/markdown-loader.js b/src/markdown-loader.js diff --git a/src/markdown-loader.js b/src/markdown-loader.js
index 8a17cb7f5a68d90d2be21682db6e95ce22a3e71c..9ee868ef9d4ff3dc914b3abc3c8006deb1e9c6c6 100644 index eaf30b114a273e68abbb92c8b07018495e63f4cb..4b06519bdb51845e4693fe877da9de01c7a81039 100644
--- a/src/markdown-loader.js --- a/src/markdown-loader.js
+++ b/src/markdown-loader.js +++ b/src/markdown-loader.js
@@ -1,5 +1,4 @@ @@ -21,7 +21,7 @@ export class MarkdownLoader extends BaseLoader {
import { micromark } from 'micromark';
-import { mdxJsx } from 'micromark-extension-mdx-jsx';
import { gfmHtml, gfm } from 'micromark-extension-gfm';
import createDebugMessages from 'debug';
import fs from 'node:fs';
@@ -21,7 +20,7 @@ export class MarkdownLoader extends BaseLoader {
? (await getSafe(this.filePathOrUrl, { format: 'buffer' })).body ? (await getSafe(this.filePathOrUrl, { format: 'buffer' })).body
: await stream2buffer(fs.createReadStream(this.filePathOrUrl)); : await streamToBuffer(fs.createReadStream(this.filePathOrUrl));
this.debug('MarkdownLoader stream created'); this.debug('MarkdownLoader stream created');
- const result = micromark(buffer, { extensions: [gfm(), mdxJsx()], htmlExtensions: [gfmHtml()] }); - const result = micromark(buffer, { extensions: [gfm(), mdxJsx()], htmlExtensions: [gfmHtml()] });
+ const result = micromark(buffer, { extensions: [gfm()], htmlExtensions: [gfmHtml()] }); + const result = micromark(buffer, { extensions: [gfm()], htmlExtensions: [gfmHtml()] });

View File

@@ -1,72 +1,21 @@
diff --git a/src/core/rag-embedding.js b/src/core/rag-embedding.js
index 50c3c4064af17bc4c7c46554d8f2419b3afceb0e..632c9b2e04d2e0e3bb09ef1cd8f29d2560e6afc1 100644
--- a/src/core/rag-embedding.js
+++ b/src/core/rag-embedding.js
@@ -1,10 +1,8 @@
export class RAGEmbedding {
static singleton;
static async init(embeddingModel) {
- if (!this.singleton) {
- await embeddingModel.init();
- this.singleton = new RAGEmbedding(embeddingModel);
- }
+ await embeddingModel.init();
+ this.singleton = new RAGEmbedding(embeddingModel);
}
static getInstance() {
return RAGEmbedding.singleton;
diff --git a/src/loaders/local-path-loader.d.ts b/src/loaders/local-path-loader.d.ts diff --git a/src/loaders/local-path-loader.d.ts b/src/loaders/local-path-loader.d.ts
index 48c20e68c469cd309be2dc8f28e44c1bd04a26e9..87002be39e7305a02e2a607b0c0d95cbbc359f9d 100644 index 48c20e68c469cd309be2dc8f28e44c1bd04a26e9..1c16d83bcbf9b7140292793d6cbb8c04281949d9 100644
--- a/src/loaders/local-path-loader.d.ts --- a/src/loaders/local-path-loader.d.ts
+++ b/src/loaders/local-path-loader.d.ts +++ b/src/loaders/local-path-loader.d.ts
@@ -1,19 +1,29 @@ @@ -4,8 +4,10 @@ export declare class LocalPathLoader extends BaseLoader<{
-import { BaseLoader } from '@llm-tools/embedjs-interfaces';
+import { BaseLoader } from "@llm-tools/embedjs-interfaces";
export declare class LocalPathLoader extends BaseLoader<{
- type: 'LocalPathLoader';
+ type: "LocalPathLoader";
}> { }> {
- private readonly debug; private readonly debug;
- private readonly path; private readonly path;
- constructor({ path }: { - constructor({ path }: {
- path: string; + constructor({ path, chunkSize, chunkOverlap }: {
- }); path: string;
- getUnfilteredChunks(): AsyncGenerator<{
- metadata: {
- type: "LocalPathLoader";
- originalPath: string;
- source: string;
- };
- pageContent: string;
- }, void, unknown>;
- private recursivelyAddPath;
+ private readonly debug;
+ private readonly path;
+ constructor({
+ path,
+ chunkSize,
+ chunkOverlap,
+ }: {
+ path: string;
+ chunkSize?: number; + chunkSize?: number;
+ chunkOverlap?: number; + chunkOverlap?: number;
+ }); });
+ getUnfilteredChunks(): AsyncGenerator< getUnfilteredChunks(): AsyncGenerator<{
+ { metadata: {
+ metadata: {
+ type: "LocalPathLoader";
+ originalPath: string;
+ source: string;
+ };
+ pageContent: string;
+ },
+ void,
+ unknown
+ >;
+ private recursivelyAddPath;
}
diff --git a/src/loaders/local-path-loader.js b/src/loaders/local-path-loader.js diff --git a/src/loaders/local-path-loader.js b/src/loaders/local-path-loader.js
index 4cf8a6bd1d890244c8ec49d4a05ee3bd58861c79..fd0fe1951c73da315b0c9bf4a8f33effbadb9f8f 100644 index 4cf8a6bd1d890244c8ec49d4a05ee3bd58861c79..ec8215b01195a21ef20f3c5d56ecc99f186bb596 100644
--- a/src/loaders/local-path-loader.js --- a/src/loaders/local-path-loader.js
+++ b/src/loaders/local-path-loader.js +++ b/src/loaders/local-path-loader.js
@@ -8,8 +8,8 @@ import { BaseLoader } from '@llm-tools/embedjs-interfaces'; @@ -8,8 +8,8 @@ import { BaseLoader } from '@llm-tools/embedjs-interfaces';
@@ -95,21 +44,15 @@ index 4cf8a6bd1d890244c8ec49d4a05ee3bd58861c79..fd0fe1951c73da315b0c9bf4a8f33eff
yield { yield {
pageContent: result.pageContent, pageContent: result.pageContent,
diff --git a/src/util/mime.d.ts b/src/util/mime.d.ts diff --git a/src/util/mime.d.ts b/src/util/mime.d.ts
index 57f56a1b8edc98366af9f84d671676c41c2f01ca..f53856fa9c78afbeee9e085c7ed0b3a131f8ee5a 100644 index 57f56a1b8edc98366af9f84d671676c41c2f01ca..14be3b5727cff6eb1978838045e9a788f8f53bfb 100644
--- a/src/util/mime.d.ts --- a/src/util/mime.d.ts
+++ b/src/util/mime.d.ts +++ b/src/util/mime.d.ts
@@ -1,2 +1,7 @@ @@ -1,2 +1,2 @@
-import { BaseLoader } from '@llm-tools/embedjs-interfaces'; import { BaseLoader } from '@llm-tools/embedjs-interfaces';
-export declare function createLoaderFromMimeType(loaderData: string, mimeType: string): Promise<BaseLoader>; -export declare function createLoaderFromMimeType(loaderData: string, mimeType: string): Promise<BaseLoader>;
+import { BaseLoader } from "@llm-tools/embedjs-interfaces"; +export declare function createLoaderFromMimeType(loaderData: string, mimeType: string, chunkSize?: number, chunkOverlap?: number): Promise<BaseLoader>;
+export declare function createLoaderFromMimeType(
+ loaderData: string,
+ mimeType: string,
+ chunkSize?: number,
+ chunkOverlap?: number
+): Promise<BaseLoader>;
diff --git a/src/util/mime.js b/src/util/mime.js diff --git a/src/util/mime.js b/src/util/mime.js
index 9af30bd5b8cf42985f547073a4c19756292c33a3..54ae20343131a533ab70236d3060b6accc8f6126 100644 index b6426a859968e2bf6206795f70333e90ae27aeb7..16ae2adb863f8d7abfa757f1c5cc39f6bb1c44fa 100644
--- a/src/util/mime.js --- a/src/util/mime.js
+++ b/src/util/mime.js +++ b/src/util/mime.js
@@ -1,7 +1,9 @@ @@ -1,7 +1,9 @@
@@ -117,7 +60,7 @@ index 9af30bd5b8cf42985f547073a4c19756292c33a3..54ae20343131a533ab70236d3060b6ac
import createDebugMessages from 'debug'; import createDebugMessages from 'debug';
import { TextLoader } from '../loaders/text-loader.js'; import { TextLoader } from '../loaders/text-loader.js';
-export async function createLoaderFromMimeType(loaderData, mimeType) { -export async function createLoaderFromMimeType(loaderData, mimeType) {
+import fs from 'node:fs'; +import fs from 'node:fs'
+ +
+export async function createLoaderFromMimeType(loaderData, mimeType, chunkSize, chunkOverlap) { +export async function createLoaderFromMimeType(loaderData, mimeType, chunkSize, chunkOverlap) {
createDebugMessages('embedjs:util:createLoaderFromMimeType')(`Incoming mime type '${mimeType}'`); createDebugMessages('embedjs:util:createLoaderFromMimeType')(`Incoming mime type '${mimeType}'`);
@@ -157,19 +100,17 @@ index 9af30bd5b8cf42985f547073a4c19756292c33a3..54ae20343131a533ab70236d3060b6ac
} }
case 'text/plain': { case 'text/plain': {
const fineType = mime.getType(loaderData); const fineType = mime.getType(loaderData);
@@ -42,24 +44,26 @@ export async function createLoaderFromMimeType(loaderData, mimeType) { @@ -42,24 +44,24 @@ export async function createLoaderFromMimeType(loaderData, mimeType) {
throw new Error('Package `@llm-tools/embedjs-loader-csv` needs to be installed to load CSV files'); throw new Error('Package `@llm-tools/embedjs-loader-csv` needs to be installed to load CSV files');
}); });
createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported CsvLoader'); createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported CsvLoader');
- return new CsvLoader({ filePathOrUrl: loaderData }); - return new CsvLoader({ filePathOrUrl: loaderData });
+ return new CsvLoader({ filePathOrUrl: loaderData, chunkSize, chunkOverlap }); + return new CsvLoader({ filePathOrUrl: loaderData, chunkSize, chunkOverlap });
+ }
+ else{
+ const content = fs.readFileSync(loaderData, 'utf-8');
+ return new TextLoader({ text: content, chunkSize, chunkOverlap });
} }
- else - else
- return new TextLoader({ text: loaderData }); - return new TextLoader({ text: loaderData });
+ const content = fs.readFileSync(loaderData, 'utf-8');
+ return new TextLoader({ text: content, chunkSize, chunkOverlap });
} }
case 'application/csv': { case 'application/csv': {
const { CsvLoader } = await import('@llm-tools/embedjs-loader-csv').catch(() => { const { CsvLoader } = await import('@llm-tools/embedjs-loader-csv').catch(() => {
@@ -189,7 +130,7 @@ index 9af30bd5b8cf42985f547073a4c19756292c33a3..54ae20343131a533ab70236d3060b6ac
} }
case 'text/xml': { case 'text/xml': {
const { SitemapLoader } = await import('@llm-tools/embedjs-loader-sitemap').catch(() => { const { SitemapLoader } = await import('@llm-tools/embedjs-loader-sitemap').catch(() => {
@@ -67,14 +71,14 @@ export async function createLoaderFromMimeType(loaderData, mimeType) { @@ -67,14 +69,14 @@ export async function createLoaderFromMimeType(loaderData, mimeType) {
}); });
createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported SitemapLoader'); createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported SitemapLoader');
if (await SitemapLoader.test(loaderData)) { if (await SitemapLoader.test(loaderData)) {
@@ -206,12 +147,12 @@ index 9af30bd5b8cf42985f547073a4c19756292c33a3..54ae20343131a533ab70236d3060b6ac
} }
case 'text/x-markdown': case 'text/x-markdown':
case 'text/markdown': { case 'text/markdown': {
@@ -82,7 +86,7 @@ export async function createLoaderFromMimeType(loaderData, mimeType) { @@ -82,7 +84,7 @@ export async function createLoaderFromMimeType(loaderData, mimeType) {
throw new Error('Package `@llm-tools/embedjs-loader-markdown` needs to be installed to load markdown files'); throw new Error('Package `@llm-tools/embedjs-loader-markdown` needs to be installed to load markdown files');
}); });
createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported MarkdownLoader'); createDebugMessages('embedjs:util:createLoaderFromMimeType')('Dynamically imported MarkdownLoader');
- return new MarkdownLoader({ filePathOrUrl: loaderData }); - return new MarkdownLoader({ filePathOrUrl: loaderData });
+ return new MarkdownLoader({ filePathOrUrl: loaderData, chunkSize, chunkOverlap }); + return new MarkdownLoader({ filePathOrUrl: loaderData, chunkSize, chunkOverlap });
} }
case undefined: case 'image/png':
throw new Error(`MIME type could not be detected. Please file an issue if you think this is a bug.`); case 'image/jpeg': {

View File

@@ -1,54 +0,0 @@
diff --git a/src/util/strings.cjs b/src/util/strings.cjs
index 9933cc6e3866c476b47342a29ddb206eb90fa4a5..2965c4f2808bf94af9ef3e2ec889e5552e30e6ae 100644
--- a/src/util/strings.cjs
+++ b/src/util/strings.cjs
@@ -38,13 +38,16 @@ function toTitleCase(str) {
});
}
function isValidURL(url) {
- try {
- new URL(url);
- return true;
- }
- catch {
- return false;
+ if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('ftp://')) {
+ try {
+ new URL(url);
+ return true;
+ }
+ catch {
+ return false;
+ }
}
+ return false;
}
function isValidJson(str) {
try {
diff --git a/src/util/strings.js b/src/util/strings.js
index f5c1655512099b880fc5022e95d5e0c4d1d073f2..1a64bd662a22efd2effd9d2846ffcf0b93391963 100644
--- a/src/util/strings.js
+++ b/src/util/strings.js
@@ -29,13 +29,16 @@ export function toTitleCase(str) {
});
}
export function isValidURL(url) {
- try {
- new URL(url);
- return true;
- }
- catch {
- return false;
+ if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('ftp://')) {
+ try {
+ new URL(url);
+ return true;
+ }
+ catch {
+ return false;
+ }
}
+ return false;
}
export function isValidJson(str) {
try {

View File

@@ -0,0 +1,57 @@
diff --git a/dist/index.js b/dist/index.js
index 88c405a000d21b3631eaa378690907c5527b8eaf..e03e66440c7c93aee38adf57df3096c6fefcd96d 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -82,7 +82,6 @@ module.exports = __toCommonJS(index_exports);
// src/utils.ts
var import_axios = __toESM(require("axios"));
-var import_js_tiktoken = require("js-tiktoken");
var BASE_URL = "https://api.tavily.com";
var DEFAULT_MODEL_ENCODING = "gpt-3.5-turbo";
var DEFAULT_MAX_TOKENS = 4e3;
@@ -97,8 +96,7 @@ function post(endpoint, body, apiKey) {
});
}
function getTotalTokensFromString(str, encodingName = DEFAULT_MODEL_ENCODING) {
- const encoding = (0, import_js_tiktoken.encodingForModel)(encodingName);
- return encoding.encode(str).length;
+ return 0;
}
function getMaxTokensFromList(data, maxTokens = DEFAULT_MAX_TOKENS) {
var result = [];
diff --git a/dist/index.mjs b/dist/index.mjs
index 0a9ea6a0add8d709e6721e806571f373d9fe0487..b81f1ea48a2b2a30ee98d53980a1b04ea3fdc5d4 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -49,7 +49,6 @@ var __async = (__this, __arguments, generator) => {
// src/utils.ts
import axios from "axios";
-import { encodingForModel } from "js-tiktoken";
var BASE_URL = "https://api.tavily.com";
var DEFAULT_MODEL_ENCODING = "gpt-3.5-turbo";
var DEFAULT_MAX_TOKENS = 4e3;
@@ -64,8 +63,7 @@ function post(endpoint, body, apiKey) {
});
}
function getTotalTokensFromString(str, encodingName = DEFAULT_MODEL_ENCODING) {
- const encoding = encodingForModel(encodingName);
- return encoding.encode(str).length;
+ return 0;
}
function getMaxTokensFromList(data, maxTokens = DEFAULT_MAX_TOKENS) {
var result = [];
diff --git a/package.json b/package.json
index 36d4a613166a7906c1dc5377a89dc0a65f746f73..dc6e0e9363046755cad123e627cc270a2e3580d1 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,6 @@
"typescript": "^5.6.2"
},
"dependencies": {
- "axios": "^1.7.7",
- "js-tiktoken": "^1.0.14"
+ "axios": "^1.7.7"
}
}

View File

@@ -1,26 +0,0 @@
diff --git a/core.js b/core.js
index 30c91e66bf595a66c09eb3dbcbda7d58154865f5..b511ff24ea1891904c60174c6ed26ecdd4d5ac51 100644
--- a/core.js
+++ b/core.js
@@ -156,7 +156,7 @@ class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
- ...getPlatformHeaders(),
+ // ...getPlatformHeaders(),
...this.authHeaders(opts),
};
}
diff --git a/core.mjs b/core.mjs
index ac267bcfcff44b1f7c9bea5513bba94726a31795..dd5bd9f29609d3f0eea4bd5b225f302893df14ad 100644
--- a/core.mjs
+++ b/core.mjs
@@ -149,7 +149,7 @@ export class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
- ...getPlatformHeaders(),
+ // ...getPlatformHeaders(),
...this.authHeaders(opts),
};
}

View File

@@ -0,0 +1,39 @@
diff --git a/core.js b/core.js
index e75a18281ce8f051990c5a50bc1076afdddf91a3..e62f796791a155f23d054e74a429516c14d6e11b 100644
--- a/core.js
+++ b/core.js
@@ -156,7 +156,7 @@ class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
- ...getPlatformHeaders(),
+ // ...getPlatformHeaders(),
...this.authHeaders(opts),
};
}
diff --git a/core.mjs b/core.mjs
index fcef58eb502664c41a77483a00db8adaf29b2817..18c5d6ed4be86b3640931277bdc27700006764d7 100644
--- a/core.mjs
+++ b/core.mjs
@@ -149,7 +149,7 @@ export class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
- ...getPlatformHeaders(),
+ // ...getPlatformHeaders(),
...this.authHeaders(opts),
};
}
diff --git a/error.mjs b/error.mjs
index 7d19f5578040afa004bc887aab1725e8703d2bac..59ec725b6142299a62798ac4bdedb63ba7d9932c 100644
--- a/error.mjs
+++ b/error.mjs
@@ -36,7 +36,7 @@ export class APIError extends OpenAIError {
if (!status || !headers) {
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}
- const error = errorResponse?.['error'];
+ const error = errorResponse?.['error'] || errorResponse;
if (status === 400) {
return new BadRequestError(status, error, message, headers);
}

View File

@@ -12,7 +12,7 @@
Cherry Studio is a desktop client that supports for multiple LLM providers, available on Windows, Mac and Linux. Cherry Studio is a desktop client that supports for multiple LLM providers, available on Windows, Mac and Linux.
👏 Join [Telegram Group](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQ Group(534635975)](https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mPMbCwUo40lYODSp-SUeY9ju9sSBeMbS&authKey=Tt8SyX2p4i1Aopn2OzPwi88tc81AW%2F4m%2Fkt4ETHTPGnM6TKOXuRxKJuUMWu5Hgay&noverify=0&group_code=534635975) 👏 Join [Telegram Group](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQ Group(1025067911)](https://qm.qq.com/q/RIBAO2pPKS)
❤️ Like Cherry Studio? Give it a star 🌟 or [Sponsor](docs/sponsor.md) to support the development! ❤️ Like Cherry Studio? Give it a star 🌟 or [Sponsor](docs/sponsor.md) to support the development!
@@ -30,7 +30,7 @@ Cherry Studio is a desktop client that supports for multiple LLM providers, avai
- ☁️ Major LLM Cloud Services: OpenAI, Gemini, Anthropic, and more - ☁️ Major LLM Cloud Services: OpenAI, Gemini, Anthropic, and more
- 🔗 AI Web Service Integration: Claude, Peplexity, Poe, and others - 🔗 AI Web Service Integration: Claude, Peplexity, Poe, and others
- 💻 Local Model Support with Ollama - 💻 Local Model Support with Ollama, LM Studio
2. **AI Assistants & Conversations**: 2. **AI Assistants & Conversations**:
@@ -60,6 +60,21 @@ Cherry Studio is a desktop client that supports for multiple LLM providers, avai
- 📝 Complete Markdown Rendering - 📝 Complete Markdown Rendering
- 🤲 Easy Content Sharing - 🤲 Easy Content Sharing
# 📝 TODO
- [x] Quick popup (read clipboard, quick question, explain, translate, summarize)
- [x] Comparison of multi-model answers
- [x] Support login using SSO provided by service providers
- [x] All models support networking
- [x] Launch of the first official version
- [x] Bug fixes and improvements (In progress...)
- [ ] Plugin functionality (JavaScript)
- [ ] Browser extension (highlight text to translate, summarize, add to knowledge base)
- [ ] iOS & Android client
- [ ] AI notes
- [ ] Voice input and output (AI call)
- [ ] Data backup supports custom backup content
# 🖥️ Develop # 🖥️ Develop
## IDE Setup ## IDE Setup
@@ -117,7 +132,8 @@ For more detailed guidelines, please refer to our [Contributing Guide](./CONTRIB
Thank you for your support and contributions! Thank you for your support and contributions!
## Related Projects ## Related Projects
* [one-api](https://github.com/songquanpeng/one-api):LLM API management and distribution system, supporting mainstream models like OpenAI, Azure, and Anthropic. Features unified API interface, suitable for key management and secondary distribution.
- [one-api](https://github.com/songquanpeng/one-api):LLM API management and distribution system, supporting mainstream models like OpenAI, Azure, and Anthropic. Features unified API interface, suitable for key management and secondary distribution.
# 🚀 Contributors # 🚀 Contributors

View File

@@ -8,9 +8,5 @@
<true/> <true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key> <key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/> <true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict> </dict>
</plist> </plist>

View File

@@ -13,7 +13,7 @@
Cherry Studioは、複数のLLMプロバイダーをサポートするデスクトップクライアントで、Windows、Mac、Linuxで利用可能です。 Cherry Studioは、複数のLLMプロバイダーをサポートするデスクトップクライアントで、Windows、Mac、Linuxで利用可能です。
👏 [Telegram](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQグループ(534635975)](https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mPMbCwUo40lYODSp-SUeY9ju9sSBeMbS&authKey=Tt8SyX2p4i1Aopn2OzPwi88tc81AW%2F4m%2Fkt4ETHTPGnM6TKOXuRxKJuUMWu5Hgay&noverify=0&group_code=534635975) 👏 [Telegram](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQグループ(1025067911)](https://qm.qq.com/q/RIBAO2pPKS)
❤️ Cherry Studioをお気に入りにしましたか小さな星をつけてください 🌟 または [スポンサー](sponsor.md) をして開発をサポートしてください!❤️ ❤️ Cherry Studioをお気に入りにしましたか小さな星をつけてください 🌟 または [スポンサー](sponsor.md) をして開発をサポートしてください!❤️
@@ -31,7 +31,7 @@ Cherry Studioは、複数のLLMプロバイダーをサポートするデスク
- ☁️ 主要な LLM クラウドサービス対応OpenAI、Gemini、Anthropic など - ☁️ 主要な LLM クラウドサービス対応OpenAI、Gemini、Anthropic など
- 🔗 AI Web サービス統合Claude、Peplexity、Poe など - 🔗 AI Web サービス統合Claude、Peplexity、Poe など
- 💻 Ollama によるローカルモデル実行対応 - 💻 Ollama、LM Studio によるローカルモデル実行対応
2. **AI アシスタントと対話** 2. **AI アシスタントと対話**
@@ -61,6 +61,21 @@ Cherry Studioは、複数のLLMプロバイダーをサポートするデスク
- 📝 完全な Markdown レンダリング - 📝 完全な Markdown レンダリング
- 🤲 簡単な共有機能 - 🤲 簡単な共有機能
# 📝 TODO
- [x] クイックポップアップ(クリップボードの読み取り、簡単な質問、説明、翻訳、要約)
- [x] 複数モデルの回答の比較
- [x] サービスプロバイダーが提供するSSOを使用したログインをサポート
- [x] すべてのモデルがネットワークをサポート
- [x] 最初の公式バージョンのリリース
- [ ] 錯誤修復と改善 (開発中...)
- [ ] プラグイン機能JavaScript
- [ ] ブラウザ拡張機能(テキストをハイライトして翻訳、要約、ナレッジベースに追加)
- [ ] iOS & Android クライアント
- [ ] AIート
- [ ] 音声入出力AIコール
- [ ] データバックアップはカスタムバックアップコンテンツをサポート
# 🖥️ 開発 # 🖥️ 開発
## IDEの設定 ## IDEの設定
@@ -118,7 +133,8 @@ Cherry Studioへの貢献を歓迎します以下の方法で貢献できま
ご支援と貢献に感謝します! ご支援と貢献に感謝します!
## 関連頁版 ## 関連頁版
* [one-api](https://github.com/songquanpeng/one-api):LLM APIの管理・配信システム。OpenAI、Azure、Anthropicなどの主要モデルに対応し、統一APIインターフェースを提供。APIキー管理と再配布に利用可能。
- [one-api](https://github.com/songquanpeng/one-api):LLM APIの管理・配信システム。OpenAI、Azure、Anthropicなどの主要モデルに対応し、統一APIインターフェースを提供。APIキー管理と再配布に利用可能。
# 🚀 コントリビューター # 🚀 コントリビューター

View File

@@ -13,7 +13,7 @@
Cherry Studio 是一款支持多个大语言模型LLM服务商的桌面客户端兼容 Windows、Mac 和 Linux 系统。 Cherry Studio 是一款支持多个大语言模型LLM服务商的桌面客户端兼容 Windows、Mac 和 Linux 系统。
👏 欢迎加入 [Telegram 群组](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQ群(534635975)](https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mPMbCwUo40lYODSp-SUeY9ju9sSBeMbS&authKey=Tt8SyX2p4i1Aopn2OzPwi88tc81AW%2F4m%2Fkt4ETHTPGnM6TKOXuRxKJuUMWu5Hgay&noverify=0&group_code=534635975) 👏 欢迎加入 [Telegram 群组](https://t.me/CherryStudioAI)[Discord](https://discord.gg/wez8HtpxqQ) | [QQ群(1025067911)](https://qm.qq.com/q/RIBAO2pPKS)
❤️ 喜欢 Cherry Studio? 点亮小星星 🌟 或 [赞助开发者](sponsor.md)! ❤️ ❤️ 喜欢 Cherry Studio? 点亮小星星 🌟 或 [赞助开发者](sponsor.md)! ❤️
@@ -31,7 +31,7 @@ Cherry Studio 是一款支持多个大语言模型LLM服务商的桌面客
- ☁️ 支持主流 LLM 云服务OpenAI、Gemini、Anthropic、硅基流动等 - ☁️ 支持主流 LLM 云服务OpenAI、Gemini、Anthropic、硅基流动等
- 🔗 集成流行 AI Web 服务Claude、Peplexity、Poe、腾讯元宝、知乎直答等 - 🔗 集成流行 AI Web 服务Claude、Peplexity、Poe、腾讯元宝、知乎直答等
- 💻 支持 Ollama 本地模型部署 - 💻 支持 Ollama、LM Studio 本地模型部署
2. **智能助手与对话** 2. **智能助手与对话**
@@ -61,6 +61,21 @@ Cherry Studio 是一款支持多个大语言模型LLM服务商的桌面客
- 📝 完整的 Markdown 渲染 - 📝 完整的 Markdown 渲染
- 🤲 便捷的内容分享功能 - 🤲 便捷的内容分享功能
# 📝 待辦事項
- [x] 快捷弹窗 (读取剪贴板、快速提问、解释、翻译、总结)
- [x] 多模型回答对比
- [x] 支持使用服务供应商提供的 SSO 进行登入
- [x] 全部模型支持连网(开发中...
- [x] 推出第一个正式版
- [x] 错误修复和改进(开发中...
- [ ] 插件功能JavaScript
- [ ] 浏览器插件(划词翻译、总结、新增至知识库)
- [ ] iOS & Android 客户端
- [ ] AI 笔记
- [ ] 语音输入输出AI 通话)
- [ ] 数据备份支持自定义备份内容
# 🖥️ 开发 # 🖥️ 开发
## IDE 设置 ## IDE 设置
@@ -118,7 +133,8 @@ $ yarn build:linux
感谢您的支持和贡献! 感谢您的支持和贡献!
## 相关项目 ## 相关项目
* [one-api](https://github.com/songquanpeng/one-api):LLM API管理及分发系统支持OpenAI、Azure、Anthropic等主流模型统一API接口可用于密钥管理与二次分发。
- [one-api](https://github.com/songquanpeng/one-api):LLM API管理及分发系统支持OpenAI、Azure、Anthropic等主流模型统一API接口可用于密钥管理与二次分发。
# 🚀 贡献者 # 🚀 贡献者

View File

@@ -24,6 +24,7 @@ files:
- '!**/{LICENSE,LICENSE.txt,LICENSE-MIT.txt,*.LICENSE.txt,NOTICE.txt,README.md,CHANGELOG.md}' - '!**/{LICENSE,LICENSE.txt,LICENSE-MIT.txt,*.LICENSE.txt,NOTICE.txt,README.md,CHANGELOG.md}'
- '!node_modules/rollup-plugin-visualizer' - '!node_modules/rollup-plugin-visualizer'
- '!node_modules/js-tiktoken' - '!node_modules/js-tiktoken'
- '!node_modules/@tavily/core/node_modules/js-tiktoken'
- '!node_modules/pdf-parse/lib/pdf.js/{v1.9.426,v1.10.88,v2.0.550}' - '!node_modules/pdf-parse/lib/pdf.js/{v1.9.426,v1.10.88,v2.0.550}'
- '!node_modules/mammoth/{mammoth.browser.js,mammoth.browser.min.js}' - '!node_modules/mammoth/{mammoth.browser.js,mammoth.browser.min.js}'
- '!node_modules/html2canvas/dist/{html2canvas.min.js,html2canvas.esm.js}' - '!node_modules/html2canvas/dist/{html2canvas.min.js,html2canvas.esm.js}'
@@ -80,12 +81,9 @@ afterPack: scripts/after-pack.js
afterSign: scripts/notarize.js afterSign: scripts/notarize.js
releaseInfo: releaseInfo:
releaseNotes: | releaseNotes: |
知识库增加设置功能 服务商新增天翼云
更加友好的错误提示信息 助手支持使用模型图标当作头像
增加百度云千帆服务商 网络搜索网站图标快速加载
修复 Groq deepseek 模型无法使用问题 macOS 移除 Option 开头快捷键限制
优化思考过程显示 @jettpark @github 代理配置优化
可以为助手绑定一个知识库 @eeee0717 界面优化和错误修复
修复知识库搜索崩溃问题 @yrom
优化 o3-mini 模型输出显示问题 @teaim
移除 QwenLM 服务商

View File

@@ -20,7 +20,8 @@ export default defineConfig({
'@llm-tools/embedjs-loader-xml', '@llm-tools/embedjs-loader-xml',
'@llm-tools/embedjs-loader-pdf', '@llm-tools/embedjs-loader-pdf',
'@llm-tools/embedjs-loader-sitemap', '@llm-tools/embedjs-loader-sitemap',
'@llm-tools/embedjs-libsql' '@llm-tools/embedjs-libsql',
'@llm-tools/embedjs-loader-image'
] ]
}), }),
...visualizerPlugin('main') ...visualizerPlugin('main')
@@ -50,7 +51,7 @@ export default defineConfig({
} }
}, },
optimizeDeps: { optimizeDeps: {
exclude: ['chunk-PZ64DZKH.js', 'chunk-JMKENWIY.js'] exclude: ['chunk-PZ64DZKH.js', 'chunk-JMKENWIY.js', 'chunk-UXYB6GHG.js']
} }
} }
}) })

View File

@@ -1,6 +1,6 @@
{ {
"name": "CherryStudio", "name": "CherryStudio",
"version": "0.9.20", "version": "1.0.2",
"private": true, "private": true,
"description": "A powerful AI assistant for producer.", "description": "A powerful AI assistant for producer.",
"main": "./out/main/index.js", "main": "./out/main/index.js",
@@ -44,23 +44,25 @@
"generate:agents": "yarn workspace @cherry-studio/database agents", "generate:agents": "yarn workspace @cherry-studio/database agents",
"generate:icons": "electron-icon-builder --input=./build/logo.png --output=build", "generate:icons": "electron-icon-builder --input=./build/logo.png --output=build",
"analyze:renderer": "VISUALIZER_RENDERER=true yarn build", "analyze:renderer": "VISUALIZER_RENDERER=true yarn build",
"analyze:main": "VISUALIZER_MAIN=true yarn build" "analyze:main": "VISUALIZER_MAIN=true yarn build",
"check": "node scripts/check-i18n.js"
}, },
"dependencies": { "dependencies": {
"@electron-toolkit/preload": "^3.0.0", "@electron-toolkit/preload": "^3.0.0",
"@electron-toolkit/utils": "^3.0.0", "@electron-toolkit/utils": "^3.0.0",
"@electron/notarize": "^2.5.0", "@electron/notarize": "^2.5.0",
"@google/generative-ai": "^0.21.0", "@google/generative-ai": "^0.21.0",
"@llm-tools/embedjs": "patch:@llm-tools/embedjs@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-npm-0.1.25-ec5645cf36.patch", "@llm-tools/embedjs": "patch:@llm-tools/embedjs@npm%3A0.1.28#~/.yarn/patches/@llm-tools-embedjs-npm-0.1.28-8e4393fa2d.patch",
"@llm-tools/embedjs-libsql": "patch:@llm-tools/embedjs-libsql@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-libsql-npm-0.1.25-fad000d74c.patch", "@llm-tools/embedjs-libsql": "^0.1.28",
"@llm-tools/embedjs-loader-csv": "^0.1.25", "@llm-tools/embedjs-loader-csv": "^0.1.28",
"@llm-tools/embedjs-loader-markdown": "patch:@llm-tools/embedjs-loader-markdown@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch", "@llm-tools/embedjs-loader-markdown": "patch:@llm-tools/embedjs-loader-markdown@npm%3A0.1.28#~/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.28-81647ffac6.patch",
"@llm-tools/embedjs-loader-msoffice": "^0.1.25", "@llm-tools/embedjs-loader-msoffice": "^0.1.28",
"@llm-tools/embedjs-loader-pdf": "^0.1.25", "@llm-tools/embedjs-loader-pdf": "^0.1.28",
"@llm-tools/embedjs-loader-sitemap": "^0.1.25", "@llm-tools/embedjs-loader-sitemap": "^0.1.28",
"@llm-tools/embedjs-loader-web": "^0.1.25", "@llm-tools/embedjs-loader-web": "^0.1.28",
"@llm-tools/embedjs-loader-xml": "^0.1.25", "@llm-tools/embedjs-loader-xml": "^0.1.28",
"@llm-tools/embedjs-openai": "^0.1.25", "@llm-tools/embedjs-openai": "^0.1.28",
"@notionhq/client": "^2.2.15",
"@types/react-infinite-scroll-component": "^5.0.0", "@types/react-infinite-scroll-component": "^5.0.0",
"adm-zip": "^0.5.16", "adm-zip": "^0.5.16",
"apache-arrow": "^18.1.0", "apache-arrow": "^18.1.0",
@@ -69,11 +71,13 @@
"electron-store": "^8.2.0", "electron-store": "^8.2.0",
"electron-updater": "^6.3.9", "electron-updater": "^6.3.9",
"electron-window-state": "^5.0.3", "electron-window-state": "^5.0.3",
"epub": "^1.3.0",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"officeparser": "^4.1.1", "officeparser": "^4.1.1",
"tokenx": "^0.4.1", "tokenx": "^0.4.1",
"undici": "^7.3.0",
"webdav": "4.11.4" "webdav": "4.11.4"
}, },
"devDependencies": { "devDependencies": {
@@ -83,12 +87,16 @@
"@electron-toolkit/tsconfig": "^1.0.1", "@electron-toolkit/tsconfig": "^1.0.1",
"@hello-pangea/dnd": "^16.6.0", "@hello-pangea/dnd": "^16.6.0",
"@kangfenmao/keyv-storage": "^0.1.0", "@kangfenmao/keyv-storage": "^0.1.0",
"@llm-tools/embedjs-loader-image": "^0.1.28",
"@reduxjs/toolkit": "^2.2.5", "@reduxjs/toolkit": "^2.2.5",
"@tavily/core": "patch:@tavily/core@npm%3A0.3.1#~/.yarn/patches/@tavily-core-npm-0.3.1-fe69bf2bea.patch",
"@types/adm-zip": "^0", "@types/adm-zip": "^0",
"@types/fs-extra": "^11", "@types/fs-extra": "^11",
"@types/lodash": "^4.17.5", "@types/lodash": "^4.17.5",
"@types/markdown-it": "^14", "@types/markdown-it": "^14",
"@types/md5": "^2.3.5",
"@types/node": "^18.19.9", "@types/node": "^18.19.9",
"@types/pako": "^1.0.2",
"@types/react": "^18.2.48", "@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18", "@types/react-dom": "^18.2.18",
"@types/react-infinite-scroll-component": "^5.0.0", "@types/react-infinite-scroll-component": "^5.0.0",
@@ -117,7 +125,7 @@
"i18next": "^23.11.5", "i18next": "^23.11.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mime": "^4.0.4", "mime": "^4.0.4",
"openai": "patch:openai@npm%3A4.76.2#~/.yarn/patches/openai-npm-4.76.2-8ff1374617.patch", "openai": "patch:openai@npm%3A4.77.3#~/.yarn/patches/openai-npm-4.77.3-59c6d42e7a.patch",
"prettier": "^3.2.4", "prettier": "^3.2.4",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
@@ -132,13 +140,14 @@
"redux": "^5.0.1", "redux": "^5.0.1",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"rehype-katex": "^7.0.1", "rehype-katex": "^7.0.1",
"rehype-mathjax": "^6.0.0", "rehype-mathjax": "^7.0.0",
"rehype-raw": "^7.0.0", "rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0", "remark-gfm": "^4.0.0",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.2", "sass": "^1.77.2",
"shiki": "^1.22.2", "shiki": "^1.22.2",
"string-width": "^7.2.0",
"styled-components": "^6.1.11", "styled-components": "^6.1.11",
"tinycolor2": "^1.6.0", "tinycolor2": "^1.6.0",
"typescript": "^5.6.2", "typescript": "^5.6.2",
@@ -151,9 +160,9 @@
}, },
"resolutions": { "resolutions": {
"pdf-parse@npm:1.1.1": "patch:pdf-parse@npm%3A1.1.1#~/.yarn/patches/pdf-parse-npm-1.1.1-04a6109b2a.patch", "pdf-parse@npm:1.1.1": "patch:pdf-parse@npm%3A1.1.1#~/.yarn/patches/pdf-parse-npm-1.1.1-04a6109b2a.patch",
"@llm-tools/embedjs-utils@npm:0.1.25": "patch:@llm-tools/embedjs-utils@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-utils-npm-0.1.25-fd8fe8a193.patch",
"@langchain/openai@npm:^0.3.16": "patch:@langchain/openai@npm%3A0.3.16#~/.yarn/patches/@langchain-openai-npm-0.3.16-e525b59526.patch", "@langchain/openai@npm:^0.3.16": "patch:@langchain/openai@npm%3A0.3.16#~/.yarn/patches/@langchain-openai-npm-0.3.16-e525b59526.patch",
"@langchain/openai@npm:>=0.1.0 <0.4.0": "patch:@langchain/openai@npm%3A0.3.16#~/.yarn/patches/@langchain-openai-npm-0.3.16-e525b59526.patch" "@langchain/openai@npm:>=0.1.0 <0.4.0": "patch:@langchain/openai@npm%3A0.3.16#~/.yarn/patches/@langchain-openai-npm-0.3.16-e525b59526.patch",
"openai@npm:^4.77.0": "patch:openai@npm%3A4.77.3#~/.yarn/patches/openai-npm-4.77.3-59c6d42e7a.patch"
}, },
"packageManager": "yarn@4.5.0" "packageManager": "yarn@4.6.0"
} }

View File

@@ -2,6 +2,8 @@ export const imageExts = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
export const videoExts = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.mkv'] export const videoExts = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.mkv']
export const audioExts = ['.mp3', '.wav', '.ogg', '.flac', '.aac'] export const audioExts = ['.mp3', '.wav', '.ogg', '.flac', '.aac']
export const documentExts = ['.pdf', '.docx', '.pptx', '.xlsx', '.odt', '.odp', '.ods'] export const documentExts = ['.pdf', '.docx', '.pptx', '.xlsx', '.odt', '.odp', '.ods']
export const thirdPartyApplicationExts = ['.draftsExport']
export const bookExts = ['.epub']
export const textExts = [ export const textExts = [
'.txt', // 普通文本文件 '.txt', // 普通文本文件
'.md', // Markdown 文件 '.md', // Markdown 文件
@@ -17,6 +19,8 @@ export const textExts = [
'.ini', // 配置文件 '.ini', // 配置文件
'.log', // 日志文件 '.log', // 日志文件
'.rtf', // 富文本格式文件 '.rtf', // 富文本格式文件
'.org', // org-mode 文件
'.wiki', // VimWiki 文件
'.tex', // LaTeX 文件 '.tex', // LaTeX 文件
'.srt', // 字幕文件 '.srt', // 字幕文件
'.xhtml', // XHTML 文件 '.xhtml', // XHTML 文件
@@ -33,6 +37,7 @@ export const textExts = [
'.bat', // Windows 批处理文件 '.bat', // Windows 批处理文件
'.sh', // Unix/Linux Shell 脚本文件 '.sh', // Unix/Linux Shell 脚本文件
'.py', // Python 脚本文件 '.py', // Python 脚本文件
'.ipynb', // Jupyter 笔记本格式
'.rb', // Ruby 脚本文件 '.rb', // Ruby 脚本文件
'.pl', // Perl 脚本文件 '.pl', // Perl 脚本文件
'.sql', // SQL 脚本文件 '.sql', // SQL 脚本文件
@@ -88,7 +93,16 @@ export const textExts = [
'.groovy', // Gradle 构建文件 '.groovy', // Gradle 构建文件
'.kts', // Kotlin Script 文件 '.kts', // Kotlin Script 文件
'.java', // Java 代码文件 '.java', // Java 代码文件
'.cs' // C# 代码文件 '.cs', // C# 代码文件
'.cpp', // C++ 代码文件
'.c', // C++ 代码文件
'.h', // C++ 头文件
'.hpp', // C++ 头文件
'.cc', // C++ 源文件
'.cxx', // C++ 源文件
'.cppm', // C++20 模块接口文件
'.ipp', // 模板实现文件
'.ixx' // C++20 模块实现文件
] ]
export const ZOOM_SHORTCUTS = [ export const ZOOM_SHORTCUTS = [

View File

@@ -0,0 +1,6 @@
export type LoaderReturn = {
entriesAdded: number
uniqueId: string
uniqueIds: string[]
loaderType: string
}

104
scripts/check-i18n.js Normal file
View File

@@ -0,0 +1,104 @@
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
var fs = require('fs')
var path = require('path')
var translationsDir = path.join(__dirname, '../src/renderer/src/i18n/locales')
var baseLocale = 'zh-CN'
var baseFileName = ''.concat(baseLocale, '.json')
var baseFilePath = path.join(translationsDir, baseFileName)
/**
* 递归同步 target 对象,使其与 template 对象保持一致
* 1. 如果 template 中存在 target 中缺少的 key则添加'[to be translated]'
* 2. 如果 target 中存在 template 中不存在的 key则删除
* 3. 对于子对象,递归同步
*
* @param target 目标对象(需要更新的语言对象)
* @param template 主模板对象(中文)
* @returns 返回是否对 target 进行了更新
*/
function syncRecursively(target, template) {
var isUpdated = false
// 添加 template 中存在但 target 中缺少的 key
for (var key in template) {
if (!(key in target)) {
target[key] =
typeof template[key] === 'object' && template[key] !== null ? {} : '[to be translated]:'.concat(template[key])
console.log('\u6DFB\u52A0\u65B0\u5C5E\u6027\uFF1A'.concat(key))
isUpdated = true
}
if (typeof template[key] === 'object' && template[key] !== null) {
if (typeof target[key] !== 'object' || target[key] === null) {
target[key] = {}
isUpdated = true
}
// 递归同步子对象
var childUpdated = syncRecursively(target[key], template[key])
if (childUpdated) {
isUpdated = true
}
}
}
// 删除 target 中存在但 template 中没有的 key
for (var targetKey in target) {
if (!(targetKey in template)) {
console.log('\u79FB\u9664\u591A\u4F59\u5C5E\u6027\uFF1A'.concat(targetKey))
delete target[targetKey]
isUpdated = true
}
}
return isUpdated
}
function syncTranslations() {
if (!fs.existsSync(baseFilePath)) {
console.error(
'\u4E3B\u6A21\u677F\u6587\u4EF6 '.concat(
baseFileName,
' \u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5\u8DEF\u5F84\u6216\u6587\u4EF6\u540D\u3002'
)
)
return
}
var baseContent = fs.readFileSync(baseFilePath, 'utf-8')
var baseJson = {}
try {
baseJson = JSON.parse(baseContent)
} catch (error) {
console.error('\u89E3\u6790 '.concat(baseFileName, ' \u51FA\u9519:'), error)
return
}
var files = fs.readdirSync(translationsDir).filter(function (file) {
return file.endsWith('.json') && file !== baseFileName
})
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var file = files_1[_i]
var filePath = path.join(translationsDir, file)
var targetJson = {}
try {
var fileContent = fs.readFileSync(filePath, 'utf-8')
targetJson = JSON.parse(fileContent)
} catch (error) {
console.error(
'\u89E3\u6790 '.concat(
file,
' \u51FA\u9519\uFF0C\u8DF3\u8FC7\u6B64\u6587\u4EF6\u3002\u9519\u8BEF\u4FE1\u606F:'
),
error
)
continue
}
var isUpdated = syncRecursively(targetJson, baseJson)
if (isUpdated) {
try {
fs.writeFileSync(filePath, JSON.stringify(targetJson, null, 2), 'utf-8')
console.log(
'\u6587\u4EF6 '.concat(file, ' \u5DF2\u66F4\u65B0\u540C\u6B65\u4E3B\u6A21\u677F\u7684\u5185\u5BB9\u3002')
)
} catch (error) {
console.error('\u5199\u5165 '.concat(file, ' \u51FA\u9519:'), error)
}
} else {
console.log('\u6587\u4EF6 '.concat(file, ' \u65E0\u9700\u66F4\u65B0\u3002'))
}
}
}
syncTranslations()

98
scripts/check-i18n.ts Normal file
View File

@@ -0,0 +1,98 @@
import * as fs from 'fs'
import * as path from 'path'
const translationsDir = path.join(__dirname, '../src/renderer/src/i18n/locales')
const baseLocale = 'zh-CN'
const baseFileName = `${baseLocale}.json`
const baseFilePath = path.join(translationsDir, baseFileName)
/**
* 递归同步 target 对象,使其与 template 对象保持一致
* 1. 如果 template 中存在 target 中缺少的 key则添加'[to be translated]'
* 2. 如果 target 中存在 template 中不存在的 key则删除
* 3. 对于子对象,递归同步
*
* @param target 目标对象(需要更新的语言对象)
* @param template 主模板对象(中文)
* @returns 返回是否对 target 进行了更新
*/
function syncRecursively(target: any, template: any): boolean {
let isUpdated = false
// 添加 template 中存在但 target 中缺少的 key
for (const key in template) {
if (!(key in target)) {
target[key] =
typeof template[key] === 'object' && template[key] !== null ? {} : `[to be translated]:${template[key]}`
console.log(`添加新属性:${key}`)
isUpdated = true
}
if (typeof template[key] === 'object' && template[key] !== null) {
if (typeof target[key] !== 'object' || target[key] === null) {
target[key] = {}
isUpdated = true
}
// 递归同步子对象
const childUpdated = syncRecursively(target[key], template[key])
if (childUpdated) {
isUpdated = true
}
}
}
// 删除 target 中存在但 template 中没有的 key
for (const targetKey in target) {
if (!(targetKey in template)) {
console.log(`移除多余属性:${targetKey}`)
delete target[targetKey]
isUpdated = true
}
}
return isUpdated
}
function syncTranslations() {
if (!fs.existsSync(baseFilePath)) {
console.error(`主模板文件 ${baseFileName} 不存在,请检查路径或文件名`)
return
}
const baseContent = fs.readFileSync(baseFilePath, 'utf-8')
let baseJson: Record<string, any> = {}
try {
baseJson = JSON.parse(baseContent)
} catch (error) {
console.error(`解析 ${baseFileName} 出错:`, error)
return
}
const files = fs.readdirSync(translationsDir).filter((file) => file.endsWith('.json') && file !== baseFileName)
for (const file of files) {
const filePath = path.join(translationsDir, file)
let targetJson: Record<string, any> = {}
try {
const fileContent = fs.readFileSync(filePath, 'utf-8')
targetJson = JSON.parse(fileContent)
} catch (error) {
console.error(`解析 ${file} 出错,跳过此文件。错误信息:`, error)
continue
}
const isUpdated = syncRecursively(targetJson, baseJson)
if (isUpdated) {
try {
fs.writeFileSync(filePath, JSON.stringify(targetJson, null, 2) + '\n', 'utf-8')
console.log(`文件 ${file} 已更新同步主模板的内容`)
} catch (error) {
console.error(`写入 ${file} 出错:`, error)
}
} else {
console.log(`文件 ${file} 无需更新`)
}
}
}
syncTranslations()

View File

@@ -1,5 +1,5 @@
import { electronApp, optimizer } from '@electron-toolkit/utils' import { electronApp, optimizer } from '@electron-toolkit/utils'
import { app, BrowserWindow } from 'electron' import { app } from 'electron'
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer' import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
import { registerIpc } from './ipc' import { registerIpc } from './ipc'
@@ -17,33 +17,9 @@ if (!app.requestSingleInstanceLock()) {
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
if (process.platform === 'darwin') {
// Enable local network access
app.commandLine.appendSwitch('enable-local-network-access')
}
app.whenReady().then(async () => { app.whenReady().then(async () => {
await updateUserDataPath() await updateUserDataPath()
// Register custom protocol
if (!app.isDefaultProtocolClient('cherrystudio')) {
app.setAsDefaultProtocolClient('cherrystudio')
}
// Handle protocol open
app.on('open-url', (event, url) => {
event.preventDefault()
const parsedUrl = new URL(url)
if (parsedUrl.pathname === 'siliconflow.oauth.login') {
const code = parsedUrl.searchParams.get('code')
if (code) {
// Handle the OAuth code here
console.log('OAuth code received:', code)
// You can send this code to your renderer process via IPC if needed
}
}
})
// Set app user model id for windows // Set app user model id for windows
electronApp.setAppUserModelId(import.meta.env.VITE_MAIN_BUNDLE_ID || 'com.kangfenmao.CherryStudio') electronApp.setAppUserModelId(import.meta.env.VITE_MAIN_BUNDLE_ID || 'com.kangfenmao.CherryStudio')
@@ -51,9 +27,8 @@ if (!app.requestSingleInstanceLock()) {
new TrayService() new TrayService()
app.on('activate', function () { app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the const mainWindow = windowService.getMainWindow()
// dock icon is clicked and there are no other windows open. if (!mainWindow || mainWindow.isDestroyed()) {
if (BrowserWindow.getAllWindows().length === 0) {
windowService.createMainWindow() windowService.createMainWindow()
} else { } else {
windowService.showMainWindow() windowService.showMainWindow()
@@ -73,12 +48,7 @@ if (!app.requestSingleInstanceLock()) {
// Listen for second instance // Listen for second instance
app.on('second-instance', () => { app.on('second-instance', () => {
const mainWindow = BrowserWindow.getAllWindows()[0] windowService.showMainWindow()
if (mainWindow) {
mainWindow.isMinimized() && mainWindow.restore()
mainWindow.show()
mainWindow.focus()
}
}) })
app.on('browser-window-created', (_, window) => { app.on('browser-window-created', (_, window) => {

View File

@@ -2,7 +2,7 @@ import fs from 'node:fs'
import path from 'node:path' import path from 'node:path'
import { Shortcut, ThemeMode } from '@types' import { Shortcut, ThemeMode } from '@types'
import { BrowserWindow, ipcMain, ProxyConfig, session, shell } from 'electron' import { BrowserWindow, ipcMain, session, shell } from 'electron'
import log from 'electron-log' import log from 'electron-log'
import { titleBarOverlayDark, titleBarOverlayLight } from './config' import { titleBarOverlayDark, titleBarOverlayLight } from './config'
@@ -14,12 +14,12 @@ import FileService from './services/FileService'
import FileStorage from './services/FileStorage' import FileStorage from './services/FileStorage'
import { GeminiService } from './services/GeminiService' import { GeminiService } from './services/GeminiService'
import KnowledgeService from './services/KnowledgeService' import KnowledgeService from './services/KnowledgeService'
import { ProxyConfig, proxyManager } from './services/ProxyManager'
import { registerShortcuts, unregisterAllShortcuts } from './services/ShortcutService' import { registerShortcuts, unregisterAllShortcuts } from './services/ShortcutService'
import { TrayService } from './services/TrayService' import { TrayService } from './services/TrayService'
import { windowService } from './services/WindowService' import { windowService } from './services/WindowService'
import { getResourcePath } from './utils' import { getResourcePath } from './utils'
import { decrypt } from './utils/aes' import { decrypt, encrypt } from './utils/aes'
import { encrypt } from './utils/aes'
import { compress, decompress } from './utils/zip' import { compress, decompress } from './utils/zip'
const fileManager = new FileStorage() const fileManager = new FileStorage()
@@ -40,9 +40,9 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
})) }))
ipcMain.handle('app:proxy', async (_, proxy: string) => { ipcMain.handle('app:proxy', async (_, proxy: string) => {
const sessions = [session.defaultSession, session.fromPartition('persist:webview')] const proxyConfig: ProxyConfig =
const proxyConfig: ProxyConfig = proxy === 'system' ? { mode: 'system' } : proxy ? { proxyRules: proxy } : {} proxy === 'system' ? { mode: 'system' } : proxy ? { mode: 'custom', url: proxy } : { mode: 'none' }
await Promise.all(sessions.map((session) => session.setProxy(proxyConfig))) await proxyManager.configureProxy(proxyConfig)
}) })
ipcMain.handle('app:reload', () => mainWindow.reload()) ipcMain.handle('app:reload', () => mainWindow.reload())

View File

@@ -0,0 +1,22 @@
import * as fs from 'node:fs'
import { JsonLoader } from '@llm-tools/embedjs'
/**
* Drafts 应用导出的笔记文件加载器
* 原始文件是一个 JSON 数组。每条笔记只保留 content、tags、modified_at 三个字段
*/
export class DraftsExportLoader extends JsonLoader {
constructor(filePath: string) {
const fileContent = fs.readFileSync(filePath, 'utf-8')
const rawJson = JSON.parse(fileContent) as any[]
const json = rawJson.map((item) => {
return {
content: item.content?.replace(/\n/g, '<br>'),
tags: item.tags,
modified_at: item.created_at
}
})
super({ object: json })
}
}

View File

@@ -0,0 +1,228 @@
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters'
import { BaseLoader } from '@llm-tools/embedjs-interfaces'
import { cleanString } from '@llm-tools/embedjs-utils'
import Logger from 'electron-log'
import EPub from 'epub'
import * as fs from 'fs'
/**
* epub 加载器的配置选项
*/
interface EpubLoaderOptions {
/** epub 文件路径 */
filePath: string
/** 文本分块大小 */
chunkSize: number
/** 分块重叠大小 */
chunkOverlap: number
}
/**
* epub 文件的元数据信息
*/
interface EpubMetadata {
/** 作者显示名称(例如:"Lewis Carroll" */
creator?: string
/** 作者规范化名称,用于排序和索引(例如:"Carroll, Lewis" */
creatorFileAs?: string
/** 书籍标题(例如:"Alice's Adventures in Wonderland" */
title?: string
/** 语言代码(例如:"en" 或 "zh-CN" */
language?: string
/** 主题或分类(例如:"Fantasy"、"Fiction" */
subject?: string
/** 创建日期(例如:"2024-02-14" */
date?: string
/** 书籍描述或简介 */
description?: string
}
/**
* epub 章节信息
*/
interface EpubChapter {
/** 章节 ID */
id: string
/** 章节标题 */
title?: string
/** 章节顺序 */
order?: number
}
/**
* epub 文件加载器
* 用于解析 epub 电子书文件,提取文本内容和元数据
*/
export class EpubLoader extends BaseLoader<Record<string, string | number | boolean>, Record<string, unknown>> {
protected filePath: string
protected chunkSize: number
protected chunkOverlap: number
private extractedText: string
private metadata: EpubMetadata | null
/**
* 创建 epub 加载器实例
* @param options 加载器配置选项
*/
constructor(options: EpubLoaderOptions) {
super(options.filePath, {
chunkSize: options.chunkSize,
chunkOverlap: options.chunkOverlap
})
this.filePath = options.filePath
this.chunkSize = options.chunkSize
this.chunkOverlap = options.chunkOverlap
this.extractedText = ''
this.metadata = null
}
/**
* 等待 epub 文件初始化完成
* epub 库使用事件机制,需要等待 'end' 事件触发后才能访问文件内容
* @param epub epub 实例
* @returns 元数据和章节信息
*/
private waitForEpubInit(epub: any): Promise<{ metadata: EpubMetadata; chapters: EpubChapter[] }> {
return new Promise((resolve, reject) => {
epub.on('end', () => {
// 提取元数据
const metadata: EpubMetadata = {
creator: epub.metadata.creator,
creatorFileAs: epub.metadata.creatorFileAs,
title: epub.metadata.title,
language: epub.metadata.language,
subject: epub.metadata.subject,
date: epub.metadata.date,
description: epub.metadata.description
}
// 提取章节信息
const chapters: EpubChapter[] = epub.flow.map((chapter: any, index: number) => ({
id: chapter.id,
title: chapter.title || `Chapter ${index + 1}`,
order: index + 1
}))
resolve({ metadata, chapters })
})
epub.on('error', (error: Error) => {
reject(error)
})
epub.parse()
})
}
/**
* 获取章节内容
* @param epub epub 实例
* @param chapterId 章节 ID
* @returns 章节文本内容
*/
private getChapter(epub: any, chapterId: string): Promise<string> {
return new Promise((resolve, reject) => {
epub.getChapter(chapterId, (error: Error | null, text: string) => {
if (error) {
reject(error)
} else {
resolve(text)
}
})
})
}
/**
* 从 epub 文件中提取文本内容
* 1. 检查文件是否存在
* 2. 初始化 epub 并获取元数据
* 3. 遍历所有章节并提取文本
* 4. 清理 HTML 标签
* 5. 合并所有章节文本
*/
private async extractTextFromEpub() {
try {
// 检查文件是否存在
if (!fs.existsSync(this.filePath)) {
throw new Error(`File not found: ${this.filePath}`)
}
const epub = new EPub(this.filePath)
// 等待 epub 初始化完成并获取元数据
const { metadata, chapters } = await this.waitForEpubInit(epub)
this.metadata = metadata
if (!epub.flow || epub.flow.length === 0) {
throw new Error('No content found in epub file')
}
const chapterTexts: string[] = []
// 遍历所有章节
for (const chapter of chapters) {
try {
const content = await this.getChapter(epub, chapter.id)
if (!content) {
continue
}
// 移除 HTML 标签并清理文本
const text = content
.replace(/<[^>]*>/g, ' ') // 移除所有 HTML 标签
.replace(/\s+/g, ' ') // 将多个空白字符替换为单个空格
.trim() // 移除首尾空白
if (text) {
chapterTexts.push(text)
}
} catch (error) {
Logger.error(`[EpubLoader] Error processing chapter ${chapter.id}:`, error)
}
}
// 使用双换行符连接所有章节文本
this.extractedText = chapterTexts.join('\n\n')
} catch (error) {
Logger.error('[EpubLoader] Error in extractTextFromEpub:', error)
throw error
}
}
/**
* 生成文本块
* 重写 BaseLoader 的方法,将提取的文本分割成适当大小的块
* 每个块都包含源文件和元数据信息
*/
override async *getUnfilteredChunks() {
// 如果还没有提取文本,先提取
if (!this.extractedText) {
await this.extractTextFromEpub()
}
Logger.info('[EpubLoader] 书名:', this.metadata?.title || '未知书名', ' 文本大小:', this.extractedText.length)
// 创建文本分块器
const chunker = new RecursiveCharacterTextSplitter({
chunkSize: this.chunkSize,
chunkOverlap: this.chunkOverlap
})
// 清理并分割文本
const chunks = await chunker.splitText(cleanString(this.extractedText))
// 为每个文本块添加元数据
for (const chunk of chunks) {
yield {
pageContent: chunk,
metadata: {
source: this.filePath,
title: this.metadata?.title || '',
creator: this.metadata?.creator || '',
language: this.metadata?.language || ''
}
}
}
}
}

159
src/main/loader/index.ts Normal file
View File

@@ -0,0 +1,159 @@
import * as fs from 'node:fs'
import { JsonLoader, LocalPathLoader, RAGApplication, TextLoader } from '@llm-tools/embedjs'
import type { AddLoaderReturn } from '@llm-tools/embedjs-interfaces'
import { WebLoader } from '@llm-tools/embedjs-loader-web'
import { LoaderReturn } from '@shared/config/types'
import { FileType, KnowledgeBaseParams } from '@types'
import Logger from 'electron-log'
import { DraftsExportLoader } from './draftsExportLoader'
import { EpubLoader } from './epubLoader'
import { OdLoader, OdType } from './odLoader'
// embedjs内置loader类型
const commonExts = ['.pdf', '.csv', '.docx', '.pptx', '.xlsx', '.md']
export async function addOdLoader(
ragApplication: RAGApplication,
file: FileType,
base: KnowledgeBaseParams,
forceReload: boolean
): Promise<AddLoaderReturn> {
const loaderMap: Record<string, OdType> = {
'.odt': OdType.OdtLoader,
'.ods': OdType.OdsLoader,
'.odp': OdType.OdpLoader
}
const odType = loaderMap[file.ext]
if (!odType) {
throw new Error('Unknown odType')
}
return ragApplication.addLoader(
new OdLoader({
odType,
filePath: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
export async function addFileLoader(
ragApplication: RAGApplication,
file: FileType,
base: KnowledgeBaseParams,
forceReload: boolean
): Promise<LoaderReturn> {
// 内置类型
if (commonExts.includes(file.ext)) {
const loaderReturn = await ragApplication.addLoader(
// @ts-ignore LocalPathLoader
new LocalPathLoader({ path: file.path, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any,
forceReload
)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
}
// 自定义类型
if (['.odt', '.ods', '.odp'].includes(file.ext)) {
const loaderReturn = await addOdLoader(ragApplication, file, base, forceReload)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
}
// epub 文件处理
if (file.ext === '.epub') {
const loaderReturn = await ragApplication.addLoader(
new EpubLoader({
filePath: file.path,
chunkSize: base.chunkSize ?? 1000,
chunkOverlap: base.chunkOverlap ?? 200
}) as any,
forceReload
)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
}
// DraftsExport类型 (file.ext会自动转换成小写)
if (['.draftsexport'].includes(file.ext)) {
const loaderReturn = await ragApplication.addLoader(new DraftsExportLoader(file.path) as any, forceReload)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
}
}
const fileContent = fs.readFileSync(file.path, 'utf-8')
// HTML类型
if (['.html', '.htm'].includes(file.ext)) {
const loaderReturn = await ragApplication.addLoader(
new WebLoader({
urlOrContent: fileContent,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
}
}
// JSON类型
if (['.json'].includes(file.ext)) {
let jsonObject = {}
let jsonParsed = true
try {
jsonObject = JSON.parse(fileContent)
} catch (error) {
jsonParsed = false
Logger.warn('[KnowledgeBase] failed parsing json file, failling back to text processing:', file.path, error)
}
if (jsonParsed) {
const loaderReturn = await ragApplication.addLoader(new JsonLoader({ object: jsonObject }))
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
}
}
}
// 文本类型
const loaderReturn = await ragApplication.addLoader(
new TextLoader({ text: fileContent, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any,
forceReload
)
Logger.info('[KnowledgeBase] processing file', file.path)
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
}

View File

@@ -0,0 +1,71 @@
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters'
import { BaseLoader } from '@llm-tools/embedjs-interfaces'
import { cleanString } from '@llm-tools/embedjs-utils'
import md5 from 'md5'
import { OfficeParserConfig, parseOfficeAsync } from 'officeparser'
export enum OdType {
OdtLoader = 'OdtLoader',
OdsLoader = 'OdsLoader',
OdpLoader = 'OdpLoader',
undefined = 'undefined'
}
export class OdLoader<OdType> extends BaseLoader<{ type: string }> {
private readonly odType: OdType
private readonly filePath: string
private extractedText: string
private config: OfficeParserConfig
constructor({
odType,
filePath,
chunkSize,
chunkOverlap
}: {
odType: OdType
filePath: string
chunkSize?: number
chunkOverlap?: number
}) {
super(`${odType}_${md5(filePath)}`, { filePath }, chunkSize ?? 1000, chunkOverlap ?? 0)
this.odType = odType
this.filePath = filePath
this.extractedText = ''
this.config = {
newlineDelimiter: ' ',
ignoreNotes: false
}
}
private async extractTextFromOdt() {
try {
this.extractedText = await parseOfficeAsync(this.filePath, this.config)
} catch (err) {
console.error('odLoader error', err)
throw err
}
}
override async *getUnfilteredChunks() {
if (!this.extractedText) {
await this.extractTextFromOdt()
}
const chunker = new RecursiveCharacterTextSplitter({
chunkSize: this.chunkSize,
chunkOverlap: this.chunkOverlap
})
const chunks = await chunker.splitText(cleanString(this.extractedText))
for (const chunk of chunks) {
yield {
pageContent: chunk,
metadata: {
type: this.odType as string,
source: this.filePath
}
}
}
}
}

View File

@@ -1,5 +1,6 @@
import { WebDavConfig } from '@types' import { WebDavConfig } from '@types'
import AdmZip from 'adm-zip' import AdmZip from 'adm-zip'
import { exec } from 'child_process'
import { app } from 'electron' import { app } from 'electron'
import Logger from 'electron-log' import Logger from 'electron-log'
import * as fs from 'fs-extra' import * as fs from 'fs-extra'
@@ -18,6 +19,53 @@ class BackupManager {
this.restoreFromWebdav = this.restoreFromWebdav.bind(this) this.restoreFromWebdav = this.restoreFromWebdav.bind(this)
} }
private async setWritableRecursive(dirPath: string): Promise<void> {
try {
const items = await fs.readdir(dirPath, { withFileTypes: true })
for (const item of items) {
const fullPath = path.join(dirPath, item.name)
// 先处理子目录
if (item.isDirectory()) {
await this.setWritableRecursive(fullPath)
}
// 统一设置权限Windows需要特殊处理
await this.forceSetWritable(fullPath)
}
// 确保根目录权限
await this.forceSetWritable(dirPath)
} catch (error) {
Logger.error(`权限设置失败:${dirPath}`, error)
throw error
}
}
// 新增跨平台权限设置方法
private async forceSetWritable(targetPath: string): Promise<void> {
try {
// Windows系统需要先取消只读属性
if (process.platform === 'win32') {
await fs.chmod(targetPath, 0o666) // Windows会忽略权限位但能移除只读
} else {
const stats = await fs.stat(targetPath)
const mode = stats.isDirectory() ? 0o777 : 0o666
await fs.chmod(targetPath, mode)
}
// 双重保险使用文件属性命令Windows专用
if (process.platform === 'win32') {
await exec(`attrib -R "${targetPath}" /L /D`)
}
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
Logger.warn(`权限设置警告:${targetPath}`, error)
}
}
}
async backup( async backup(
_: Electron.IpcMainInvokeEvent, _: Electron.IpcMainInvokeEvent,
fileName: string, fileName: string,
@@ -35,6 +83,7 @@ class BackupManager {
const sourcePath = path.join(app.getPath('userData'), 'Data') const sourcePath = path.join(app.getPath('userData'), 'Data')
const tempDataDir = path.join(this.tempDir, 'Data') const tempDataDir = path.join(this.tempDir, 'Data')
await fs.copy(sourcePath, tempDataDir) await fs.copy(sourcePath, tempDataDir)
await this.setWritableRecursive(tempDataDir)
// 使用 adm-zip 创建压缩文件 // 使用 adm-zip 创建压缩文件
const zip = new AdmZip() const zip = new AdmZip()
@@ -75,12 +124,14 @@ class BackupManager {
// 恢复 Data 目录 // 恢复 Data 目录
const sourcePath = path.join(this.tempDir, 'Data') const sourcePath = path.join(this.tempDir, 'Data')
const destPath = path.join(app.getPath('userData'), 'Data') const destPath = path.join(app.getPath('userData'), 'Data')
await this.setWritableRecursive(destPath)
await fs.remove(destPath) await fs.remove(destPath)
await fs.copy(sourcePath, destPath) await fs.copy(sourcePath, destPath)
Logger.log('[backup] step 4: clean up temp directory') Logger.log('[backup] step 4: clean up temp directory')
// 清理临时目录 // 清理临时目录
await this.setWritableRecursive(this.tempDir)
await fs.remove(this.tempDir) await fs.remove(this.tempDir)
Logger.log('[backup] step 5: Restore completed successfully') Logger.log('[backup] step 5: Restore completed successfully')

View File

@@ -1,14 +1,16 @@
import { FileMetadataResponse, FileState, GoogleAIFileManager } from '@google/generative-ai/server' import { FileMetadataResponse, FileState, GoogleAIFileManager } from '@google/generative-ai/server'
import { FileType } from '@types' import { FileType } from '@types'
import fs from 'fs' import fs from 'fs'
import { ProxyAgent, setGlobalDispatcher } from 'undici'
import { CacheService } from './CacheService' import { CacheService } from './CacheService'
import { proxyManager } from './ProxyManager'
export class GeminiService { export class GeminiService {
private static readonly FILE_LIST_CACHE_KEY = 'gemini_file_list' private static readonly FILE_LIST_CACHE_KEY = 'gemini_file_list'
private static readonly CACHE_DURATION = 3000 private static readonly CACHE_DURATION = 3000
static async uploadFile(_: Electron.IpcMainInvokeEvent, file: FileType, apiKey: string) { static async uploadFile(_: Electron.IpcMainInvokeEvent, file: FileType, apiKey: string) {
setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || ''))
const fileManager = new GoogleAIFileManager(apiKey) const fileManager = new GoogleAIFileManager(apiKey)
const uploadResult = await fileManager.uploadFile(file.path, { const uploadResult = await fileManager.uploadFile(file.path, {
mimeType: 'application/pdf', mimeType: 'application/pdf',
@@ -29,6 +31,7 @@ export class GeminiService {
file: FileType, file: FileType,
apiKey: string apiKey: string
): Promise<FileMetadataResponse | undefined> { ): Promise<FileMetadataResponse | undefined> {
setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || ''))
const fileManager = new GoogleAIFileManager(apiKey) const fileManager = new GoogleAIFileManager(apiKey)
const cachedResponse = CacheService.get<any>(GeminiService.FILE_LIST_CACHE_KEY) const cachedResponse = CacheService.get<any>(GeminiService.FILE_LIST_CACHE_KEY)
@@ -52,11 +55,13 @@ export class GeminiService {
} }
static async listFiles(_: Electron.IpcMainInvokeEvent, apiKey: string) { static async listFiles(_: Electron.IpcMainInvokeEvent, apiKey: string) {
setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || ''))
const fileManager = new GoogleAIFileManager(apiKey) const fileManager = new GoogleAIFileManager(apiKey)
return await fileManager.listFiles() return await fileManager.listFiles()
} }
static async deleteFile(_: Electron.IpcMainInvokeEvent, apiKey: string, fileId: string) { static async deleteFile(_: Electron.IpcMainInvokeEvent, apiKey: string, fileId: string) {
setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || ''))
const fileManager = new GoogleAIFileManager(apiKey) const fileManager = new GoogleAIFileManager(apiKey)
await fileManager.deleteFile(fileId) await fileManager.deleteFile(fileId)
} }

View File

@@ -1,18 +1,23 @@
import * as fs from 'node:fs' import * as fs from 'node:fs'
import path from 'node:path' import path from 'node:path'
import { LocalPathLoader, RAGApplication, RAGApplicationBuilder, TextLoader } from '@llm-tools/embedjs' import { RAGApplication, RAGApplicationBuilder, TextLoader } from '@llm-tools/embedjs'
import type { AddLoaderReturn, ExtractChunkData } from '@llm-tools/embedjs-interfaces' import type { ExtractChunkData } from '@llm-tools/embedjs-interfaces'
import { LibSqlDb } from '@llm-tools/embedjs-libsql' import { LibSqlDb } from '@llm-tools/embedjs-libsql'
import { MarkdownLoader } from '@llm-tools/embedjs-loader-markdown'
import { DocxLoader, ExcelLoader, PptLoader } from '@llm-tools/embedjs-loader-msoffice'
import { PdfLoader } from '@llm-tools/embedjs-loader-pdf'
import { SitemapLoader } from '@llm-tools/embedjs-loader-sitemap' import { SitemapLoader } from '@llm-tools/embedjs-loader-sitemap'
import { WebLoader } from '@llm-tools/embedjs-loader-web' import { WebLoader } from '@llm-tools/embedjs-loader-web'
import { AzureOpenAiEmbeddings, OpenAiEmbeddings } from '@llm-tools/embedjs-openai' import { AzureOpenAiEmbeddings, OpenAiEmbeddings } from '@llm-tools/embedjs-openai'
import { addFileLoader } from '@main/loader'
import { getInstanceName } from '@main/utils' import { getInstanceName } from '@main/utils'
import { getAllFiles } from '@main/utils/file'
import type { LoaderReturn } from '@shared/config/types'
import { FileType, KnowledgeBaseParams, KnowledgeItem } from '@types' import { FileType, KnowledgeBaseParams, KnowledgeItem } from '@types'
import { app } from 'electron' import { app } from 'electron'
import { ProxyAgent, setGlobalDispatcher } from 'undici'
import { v4 as uuidv4 } from 'uuid'
import { proxyManager } from './ProxyManager'
import { windowService } from './WindowService'
class KnowledgeService { class KnowledgeService {
private storageDir = path.join(app.getPath('userData'), 'Data', 'KnowledgeBase') private storageDir = path.join(app.getPath('userData'), 'Data', 'KnowledgeBase')
@@ -45,13 +50,14 @@ class KnowledgeService {
azureOpenAIApiVersion: apiVersion, azureOpenAIApiVersion: apiVersion,
azureOpenAIApiDeploymentName: model, azureOpenAIApiDeploymentName: model,
azureOpenAIApiInstanceName: getInstanceName(baseURL), azureOpenAIApiInstanceName: getInstanceName(baseURL),
configuration: { httpAgent: proxyManager.getProxyAgent() },
dimensions, dimensions,
batchSize batchSize
}) })
: new OpenAiEmbeddings({ : new OpenAiEmbeddings({
model, model,
apiKey, apiKey,
configuration: { baseURL }, configuration: { baseURL, httpAgent: proxyManager.getProxyAgent() },
dimensions, dimensions,
batchSize batchSize
}) })
@@ -79,120 +85,109 @@ class KnowledgeService {
public add = async ( public add = async (
_: Electron.IpcMainInvokeEvent, _: Electron.IpcMainInvokeEvent,
{ base, item, forceReload = false }: { base: KnowledgeBaseParams; item: KnowledgeItem; forceReload: boolean } { base, item, forceReload = false }: { base: KnowledgeBaseParams; item: KnowledgeItem; forceReload: boolean }
): Promise<AddLoaderReturn> => { ): Promise<LoaderReturn> => {
setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || ''))
const ragApplication = await this.getRagApplication(base) const ragApplication = await this.getRagApplication(base)
const sendDirectoryProcessingPercent = (totalFiles: number, processedFiles: number) => {
const mainWindow = windowService.getMainWindow()
mainWindow?.webContents.send('directory-processing-percent', {
itemId: item.id,
percent: (processedFiles / totalFiles) * 100
})
}
if (item.type === 'directory') { if (item.type === 'directory') {
const directory = item.content as string const directory = item.content as string
return await ragApplication.addLoader( const files = getAllFiles(directory)
new LocalPathLoader({ path: directory, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any, const totalFiles = files.length
forceReload let processedFiles = 0
)
const loaderPromises = files.map(async (file) => {
const result = await addFileLoader(ragApplication, file, base, forceReload)
processedFiles++
sendDirectoryProcessingPercent(totalFiles, processedFiles)
return result
})
const loaderResults = await Promise.allSettled(loaderPromises)
// @ts-ignore uniqueId
const uniqueIds = loaderResults
.filter((result) => result.status === 'fulfilled')
.map((result) => result.value.uniqueId)
return {
entriesAdded: loaderResults.length,
uniqueId: `DirectoryLoader_${uuidv4()}`,
uniqueIds,
loaderType: 'DirectoryLoader'
} as LoaderReturn
} }
if (item.type === 'url') { if (item.type === 'url') {
const content = item.content as string const content = item.content as string
if (content.startsWith('http')) { if (content.startsWith('http')) {
return await ragApplication.addLoader( const loaderReturn = await ragApplication.addLoader(
new WebLoader({ urlOrContent: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any, new WebLoader({ urlOrContent: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any,
forceReload forceReload
) )
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
} }
} }
if (item.type === 'sitemap') { if (item.type === 'sitemap') {
const content = item.content as string const content = item.content as string
// @ts-ignore loader type // @ts-ignore loader type
return await ragApplication.addLoader( const loaderReturn = await ragApplication.addLoader(
new SitemapLoader({ url: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any, new SitemapLoader({ url: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }) as any,
forceReload forceReload
) )
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
} }
if (item.type === 'note') { if (item.type === 'note') {
const content = item.content as string const content = item.content as string
console.debug('chunkSize', base.chunkSize) console.debug('chunkSize', base.chunkSize)
return await ragApplication.addLoader( const loaderReturn = await ragApplication.addLoader(
new TextLoader({ text: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }), new TextLoader({ text: content, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }),
forceReload forceReload
) )
return {
entriesAdded: loaderReturn.entriesAdded,
uniqueId: loaderReturn.uniqueId,
uniqueIds: [loaderReturn.uniqueId],
loaderType: loaderReturn.loaderType
} as LoaderReturn
} }
if (item.type === 'file') { if (item.type === 'file') {
const file = item.content as FileType const file = item.content as FileType
if (file.ext === '.pdf') { return await addFileLoader(ragApplication, file, base, forceReload)
return await ragApplication.addLoader(
new PdfLoader({
filePathOrUrl: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
} }
if (file.ext === '.docx') { return { entriesAdded: 0, uniqueId: '', uniqueIds: [''], loaderType: '' }
return await ragApplication.addLoader(
new DocxLoader({
filePathOrUrl: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
if (file.ext === '.pptx') {
return await ragApplication.addLoader(
new PptLoader({
filePathOrUrl: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
if (file.ext === '.xlsx') {
return await ragApplication.addLoader(
new ExcelLoader({
filePathOrUrl: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
if (['.md'].includes(file.ext)) {
return await ragApplication.addLoader(
new MarkdownLoader({
filePathOrUrl: file.path,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
const fileContent = fs.readFileSync(file.path, 'utf-8')
return await ragApplication.addLoader(
new TextLoader({ text: fileContent, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }),
forceReload
)
}
return { entriesAdded: 0, uniqueId: '', loaderType: '' }
} }
public remove = async ( public remove = async (
_: Electron.IpcMainInvokeEvent, _: Electron.IpcMainInvokeEvent,
{ uniqueId, base }: { uniqueId: string; base: KnowledgeBaseParams } { uniqueId, uniqueIds, base }: { uniqueId: string; uniqueIds: string[]; base: KnowledgeBaseParams }
): Promise<void> => { ): Promise<void> => {
const ragApplication = await this.getRagApplication(base) const ragApplication = await this.getRagApplication(base)
await ragApplication.deleteLoader(uniqueId) console.debug(`[ KnowledgeService Remove Item UniqueId: ${uniqueId}]`)
for (const id of uniqueIds) {
await ragApplication.deleteLoader(id)
}
} }
public search = async ( public search = async (

View File

@@ -0,0 +1,116 @@
import { ProxyConfig as _ProxyConfig, session } from 'electron'
import { HttpsProxyAgent } from 'https-proxy-agent'
type ProxyMode = 'system' | 'custom' | 'none'
export interface ProxyConfig {
mode: ProxyMode
url?: string | null
}
export class ProxyManager {
private config: ProxyConfig
private proxyAgent: HttpsProxyAgent | null = null
private proxyUrl: string | null = null
constructor() {
this.config = {
mode: 'system',
url: ''
}
}
private async setSessionsProxy(config: _ProxyConfig): Promise<void> {
const sessions = [session.defaultSession, session.fromPartition('persist:webview')]
await Promise.all(sessions.map((session) => session.setProxy(config)))
}
async configureProxy(config: ProxyConfig): Promise<void> {
try {
this.config = config
if (this.config.mode === 'system') {
await this.setSystemProxy()
} else if (this.config.mode == 'custom') {
await this.setCustomProxy()
} else {
await this.clearProxy()
}
} catch (error) {
console.error('Failed to config proxy:', error)
throw error
}
}
private setEnvironment(url: string): void {
process.env.grpc_proxy = url
process.env.HTTP_PROXY = url
process.env.HTTPS_PROXY = url
process.env.http_proxy = url
process.env.https_proxy = url
}
private async setSystemProxy(): Promise<void> {
try {
this.proxyUrl = await this.resolveSystemProxy()
if (this.proxyUrl) {
this.proxyAgent = new HttpsProxyAgent(this.proxyUrl)
this.setEnvironment(this.proxyUrl)
await this.setSessionsProxy({ mode: 'system' })
}
} catch (error) {
console.error('Failed to set system proxy:', error)
throw error
}
}
private async setCustomProxy(): Promise<void> {
try {
if (this.config.url) {
this.proxyUrl = this.config.url
this.proxyAgent = new HttpsProxyAgent(this.config.url)
this.setEnvironment(this.config.url)
await this.setSessionsProxy({ proxyRules: this.config.url })
}
} catch (error) {
console.error('Failed to set custom proxy:', error)
throw error
}
}
private async clearProxy(): Promise<void> {
delete process.env.HTTP_PROXY
delete process.env.HTTPS_PROXY
await this.setSessionsProxy({})
this.config = { mode: 'none' }
}
private async resolveSystemProxy(): Promise<string | null> {
try {
return await this.resolveElectronProxy()
} catch (error) {
console.error('Failed to resolve system proxy:', error)
return null
}
}
private async resolveElectronProxy(): Promise<string | null> {
try {
const proxyString = await session.defaultSession.resolveProxy('https://dummy.com')
const [protocol, address] = proxyString.split(';')[0].split(' ')
return protocol === 'PROXY' ? `http://${address}` : null
} catch (error) {
console.error('Failed to resolve electron proxy:', error)
return null
}
}
getProxyAgent(): HttpsProxyAgent | null {
return this.proxyAgent
}
getProxyUrl(): string | null {
return this.proxyUrl
}
}
export const proxyManager = new ProxyManager()

View File

@@ -22,7 +22,11 @@ function getShortcutHandler(shortcut: Shortcut) {
case 'show_app': case 'show_app':
return (window: BrowserWindow) => { return (window: BrowserWindow) => {
if (window.isVisible()) { if (window.isVisible()) {
if (window.isFocused()) {
window.hide() window.hide()
} else {
window.focus()
}
} else { } else {
window.show() window.show()
window.focus() window.focus()
@@ -43,8 +47,8 @@ function formatShortcutKey(shortcut: string[]): string {
function handleZoom(delta: number) { function handleZoom(delta: number) {
return (window: BrowserWindow) => { return (window: BrowserWindow) => {
const currentZoom = window.webContents.getZoomFactor() const currentZoom = configManager.getZoomFactor()
const newZoom = currentZoom + delta const newZoom = Number((currentZoom + delta).toFixed(1))
if (newZoom >= 0.1 && newZoom <= 5.0) { if (newZoom >= 0.1 && newZoom <= 5.0) {
window.webContents.setZoomFactor(newZoom) window.webContents.setZoomFactor(newZoom)
configManager.setZoomFactor(newZoom) configManager.setZoomFactor(newZoom)
@@ -52,8 +56,65 @@ function handleZoom(delta: number) {
} }
} }
const convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutFormat = (
shortcut: string | string[]
): string => {
const accelerator = (() => {
if (Array.isArray(shortcut)) {
return shortcut
} else {
return shortcut.split('+').map((key) => key.trim())
}
})()
return accelerator
.map((key) => {
switch (key) {
case 'Command':
return 'CommandOrControl'
case 'Control':
return 'Control'
case 'Ctrl':
return 'Control'
case 'ArrowUp':
return 'Up'
case 'ArrowDown':
return 'Down'
case 'ArrowLeft':
return 'Left'
case 'ArrowRight':
return 'Right'
case 'AltGraph':
return 'Alt'
case 'Slash':
return '/'
case 'Semicolon':
return ';'
case 'BracketLeft':
return '['
case 'BracketRight':
return ']'
case 'Backslash':
return '\\'
case 'Quote':
return "'"
case 'Comma':
return ','
case 'Minus':
return '-'
case 'Equal':
return '='
default:
return key
}
})
.join('+')
}
export function registerShortcuts(window: BrowserWindow) { export function registerShortcuts(window: BrowserWindow) {
window.once('ready-to-show', () => {
window.webContents.setZoomFactor(configManager.getZoomFactor()) window.webContents.setZoomFactor(configManager.getZoomFactor())
})
const register = () => { const register = () => {
if (window.isDestroyed()) return if (window.isDestroyed()) return
@@ -75,11 +136,11 @@ export function registerShortcuts(window: BrowserWindow) {
const accelerator = formatShortcutKey(shortcut.shortcut) const accelerator = formatShortcutKey(shortcut.shortcut)
if (shortcut.key === 'show_app') { if (shortcut.key === 'show_app' && shortcut.enabled) {
showAppAccelerator = accelerator showAppAccelerator = accelerator
} }
if (shortcut.key === 'mini_window') { if (shortcut.key === 'mini_window' && shortcut.enabled) {
showMiniWindowAccelerator = accelerator showMiniWindowAccelerator = accelerator
} }
@@ -100,7 +161,10 @@ export function registerShortcuts(window: BrowserWindow) {
} }
if (shortcut.enabled) { if (shortcut.enabled) {
globalShortcut.register(formatShortcutKey(shortcut.shortcut), () => handler(window)) const accelerator = convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutFormat(
shortcut.shortcut
)
globalShortcut.register(accelerator, () => handler(window))
} }
} catch (error) { } catch (error) {
Logger.error(`[ShortcutService] Failed to register shortcut ${shortcut.key}`) Logger.error(`[ShortcutService] Failed to register shortcut ${shortcut.key}`)
@@ -116,12 +180,16 @@ export function registerShortcuts(window: BrowserWindow) {
if (showAppAccelerator) { if (showAppAccelerator) {
const handler = getShortcutHandler({ key: 'show_app' } as Shortcut) const handler = getShortcutHandler({ key: 'show_app' } as Shortcut)
handler && globalShortcut.register(showAppAccelerator, () => handler(window)) const accelerator =
convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutFormat(showAppAccelerator)
handler && globalShortcut.register(accelerator, () => handler(window))
} }
if (showMiniWindowAccelerator) { if (showMiniWindowAccelerator) {
const handler = getShortcutHandler({ key: 'mini_window' } as Shortcut) const handler = getShortcutHandler({ key: 'mini_window' } as Shortcut)
handler && globalShortcut.register(showMiniWindowAccelerator, () => handler(window)) const accelerator =
convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutFormat(showMiniWindowAccelerator)
handler && globalShortcut.register(accelerator, () => handler(window))
} }
} catch (error) { } catch (error) {
Logger.error('[ShortcutService] Failed to unregister shortcuts') Logger.error('[ShortcutService] Failed to unregister shortcuts')

View File

@@ -1,8 +1,12 @@
import { WebDavConfig } from '@types' import { WebDavConfig } from '@types'
import Logger from 'electron-log' import Logger from 'electron-log'
import { HttpProxyAgent } from 'http-proxy-agent'
import { HttpsProxyAgent } from 'https-proxy-agent'
import Stream from 'stream' import Stream from 'stream'
import { BufferLike, createClient, GetFileContentsOptions, PutFileContentsOptions, WebDAVClient } from 'webdav' import { BufferLike, createClient, GetFileContentsOptions, PutFileContentsOptions, WebDAVClient } from 'webdav'
import { proxyManager } from './ProxyManager'
export default class WebDav { export default class WebDav {
public instance: WebDAVClient | undefined public instance: WebDAVClient | undefined
private webdavPath: string private webdavPath: string
@@ -10,11 +14,16 @@ export default class WebDav {
constructor(params: WebDavConfig) { constructor(params: WebDavConfig) {
this.webdavPath = params.webdavPath this.webdavPath = params.webdavPath
const httpProxy = proxyManager.getProxyUrl() || ''
const httpsProxy = proxyManager.getProxyUrl() || ''
this.instance = createClient(params.webdavHost, { this.instance = createClient(params.webdavHost, {
username: params.webdavUser, username: params.webdavUser,
password: params.webdavPass, password: params.webdavPass,
maxBodyLength: Infinity, maxBodyLength: Infinity,
maxContentLength: Infinity maxContentLength: Infinity,
httpAgent: httpProxy ? new HttpProxyAgent(httpProxy) : undefined,
httpsAgent: httpsProxy ? new HttpsProxyAgent(httpsProxy) : undefined
}) })
this.putFileContents = this.putFileContents.bind(this) this.putFileContents = this.putFileContents.bind(this)

View File

@@ -28,6 +28,7 @@ export class WindowService {
public createMainWindow(): BrowserWindow { public createMainWindow(): BrowserWindow {
if (this.mainWindow && !this.mainWindow.isDestroyed()) { if (this.mainWindow && !this.mainWindow.isDestroyed()) {
this.mainWindow.show()
return this.mainWindow return this.mainWindow
} }
@@ -50,7 +51,7 @@ export class WindowService {
show: false, // 初始不显示 show: false, // 初始不显示
autoHideMenuBar: true, autoHideMenuBar: true,
transparent: isMac, transparent: isMac,
vibrancy: 'under-window', vibrancy: 'sidebar',
visualEffectState: 'active', visualEffectState: 'active',
titleBarStyle: isLinux ? 'default' : 'hidden', titleBarStyle: isLinux ? 'default' : 'hidden',
titleBarOverlay: theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight, titleBarOverlay: theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight,
@@ -61,7 +62,8 @@ export class WindowService {
preload: join(__dirname, '../preload/index.js'), preload: join(__dirname, '../preload/index.js'),
sandbox: false, sandbox: false,
webSecurity: false, webSecurity: false,
webviewTag: true webviewTag: true,
allowRunningInsecureContent: true
} }
}) })
@@ -166,7 +168,7 @@ export class WindowService {
const oauthProviderUrls = [ const oauthProviderUrls = [
'https://account.siliconflow.cn/oauth', 'https://account.siliconflow.cn/oauth',
'https://cloud.siliconflow.cn/expensebill', 'https://cloud.siliconflow.cn/expensebill',
'https://aihubmix.com/oauth', 'https://aihubmix.com/token',
'https://aihubmix.com/topup' 'https://aihubmix.com/topup'
] ]
@@ -247,17 +249,32 @@ export class WindowService {
event.preventDefault() event.preventDefault()
mainWindow.hide() mainWindow.hide()
}) })
mainWindow.on('closed', () => {
this.mainWindow = null
})
mainWindow.on('show', () => {
if (this.miniWindow && !this.miniWindow.isDestroyed()) {
this.miniWindow.hide()
}
})
} }
public showMainWindow() { public showMainWindow() {
if (this.mainWindow) { if (this.miniWindow && !this.miniWindow.isDestroyed()) {
this.miniWindow.hide()
}
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
if (this.mainWindow.isMinimized()) { if (this.mainWindow.isMinimized()) {
return this.mainWindow.restore() this.mainWindow.restore()
} }
this.mainWindow.show() this.mainWindow.show()
this.mainWindow.focus() this.mainWindow.focus()
} else { } else {
this.createMainWindow() this.mainWindow = this.createMainWindow()
this.mainWindow.focus()
} }
} }
@@ -268,7 +285,10 @@ export class WindowService {
return return
} }
if (this.selectionMenuWindow) { if (this.mainWindow && !this.mainWindow.isDestroyed()) {
this.mainWindow.hide()
}
if (this.selectionMenuWindow && !this.selectionMenuWindow.isDestroyed()) {
this.selectionMenuWindow.hide() this.selectionMenuWindow.hide()
} }

View File

@@ -1,5 +1,9 @@
import * as fs from 'node:fs'
import path from 'node:path'
import { audioExts, documentExts, imageExts, textExts, videoExts } from '@shared/config/constant' import { audioExts, documentExts, imageExts, textExts, videoExts } from '@shared/config/constant'
import { FileTypes } from '@types' import { FileType, FileTypes } from '@types'
import { v4 as uuidv4 } from 'uuid'
export function getFileType(ext: string): FileTypes { export function getFileType(ext: string): FileTypes {
ext = ext.toLowerCase() ext = ext.toLowerCase()
@@ -10,3 +14,43 @@ export function getFileType(ext: string): FileTypes {
if (documentExts.includes(ext)) return FileTypes.DOCUMENT if (documentExts.includes(ext)) return FileTypes.DOCUMENT
return FileTypes.OTHER return FileTypes.OTHER
} }
export function getAllFiles(dirPath: string, arrayOfFiles: FileType[] = []): FileType[] {
const files = fs.readdirSync(dirPath)
files.forEach((file) => {
if (file.startsWith('.')) {
return
}
const fullPath = path.join(dirPath, file)
if (fs.statSync(fullPath).isDirectory()) {
arrayOfFiles = getAllFiles(fullPath, arrayOfFiles)
} else {
const ext = path.extname(file)
const fileType = getFileType(ext)
if ([FileTypes.OTHER, FileTypes.IMAGE, FileTypes.VIDEO, FileTypes.AUDIO].includes(fileType)) {
return
}
const name = path.basename(file)
const size = fs.statSync(fullPath).size
const fileItem: FileType = {
id: uuidv4(),
name,
path: fullPath,
size,
ext,
count: 1,
origin_name: name,
type: fileType,
created_at: new Date()
}
arrayOfFiles.push(fileItem)
}
})
return arrayOfFiles
}

View File

@@ -1,9 +1,10 @@
import { ElectronAPI } from '@electron-toolkit/preload' import { ElectronAPI } from '@electron-toolkit/preload'
import type { FileMetadataResponse, ListFilesResponse, UploadFileResponse } from '@google/generative-ai/server' import type { FileMetadataResponse, ListFilesResponse, UploadFileResponse } from '@google/generative-ai/server'
import { AddLoaderReturn, ExtractChunkData } from '@llm-tools/embedjs-interfaces' import { ExtractChunkData } from '@llm-tools/embedjs-interfaces'
import { FileType } from '@renderer/types' import { FileType } from '@renderer/types'
import { WebDavConfig } from '@renderer/types' import { WebDavConfig } from '@renderer/types'
import { AppInfo, KnowledgeBaseParams, KnowledgeItem, LanguageVarious } from '@renderer/types' import { AppInfo, KnowledgeBaseParams, KnowledgeItem, LanguageVarious } from '@renderer/types'
import type { LoaderReturn } from '@shared/config/types'
import type { OpenDialogOptions } from 'electron' import type { OpenDialogOptions } from 'electron'
import type { UpdateInfo } from 'electron-updater' import type { UpdateInfo } from 'electron-updater'
import { Readable } from 'stream' import { Readable } from 'stream'
@@ -78,8 +79,16 @@ declare global {
base: KnowledgeBaseParams base: KnowledgeBaseParams
item: KnowledgeItem item: KnowledgeItem
forceReload?: boolean forceReload?: boolean
}) => Promise<AddLoaderReturn> }) => Promise<LoaderReturn>
remove: ({ uniqueId, base }: { uniqueId: string; base: KnowledgeBaseParams }) => Promise<void> remove: ({
uniqueId,
uniqueIds,
base
}: {
uniqueId: string
uniqueIds: string[]
base: KnowledgeBaseParams
}) => Promise<void>
search: ({ search, base }: { search: string; base: KnowledgeBaseParams }) => Promise<ExtractChunkData[]> search: ({ search, base }: { search: string; base: KnowledgeBaseParams }) => Promise<ExtractChunkData[]>
} }
window: { window: {
@@ -110,6 +119,9 @@ declare global {
encrypt: (text: string, secretKey: string, iv: string) => Promise<{ iv: string; encryptedData: string }> encrypt: (text: string, secretKey: string, iv: string) => Promise<{ iv: string; encryptedData: string }>
decrypt: (encryptedData: string, iv: string, secretKey: string) => Promise<string> decrypt: (encryptedData: string, iv: string, secretKey: string) => Promise<string>
} }
shell: {
openExternal: (url: string, options?: OpenExternalOptions) => Promise<void>
}
} }
} }
} }

View File

@@ -1,6 +1,6 @@
import { electronAPI } from '@electron-toolkit/preload' import { electronAPI } from '@electron-toolkit/preload'
import { FileType, KnowledgeBaseParams, KnowledgeItem, Shortcut, WebDavConfig } from '@types' import { FileType, KnowledgeBaseParams, KnowledgeItem, Shortcut, WebDavConfig } from '@types'
import { contextBridge, ipcRenderer, OpenDialogOptions } from 'electron' import { contextBridge, ipcRenderer, OpenDialogOptions, shell } from 'electron'
// Custom APIs for renderer // Custom APIs for renderer
const api = { const api = {
@@ -71,8 +71,8 @@ const api = {
item: KnowledgeItem item: KnowledgeItem
forceReload?: boolean forceReload?: boolean
}) => ipcRenderer.invoke('knowledge-base:add', { base, item, forceReload }), }) => ipcRenderer.invoke('knowledge-base:add', { base, item, forceReload }),
remove: ({ uniqueId, base }: { uniqueId: string; base: KnowledgeBaseParams }) => remove: ({ uniqueId, uniqueIds, base }: { uniqueId: string; uniqueIds: string[]; base: KnowledgeBaseParams }) =>
ipcRenderer.invoke('knowledge-base:remove', { uniqueId, base }), ipcRenderer.invoke('knowledge-base:remove', { uniqueId, uniqueIds, base }),
search: ({ search, base }: { search: string; base: KnowledgeBaseParams }) => search: ({ search, base }: { search: string; base: KnowledgeBaseParams }) =>
ipcRenderer.invoke('knowledge-base:search', { search, base }) ipcRenderer.invoke('knowledge-base:search', { search, base })
}, },
@@ -104,6 +104,9 @@ const api = {
encrypt: (text: string, secretKey: string, iv: string) => ipcRenderer.invoke('aes:encrypt', text, secretKey, iv), encrypt: (text: string, secretKey: string, iv: string) => ipcRenderer.invoke('aes:encrypt', text, secretKey, iv),
decrypt: (encryptedData: string, iv: string, secretKey: string) => decrypt: (encryptedData: string, iv: string, secretKey: string) =>
ipcRenderer.invoke('aes:decrypt', encryptedData, iv, secretKey) ipcRenderer.invoke('aes:decrypt', encryptedData, iv, secretKey)
},
shell: {
openExternal: shell.openExternal
} }
} }

View File

@@ -6,6 +6,7 @@
<meta name="viewport" content="initial-scale=1, width=device-width" /> <meta name="viewport" content="initial-scale=1, width=device-width" />
<meta http-equiv="Content-Security-Policy" <meta http-equiv="Content-Security-Policy"
content="default-src 'self'; connect-src blob: *; script-src 'self' 'unsafe-eval' *; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' *; font-src 'self' data: *; img-src 'self' data: file: * blob:; frame-src * file:" /> content="default-src 'self'; connect-src blob: *; script-src 'self' 'unsafe-eval' *; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' *; font-src 'self' data: *; img-src 'self' data: file: * blob:; frame-src * file:" />
<title>Cherry Studio</title>
<style> <style>
html, html,

View File

@@ -10,6 +10,7 @@ import TopViewContainer from './components/TopView'
import AntdProvider from './context/AntdProvider' import AntdProvider from './context/AntdProvider'
import { SyntaxHighlighterProvider } from './context/SyntaxHighlighterProvider' import { SyntaxHighlighterProvider } from './context/SyntaxHighlighterProvider'
import { ThemeProvider } from './context/ThemeProvider' import { ThemeProvider } from './context/ThemeProvider'
import NavigationHandler from './handler/NavigationHandler'
import AgentsPage from './pages/agents/AgentsPage' import AgentsPage from './pages/agents/AgentsPage'
import AppsPage from './pages/apps/AppsPage' import AppsPage from './pages/apps/AppsPage'
import FilesPage from './pages/files/FilesPage' import FilesPage from './pages/files/FilesPage'
@@ -28,6 +29,8 @@ function App(): JSX.Element {
<PersistGate loading={null} persistor={persistor}> <PersistGate loading={null} persistor={persistor}>
<TopViewContainer> <TopViewContainer>
<HashRouter> <HashRouter>
<NavigationHandler />
{/* 添加导航处理组件 */}
<Sidebar /> <Sidebar />
<Routes> <Routes>
<Route path="/" element={<HomePage />} /> <Route path="/" element={<HomePage />} />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,27 @@
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="256" height="256" rx="32" fill="#0057CE"/>
<mask id="path-2-inside-1_4113_89308" fill="white">
<path d="M169.6 131.626C173.075 129.641 176.32 128.241 180.1 126.943C183.74 125.695 187.444 124.664 191.186 123.735C194.915 122.806 198.682 122.017 202.449 121.228C206.216 120.439 209.958 119.675 213.598 118.314C231.429 111.619 242.221 93.6357 239.612 74.9396C237.003 56.2435 221.692 41.8237 202.691 40.1564C194.062 39.4055 185.726 41.4164 178.013 44.9418C170.326 48.4545 163.288 53.4435 157.166 59.158C144.795 70.676 135.657 85.4649 130.083 101.208C124.47 117.054 122.37 134.095 123.694 150.806C124.356 159.129 125.883 167.504 128.326 175.509C130.719 183.362 134.181 191.469 138.839 198.342C136.828 185.475 138.559 172.175 143.917 160.262C149.262 148.375 158.121 138.193 169.6 131.626Z"/>
</mask>
<path d="M169.6 131.626C173.075 129.641 176.32 128.241 180.1 126.943C183.74 125.695 187.444 124.664 191.186 123.735C194.915 122.806 198.682 122.017 202.449 121.228C206.216 120.439 209.958 119.675 213.598 118.314C231.429 111.619 242.221 93.6357 239.612 74.9396C237.003 56.2435 221.692 41.8237 202.691 40.1564C194.062 39.4055 185.726 41.4164 178.013 44.9418C170.326 48.4545 163.288 53.4435 157.166 59.158C144.795 70.676 135.657 85.4649 130.083 101.208C124.47 117.054 122.37 134.095 123.694 150.806C124.356 159.129 125.883 167.504 128.326 175.509C130.719 183.362 134.181 191.469 138.839 198.342C136.828 185.475 138.559 172.175 143.917 160.262C149.262 148.375 158.121 138.193 169.6 131.626Z" fill="white" stroke="white" stroke-width="32" mask="url(#path-2-inside-1_4113_89308)"/>
<path d="M162.246 150.4C161.915 153.913 163.073 157.464 165.542 160.06C168.011 162.657 171.499 164.031 174.668 165.253C178.13 166.577 181.12 167.658 184.353 169.529C187.433 171.311 190.157 173.526 192.435 176.262C201.802 187.449 200.937 203.867 190.462 214.049C179.988 224.23 163.379 224.778 152.243 215.321C149.404 212.903 146.884 209.798 144.81 206.756C141.654 186.52 147.775 165.317 162.246 150.4Z" fill="white"/>
<mask id="path-4-outside-2_4113_89308" maskUnits="userSpaceOnUse" x="136" y="138.4" width="71" height="92" fill="black">
<rect fill="white" x="136" y="138.4" width="71" height="92"/>
<path d="M162.246 150.4C165.542 153.666 163.073 157.464 165.542 160.06C168.011 162.657 171.499 164.031 174.668 165.253C178.13 166.577 181.12 167.658 184.353 169.529C187.433 171.311 190.157 173.526 192.435 176.262C201.802 187.449 200.937 203.867 190.462 214.049C179.988 224.23 163.379 224.778 152.243 215.321C149.404 212.903 146.884 209.798 144.81 206.756C141.654 186.52 147.775 165.317 162.246 150.4Z"/>
</mask>
<path d="M162.246 150.4C165.542 153.666 163.073 157.464 165.542 160.06C168.011 162.657 171.499 164.031 174.668 165.253C178.13 166.577 181.12 167.658 184.353 169.529C187.433 171.311 190.157 173.526 192.435 176.262C201.802 187.449 200.937 203.867 190.462 214.049C179.988 224.23 163.379 224.778 152.243 215.321C149.404 212.903 146.884 209.798 144.81 206.756C141.654 186.52 147.775 165.317 162.246 150.4Z" stroke="#0057CE" stroke-width="16" mask="url(#path-4-outside-2_4113_89308)"/>
<mask id="path-5-inside-3_4113_89308" fill="white">
<path d="M50.4113 61.9063C63.3547 61.8935 75.9164 69.008 85.0163 76.9879C94.6761 85.4641 102.16 96.2567 107.085 107.991C112.036 119.789 114.416 132.542 114.327 145.282C114.238 157.665 111.769 171.079 106.296 182.394C105.774 167.821 100.123 153.885 90.3107 143.003C88.5926 141.107 86.7981 139.389 84.6599 137.938C82.5218 136.487 80.2691 135.418 77.8382 134.565C73.1164 132.911 67.7838 132.134 62.8711 131.6C57.8057 131.04 52.7149 130.709 47.6622 129.971C42.4695 129.207 37.8114 128.087 33.1787 125.427C19.688 117.715 13.1463 102.009 17.1808 87.1441C21.2153 72.2661 34.846 61.919 50.4113 61.9063Z"/>
</mask>
<path d="M50.4113 61.9063C63.3547 61.8935 75.9164 69.008 85.0163 76.9879C94.6761 85.4641 102.16 96.2567 107.085 107.991C112.036 119.789 114.416 132.542 114.327 145.282C114.238 157.665 111.769 171.079 106.296 182.394C105.774 167.821 100.123 153.885 90.3107 143.003C88.5926 141.107 86.7981 139.389 84.6599 137.938C82.5218 136.487 80.2691 135.418 77.8382 134.565C73.1164 132.911 67.7838 132.134 62.8711 131.6C57.8057 131.04 52.7149 130.709 47.6622 129.971C42.4695 129.207 37.8114 128.087 33.1787 125.427C19.688 117.715 13.1463 102.009 17.1808 87.1441C21.2153 72.2661 34.846 61.919 50.4113 61.9063Z" fill="white" stroke="white" stroke-width="32" mask="url(#path-5-inside-3_4113_89308)"/>
<mask id="path-6-inside-4_4113_89308" fill="white">
<path d="M82.5802 149.38C81.3584 148.03 80.0857 146.745 78.673 145.6C80.4294 148.578 80.6075 151.95 79.8694 155.196C79.1312 158.429 77.5021 161.419 75.4403 163.99C73.3149 166.625 70.8204 168.725 68.1095 170.71C65.7423 172.441 62.2932 174.656 60.1551 176.73C53.8679 182.839 52.5824 192.384 57.0369 199.893C61.4914 207.415 70.5277 210.979 78.9912 208.535C83.662 207.186 87.6202 204.144 90.7638 200.67C93.9455 197.157 96.5291 192.983 98.5655 188.757C98.0437 174.185 92.3928 160.261 82.5802 149.38Z"/>
</mask>
<path d="M82.5802 149.38C81.3584 148.03 80.0857 146.745 78.673 145.6C80.4294 148.578 80.6075 151.95 79.8694 155.196C79.1312 158.429 77.5021 161.419 75.4403 163.99C73.3149 166.625 70.8204 168.725 68.1095 170.71C65.7423 172.441 62.2932 174.656 60.1551 176.73C53.8679 182.839 52.5824 192.384 57.0369 199.893C61.4914 207.415 70.5277 210.979 78.9912 208.535C83.662 207.186 87.6202 204.144 90.7638 200.67C93.9455 197.157 96.5291 192.983 98.5655 188.757C98.0437 174.185 92.3928 160.261 82.5802 149.38Z" stroke="white" stroke-width="24" mask="url(#path-6-inside-4_4113_89308)"/>
<mask id="path-7-outside-5_4113_89308" maskUnits="userSpaceOnUse" x="45.3994" y="138.6" width="62" height="79" fill="black">
<rect fill="white" x="45.3994" y="138.6" width="62" height="79"/>
<path d="M82.5802 149.38C81.3584 148.03 80.0857 146.745 78.673 145.6C80.4294 148.578 80.6075 151.95 79.8694 155.196C79.1312 158.429 77.5021 161.419 75.4403 163.99C73.3149 166.625 70.8204 168.725 68.1095 170.71C65.7423 172.441 62.2932 174.656 60.1551 176.73C53.8679 182.839 52.5824 192.384 57.0369 199.893C61.4914 207.415 70.5277 210.979 78.9912 208.535C83.662 207.186 87.6202 204.144 90.7638 200.67C93.9455 197.157 96.5291 192.983 98.5655 188.757C98.0437 174.185 92.3928 160.261 82.5802 149.38Z"/>
</mask>
<path d="M82.5802 149.38C81.3584 148.03 80.0857 146.745 78.673 145.6C80.4294 148.578 80.6075 151.95 79.8694 155.196C79.1312 158.429 77.5021 161.419 75.4403 163.99C73.3149 166.625 70.8204 168.725 68.1095 170.71C65.7423 172.441 62.2932 174.656 60.1551 176.73C53.8679 182.839 52.5824 192.384 57.0369 199.893C61.4914 207.415 70.5277 210.979 78.9912 208.535C83.662 207.186 87.6202 204.144 90.7638 200.67C93.9455 197.157 96.5291 192.983 98.5655 188.757C98.0437 174.185 92.3928 160.261 82.5802 149.38Z" fill="white"/>
<path d="M82.5802 149.38C81.3584 148.03 80.0857 146.745 78.673 145.6C80.4294 148.578 80.6075 151.95 79.8694 155.196C79.1312 158.429 77.5021 161.419 75.4403 163.99C73.3149 166.625 70.8204 168.725 68.1095 170.71C65.7423 172.441 62.2932 174.656 60.1551 176.73C53.8679 182.839 52.5824 192.384 57.0369 199.893C61.4914 207.415 70.5277 210.979 78.9912 208.535C83.662 207.186 87.6202 204.144 90.7638 200.67C93.9455 197.157 96.5291 192.983 98.5655 188.757C98.0437 174.185 92.3928 160.261 82.5802 149.38Z" stroke="#0057CE" stroke-width="16" mask="url(#path-7-outside-5_4113_89308)"/>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1 @@
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Dify</title><clipPath id="lobe-icons-dify-fill"><path d="M1 0h10.286c6.627 0 12 5.373 12 12s-5.373 12-12 12H1V0z"></path></clipPath><foreignObject clip-path="url(#lobe-icons-dify-fill)" height="24" style="background:conic-gradient(from 180deg at 50% 50%, #0222C3, #8FB1F4, #FFFFFF)" width="24"></foreignObject></svg>

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="512px" height="512px" viewBox="0 0 512 512" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(85.09804%,85.09804%,85.09804%);fill-opacity:1;" d="M 512 256 C 512 114.613281 397.386719 0 256 0 C 114.613281 0 0 114.613281 0 256 C 0 397.386719 114.613281 512 256 512 C 397.386719 512 512 397.386719 512 256 Z M 512 256 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 256.011719 114.753906 C 167.050781 114.753906 94.945312 186.261719 94.945312 274.507812 L 94.945312 350.988281 L 124.628906 350.988281 L 124.628906 343.359375 C 124.628906 307.574219 153.867188 278.558594 189.941406 278.558594 C 226.015625 278.558594 255.253906 307.585938 255.253906 343.359375 L 255.253906 350.988281 L 284.9375 350.988281 L 284.9375 343.359375 C 284.9375 291.308594 242.390625 249.140625 189.929688 249.140625 C 169.503906 249.140625 150.582031 255.53125 135.082031 266.433594 C 151.296875 234.464844 184.691406 212.535156 223.242188 212.535156 C 277.707031 212.535156 321.867188 256.339844 321.867188 310.355469 L 321.867188 350.996094 L 351.5625 350.996094 L 351.5625 310.355469 C 351.5625 240.074219 294.113281 183.082031 223.242188 183.082031 C 191.382812 183.082031 162.230469 194.601562 139.785156 213.683594 C 161.824219 172.375 205.578125 144.214844 256 144.214844 C 328.566406 144.214844 387.382812 202.550781 387.382812 274.515625 L 387.382812 350.996094 L 417.066406 350.996094 L 417.066406 274.515625 C 417.066406 186.28125 344.960938 114.761719 256 114.761719 Z M 256.011719 114.753906 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,14 @@
<svg width="778" height="257" viewBox="0 0 778 257" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M97.1853 5.35901L127.346 53.1064C132.19 60.7745 126.68 70.7725 117.61 70.7725H105.279V142.278H87.4492V-0.00683594C91.1876 -0.00683594 94.926 1.78179 97.1853 5.35901Z" fill="#8FBCFA"/>
<path d="M47.5482 53.1064L77.7098 5.35901C79.9691 1.78179 83.7075 -0.00683594 87.4459 -0.00683594V142.279C81.0587 141.981 74.8755 143.829 69.616 147.544V70.7725H57.2849C48.2149 70.7725 42.7047 60.7745 47.5482 53.1064Z" fill="#468BFF"/>
<path d="M182.003 189.445L107.34 189.445C111.648 184.622 114.201 178.481 114.476 171.615H252.782C252.782 175.353 250.993 179.092 247.416 181.351L199.669 211.512C192.001 216.356 182.003 210.846 182.003 201.776V189.445Z" fill="#FDBB11"/>
<path d="M199.668 131.718L247.415 161.879C250.993 164.138 252.781 167.877 252.781 171.615H114.471C114.72 165.212 112.733 158.898 108.957 153.785H182.002V141.454C182.002 132.384 192 126.874 199.668 131.718Z" fill="#F6D785"/>
<path d="M46.9409 209.797L3.37891 253.359C6.02226 256.003 9.93035 257.381 14.0576 256.45L69.1472 244.014C77.9944 242.017 81.1678 231.051 74.7545 224.638L66.035 215.918L98.7916 183.055C105.771 176.075 105.462 164.899 98.6758 158.113L46.9409 209.797Z" fill="#FF9A9D"/>
<path d="M40.8221 190.708L73.6898 157.963C80.6694 150.983 91.8931 151.328 98.679 158.113L46.9436 209.802L3.38131 253.364C0.737954 250.721 -0.640662 246.812 0.291 242.685L12.7265 187.596C14.7236 178.748 25.6895 175.575 32.1028 181.988L40.8221 190.708Z" fill="#FE363B"/>
<path d="M777.344 93.6689L718.337 234.049H692.704L713.348 186.567L675.156 93.6689H702.166L726.766 160.246L751.711 93.6689H777.344Z" fill="#FFFFFF"/>
<path d="M664.096 70.1191V188.976H640.012V70.1191H664.096Z" fill="#FFFFFF"/>
<path d="M606.041 82.2736C601.797 82.2736 598.242 80.9547 595.375 78.3168C592.622 75.5643 591.246 72.181 591.246 68.1668C591.246 64.1527 592.622 60.8267 595.375 58.1889C598.242 55.4363 601.797 54.0601 606.041 54.0601C610.284 54.0601 613.783 55.4363 616.535 58.1889C619.402 60.8267 620.836 63.6942 620.836 67.7084C620.836 71.7225 619.402 75.5643 616.535 78.3168C613.783 80.9547 610.284 82.2736 606.041 82.2736ZM617.911 93.6279V188.978H593.827V93.6279H617.911Z" fill="#FFFFFF"/>
<path d="M532.3 166.783L556.385 93.6689H582.018L546.751 188.976H517.505L482.41 93.6689H508.215L532.3 166.783Z" fill="#FFFFFF"/>
<path d="M371.52 140.972C371.52 131.338 373.412 122.794 377.197 115.339C381.096 107.884 386.314 102.15 392.852 98.1355C399.504 94.1213 406.901 92.1143 415.044 92.1143C422.155 92.1143 428.348 93.5479 433.624 96.4151C439.014 99.2823 443.315 102.895 446.526 107.253V93.6626H470.783V188.969H446.526V175.035C443.43 179.507 439.129 183.235 433.624 186.217C428.233 189.084 421.983 190.518 414.872 190.518C406.844 190.518 399.504 188.453 392.852 184.324C386.314 180.196 381.096 174.404 377.197 166.949C373.412 159.38 371.52 150.72 371.52 140.972ZM446.526 141.316C446.526 135.467 445.379 130.478 443.086 126.349C440.792 122.105 437.695 118.894 433.796 116.715C429.896 114.421 425.71 113.274 421.237 113.274C416.764 113.274 412.636 114.364 408.851 116.543C405.066 118.722 401.97 121.933 399.561 126.177C397.267 130.306 396.12 135.237 396.12 140.972C396.12 146.706 397.267 151.753 399.561 156.111C401.97 160.354 405.066 163.623 408.851 165.917C412.75 168.211 416.879 169.357 421.237 169.357C425.71 169.357 429.896 168.268 433.796 166.089C437.695 163.795 440.792 160.584 443.086 156.455C445.379 152.211 446.526 147.165 446.526 141.316Z" fill="#FFFFFF"/>
<path d="M340.767 113.445V159.55C340.767 162.762 341.513 165.113 343.004 166.604C344.609 167.98 347.247 168.668 350.917 168.668H362.099V188.968H346.96C326.66 188.968 316.51 179.105 316.51 159.378V113.445H305.156V93.6614H316.51V70.0928H340.767V93.6614H362.099V113.445H340.767Z" fill="#FFFFFF"/>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,14 @@
<svg width="778" height="257" viewBox="0 0 778 257" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M97.1853 5.35901L127.346 53.1064C132.19 60.7745 126.68 70.7725 117.61 70.7725H105.279V142.278H87.4492V-0.00683594C91.1876 -0.00683594 94.926 1.78179 97.1853 5.35901Z" fill="#8FBCFA"/>
<path d="M47.5482 53.1064L77.7098 5.35901C79.9691 1.78179 83.7075 -0.00683594 87.4459 -0.00683594V142.279C81.0587 141.981 74.8755 143.829 69.616 147.544V70.7725H57.2849C48.2149 70.7725 42.7047 60.7745 47.5482 53.1064Z" fill="#468BFF"/>
<path d="M182.003 189.445L107.34 189.445C111.648 184.622 114.201 178.481 114.476 171.615H252.782C252.782 175.353 250.993 179.092 247.416 181.351L199.669 211.512C192.001 216.356 182.003 210.846 182.003 201.776V189.445Z" fill="#FDBB11"/>
<path d="M199.668 131.718L247.415 161.879C250.993 164.138 252.781 167.877 252.781 171.615H114.471C114.72 165.212 112.733 158.898 108.957 153.785H182.002V141.454C182.002 132.384 192 126.874 199.668 131.718Z" fill="#F6D785"/>
<path d="M46.9409 209.797L3.37891 253.359C6.02226 256.003 9.93035 257.381 14.0576 256.45L69.1472 244.014C77.9944 242.017 81.1678 231.051 74.7545 224.638L66.035 215.918L98.7916 183.055C105.771 176.075 105.462 164.899 98.6758 158.113L46.9409 209.797Z" fill="#FF9A9D"/>
<path d="M40.8221 190.708L73.6898 157.963C80.6694 150.983 91.8931 151.328 98.679 158.113L46.9436 209.802L3.38131 253.364C0.737954 250.721 -0.640662 246.812 0.291 242.685L12.7265 187.596C14.7236 178.748 25.6895 175.575 32.1028 181.988L40.8221 190.708Z" fill="#FE363B"/>
<path d="M777.344 93.6689L718.337 234.049H692.704L713.348 186.567L675.156 93.6689H702.166L726.766 160.246L751.711 93.6689H777.344Z" fill="#2C2F32"/>
<path d="M664.096 70.1191V188.976H640.012V70.1191H664.096Z" fill="#2C2F32"/>
<path d="M606.041 82.2736C601.797 82.2736 598.242 80.9547 595.375 78.3168C592.622 75.5643 591.246 72.181 591.246 68.1668C591.246 64.1527 592.622 60.8267 595.375 58.1889C598.242 55.4363 601.797 54.0601 606.041 54.0601C610.284 54.0601 613.783 55.4363 616.535 58.1889C619.402 60.8267 620.836 63.6942 620.836 67.7084C620.836 71.7225 619.402 75.5643 616.535 78.3168C613.783 80.9547 610.284 82.2736 606.041 82.2736ZM617.911 93.6279V188.978H593.827V93.6279H617.911Z" fill="#2C2F32"/>
<path d="M532.3 166.783L556.385 93.6689H582.018L546.751 188.976H517.505L482.41 93.6689H508.215L532.3 166.783Z" fill="#2C2F32"/>
<path d="M371.52 140.972C371.52 131.338 373.412 122.794 377.197 115.339C381.096 107.884 386.314 102.15 392.852 98.1355C399.504 94.1213 406.901 92.1143 415.044 92.1143C422.155 92.1143 428.348 93.5479 433.624 96.4151C439.014 99.2823 443.315 102.895 446.526 107.253V93.6626H470.783V188.969H446.526V175.035C443.43 179.507 439.129 183.235 433.624 186.217C428.233 189.084 421.983 190.518 414.872 190.518C406.844 190.518 399.504 188.453 392.852 184.324C386.314 180.196 381.096 174.404 377.197 166.949C373.412 159.38 371.52 150.72 371.52 140.972ZM446.526 141.316C446.526 135.467 445.379 130.478 443.086 126.349C440.792 122.105 437.695 118.894 433.796 116.715C429.896 114.421 425.71 113.274 421.237 113.274C416.764 113.274 412.636 114.364 408.851 116.543C405.066 118.722 401.97 121.933 399.561 126.177C397.267 130.306 396.12 135.237 396.12 140.972C396.12 146.706 397.267 151.753 399.561 156.111C401.97 160.354 405.066 163.623 408.851 165.917C412.75 168.211 416.879 169.357 421.237 169.357C425.71 169.357 429.896 168.268 433.796 166.089C437.695 163.795 440.792 160.584 443.086 156.455C445.379 152.211 446.526 147.165 446.526 141.316Z" fill="#2C2F32"/>
<path d="M340.767 113.445V159.55C340.767 162.762 341.513 165.113 343.004 166.604C344.609 167.98 347.247 168.668 350.917 168.668H362.099V188.968H346.96C326.66 188.968 316.51 179.105 316.51 159.378V113.445H305.156V93.6614H316.51V70.0928H340.767V93.6614H362.099V113.445H340.767Z" fill="#2C2F32"/>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -1,3 +1,5 @@
@use './container.scss';
#inputbar { #inputbar {
resize: none; resize: none;
} }

View File

@@ -0,0 +1,7 @@
#content-container {
background-color: var(--color-background);
border-top: 0.5px solid var(--color-border);
border-top-left-radius: 10px;
border-left: 0.5px solid var(--color-border);
box-shadow: -2px 0px 20px -4px rgba(0, 0, 0, 0.06);
}

View File

@@ -1,6 +1,7 @@
@import './markdown.scss'; @use './markdown.scss';
@import './ant.scss'; @use './ant.scss';
@import './scrollbar.scss'; @use './scrollbar.scss';
@use './container.scss';
@import '../fonts/icon-fonts/iconfont.css'; @import '../fonts/icon-fonts/iconfont.css';
@import '../fonts/ubuntu/ubuntu.css'; @import '../fonts/ubuntu/ubuntu.css';
@@ -88,7 +89,7 @@ body[theme-mode='light'] {
--color-background: var(--color-white); --color-background: var(--color-white);
--color-background-soft: var(--color-white-soft); --color-background-soft: var(--color-white-soft);
--color-background-mute: var(--color-white-mute); --color-background-mute: var(--color-white-mute);
--color-background-opacity: rgba(255, 255, 255, 0.7); --color-background-opacity: rgba(235, 235, 235, 0.7);
--color-primary: #00b96b; --color-primary: #00b96b;
--color-primary-soft: #00b96b99; --color-primary-soft: #00b96b99;
@@ -176,14 +177,6 @@ body,
flex: 1; flex: 1;
} }
#content-container {
background-color: var(--color-background);
border-top: 0.5px solid var(--color-border);
border-top-left-radius: 10px;
border-left: 0.5px solid var(--color-border);
box-shadow: -2px 0px 20px -4px rgba(0, 0, 0, 0.06);
}
.loader { .loader {
width: 16px; width: 16px;
height: 16px; height: 16px;
@@ -256,6 +249,9 @@ body,
border: 1px solid var(--color-background-mute); border: 1px solid var(--color-background-mute);
} }
} }
.group-menu-bar {
background-color: var(--color-background);
}
code { code {
color: var(--color-text); color: var(--color-text);
} }

View File

@@ -64,6 +64,10 @@
&:first-child { &:first-child {
margin-top: 0; margin-top: 0;
} }
&:has(+ ul) {
margin-bottom: 0;
}
} }
ul { ul {

View File

@@ -14,7 +14,15 @@ const ModelAvatar: FC<Props> = ({ model, size, props }) => {
return ( return (
<Avatar <Avatar
src={getModelLogo(model?.id || '')} src={getModelLogo(model?.id || '')}
style={{ width: size, height: size, display: 'flex', alignItems: 'center', justifyContent: 'center' }} style={{
width: size,
height: size,
minWidth: size,
minHeight: size,
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
{...props}> {...props}>
{first(model?.name)} {first(model?.name)}
</Avatar> </Avatar>

View File

@@ -46,23 +46,28 @@ const DragableList: FC<Props<any>> = ({
<DragDropContext onDragStart={onDragStart} onDragEnd={_onDragEnd}> <DragDropContext onDragStart={onDragStart} onDragEnd={_onDragEnd}>
<Droppable droppableId="droppable" {...droppableProps}> <Droppable droppableId="droppable" {...droppableProps}>
{(provided) => ( {(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef} style={{ ...style }}> <div {...provided.droppableProps} ref={provided.innerRef} style={style}>
{list.map((item, index) => { {list.map((item, index) => {
const id = item.id || item const id = item.id || item
return ( return (
<Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index} {...droppableProps}> <Draggable key={`draggable_${id}_${index}`} draggableId={id} index={index}>
{(provided) => ( {(provided) => (
<div <div
ref={provided.innerRef} ref={provided.innerRef}
{...provided.draggableProps} {...provided.draggableProps}
{...provided.dragHandleProps} {...provided.dragHandleProps}
style={{ ...provided.draggableProps.style, marginBottom: 8, ...listStyle }}> style={{
...listStyle,
...provided.draggableProps.style,
marginBottom: 8
}}>
{children(item, index)} {children(item, index)}
</div> </div>
)} )}
</Draggable> </Draggable>
) )
})} })}
{provided.placeholder}
</div> </div>
)} )}
</Droppable> </Droppable>

View File

@@ -0,0 +1,26 @@
import React from 'react'
import styled from 'styled-components'
type Props = {
text: string | number
maxLine?: number
} & React.HTMLAttributes<HTMLDivElement>
const Ellipsis = (props: Props) => {
const { text, maxLine = 1, ...rest } = props
return (
<EllipsisContainer maxLine={maxLine} {...rest}>
{text}
</EllipsisContainer>
)
}
const EllipsisContainer = styled.div<{ maxLine: number }>`
display: -webkit-box;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
overflow: hidden;
-webkit-line-clamp: ${({ maxLine }) => maxLine};
`
export default Ellipsis

View File

@@ -0,0 +1,134 @@
import { useEffect, useState } from 'react'
import styled from 'styled-components'
// FallbackFavicon component that tries multiple favicon sources
interface FallbackFaviconProps {
hostname: string
alt: string
}
const FallbackFavicon: React.FC<FallbackFaviconProps> = ({ hostname, alt }) => {
type FaviconState =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'failed' }
| { status: 'loaded'; src: string }
const [faviconState, setFaviconState] = useState<FaviconState>({ status: 'idle' })
useEffect(() => {
// Reset state when hostname changes
setFaviconState({ status: 'loading' })
// Generate all possible favicon URLs
const faviconUrls = [
`https://favicon.splitbee.io/?url=${hostname}`,
`https://${hostname}/favicon.ico`,
`https://icon.horse/icon/${hostname}`,
`https://favicon.cccyun.cc/${hostname}`,
`https://favicon.im/${hostname}`,
`https://www.google.com/s2/favicons?domain=${hostname}`
]
// Main controller to abort all requests when needed
const controller = new AbortController()
const { signal } = controller
// Create a promise for each favicon URL
const faviconPromises = faviconUrls.map((url) =>
fetch(url, {
method: 'HEAD',
signal,
credentials: 'omit'
})
.then((response) => {
if (response.ok) {
return url
}
throw new Error(`Failed to fetch ${url}`)
})
.catch((error) => {
// Rethrow aborted errors but silence other failures
if (error.name === 'AbortError') {
throw error
}
console.debug(`Failed to fetch favicon from ${url}:`, error)
return null // Return null for failed requests
})
)
// Create a timeout promise
const timeoutPromise = new Promise<string>((resolve) => {
const timer = setTimeout(() => {
resolve(faviconUrls[0]) // Default to first URL after timeout
}, 2000)
// Clear timeout if signal is aborted
signal.addEventListener('abort', () => clearTimeout(timer))
})
// Use Promise.race to get the first successful result
Promise.race([
// Filter out failed requests (null results)
Promise.any(faviconPromises)
.then((result) => result || faviconUrls[0]) // Ensure we always have a string, not null
.catch(() => faviconUrls[0]),
timeoutPromise
])
.then((url) => {
setFaviconState({ status: 'loaded', src: url })
})
.catch((error) => {
console.debug('All favicon requests failed:', error)
setFaviconState({ status: 'loaded', src: faviconUrls[0] })
})
// Cleanup function
return () => {
controller.abort()
}
}, [hostname]) // Only depend on hostname
const handleError = () => {
setFaviconState({ status: 'failed' })
}
// Render based on current state
if (faviconState.status === 'failed') {
return <FaviconPlaceholder>{hostname.charAt(0).toUpperCase()}</FaviconPlaceholder>
}
if (faviconState.status === 'loaded') {
return <Favicon src={faviconState.src} alt={alt} onError={handleError} />
}
return <FaviconLoading />
}
const FaviconLoading = styled.div`
width: 16px;
height: 16px;
border-radius: 4px;
background-color: var(--color-background-mute);
`
const FaviconPlaceholder = styled.div`
width: 16px;
height: 16px;
border-radius: 4px;
background-color: var(--color-primary-1);
color: var(--color-primary-6);
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
`
const Favicon = styled.img`
width: 16px;
height: 16px;
border-radius: 4px;
background-color: var(--color-background-mute);
`
export default FallbackFavicon

View File

@@ -24,6 +24,7 @@ const MinAppIcon: FC<Props> = ({ app, size = 48, style }) => {
width: `${size}px`, width: `${size}px`,
height: `${size}px`, height: `${size}px`,
backgroundColor: _app.background, backgroundColor: _app.background,
...app.style,
...style ...style
}} }}
/> />

View File

@@ -95,14 +95,14 @@ export const Box = styled.div<BoxProps>`
box-sizing: border-box; box-sizing: border-box;
border: ${(props) => props?.border || 'none'}; border: ${(props) => props?.border || 'none'};
gap: ${(p) => (p.gap ? getElementValue(p.gap) : 0)}; gap: ${(p) => (p.gap ? getElementValue(p.gap) : 0)};
margin: ${(props) => (props.m || props.margin ? props.m ?? props.margin : 'none')}; margin: ${(props) => (props.m || props.margin ? (props.m ?? props.margin) : 'none')};
margin-top: ${(props) => (props.mt || props.marginTop ? getElementValue(props.mt || props.marginTop) : 'default')}; margin-top: ${(props) => (props.mt || props.marginTop ? getElementValue(props.mt || props.marginTop) : 'default')};
margin-bottom: ${(props) => margin-bottom: ${(props) =>
props.mb || props.marginBottom ? getElementValue(props.mb ?? props.marginBottom) : 'default'}; props.mb || props.marginBottom ? getElementValue(props.mb ?? props.marginBottom) : 'default'};
margin-left: ${(props) => (props.ml || props.marginLeft ? getElementValue(props.ml ?? props.marginLeft) : 'default')}; margin-left: ${(props) => (props.ml || props.marginLeft ? getElementValue(props.ml ?? props.marginLeft) : 'default')};
margin-right: ${(props) => margin-right: ${(props) =>
props.mr || props.marginRight ? getElementValue(props.mr ?? props.marginRight) : 'default'}; props.mr || props.marginRight ? getElementValue(props.mr ?? props.marginRight) : 'default'};
padding: ${(props) => (props.p || props.padding ? props.p ?? props.padding : 'none')}; padding: ${(props) => (props.p || props.padding ? (props.p ?? props.padding) : 'none')};
padding-top: ${(props) => (props.pt || props.paddingTop ? getElementValue(props.pt ?? props.paddingTop) : 'auto')}; padding-top: ${(props) => (props.pt || props.paddingTop ? getElementValue(props.pt ?? props.paddingTop) : 'auto')};
padding-bottom: ${(props) => padding-bottom: ${(props) =>
props.pb || props.paddingBottom ? getElementValue(props.pb ?? props.paddingBottom) : 'auto'}; props.pb || props.paddingBottom ? getElementValue(props.pb ?? props.paddingBottom) : 'auto'};

View File

@@ -1,6 +1,7 @@
/* eslint-disable react/no-unknown-property */ /* eslint-disable react/no-unknown-property */
import { CloseOutlined, ExportOutlined, PushpinOutlined, ReloadOutlined } from '@ant-design/icons' import { CloseOutlined, CodeOutlined, ExportOutlined, PushpinOutlined, ReloadOutlined } from '@ant-design/icons'
import { isMac, isWindows } from '@renderer/config/constant' import { isMac, isWindows } from '@renderer/config/constant'
import { AppLogo } from '@renderer/config/env'
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
import { useBridge } from '@renderer/hooks/useBridge' import { useBridge } from '@renderer/hooks/useBridge'
import { useMinapps } from '@renderer/hooks/useMinapps' import { useMinapps } from '@renderer/hooks/useMinapps'
@@ -41,7 +42,11 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
} }
MinApp.onClose = onClose MinApp.onClose = onClose
const openDevTools = () => {
if (webviewRef.current) {
webviewRef.current.openDevTools()
}
}
const onReload = () => { const onReload = () => {
if (webviewRef.current) { if (webviewRef.current) {
webviewRef.current.src = app.url webviewRef.current.src = app.url
@@ -49,14 +54,17 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
} }
const onOpenLink = () => { const onOpenLink = () => {
window.api.openWebsite(app.url) if (webviewRef.current) {
const currentUrl = webviewRef.current.getURL()
window.api.openWebsite(currentUrl)
}
} }
const onTogglePin = () => { const onTogglePin = () => {
const newPinned = isPinned ? pinned.filter((item) => item.id !== app.id) : [...pinned, app] const newPinned = isPinned ? pinned.filter((item) => item.id !== app.id) : [...pinned, app]
updatePinnedMinapps(newPinned) updatePinnedMinapps(newPinned)
} }
const isInDevelopment = process.env.NODE_ENV === 'development'
const Title = () => { const Title = () => {
return ( return (
<TitleContainer style={{ justifyContent: 'space-between' }}> <TitleContainer style={{ justifyContent: 'space-between' }}>
@@ -75,6 +83,11 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
<ExportOutlined /> <ExportOutlined />
</Button> </Button>
)} )}
{isInDevelopment && (
<Button onClick={openDevTools}>
<CodeOutlined />
</Button>
)}
<Button onClick={() => onClose()}> <Button onClick={() => onClose()}>
<CloseOutlined /> <CloseOutlined />
</Button> </Button>
@@ -236,6 +249,10 @@ export default class MinApp {
await delay(0) await delay(0)
} }
if (!app.logo) {
app.logo = AppLogo
}
MinApp.app = app MinApp.app = app
store.dispatch(setMinappShow(true)) store.dispatch(setMinappShow(true))
@@ -257,5 +274,6 @@ export default class MinApp {
TopView.hide('MinApp') TopView.hide('MinApp')
store.dispatch(setMinappShow(false)) store.dispatch(setMinappShow(false))
MinApp.app = null MinApp.app = null
MinApp.onClose = () => {}
} }
} }

View File

@@ -4,7 +4,7 @@ import App from '@renderer/pages/apps/App'
import { Popover } from 'antd' import { Popover } from 'antd'
import { Empty } from 'antd' import { Empty } from 'antd'
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { FC, useState } from 'react' import { FC, useEffect, useState } from 'react'
import { useHotkeys } from 'react-hotkeys-hook' import { useHotkeys } from 'react-hotkeys-hook'
import styled from 'styled-components' import styled from 'styled-components'
@@ -26,8 +26,22 @@ const MinAppsPopover: FC<Props> = ({ children }) => {
setOpen(false) setOpen(false)
} }
const [maxHeight, setMaxHeight] = useState(window.innerHeight - 100)
useEffect(() => {
const handleResize = () => {
setMaxHeight(window.innerHeight - 100)
}
window.addEventListener('resize', handleResize)
return () => {
window.removeEventListener('resize', handleResize)
}
}, [])
const content = ( const content = (
<PopoverContent> <PopoverContent maxHeight={maxHeight}>
<AppsContainer> <AppsContainer>
{minapps.map((app) => ( {minapps.map((app) => (
<App key={app.id} app={app} onClick={handleClose} size={50} /> <App key={app.id} app={app} onClick={handleClose} size={50} />
@@ -54,7 +68,10 @@ const MinAppsPopover: FC<Props> = ({ children }) => {
) )
} }
const PopoverContent = styled(Scrollbar)`` const PopoverContent = styled(Scrollbar)<{ maxHeight: number }>`
max-height: ${(props) => props.maxHeight}px;
overflow-y: auto;
`
const AppsContainer = styled.div` const AppsContainer = styled.div`
display: grid; display: grid;

View File

@@ -1,6 +1,6 @@
import { Input, Modal } from 'antd' import { Input, Modal } from 'antd'
import { TextAreaProps } from 'antd/es/input' import { TextAreaProps } from 'antd/es/input'
import { useState } from 'react' import { useRef, useState } from 'react'
import { Box } from '../Layout' import { Box } from '../Layout'
import { TopView } from '../TopView' import { TopView } from '../TopView'
@@ -27,6 +27,7 @@ const PromptPopupContainer: React.FC<Props> = ({
}) => { }) => {
const [value, setValue] = useState(defaultValue) const [value, setValue] = useState(defaultValue)
const [open, setOpen] = useState(true) const [open, setOpen] = useState(true)
const textAreaRef = useRef<any>(null)
const onOk = () => { const onOk = () => {
setOpen(false) setOpen(false)
@@ -41,17 +42,35 @@ const PromptPopupContainer: React.FC<Props> = ({
resolve(null) resolve(null)
} }
const handleAfterOpenChange = (visible: boolean) => {
if (visible) {
const textArea = textAreaRef.current?.resizableTextArea?.textArea
if (textArea) {
textArea.focus()
const length = textArea.value.length
textArea.setSelectionRange(length, length)
}
}
}
PromptPopup.hide = onCancel PromptPopup.hide = onCancel
return ( return (
<Modal title={title} open={open} onOk={onOk} onCancel={onCancel} afterClose={onClose} centered> <Modal
title={title}
open={open}
onOk={onOk}
onCancel={onCancel}
afterClose={onClose}
afterOpenChange={handleAfterOpenChange}
centered>
<Box mb={8}>{message}</Box> <Box mb={8}>{message}</Box>
<Input.TextArea <Input.TextArea
ref={textAreaRef}
placeholder={inputPlaceholder} placeholder={inputPlaceholder}
value={value} value={value}
onChange={(e) => setValue(e.target.value)} onChange={(e) => setValue(e.target.value)}
allowClear allowClear
autoFocus
onPressEnter={onOk} onPressEnter={onOk}
rows={1} rows={1}
{...inputProps} {...inputProps}

View File

@@ -7,7 +7,7 @@ import { getModelUniqId } from '@renderer/services/ModelService'
import { Model } from '@renderer/types' import { Model } from '@renderer/types'
import { Avatar, Divider, Empty, Input, InputRef, Menu, MenuProps, Modal } from 'antd' import { Avatar, Divider, Empty, Input, InputRef, Menu, MenuProps, Modal } from 'antd'
import { first, sortBy } from 'lodash' import { first, sortBy } from 'lodash'
import { useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import styled from 'styled-components' import styled from 'styled-components'
@@ -33,6 +33,7 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
const { providers } = useProviders() const { providers } = useProviders()
const [pinnedModels, setPinnedModels] = useState<string[]>([]) const [pinnedModels, setPinnedModels] = useState<string[]>([])
const scrollContainerRef = useRef<HTMLDivElement>(null) const scrollContainerRef = useRef<HTMLDivElement>(null)
const [keyboardSelectedId, setKeyboardSelectedId] = useState<string>('')
useEffect(() => { useEffect(() => {
const loadPinnedModels = async () => { const loadPinnedModels = async () => {
@@ -153,10 +154,12 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
} }
const onCancel = () => { const onCancel = () => {
setKeyboardSelectedId('')
setOpen(false) setOpen(false)
} }
const onClose = async () => { const onClose = async () => {
setKeyboardSelectedId('')
resolve(undefined) resolve(undefined)
SelectModelPopup.hide() SelectModelPopup.hide()
} }
@@ -176,6 +179,90 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
} }
}, [open, model]) }, [open, model])
// 获取所有可见的模型项
const getVisibleModelItems = useCallback(() => {
const items: { key: string; model: Model }[] = []
// 如果有置顶模型且没有搜索文本,添加置顶模型
if (pinnedModels.length > 0 && searchText.length === 0) {
providers
.flatMap((p) => p.models || [])
.filter((m) => pinnedModels.includes(getModelUniqId(m)))
.forEach((m) => items.push({ key: getModelUniqId(m) + '_pinned', model: m }))
}
// 添加其他过滤后的模型
providers.forEach((p) => {
if (p.models) {
sortBy(p.models, ['group', 'name'])
.filter((m) => !isEmbeddingModel(m))
.filter((m) =>
[m.name + m.provider + t('provider.' + p.id)].join('').toLowerCase().includes(searchText.toLowerCase())
)
.forEach((m) => {
const modelId = getModelUniqId(m)
const isPinned = pinnedModels.includes(modelId)
// 如果是搜索状态,或者不是固定模型,才添加到列表中
if (searchText.length > 0 || !isPinned) {
items.push({
key: isPinned ? modelId + '_pinned' : modelId,
model: m
})
}
})
}
})
return items
}, [pinnedModels, searchText, providers, t])
// 处理键盘导航
const handleKeyDown = useCallback(
(e: KeyboardEvent) => {
const items = getVisibleModelItems()
if (items.length === 0) return
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault()
const currentIndex = items.findIndex((item) => item.key === keyboardSelectedId)
let nextIndex
if (currentIndex === -1) {
nextIndex = e.key === 'ArrowDown' ? 0 : items.length - 1
} else {
nextIndex =
e.key === 'ArrowDown' ? (currentIndex + 1) % items.length : (currentIndex - 1 + items.length) % items.length
}
const nextItem = items[nextIndex]
setKeyboardSelectedId(nextItem.key)
const element = document.querySelector(`[data-menu-id="${nextItem.key}"]`)
element?.scrollIntoView({ block: 'nearest', behavior: 'smooth' })
} else if (e.key === 'Enter') {
e.preventDefault() // 阻止回车的默认行为
if (keyboardSelectedId) {
const selectedItem = items.find((item) => item.key === keyboardSelectedId)
if (selectedItem) {
resolve(selectedItem.model)
setOpen(false)
}
}
}
},
[keyboardSelectedId, getVisibleModelItems, resolve, setOpen]
)
useEffect(() => {
window.addEventListener('keydown', handleKeyDown)
return () => window.removeEventListener('keydown', handleKeyDown)
}, [handleKeyDown])
// 搜索文本改变时重置键盘选中状态
useEffect(() => {
setKeyboardSelectedId('')
}, [searchText])
return ( return (
<Modal <Modal
centered centered
@@ -210,18 +297,19 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
style={{ paddingLeft: 0 }} style={{ paddingLeft: 0 }}
bordered={false} bordered={false}
size="middle" size="middle"
onKeyDown={(e) => {
// 防止上下键移动光标
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
e.preventDefault()
}
}}
/> />
</HStack> </HStack>
<Divider style={{ margin: 0, borderBlockStartWidth: 0.5 }} /> <Divider style={{ margin: 0, borderBlockStartWidth: 0.5 }} />
<Scrollbar style={{ height: '50vh' }} ref={scrollContainerRef}> <Scrollbar style={{ height: '50vh' }} ref={scrollContainerRef}>
<Container> <Container>
{filteredItems.length > 0 ? ( {filteredItems.length > 0 ? (
<StyledMenu <StyledMenu items={filteredItems} selectedKeys={[keyboardSelectedId]} mode="inline" inlineIndent={6} />
items={filteredItems}
selectedKeys={model ? [getModelUniqId(model)] : []}
mode="inline"
inlineIndent={6}
/>
) : ( ) : (
<EmptyState> <EmptyState>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />

Some files were not shown because too many files have changed in this diff Show More