Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2dc325896 | ||
|
|
b131d320ea | ||
|
|
b88f4a869e | ||
|
|
461458e5ec | ||
|
|
4c2014f1d6 | ||
|
|
647dd3e751 | ||
|
|
4225312d4a | ||
|
|
c2a4613e32 | ||
|
|
5d5c1eee74 | ||
|
|
c1b5e6b183 | ||
|
|
fd37ba18dc | ||
|
|
4a26f7ce78 | ||
|
|
8b38ebcac4 | ||
|
|
e8dac28787 | ||
|
|
3ccebb503f | ||
|
|
42327836de | ||
|
|
4d7a3bb8c3 | ||
|
|
1996e163c9 | ||
|
|
e43f7f87ab | ||
|
|
47a83fa67f | ||
|
|
5e954566c9 | ||
|
|
b8960ef02c | ||
|
|
1866b00265 | ||
|
|
be0799a4c6 | ||
|
|
d0f5547419 | ||
|
|
076011b02b | ||
|
|
ba5c70c45a | ||
|
|
ebe74ffd05 | ||
|
|
d0bea0491f | ||
|
|
514e1a4796 | ||
|
|
2ffedadee4 | ||
|
|
7b72783ae7 | ||
|
|
4485a00395 | ||
|
|
77c0952635 | ||
|
|
e1c7a25b87 | ||
|
|
b0c479190c | ||
|
|
c7c3d28893 | ||
|
|
994ee8d7df | ||
|
|
57f9550891 | ||
|
|
0c0d1560db | ||
|
|
145d7ee748 | ||
|
|
52af23b931 | ||
|
|
f7151bd066 | ||
|
|
744a1fedba | ||
|
|
978432d910 | ||
|
|
b6cb1e4d84 | ||
|
|
0096783f26 | ||
|
|
4fc53d7c19 | ||
|
|
34d99b711c | ||
|
|
5dd74a1018 | ||
|
|
e028d0600f | ||
|
|
64ee3f2108 | ||
|
|
30a082b979 | ||
|
|
5a0927393d | ||
|
|
16c68dcdcb | ||
|
|
b6500977b0 | ||
|
|
78cf33e8bc | ||
|
|
2f62f04adf | ||
|
|
84915b1ede | ||
|
|
248c7ea20e | ||
|
|
1031d40ddb | ||
|
|
3d44fc2208 | ||
|
|
22e3c0e270 | ||
|
|
5d81874166 |
4
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest]
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
@@ -52,8 +52,6 @@ jobs:
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: yarn build:win
|
||||
env:
|
||||
CSC_LINK: ${{ secrets.CSC_LINK }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Replace spaces in filenames
|
||||
|
||||
27
README.md
@@ -1,18 +1,18 @@
|
||||
# Cherry Studio
|
||||
# 🍒 Cherry Studio
|
||||
|
||||
🍒 Cherry Studio is a desktop client that supports multiple Large Language Model (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.
|
||||
|
||||
# Screenshot
|
||||
# 🌠 Screenshot
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
# Feature
|
||||
# 🌟 Features
|
||||
|
||||
1. Supports multiple large language model service providers.
|
||||
1. Support for Multiple LLM Providers.
|
||||
2. Allows creation of multiple Assistants.
|
||||
3. Enables creation of multiple topics.
|
||||
4. Allows using multiple models to answer questions in the same conversation.
|
||||
@@ -20,7 +20,8 @@
|
||||
6. Code highlighting.
|
||||
7. Mermaid chart
|
||||
|
||||
# Develop
|
||||
# 🖥️ Develop
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
|
||||
@@ -51,3 +52,11 @@ $ yarn build:mac
|
||||
# For Linux
|
||||
$ yarn build:linux
|
||||
```
|
||||
|
||||
# ⭐️ Star History
|
||||
|
||||
[](https://star-history.com/#kangfenmao/cherry-studio&Timeline)
|
||||
|
||||
# 📃 License
|
||||
|
||||
[LICENSE](./LICENSE)
|
||||
|
||||
@@ -40,8 +40,8 @@ dmg:
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
- snap
|
||||
- deb
|
||||
# - snap
|
||||
# - deb
|
||||
maintainer: electronjs.org
|
||||
category: Utility
|
||||
appImage:
|
||||
@@ -56,5 +56,5 @@ electronDownload:
|
||||
afterSign: scripts/notarize.js
|
||||
releaseInfo:
|
||||
releaseNotes: |
|
||||
支持保存自定义智能体
|
||||
修复话题重命名的问题
|
||||
增加应用备份和恢复功能
|
||||
增加更多AI小程序
|
||||
|
||||
@@ -15,7 +15,6 @@ export default defineConfig({
|
||||
'@renderer': resolve('src/renderer/src')
|
||||
}
|
||||
},
|
||||
plugins: [react()],
|
||||
assetsInclude: ['**/*.md']
|
||||
plugins: [react()]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cherry-studio",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.1",
|
||||
"description": "A powerful AI assistant for producer.",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "kangfenmao@qq.com",
|
||||
@@ -37,6 +37,7 @@
|
||||
"@electron-toolkit/eslint-config-prettier": "^2.0.0",
|
||||
"@electron-toolkit/eslint-config-ts": "^1.0.1",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@google/generative-ai": "^0.16.0",
|
||||
"@hello-pangea/dnd": "^16.6.0",
|
||||
"@kangfenmao/keyv-storage": "^0.1.0",
|
||||
"@reduxjs/toolkit": "^2.2.5",
|
||||
@@ -45,8 +46,8 @@
|
||||
"@types/react": "^18.2.48",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"ahooks": "^3.8.0",
|
||||
"antd": "^5.18.3",
|
||||
"axios": "^1.7.3",
|
||||
"browser-image-compression": "^2.0.2",
|
||||
"dayjs": "^1.11.11",
|
||||
"dotenv-cli": "^7.4.2",
|
||||
|
||||
68
resources/graphrag.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<script src="https://unpkg.com/3d-force-graph"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="3d-graph"></div>
|
||||
<script src="./js/bridge.js"></script>
|
||||
<script type="module">
|
||||
import { getQueryParam } from './js/utils.js'
|
||||
|
||||
const apiUrl = getQueryParam('apiUrl')
|
||||
const modelId = getQueryParam('modelId')
|
||||
const jsonUrl = `${apiUrl}/v1/global_graph/${modelId}`
|
||||
|
||||
const infoCard = document.createElement('div')
|
||||
infoCard.style.position = 'fixed'
|
||||
infoCard.style.backgroundColor = 'rgba(255, 255, 255, 0.9)'
|
||||
infoCard.style.padding = '8px'
|
||||
infoCard.style.borderRadius = '4px'
|
||||
infoCard.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)'
|
||||
infoCard.style.fontSize = '12px'
|
||||
infoCard.style.maxWidth = '200px'
|
||||
infoCard.style.display = 'none'
|
||||
infoCard.style.zIndex = '1000'
|
||||
document.body.appendChild(infoCard)
|
||||
|
||||
document.addEventListener('mousemove', (event) => {
|
||||
infoCard.style.left = `${event.clientX + 10}px`
|
||||
infoCard.style.top = `${event.clientY + 10}px`
|
||||
})
|
||||
|
||||
const elem = document.getElementById('3d-graph')
|
||||
const Graph = ForceGraph3D()(elem)
|
||||
.jsonUrl(jsonUrl)
|
||||
.nodeAutoColorBy((node) => node.properties.type || 'default')
|
||||
.nodeVal((node) => node.properties.degree)
|
||||
.linkWidth((link) => link.properties.weight)
|
||||
.onNodeHover((node) => {
|
||||
if (node) {
|
||||
infoCard.innerHTML = `
|
||||
<div style="font-weight: bold; margin-bottom: 4px; color: #333;">
|
||||
${node.properties.title}
|
||||
</div>
|
||||
<div style="color: #666;">
|
||||
${node.properties.description}
|
||||
</div>`
|
||||
infoCard.style.display = 'block'
|
||||
} else {
|
||||
infoCard.style.display = 'none'
|
||||
}
|
||||
})
|
||||
.onNodeClick((node) => {
|
||||
const url = `${apiUrl}/v1/references/${modelId}/entities/${node.properties.human_readable_id}`
|
||||
window.api.minApp({
|
||||
url,
|
||||
windowOptions: {
|
||||
title: node.properties.title,
|
||||
width: 500,
|
||||
height: 800
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
Before Width: | Height: | Size: 197 KiB |
36
resources/js/bridge.js
Normal file
@@ -0,0 +1,36 @@
|
||||
;(() => {
|
||||
let messageId = 0
|
||||
const pendingCalls = new Map()
|
||||
|
||||
function api(method, ...args) {
|
||||
const id = messageId++
|
||||
return new Promise((resolve, reject) => {
|
||||
pendingCalls.set(id, { resolve, reject })
|
||||
window.parent.postMessage({ id, type: 'api-call', method, args }, '*')
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data.type === 'api-response') {
|
||||
const { id, result, error } = event.data
|
||||
const pendingCall = pendingCalls.get(id)
|
||||
if (pendingCall) {
|
||||
if (error) {
|
||||
pendingCall.reject(new Error(error))
|
||||
} else {
|
||||
pendingCall.resolve(result)
|
||||
}
|
||||
pendingCalls.delete(id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
window.api = new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (target, prop) => {
|
||||
return (...args) => api(prop, ...args)
|
||||
}
|
||||
}
|
||||
)
|
||||
})()
|
||||
5
resources/js/utils.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export function getQueryParam(paramName) {
|
||||
const url = new URL(window.location.href)
|
||||
const params = new URLSearchParams(url.search)
|
||||
return params.get(paramName)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { dialog, SaveDialogOptions, SaveDialogReturnValue } from 'electron'
|
||||
import logger from 'electron-log'
|
||||
import { writeFile } from 'fs'
|
||||
|
||||
export async function saveFile(_: Electron.IpcMainInvokeEvent, fileName: string, content: string): Promise<void> {
|
||||
try {
|
||||
const options: SaveDialogOptions = {
|
||||
title: '保存文件',
|
||||
defaultPath: fileName
|
||||
}
|
||||
|
||||
const result: SaveDialogReturnValue = await dialog.showSaveDialog(options)
|
||||
|
||||
if (!result.canceled && result.filePath) {
|
||||
writeFile(result.filePath, content, { encoding: 'utf-8' }, (err) => {
|
||||
if (err) {
|
||||
logger.error('[IPC - Error]', 'An error occurred saving the file:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('[IPC - Error]', 'An error occurred saving the file:', err)
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,10 @@
|
||||
import { electronApp, is, optimizer } from '@electron-toolkit/utils'
|
||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||
import * as Sentry from '@sentry/electron/main'
|
||||
import { app, BrowserWindow, ipcMain, Menu, MenuItem, session, shell } from 'electron'
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
||||
import windowStateKeeper from 'electron-window-state'
|
||||
import { join } from 'path'
|
||||
|
||||
import icon from '../../resources/icon.png?asset'
|
||||
import { appConfig, titleBarOverlayDark, titleBarOverlayLight } from './config'
|
||||
import { saveFile } from './event'
|
||||
import AppUpdater from './updater'
|
||||
|
||||
function createWindow() {
|
||||
// Load the previous state with fallback to defaults
|
||||
const mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 1080,
|
||||
defaultHeight: 670
|
||||
})
|
||||
|
||||
const theme = appConfig.get('theme') || 'light'
|
||||
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
x: mainWindowState.x,
|
||||
y: mainWindowState.y,
|
||||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
minWidth: 1080,
|
||||
minHeight: 600,
|
||||
show: true,
|
||||
autoHideMenuBar: true,
|
||||
transparent: process.platform === 'darwin',
|
||||
vibrancy: 'fullscreen-ui',
|
||||
titleBarStyle: 'hidden',
|
||||
titleBarOverlay: theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight,
|
||||
trafficLightPosition: { x: 8, y: 12 },
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
webSecurity: false
|
||||
// devTools: !app.isPackaged,
|
||||
}
|
||||
})
|
||||
|
||||
mainWindowState.manage(mainWindow)
|
||||
|
||||
mainWindow.webContents.on('context-menu', () => {
|
||||
const menu = new Menu()
|
||||
menu.append(new MenuItem({ label: '复制', role: 'copy', sublabel: '⌘ + C' }))
|
||||
menu.append(new MenuItem({ label: '粘贴', role: 'paste', sublabel: '⌘ + V' }))
|
||||
menu.append(new MenuItem({ label: '剪切', role: 'cut', sublabel: '⌘ + X' }))
|
||||
menu.append(new MenuItem({ type: 'separator' }))
|
||||
menu.append(new MenuItem({ label: '全选', role: 'selectAll', sublabel: '⌘ + A' }))
|
||||
menu.popup()
|
||||
})
|
||||
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.show()
|
||||
})
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
})
|
||||
|
||||
// HMR for renderer base on electron-vite cli.
|
||||
// Load the remote URL for development or the local html file for production.
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
|
||||
} else {
|
||||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||
}
|
||||
|
||||
return mainWindow
|
||||
}
|
||||
import { registerIpc } from './ipc'
|
||||
import { createMainWindow } from './window'
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
@@ -97,43 +23,12 @@ app.whenReady().then(() => {
|
||||
app.on('activate', function () {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
|
||||
})
|
||||
|
||||
const mainWindow = createWindow()
|
||||
const mainWindow = createMainWindow()
|
||||
|
||||
const { autoUpdater } = new AppUpdater(mainWindow)
|
||||
|
||||
// IPC
|
||||
ipcMain.handle('get-app-info', () => ({
|
||||
version: app.getVersion(),
|
||||
isPackaged: app.isPackaged
|
||||
}))
|
||||
|
||||
ipcMain.handle('open-website', (_, url: string) => {
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
ipcMain.handle('set-proxy', (_, proxy: string) => {
|
||||
session.defaultSession.setProxy(proxy ? { proxyRules: proxy } : {})
|
||||
})
|
||||
|
||||
ipcMain.handle('save-file', saveFile)
|
||||
|
||||
ipcMain.handle('set-theme', (_, theme: 'light' | 'dark') => {
|
||||
appConfig.set('theme', theme)
|
||||
mainWindow?.setTitleBarOverlay &&
|
||||
mainWindow.setTitleBarOverlay(theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight)
|
||||
})
|
||||
|
||||
// 触发检查更新(此方法用于被渲染线程调用,例如页面点击检查更新按钮来调用此方法)
|
||||
ipcMain.handle('check-for-update', async () => {
|
||||
autoUpdater.logger?.info('触发检查更新')
|
||||
return {
|
||||
currentVersion: autoUpdater.currentVersion,
|
||||
update: await autoUpdater.checkForUpdates()
|
||||
}
|
||||
})
|
||||
registerIpc(mainWindow, app)
|
||||
|
||||
installExtension(REDUX_DEVTOOLS)
|
||||
})
|
||||
|
||||
59
src/main/ipc.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { BrowserWindow, ipcMain, session, shell } from 'electron'
|
||||
|
||||
import { appConfig, titleBarOverlayDark, titleBarOverlayLight } from './config'
|
||||
import AppUpdater from './updater'
|
||||
import { openFile, saveFile } from './utils/file'
|
||||
import { compress, decompress } from './utils/zip'
|
||||
import { createMinappWindow } from './window'
|
||||
|
||||
export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
|
||||
const { autoUpdater } = new AppUpdater(mainWindow)
|
||||
|
||||
// IPC
|
||||
ipcMain.handle('get-app-info', () => ({
|
||||
version: app.getVersion(),
|
||||
isPackaged: app.isPackaged,
|
||||
appPath: app.getAppPath()
|
||||
}))
|
||||
|
||||
ipcMain.handle('open-website', (_, url: string) => {
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
ipcMain.handle('set-proxy', (_, proxy: string) => {
|
||||
session.defaultSession.setProxy(proxy ? { proxyRules: proxy } : {})
|
||||
})
|
||||
|
||||
ipcMain.handle('save-file', saveFile)
|
||||
ipcMain.handle('open-file', openFile)
|
||||
ipcMain.handle('reload', () => mainWindow.reload())
|
||||
|
||||
ipcMain.handle('zip:compress', (_, text: string) => compress(text))
|
||||
ipcMain.handle('zip:decompress', (_, text: Buffer) => decompress(text))
|
||||
|
||||
ipcMain.handle('minapp', (_, args) => {
|
||||
createMinappWindow({
|
||||
url: args.url,
|
||||
parent: mainWindow,
|
||||
windowOptions: {
|
||||
...mainWindow.getBounds(),
|
||||
...args.windowOptions
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.handle('set-theme', (_, theme: 'light' | 'dark') => {
|
||||
appConfig.set('theme', theme)
|
||||
mainWindow?.setTitleBarOverlay &&
|
||||
mainWindow.setTitleBarOverlay(theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight)
|
||||
})
|
||||
|
||||
// 触发检查更新(此方法用于被渲染线程调用,例如页面点击检查更新按钮来调用此方法)
|
||||
ipcMain.handle('check-for-update', async () => {
|
||||
autoUpdater.logger?.info('触发检查更新')
|
||||
return {
|
||||
currentVersion: autoUpdater.currentVersion,
|
||||
update: await autoUpdater.checkForUpdates()
|
||||
}
|
||||
})
|
||||
}
|
||||
24
src/main/utils/aes.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
// 定义密钥和初始化向量(IV)
|
||||
const secretKey = 'kDQvWz5slot3syfucoo53X6KKsEUJoeFikpiUWRJTLIo3zcUPpFvEa009kK13KCr'
|
||||
const iv = Buffer.from('Cherry Studio', 'hex')
|
||||
|
||||
// 加密函数
|
||||
export function encrypt(text: string): { iv: string; encryptedData: string } {
|
||||
const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(secretKey), iv)
|
||||
let encrypted = cipher.update(text, 'utf8', 'hex')
|
||||
encrypted += cipher.final('hex')
|
||||
return {
|
||||
iv: iv.toString('hex'),
|
||||
encryptedData: encrypted
|
||||
}
|
||||
}
|
||||
|
||||
// 解密函数
|
||||
export function decrypt(encryptedData: string, iv: string): string {
|
||||
const decipher = crypto.createDecipheriv('aes-256-cbc', Buffer.from(secretKey), Buffer.from(iv, 'hex'))
|
||||
let decrypted = decipher.update(encryptedData, 'hex', 'utf8')
|
||||
decrypted += decipher.final('utf8')
|
||||
return decrypted
|
||||
}
|
||||
55
src/main/utils/file.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { dialog, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'electron'
|
||||
import logger from 'electron-log'
|
||||
import { writeFile } from 'fs'
|
||||
import { readFile } from 'fs/promises'
|
||||
|
||||
export async function saveFile(
|
||||
_: Electron.IpcMainInvokeEvent,
|
||||
fileName: string,
|
||||
content: string,
|
||||
options?: SaveDialogOptions
|
||||
): Promise<void> {
|
||||
try {
|
||||
const result: SaveDialogReturnValue = await dialog.showSaveDialog({
|
||||
title: '保存文件',
|
||||
defaultPath: fileName,
|
||||
...options
|
||||
})
|
||||
|
||||
if (!result.canceled && result.filePath) {
|
||||
writeFile(result.filePath, content, { encoding: 'utf-8' }, (err) => {
|
||||
if (err) {
|
||||
logger.error('[IPC - Error]', 'An error occurred saving the file:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('[IPC - Error]', 'An error occurred saving the file:', err)
|
||||
}
|
||||
}
|
||||
|
||||
export async function openFile(
|
||||
_: Electron.IpcMainInvokeEvent,
|
||||
options: OpenDialogOptions
|
||||
): Promise<{ fileName: string; content: Buffer } | null> {
|
||||
try {
|
||||
const result: OpenDialogReturnValue = await dialog.showOpenDialog({
|
||||
title: '打开文件',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: '所有文件', extensions: ['*'] }],
|
||||
...options
|
||||
})
|
||||
|
||||
if (!result.canceled && result.filePaths.length > 0) {
|
||||
const filePath = result.filePaths[0]
|
||||
const fileName = filePath.split('/').pop() || ''
|
||||
const content = await readFile(filePath)
|
||||
return { fileName, content }
|
||||
}
|
||||
|
||||
return null
|
||||
} catch (err) {
|
||||
logger.error('[IPC - Error]', 'An error occurred opening the file:', err)
|
||||
return null
|
||||
}
|
||||
}
|
||||
37
src/main/utils/zip.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import util from 'node:util'
|
||||
import zlib from 'node:zlib'
|
||||
|
||||
// 将 zlib 的 gzip 和 gunzip 方法转换为 Promise 版本
|
||||
const gzipPromise = util.promisify(zlib.gzip)
|
||||
const gunzipPromise = util.promisify(zlib.gunzip)
|
||||
|
||||
/**
|
||||
* 压缩字符串
|
||||
* @param {string} string - 要压缩的 JSON 字符串
|
||||
* @returns {Promise<Buffer>} 压缩后的 Buffer
|
||||
*/
|
||||
export async function compress(str) {
|
||||
try {
|
||||
const buffer = Buffer.from(str, 'utf-8')
|
||||
const compressedBuffer = await gzipPromise(buffer)
|
||||
return compressedBuffer
|
||||
} catch (error) {
|
||||
console.error('Compression failed:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压缩 Buffer 到 JSON 字符串
|
||||
* @param {Buffer} compressedBuffer - 压缩的 Buffer
|
||||
* @returns {Promise<string>} 解压缩后的 JSON 字符串
|
||||
*/
|
||||
export async function decompress(compressedBuffer) {
|
||||
try {
|
||||
const buffer = await gunzipPromise(compressedBuffer)
|
||||
return buffer.toString('utf-8')
|
||||
} catch (error) {
|
||||
console.error('Decompression failed:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
124
src/main/window.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { is } from '@electron-toolkit/utils'
|
||||
import { BrowserWindow, Menu, MenuItem, shell } from 'electron'
|
||||
import windowStateKeeper from 'electron-window-state'
|
||||
import { join } from 'path'
|
||||
|
||||
import icon from '../../build/icon.png?asset'
|
||||
import { appConfig, titleBarOverlayDark, titleBarOverlayLight } from './config'
|
||||
|
||||
export function createMainWindow() {
|
||||
// Load the previous state with fallback to defaults
|
||||
const mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 1080,
|
||||
defaultHeight: 670
|
||||
})
|
||||
|
||||
const theme = appConfig.get('theme') || 'light'
|
||||
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
x: mainWindowState.x,
|
||||
y: mainWindowState.y,
|
||||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
minWidth: 1080,
|
||||
minHeight: 600,
|
||||
show: true,
|
||||
autoHideMenuBar: true,
|
||||
transparent: process.platform === 'darwin',
|
||||
vibrancy: 'fullscreen-ui',
|
||||
titleBarStyle: 'hidden',
|
||||
titleBarOverlay: theme === 'dark' ? titleBarOverlayDark : titleBarOverlayLight,
|
||||
trafficLightPosition: { x: 8, y: 12 },
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
webSecurity: false
|
||||
// devTools: !app.isPackaged,
|
||||
}
|
||||
})
|
||||
|
||||
mainWindowState.manage(mainWindow)
|
||||
|
||||
mainWindow.webContents.on('context-menu', () => {
|
||||
const menu = new Menu()
|
||||
menu.append(new MenuItem({ label: '复制', role: 'copy', sublabel: '⌘ + C' }))
|
||||
menu.append(new MenuItem({ label: '粘贴', role: 'paste', sublabel: '⌘ + V' }))
|
||||
menu.append(new MenuItem({ label: '剪切', role: 'cut', sublabel: '⌘ + X' }))
|
||||
menu.append(new MenuItem({ type: 'separator' }))
|
||||
menu.append(new MenuItem({ label: '全选', role: 'selectAll', sublabel: '⌘ + A' }))
|
||||
menu.popup()
|
||||
})
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.show()
|
||||
})
|
||||
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
})
|
||||
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived({ urls: ['*://*/*'] }, (details, callback) => {
|
||||
if (details.responseHeaders?.['X-Frame-Options']) {
|
||||
delete details.responseHeaders['X-Frame-Options']
|
||||
}
|
||||
if (details.responseHeaders?.['x-frame-options']) {
|
||||
delete details.responseHeaders['x-frame-options']
|
||||
}
|
||||
if (details.responseHeaders?.['Content-Security-Policy']) {
|
||||
delete details.responseHeaders['Content-Security-Policy']
|
||||
}
|
||||
if (details.responseHeaders?.['content-security-policy']) {
|
||||
delete details.responseHeaders['content-security-policy']
|
||||
}
|
||||
callback({ cancel: false, responseHeaders: details.responseHeaders })
|
||||
})
|
||||
|
||||
// HMR for renderer base on electron-vite cli.
|
||||
// Load the remote URL for development or the local html file for production.
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
|
||||
} else {
|
||||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||
}
|
||||
|
||||
return mainWindow
|
||||
}
|
||||
|
||||
export function createMinappWindow({
|
||||
url,
|
||||
parent,
|
||||
windowOptions
|
||||
}: {
|
||||
url: string
|
||||
parent?: BrowserWindow
|
||||
windowOptions?: Electron.BrowserWindowConstructorOptions
|
||||
}) {
|
||||
const width = windowOptions?.width || 1000
|
||||
const height = windowOptions?.height || 680
|
||||
|
||||
const minappWindow = new BrowserWindow({
|
||||
width,
|
||||
height,
|
||||
autoHideMenuBar: true,
|
||||
title: 'Cherry Studio',
|
||||
...windowOptions,
|
||||
parent,
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/minapp.js'),
|
||||
sandbox: false,
|
||||
contextIsolation: false
|
||||
}
|
||||
})
|
||||
|
||||
minappWindow.loadURL(url)
|
||||
|
||||
return minappWindow
|
||||
}
|
||||
9
src/preload/index.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import { ElectronAPI } from '@electron-toolkit/preload'
|
||||
import type { OpenDialogOptions } from 'electron'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -7,12 +8,18 @@ declare global {
|
||||
getAppInfo: () => Promise<{
|
||||
version: string
|
||||
isPackaged: boolean
|
||||
appPath: string
|
||||
}>
|
||||
checkForUpdate: () => void
|
||||
openWebsite: (url: string) => void
|
||||
setProxy: (proxy: string | undefined) => void
|
||||
saveFile: (path: string, content: string) => void
|
||||
saveFile: (path: string, content: string | NodeJS.ArrayBufferView, options?: SaveDialogOptions) => void
|
||||
openFile: (options?: OpenDialogOptions) => Promise<{ fileName: string; content: Buffer } | null>
|
||||
setTheme: (theme: 'light' | 'dark') => void
|
||||
minApp: (options: { url: string; windowOptions?: Electron.BrowserWindowConstructorOptions }) => void
|
||||
reload: () => void
|
||||
compress: (text: string) => Promise<Buffer>
|
||||
decompress: (text: Buffer) => Promise<string>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,15 @@ const api = {
|
||||
checkForUpdate: () => ipcRenderer.invoke('check-for-update'),
|
||||
openWebsite: (url: string) => ipcRenderer.invoke('open-website', url),
|
||||
setProxy: (proxy: string) => ipcRenderer.invoke('set-proxy', proxy),
|
||||
saveFile: (path: string, content: string) => ipcRenderer.invoke('save-file', path, content),
|
||||
setTheme: (theme: 'light' | 'dark') => ipcRenderer.invoke('set-theme', theme)
|
||||
setTheme: (theme: 'light' | 'dark') => ipcRenderer.invoke('set-theme', theme),
|
||||
minApp: (url: string) => ipcRenderer.invoke('minapp', url),
|
||||
openFile: (options?: { decompress: boolean }) => ipcRenderer.invoke('open-file', options),
|
||||
reload: () => ipcRenderer.invoke('reload'),
|
||||
saveFile: (path: string, content: string, options?: { compress: boolean }) => {
|
||||
ipcRenderer.invoke('save-file', path, content, options)
|
||||
},
|
||||
compress: (text: string) => ipcRenderer.invoke('zip:compress', text),
|
||||
decompress: (text: Buffer) => ipcRenderer.invoke('zip:decompress', text)
|
||||
}
|
||||
|
||||
// Use `contextBridge` APIs to expose Electron APIs to
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="initial-scale=1, width=device-width" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self'; connect-src *; script-src 'self' *; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' *; font-src 'self' data: *; img-src 'self' data:" />
|
||||
content="default-src 'self'; connect-src *; script-src 'self' *; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' *; font-src 'self' data: *; img-src 'self' data:; frame-src * file:" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { PersistGate } from 'redux-persist/integration/react'
|
||||
import Sidebar from './components/app/Sidebar'
|
||||
import TopViewContainer from './components/TopView'
|
||||
import AgentsPage from './pages/agents/AgentsPage'
|
||||
import AppsPage from './pages/apps/AppsPage'
|
||||
import HomePage from './pages/home/HomePage'
|
||||
import SettingsPage from './pages/settings/SettingsPage'
|
||||
import TranslatePage from './pages/translate/TranslatePage'
|
||||
@@ -23,8 +24,9 @@ function App(): JSX.Element {
|
||||
<Sidebar />
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/apps" element={<AgentsPage />} />
|
||||
<Route path="/agents" element={<AgentsPage />} />
|
||||
<Route path="/translate" element={<TranslatePage />} />
|
||||
<Route path="/apps" element={<AppsPage />} />
|
||||
<Route path="/settings/*" element={<SettingsPage />} />
|
||||
</Routes>
|
||||
</HashRouter>
|
||||
|
||||
@@ -1,55 +1,64 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 4563475 */
|
||||
src: url('iconfont.woff2?t=1722242729348') format('woff2'),
|
||||
url('iconfont.woff?t=1722242729348') format('woff'),
|
||||
url('iconfont.ttf?t=1722242729348') format('truetype');
|
||||
font-family: 'iconfont'; /* Project id 4563475 */
|
||||
src: url('iconfont.woff2?t=1724204739157') format('woff2');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-family: 'iconfont' !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-business-smart-assistant:before {
|
||||
content: '\e601';
|
||||
}
|
||||
|
||||
.icon-copy:before {
|
||||
content: '\e6ae';
|
||||
}
|
||||
|
||||
.icon-ic_send:before {
|
||||
content: '\e795';
|
||||
}
|
||||
|
||||
.icon-dark1:before {
|
||||
content: "\e72f";
|
||||
content: '\e72f';
|
||||
}
|
||||
|
||||
.icon-theme-light:before {
|
||||
content: "\e6b7";
|
||||
content: '\e6b7';
|
||||
}
|
||||
|
||||
.icon-translate_line:before {
|
||||
content: "\e7de";
|
||||
content: '\e7de';
|
||||
}
|
||||
|
||||
.icon-history:before {
|
||||
content: "\e758";
|
||||
content: '\e758';
|
||||
}
|
||||
|
||||
.icon-hidesidebarhoriz:before {
|
||||
content: "\e8eb";
|
||||
content: '\e8eb';
|
||||
}
|
||||
|
||||
.icon-showsidebarhoriz:before {
|
||||
content: "\e944";
|
||||
content: '\e944';
|
||||
}
|
||||
|
||||
.icon-a-addchat:before {
|
||||
content: "\e658";
|
||||
content: '\e658';
|
||||
}
|
||||
|
||||
.icon-appstore:before {
|
||||
content: "\e792";
|
||||
content: '\e792';
|
||||
}
|
||||
|
||||
.icon-chat:before {
|
||||
content: "\e615";
|
||||
content: '\e615';
|
||||
}
|
||||
|
||||
.icon-setting:before {
|
||||
content: "\e78e";
|
||||
content: '\e78e';
|
||||
}
|
||||
|
||||
|
||||
BIN
src/renderer/src/assets/images/apps/360-ai.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
src/renderer/src/assets/images/apps/ai-search.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src/renderer/src/assets/images/apps/baidu-ai.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/renderer/src/assets/images/apps/baixiaoying.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
src/renderer/src/assets/images/apps/devv.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/src/assets/images/apps/kimi.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
src/renderer/src/assets/images/apps/metaso.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src/renderer/src/assets/images/apps/sensetime.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
src/renderer/src/assets/images/apps/sparkdesk.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src/renderer/src/assets/images/apps/tiangong.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/renderer/src/assets/images/apps/yuanbao.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/renderer/src/assets/images/apps/yuewen.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
src/renderer/src/assets/images/models/doubao.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/src/assets/images/models/embedding.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
src/renderer/src/assets/images/models/gemini.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
src/renderer/src/assets/images/models/hailuo.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
67
src/renderer/src/assets/images/models/palm.svg
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Standard_product_icon__x28_1:1_x29_"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="192px" height="192px"
|
||||
viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
|
||||
<symbol id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" viewBox="-96 -96 192 192">
|
||||
<g opacity="0.4">
|
||||
<defs>
|
||||
<path id="SVGID_1_" opacity="0.4" d="M-96,96V-96H96V96H-96z"/>
|
||||
</defs>
|
||||
<clipPath id="SVGID_00000071517564283228984050000017848131202901217410_">
|
||||
<use xlink:href="#SVGID_1_" overflow="visible"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)">
|
||||
<g>
|
||||
<path d="M95.75,95.75v-191.5h-191.5v191.5H95.75 M96,96H-96V-96H96V96L96,96z"/>
|
||||
</g>
|
||||
<circle fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="64"/>
|
||||
</g>
|
||||
|
||||
<circle clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="88"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M64,76H-64c-6.6,0-12-5.4-12-12V-64c0-6.6,5.4-12,12-12H64c6.6,0,12,5.4,12,12V64C76,70.6,70.6,76,64,76z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M52,88H-52c-6.6,0-12-5.4-12-12V-76c0-6.6,5.4-12,12-12H52c6.6,0,12,5.4,12,12V76C64,82.6,58.6,88,52,88z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M76,64H-76c-6.6,0-12-5.4-12-12V-52c0-6.6,5.4-12,12-12H76c6.6,0,12,5.4,12,12V52C88,58.6,82.6,64,76,64z"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<rect id="bounding_box_1_" display="none" fill="none" width="192" height="192"/>
|
||||
<g id="art_layer">
|
||||
<g>
|
||||
<path fill="#F9AB00" d="M96,181.92L96,181.92c6.63,0,12-5.37,12-12v-104H84v104C84,176.55,89.37,181.92,96,181.92z"/>
|
||||
<g>
|
||||
<path fill="#5BB974" d="M143.81,103.87C130.87,90.94,111.54,88.32,96,96l51.37,51.37c2.12,2.12,5.77,1.28,6.67-1.57
|
||||
C158.56,131.49,155.15,115.22,143.81,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#129EAF" d="M48.19,103.87C61.13,90.94,80.46,88.32,96,96l-51.37,51.37c-2.12,2.12-5.77,1.28-6.67-1.57
|
||||
C33.44,131.49,36.85,115.22,48.19,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#AF5CF7" d="M140,64c-20.44,0-37.79,13.4-44,32h81.24c3.33,0,5.55-3.52,4.04-6.49C173.56,74.36,157.98,64,140,64z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FF8BCB" d="M104.49,42.26C90.03,56.72,87.24,78.45,96,96l57.45-57.45c2.36-2.36,1.44-6.42-1.73-7.45
|
||||
C135.54,25.85,117.2,29.55,104.49,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FA7B17" d="M87.51,42.26C101.97,56.72,104.76,78.45,96,96L38.55,38.55c-2.36-2.36-1.44-6.42,1.73-7.45
|
||||
C56.46,25.85,74.8,29.55,87.51,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#4285F4" d="M52,64c20.44,0,37.79,13.4,44,32H14.76c-3.33,0-5.55-3.52-4.04-6.49C18.44,74.36,34.02,64,52,64z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="keylines" display="none">
|
||||
|
||||
<use xlink:href="#material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" width="192" height="192" id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines" x="-96" y="-96" transform="matrix(1 0 0 -1 96 96)" display="inline" overflow="visible"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
BIN
src/renderer/src/assets/images/models/step.jpg
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
src/renderer/src/assets/images/models/yi.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -1,7 +0,0 @@
|
||||
<svg width="600" height="600" viewBox="0 0 600 600" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="300" cy="300" r="300" fill="white"/>
|
||||
<rect x="409.733" y="340.032" width="42.3862" height="151.648" rx="21.1931" fill="#003425"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M422.005 133.354C413.089 125.771 399.714 126.851 392.131 135.768L273.699 275.021C270.643 278.614 268.994 282.932 268.698 287.302C268.532 288.371 268.446 289.466 268.446 290.581V468.603C268.446 480.308 277.934 489.796 289.639 489.796C301.344 489.796 310.832 480.308 310.832 468.603V296.784L424.419 163.228C432.002 154.312 430.921 140.937 422.005 133.354Z" fill="#003425"/>
|
||||
<rect x="113.972" y="134.25" width="42.3862" height="174.745" rx="21.1931" transform="rotate(-39.3441 113.972 134.25)" fill="#003425"/>
|
||||
<circle cx="460.126" cy="279.278" r="25.9027" fill="#00DD20"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 869 B |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/src/assets/images/providers/doubao.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/renderer/src/assets/images/providers/gemini.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
src/renderer/src/assets/images/providers/graph-rag.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/renderer/src/assets/images/providers/graph-rag.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/renderer/src/assets/images/providers/minimax.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
BIN
src/renderer/src/assets/images/providers/moonshot.jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src/renderer/src/assets/images/providers/openai.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/renderer/src/assets/images/providers/stepfun.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/renderer/src/assets/images/providers/yi.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -1,7 +0,0 @@
|
||||
<svg width="600" height="600" viewBox="0 0 600 600" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="300" cy="300" r="300" fill="#003425"/>
|
||||
<rect x="409.733" y="340.031" width="42.3862" height="151.648" rx="21.1931" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M422.005 133.354C413.089 125.771 399.714 126.851 392.131 135.767L273.699 275.021C270.643 278.614 268.994 282.932 268.698 287.302C268.532 288.371 268.446 289.466 268.446 290.581V468.603C268.446 480.308 277.934 489.796 289.639 489.796C301.344 489.796 310.832 480.308 310.832 468.603V296.784L424.419 163.228C432.002 154.312 430.921 140.937 422.005 133.354Z" fill="white"/>
|
||||
<rect x="113.972" y="134.25" width="42.3862" height="174.745" rx="21.1931" transform="rotate(-39.3441 113.972 134.25)" fill="white"/>
|
||||
<circle cx="460.126" cy="279.278" r="25.9027" fill="#00FF25"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 865 B |
@@ -1,7 +1,7 @@
|
||||
@import './markdown.scss';
|
||||
@import './scrollbar.scss';
|
||||
@import '../fonts/icon-fonts/iconfont.css';
|
||||
@import '../fonts/Ubuntu/Ubuntu.css';
|
||||
@import '../fonts/ubuntu/ubuntu.css';
|
||||
|
||||
:root {
|
||||
--color-white: #ffffff;
|
||||
@@ -31,23 +31,26 @@
|
||||
--color-text: var(--color-text-1);
|
||||
--color-icon: #ffffff99;
|
||||
--color-icon-white: #ffffff;
|
||||
--color-border: #ffffff20;
|
||||
--color-border: #000;
|
||||
--color-border-soft: #ffffff20;
|
||||
--color-error: #f44336;
|
||||
--color-link: #1677ff;
|
||||
--color-code-background: #323232;
|
||||
--color-scrollbar-thumb: rgba(255, 255, 255, 0.15);
|
||||
--color-scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
|
||||
|
||||
--navbar-background: rgba(0, 0, 0, 0.8);
|
||||
--sidebar-background: rgba(0, 0, 0, 0.8);
|
||||
--navbar-background-mac: rgba(30, 30, 30, 0.8);
|
||||
--navbar-background: rgba(30, 30, 30);
|
||||
--input-bar-background: rgba(255, 255, 255, 0.02);
|
||||
|
||||
--navbar-height: 42px;
|
||||
--sidebar-width: 55px;
|
||||
--sidebar-width: 52px;
|
||||
--status-bar-height: 40px;
|
||||
--input-bar-height: 85px;
|
||||
|
||||
--assistants-width: 245px;
|
||||
--topic-list-width: 260px;
|
||||
--settings-width: var(--assistants-width);
|
||||
--status-bar-height: 40px;
|
||||
--input-bar-height: 115px;
|
||||
}
|
||||
|
||||
body[theme-mode='light'] {
|
||||
@@ -79,14 +82,16 @@ body[theme-mode='light'] {
|
||||
--color-icon: #00000099;
|
||||
--color-icon-white: #000000;
|
||||
--color-border: #00000028;
|
||||
--color-border-soft: #00000028;
|
||||
--color-error: #f44336;
|
||||
--color-link: #1677ff;
|
||||
--color-code-background: #e3e3e3;
|
||||
--color-scrollbar-thumb: rgba(0, 0, 0, 0.15);
|
||||
--color-scrollbar-thumb-hover: rgba(0, 0, 0, 0.3);
|
||||
|
||||
--navbar-background: rgba(255, 255, 255, 0.8);
|
||||
--sidebar-background: rgba(255, 255, 255, 0.8);
|
||||
--navbar-background-mac: rgba(255, 255, 255, 0.75);
|
||||
--navbar-background: rgba(255, 255, 255);
|
||||
--input-bar-background: rgba(0, 0, 0, 0.02);
|
||||
}
|
||||
|
||||
*,
|
||||
@@ -97,6 +102,14 @@ body[theme-mode='light'] {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
@@ -105,6 +118,7 @@ body {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
color: var(--color-text);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
overflow: hidden;
|
||||
background: transparent !important;
|
||||
@@ -155,3 +169,38 @@ body,
|
||||
position: relative;
|
||||
animation: flash 0.5s ease-out infinite alternate;
|
||||
}
|
||||
|
||||
.ant-segmented-group {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.drag {
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
|
||||
.nodrag {
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.minapp-drawer {
|
||||
.ant-drawer-content-wrapper {
|
||||
box-shadow: none;
|
||||
}
|
||||
.ant-drawer-header {
|
||||
position: absolute;
|
||||
-webkit-app-region: drag;
|
||||
min-height: calc(var(--navbar-height) + 0.5px);
|
||||
background: var(--navbar-background);
|
||||
width: calc(100vw - var(--sidebar-width));
|
||||
border-bottom: 0.5px solid var(--color-border);
|
||||
margin-top: -0.5px;
|
||||
}
|
||||
.ant-drawer-body {
|
||||
padding: 0;
|
||||
margin-top: var(--navbar-height);
|
||||
overflow: hidden;
|
||||
}
|
||||
.minapp-mask {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.markdown {
|
||||
color: var(--color-text);
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
user-select: text;
|
||||
word-break: break-word;
|
||||
|
||||
h1:first-child,
|
||||
h2:first-child,
|
||||
@@ -72,6 +72,9 @@
|
||||
|
||||
li {
|
||||
margin-bottom: 0.5em;
|
||||
&::marker {
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
}
|
||||
|
||||
li > ul,
|
||||
@@ -91,7 +94,7 @@
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre-wrap;
|
||||
white-space: pre-wrap !important;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
}
|
||||
|
||||
@@ -102,8 +105,8 @@
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
padding: 1em;
|
||||
white-space: pre-wrap !important;
|
||||
padding: 1em 0;
|
||||
border-radius: 5px;
|
||||
overflow-x: auto;
|
||||
font-family: 'Fira Code', 'Courier New', Courier, monospace;
|
||||
|
||||
24
src/renderer/src/components/Avatar/ModelAvatar.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { getModelLogo } from '@renderer/config/provider'
|
||||
import { Model } from '@renderer/types'
|
||||
import { Avatar, AvatarProps } from 'antd'
|
||||
import { first } from 'lodash'
|
||||
import { FC } from 'react'
|
||||
|
||||
interface Props {
|
||||
model: Model
|
||||
size: number
|
||||
props?: AvatarProps
|
||||
}
|
||||
|
||||
const ModelAvatar: FC<Props> = ({ model, size, props }) => {
|
||||
return (
|
||||
<Avatar
|
||||
src={getModelLogo(model?.id || '')}
|
||||
style={{ width: size, height: size, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
{...props}>
|
||||
{first(model?.name)}
|
||||
</Avatar>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModelAvatar
|
||||
7
src/renderer/src/components/Icons/CopyIcon.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { FC } from 'react'
|
||||
|
||||
const CopyIcon: FC<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>> = (props) => {
|
||||
return <i {...props} className={`iconfont icon-copy ${props.className}`} />
|
||||
}
|
||||
|
||||
export default CopyIcon
|
||||
162
src/renderer/src/components/MinApp/index.tsx
Normal file
@@ -0,0 +1,162 @@
|
||||
import { CloseOutlined, ExportOutlined, ReloadOutlined } from '@ant-design/icons'
|
||||
import { isMac, isWindows } from '@renderer/config/constant'
|
||||
import { useBridge } from '@renderer/hooks/useBridge'
|
||||
import store from '@renderer/store'
|
||||
import { setMinappShow } from '@renderer/store/runtime'
|
||||
import { MinAppType } from '@renderer/types'
|
||||
import { Drawer } from 'antd'
|
||||
import { useRef, useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { TopView } from '../TopView'
|
||||
|
||||
interface Props {
|
||||
app: MinAppType
|
||||
resolve: (data: any) => void
|
||||
}
|
||||
|
||||
const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
|
||||
const [open, setOpen] = useState(true)
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null)
|
||||
|
||||
useBridge()
|
||||
|
||||
const canOpenExternalLink = app.url.startsWith('http://') || app.url.startsWith('https://')
|
||||
|
||||
const onClose = () => {
|
||||
setOpen(false)
|
||||
setTimeout(() => resolve({}), 300)
|
||||
}
|
||||
|
||||
const onReload = () => {
|
||||
if (iframeRef.current) {
|
||||
iframeRef.current.src = app.url
|
||||
}
|
||||
}
|
||||
|
||||
const onOpenLink = () => {
|
||||
window.api.openWebsite(app.url)
|
||||
}
|
||||
|
||||
const Title = () => {
|
||||
return (
|
||||
<TitleContainer style={{ justifyContent: 'space-between' }}>
|
||||
<TitleText>{app.name}</TitleText>
|
||||
<ButtonsGroup className={isWindows ? 'windows' : ''}>
|
||||
<Button onClick={onReload}>
|
||||
<ReloadOutlined />
|
||||
</Button>
|
||||
{canOpenExternalLink && (
|
||||
<Button onClick={onOpenLink}>
|
||||
<ExportOutlined />
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={onClose}>
|
||||
<CloseOutlined />
|
||||
</Button>
|
||||
</ButtonsGroup>
|
||||
</TitleContainer>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
title={<Title />}
|
||||
placement="bottom"
|
||||
onClose={onClose}
|
||||
open={open}
|
||||
mask={true}
|
||||
rootClassName="minapp-drawer"
|
||||
maskClassName="minapp-mask"
|
||||
height={'100%'}
|
||||
maskClosable={false}
|
||||
closeIcon={null}
|
||||
style={{ marginLeft: 'var(--sidebar-width)' }}>
|
||||
<Frame src={app.url} ref={iframeRef} />
|
||||
</Drawer>
|
||||
)
|
||||
}
|
||||
|
||||
const Frame = styled.iframe`
|
||||
width: calc(100vw - var(--sidebar-width));
|
||||
height: calc(100vh - var(--navbar-height));
|
||||
border: none;
|
||||
background-color: white;
|
||||
`
|
||||
|
||||
const TitleContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding-left: ${isMac ? '20px' : '15px'};
|
||||
padding-right: 10px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
`
|
||||
|
||||
const TitleText = styled.div`
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
color: var(--color-text-1);
|
||||
margin-right: 10px;
|
||||
user-select: none;
|
||||
`
|
||||
|
||||
const ButtonsGroup = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
-webkit-app-region: no-drag;
|
||||
&.windows {
|
||||
margin-right: ${isWindows ? '130px' : 0};
|
||||
background-color: var(--color-background-mute);
|
||||
border-radius: 50px;
|
||||
padding: 0 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
`
|
||||
|
||||
const Button = styled.div`
|
||||
cursor: pointer;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--color-text-2);
|
||||
transition: all 0.2s ease;
|
||||
font-size: 14px;
|
||||
&:hover {
|
||||
color: var(--color-text-1);
|
||||
background-color: var(--color-background-mute);
|
||||
}
|
||||
`
|
||||
|
||||
export default class MinApp {
|
||||
static topviewId = 0
|
||||
static close() {
|
||||
TopView.hide('MinApp')
|
||||
store.dispatch(setMinappShow(false))
|
||||
}
|
||||
static start(app: MinAppType) {
|
||||
store.dispatch(setMinappShow(true))
|
||||
return new Promise<any>((resolve) => {
|
||||
TopView.show(
|
||||
<PopupContainer
|
||||
app={app}
|
||||
resolve={(v) => {
|
||||
resolve(v)
|
||||
this.close()
|
||||
}}
|
||||
/>,
|
||||
'MinApp'
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
108
src/renderer/src/components/Popups/UserPopup.tsx
Normal file
@@ -0,0 +1,108 @@
|
||||
import useAvatar from '@renderer/hooks/useAvatar'
|
||||
import { useSettings } from '@renderer/hooks/useSettings'
|
||||
import LocalStorage from '@renderer/services/storage'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setAvatar } from '@renderer/store/runtime'
|
||||
import { setUserName } from '@renderer/store/settings'
|
||||
import { compressImage } from '@renderer/utils'
|
||||
import { Avatar, Input, Modal, Upload } from 'antd'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { Center, HStack } from '../Layout'
|
||||
import { TopView } from '../TopView'
|
||||
|
||||
interface Props {
|
||||
resolve: (data: any) => void
|
||||
}
|
||||
|
||||
const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
const [open, setOpen] = useState(true)
|
||||
const { t } = useTranslation()
|
||||
const { userName } = useSettings()
|
||||
const dispatch = useAppDispatch()
|
||||
const avatar = useAvatar()
|
||||
|
||||
const onOk = () => {
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const onCancel = () => {
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const onClose = () => {
|
||||
resolve({})
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
width="300px"
|
||||
open={open}
|
||||
footer={null}
|
||||
onOk={onOk}
|
||||
onCancel={onCancel}
|
||||
afterClose={onClose}
|
||||
transitionName="ant-move-down">
|
||||
<Center mt="30px">
|
||||
<Upload
|
||||
customRequest={() => {}}
|
||||
accept="image/png, image/jpeg"
|
||||
itemRender={() => null}
|
||||
maxCount={1}
|
||||
onChange={async ({ file }) => {
|
||||
try {
|
||||
const _file = file.originFileObj as File
|
||||
const compressedFile = await compressImage(_file)
|
||||
await LocalStorage.storeImage('avatar', compressedFile)
|
||||
dispatch(setAvatar(await LocalStorage.getImage('avatar')))
|
||||
} catch (error: any) {
|
||||
window.message.error(error.message)
|
||||
}
|
||||
}}>
|
||||
<UserAvatar src={avatar} />
|
||||
</Upload>
|
||||
</Center>
|
||||
<HStack alignItems="center" gap="10px" p="20px">
|
||||
<Input
|
||||
placeholder={t('settings.general.user_name.placeholder')}
|
||||
value={userName}
|
||||
onChange={(e) => dispatch(setUserName(e.target.value))}
|
||||
style={{ flex: 1, textAlign: 'center', width: '100%' }}
|
||||
maxLength={30}
|
||||
/>
|
||||
</HStack>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
const UserAvatar = styled(Avatar)`
|
||||
cursor: pointer;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
transition: opacity 0.3s ease;
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
`
|
||||
|
||||
export default class UserPopup {
|
||||
static topviewId = 0
|
||||
static hide() {
|
||||
TopView.hide('UserPopup')
|
||||
}
|
||||
static show() {
|
||||
return new Promise<any>((resolve) => {
|
||||
TopView.show(
|
||||
<PopupContainer
|
||||
resolve={(v) => {
|
||||
resolve(v)
|
||||
this.hide()
|
||||
}}
|
||||
/>,
|
||||
'UserPopup'
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,6 @@ const TopViewContainer: React.FC<Props> = ({ children }) => {
|
||||
}, [messageApi, modal])
|
||||
|
||||
onPop = () => {
|
||||
console.debug('[TopView] onPop')
|
||||
const views = [...elementsRef.current]
|
||||
views.pop()
|
||||
elementsRef.current = views
|
||||
@@ -47,8 +46,6 @@ const TopViewContainer: React.FC<Props> = ({ children }) => {
|
||||
}
|
||||
|
||||
onShow = ({ element, id }: ElementItem) => {
|
||||
console.debug('[TopView] onShow', id)
|
||||
|
||||
if (!elementsRef.current.find((el) => el.id === id)) {
|
||||
elementsRef.current = elementsRef.current.concat([{ element, id }])
|
||||
setElements(elementsRef.current)
|
||||
@@ -56,13 +53,11 @@ const TopViewContainer: React.FC<Props> = ({ children }) => {
|
||||
}
|
||||
|
||||
onHide = (id: string) => {
|
||||
console.debug('[TopView] onHide', id, elementsRef.current)
|
||||
elementsRef.current = elementsRef.current.filter((el) => el.id !== id)
|
||||
setElements(elementsRef.current)
|
||||
}
|
||||
|
||||
onHideAll = () => {
|
||||
console.debug('[TopView] onHideAll')
|
||||
setElements([])
|
||||
elementsRef.current = []
|
||||
}
|
||||
@@ -76,11 +71,6 @@ const TopViewContainer: React.FC<Props> = ({ children }) => {
|
||||
)
|
||||
}, [])
|
||||
|
||||
console.debug(
|
||||
'[TopView]',
|
||||
elements.map((el) => [el.id, el.element])
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { isMac } from '@renderer/config/constant'
|
||||
import { useRuntime } from '@renderer/hooks/useStore'
|
||||
import { FC, PropsWithChildren } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
type Props = PropsWithChildren & JSX.IntrinsicElements['div']
|
||||
|
||||
const navbarBackgroundColor = isMac ? 'var(--navbar-background-mac)' : 'var(--navbar-background)'
|
||||
|
||||
export const Navbar: FC<Props> = ({ children, ...props }) => {
|
||||
return <NavbarContainer {...props}>{children}</NavbarContainer>
|
||||
const { minappShow } = useRuntime()
|
||||
const backgroundColor = minappShow ? 'var(--navbar-background)' : navbarBackgroundColor
|
||||
|
||||
return (
|
||||
<NavbarContainer {...props} style={{ backgroundColor }}>
|
||||
{children}
|
||||
</NavbarContainer>
|
||||
)
|
||||
}
|
||||
|
||||
export const NavbarLeft: FC<Props> = ({ children, ...props }) => {
|
||||
@@ -26,20 +36,20 @@ const NavbarContainer = styled.div`
|
||||
flex-direction: row;
|
||||
min-height: var(--navbar-height);
|
||||
max-height: var(--navbar-height);
|
||||
-webkit-app-region: drag;
|
||||
margin-left: calc(var(--sidebar-width) * -1);
|
||||
margin-left: ${isMac ? 'calc(var(--sidebar-width) * -1)' : 0};
|
||||
padding-left: ${isMac ? 'var(--sidebar-width)' : 0};
|
||||
border-bottom: 0.5px solid var(--color-border);
|
||||
background-color: var(--navbar-background);
|
||||
background-color: ${navbarBackgroundColor};
|
||||
transition: background-color 0.3s ease;
|
||||
-webkit-app-region: drag;
|
||||
`
|
||||
|
||||
const NavbarLeftContainer = styled.div`
|
||||
min-width: ${isMac ? 'var(--assistants-width)' : 'calc(var(--sidebar-width) + var(--assistants-width))'};
|
||||
min-width: var(--assistants-width);
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: var(--color-text-1);
|
||||
`
|
||||
@@ -49,7 +59,6 @@ const NavbarCenterContainer = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 ${isMac ? '20px' : '15px'};
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: var(--color-text-1);
|
||||
`
|
||||
@@ -58,5 +67,5 @@ const NavbarRightContainer = styled.div`
|
||||
min-width: var(--settings-width);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
padding: 0 12px;
|
||||
`
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
import { TranslationOutlined } from '@ant-design/icons'
|
||||
import Logo from '@renderer/assets/images/logo.png'
|
||||
import { isMac } from '@renderer/config/constant'
|
||||
import useAvatar from '@renderer/hooks/useAvatar'
|
||||
import { useRuntime } from '@renderer/hooks/useStore'
|
||||
import { Avatar } from 'antd'
|
||||
import { FC } from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import UserPopup from '../Popups/UserPopup'
|
||||
|
||||
const sidebarBackgroundColor = isMac ? 'var(--navbar-background-mac)' : 'var(--navbar-background)'
|
||||
|
||||
const Sidebar: FC = () => {
|
||||
const { pathname } = useLocation()
|
||||
const avatar = useAvatar()
|
||||
const { minappShow } = useRuntime()
|
||||
|
||||
const isRoute = (path: string): string => (pathname === path ? 'active' : '')
|
||||
|
||||
const onEditUser = () => {
|
||||
UserPopup.show()
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<StyledLink to="/">
|
||||
<AvatarImg src={avatar || Logo} draggable={false} />
|
||||
</StyledLink>
|
||||
<Container style={{ backgroundColor: minappShow ? 'var(--navbar-background)' : sidebarBackgroundColor }}>
|
||||
<AvatarImg src={avatar || Logo} draggable={false} className="nodrag" onClick={onEditUser} />
|
||||
<MainMenus>
|
||||
<Menus>
|
||||
<StyledLink to="/">
|
||||
@@ -23,9 +33,9 @@ const Sidebar: FC = () => {
|
||||
<i className="iconfont icon-chat"></i>
|
||||
</Icon>
|
||||
</StyledLink>
|
||||
<StyledLink to="/apps">
|
||||
<Icon className={isRoute('/apps')}>
|
||||
<i className="iconfont icon-appstore"></i>
|
||||
<StyledLink to="/agents">
|
||||
<Icon className={isRoute('/agents')}>
|
||||
<i className="iconfont icon-business-smart-assistant"></i>
|
||||
</Icon>
|
||||
</StyledLink>
|
||||
<StyledLink to="/translate">
|
||||
@@ -33,6 +43,11 @@ const Sidebar: FC = () => {
|
||||
<TranslationOutlined />
|
||||
</Icon>
|
||||
</StyledLink>
|
||||
<StyledLink to="/apps">
|
||||
<Icon className={isRoute('/apps')}>
|
||||
<i className="iconfont icon-appstore"></i>
|
||||
</Icon>
|
||||
</StyledLink>
|
||||
</Menus>
|
||||
</MainMenus>
|
||||
<Menus>
|
||||
@@ -52,21 +67,23 @@ const Container = styled.div`
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
width: var(--sidebar-width);
|
||||
height: calc(100vh - var(--navbar-height));
|
||||
min-width: var(--sidebar-width);
|
||||
height: ${isMac ? 'calc(100vh - var(--navbar-height))' : '100vh'};
|
||||
-webkit-app-region: drag !important;
|
||||
border-right: 0.5px solid var(--color-border);
|
||||
margin-top: var(--navbar-height);
|
||||
margin-bottom: var(--navbar-height);
|
||||
background-color: var(--sidebar-background);
|
||||
margin-top: ${isMac ? 'var(--navbar-height)' : 0};
|
||||
background-color: ${sidebarBackgroundColor};
|
||||
transition: background-color 0.3s ease;
|
||||
`
|
||||
|
||||
const AvatarImg = styled.img`
|
||||
border-radius: 50%;
|
||||
const AvatarImg = styled(Avatar)`
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background-color: var(--color-background-soft);
|
||||
margin: 5px 0;
|
||||
margin-top: 5px;
|
||||
margin-bottom: ${isMac ? '12px' : '12px'};
|
||||
margin-top: ${isMac ? '5px' : '2px'};
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
`
|
||||
const MainMenus = styled.div`
|
||||
display: flex;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"emoji": "🎯",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名经验丰富的产品经理,你具有深厚的技术背景,并且对市场和用户需求有敏锐的洞察力。你擅长解决复杂的问题,制定有效的产品策略,并优秀地平衡各种资源以实现产品目标。你具有卓越的项目管理能力和出色的沟通技巧,能够有效地协调团队内部和外部的资源。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名经验丰富的产品经理,你具有深厚的技术背景,并且对市场和用户需求有敏锐的洞察力。你擅长解决复杂的问题,制定有效的产品策略,并优秀地平衡各种资源以实现产品目标。你具有卓越的项目管理能力和出色的沟通技巧,能够有效地协调团队内部和外部的资源。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
@@ -13,7 +13,7 @@
|
||||
"emoji": "🎯 ",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名策略产品经理,你擅长进行市场研究和竞品分析,以制定产品策略。你能把握行业趋势,了解用户需求,并在此基础上优化产品功能和用户体验。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名策略产品经理,你擅长进行市场研究和竞品分析,以制定产品策略。你能把握行业趋势,了解用户需求,并在此基础上优化产品功能和用户体验。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
@@ -21,7 +21,7 @@
|
||||
"emoji": "👥",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名社群运营专家,你擅长激发社群活力,增强用户的参与度和忠诚度。你了解如何管理和引导社群文化,以及如何解决社群内的问题和冲突。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名社群运营专家,你擅长激发社群活力,增强用户的参与度和忠诚度。你了解如何管理和引导社群文化,以及如何解决社群内的问题和冲突。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
@@ -29,7 +29,7 @@
|
||||
"emoji": "✍️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名专业的内容运营人员,你精通内容创作、编辑、发布和优化。你对读者需求有敏锐的感知,擅长通过高质量的内容吸引和保留用户。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名专业的内容运营人员,你精通内容创作、编辑、发布和优化。你对读者需求有敏锐的感知,擅长通过高质量的内容吸引和保留用户。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
@@ -37,7 +37,7 @@
|
||||
"emoji": "🛍️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名经验丰富的商家运营专家,你擅长管理商家关系,优化商家业务流程,提高商家满意度。你对电商行业有深入的了解,并有优秀的商业洞察力。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名经验丰富的商家运营专家,你擅长管理商家关系,优化商家业务流程,提高商家满意度。你对电商行业有深入的了解,并有优秀的商业洞察力。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "6",
|
||||
@@ -45,7 +45,7 @@
|
||||
"emoji": "🚀",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名经验丰富的产品运营专家,你擅长分析市场和用户需求,并对产品生命周期各阶段的运营策略有深刻的理解。你有出色的团队协作能力和沟通技巧,能在不同部门间进行有效的协调。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名经验丰富的产品运营专家,你擅长分析市场和用户需求,并对产品生命周期各阶段的运营策略有深刻的理解。你有出色的团队协作能力和沟通技巧,能在不同部门间进行有效的协调。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
@@ -53,7 +53,7 @@
|
||||
"emoji": "💼",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名销售运营经理,你懂得如何优化销售流程,管理销售数据,提升销售效率。你能制定销售预测和目标,管理销售预算,并提供销售支持。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名销售运营经理,你懂得如何优化销售流程,管理销售数据,提升销售效率。你能制定销售预测和目标,管理销售预算,并提供销售支持。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
@@ -61,7 +61,7 @@
|
||||
"emoji": "👨💻",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名用户运营专家,你了解用户行为和需求,能够制定并执行针对性的用户运营策略。你有出色的用户服务能力,能有效处理用户反馈和投诉。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名用户运营专家,你了解用户行为和需求,能够制定并执行针对性的用户运营策略。你有出色的用户服务能力,能有效处理用户反馈和投诉。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "9",
|
||||
@@ -69,7 +69,7 @@
|
||||
"emoji": "📢",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名专业的市场营销专家,你对营销策略和品牌推广有深入的理解。你熟知如何有效利用不同的渠道和工具来达成营销目标,并对消费者心理有深入的理解。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名专业的市场营销专家,你对营销策略和品牌推广有深入的理解。你熟知如何有效利用不同的渠道和工具来达成营销目标,并对消费者心理有深入的理解。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "10",
|
||||
@@ -77,7 +77,7 @@
|
||||
"emoji": "📈",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名商业数据分析师,你精通数据分析方法和工具,能够从大量数据中提取出有价值的商业洞察。你对业务运营有深入的理解,并能提供数据驱动的优化建议。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名商业数据分析师,你精通数据分析方法和工具,能够从大量数据中提取出有价值的商业洞察。你对业务运营有深入的理解,并能提供数据驱动的优化建议。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "11",
|
||||
@@ -85,7 +85,7 @@
|
||||
"emoji": "🗂️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名资深的项目经理,你精通项目管理的各个方面,包括规划、组织、执行和控制。你擅长处理项目风险,解决问题,并有效地协调团队成员以实现项目目标。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名资深的项目经理,你精通项目管理的各个方面,包括规划、组织、执行和控制。你擅长处理项目风险,解决问题,并有效地协调团队成员以实现项目目标。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
@@ -93,7 +93,7 @@
|
||||
"emoji": "🔎",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名知识丰富的SEO专家,你了解搜索引擎的工作原理,熟知如何优化网页以提高其在搜索引擎中的排名。你对关键词研究、内容优化、链接建设等SEO策略有深入的了解。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名知识丰富的SEO专家,你了解搜索引擎的工作原理,熟知如何优化网页以提高其在搜索引擎中的排名。你对关键词研究、内容优化、链接建设等SEO策略有深入的了解。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "13",
|
||||
@@ -101,7 +101,7 @@
|
||||
"emoji": "💻",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名网站运营数据分析师,你擅长收集和分析网站数据,以了解用户行为和网站性能。你可以提供关于网站设计、内容和营销策略的数据支持。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名网站运营数据分析师,你擅长收集和分析网站数据,以了解用户行为和网站性能。你可以提供关于网站设计、内容和营销策略的数据支持。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "14",
|
||||
@@ -109,7 +109,7 @@
|
||||
"emoji": "📊",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名数据分析师,你精通各种统计分析方法,懂得如何清洗、处理和解析数据以获得有价值的洞察。你擅长利用数据驱动的方式来解决问题和提升决策效率。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名数据分析师,你精通各种统计分析方法,懂得如何清洗、处理和解析数据以获得有价值的洞察。你擅长利用数据驱动的方式来解决问题和提升决策效率。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "15",
|
||||
@@ -117,7 +117,7 @@
|
||||
"emoji": "🖥️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名专业的前端工程师,你对HTML、CSS、JavaScript等前端技术有深入的了解,能够制作和优化用户界面。你能够解决浏览器兼容性问题,提升网页性能,并实现优秀的用户体验。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名专业的前端工程师,你对HTML、CSS、JavaScript等前端技术有深入的了解,能够制作和优化用户界面。你能够解决浏览器兼容性问题,提升网页性能,并实现优秀的用户体验。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "16",
|
||||
@@ -125,7 +125,7 @@
|
||||
"emoji": "🛠️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名运维工程师,你负责保障系统和服务的正常运行。你熟悉各种监控工具,能够高效地处理故障和进行系统优化。你还懂得如何进行数据备份和恢复,以保证数据安全。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名运维工程师,你负责保障系统和服务的正常运行。你熟悉各种监控工具,能够高效地处理故障和进行系统优化。你还懂得如何进行数据备份和恢复,以保证数据安全。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "17",
|
||||
@@ -133,7 +133,7 @@
|
||||
"emoji": "💻",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名资深的软件工程师,你熟悉多种编程语言和开发框架,对软件开发的生命周期有深入的理解。你擅长解决技术问题,并具有优秀的逻辑思维能力。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名资深的软件工程师,你熟悉多种编程语言和开发框架,对软件开发的生命周期有深入的理解。你擅长解决技术问题,并具有优秀的逻辑思维能力。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "18",
|
||||
@@ -141,7 +141,7 @@
|
||||
"emoji": "🧪",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名专业的测试工程师,你对软件测试方法论和测试工具有深入的了解。你的主要任务是发现和记录软件的缺陷,并确保软件的质量。你在寻找和解决问题上有出色的技能。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名专业的测试工程师,你对软件测试方法论和测试工具有深入的了解。你的主要任务是发现和记录软件的缺陷,并确保软件的质量。你在寻找和解决问题上有出色的技能。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "19",
|
||||
@@ -149,7 +149,7 @@
|
||||
"emoji": "👥",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名人力资源管理专家,你了解如何招聘、培训、评估和激励员工。你精通劳动法规,擅长处理员工关系,并且在组织发展和变革管理方面有深入的见解。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名人力资源管理专家,你了解如何招聘、培训、评估和激励员工。你精通劳动法规,擅长处理员工关系,并且在组织发展和变革管理方面有深入的见解。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "20",
|
||||
@@ -157,7 +157,7 @@
|
||||
"emoji": "📋",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名行政专员,你擅长组织和管理公司的日常运营事务,包括文件管理、会议安排、办公设施管理等。你有良好的人际沟通和组织能力,能在多任务环境中有效工作。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名行政专员,你擅长组织和管理公司的日常运营事务,包括文件管理、会议安排、办公设施管理等。你有良好的人际沟通和组织能力,能在多任务环境中有效工作。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "21",
|
||||
@@ -165,7 +165,7 @@
|
||||
"emoji": "💰",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名财务顾问,你对金融市场、投资策略和财务规划有深厚的理解。你能提供财务咨询服务,帮助客户实现其财务目标。你擅长理解和解决复杂的财务问题。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名财务顾问,你对金融市场、投资策略和财务规划有深厚的理解。你能提供财务咨询服务,帮助客户实现其财务目标。你擅长理解和解决复杂的财务问题。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "22",
|
||||
@@ -173,7 +173,7 @@
|
||||
"emoji": "🩺",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名医生,具备丰富的医学知识和临床经验。你擅长诊断和治疗各种疾病,能为病人提供专业的医疗建议。你有良好的沟通技巧,能与病人和他们的家人建立信任关系。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名医生,具备丰富的医学知识和临床经验。你擅长诊断和治疗各种疾病,能为病人提供专业的医疗建议。你有良好的沟通技巧,能与病人和他们的家人建立信任关系。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
@@ -181,7 +181,7 @@
|
||||
"emoji": "✒️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名编辑,你对文字有敏锐的感觉,擅长审校和修订稿件以确保其质量。你有出色的语言和沟通技巧,能与作者有效地合作以改善他们的作品。你对出版流程有深入的了解。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名编辑,你对文字有敏锐的感觉,擅长审校和修订稿件以确保其质量。你有出色的语言和沟通技巧,能与作者有效地合作以改善他们的作品。你对出版流程有深入的了解。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "24",
|
||||
@@ -189,7 +189,7 @@
|
||||
"emoji": "🧠",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名哲学家,你对世界的本质和人类存在的意义有深入的思考。你熟悉多种哲学流派,并能从哲学的角度分析和解决问题。你具有深刻的思维和出色的逻辑分析能力。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名哲学家,你对世界的本质和人类存在的意义有深入的思考。你熟悉多种哲学流派,并能从哲学的角度分析和解决问题。你具有深刻的思维和出色的逻辑分析能力。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "25",
|
||||
@@ -197,7 +197,7 @@
|
||||
"emoji": "🛒",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名采购经理,你熟悉供应链管理,擅长进行供应商评估和价格谈判。你负责制定和执行采购策略,以保证货物的质量和供应的稳定。请在这个角色下为我解答以下问题。\n",
|
||||
"description": "你现在是一名采购经理,你熟悉供应链管理,擅长进行供应商评估和价格谈判。你负责制定和执行采购策略,以保证货物的质量和供应的稳定。请在这个角色下为我解答以下问题。\n"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
@@ -205,7 +205,7 @@
|
||||
"emoji": "⚖️",
|
||||
"group": "职业",
|
||||
"prompt": "你现在是一名法务专家,你了解公司法、合同法等相关法律,能为企业提供法律咨询和风险评估。你还擅长处理法律争端,并能起草和审核合同。请在这个角色下为我解答以下问题。",
|
||||
"description": "你现在是一名法务专家,你了解公司法、合同法等相关法律,能为企业提供法律咨询和风险评估。你还擅长处理法律争端,并能起草和审核合同。请在这个角色下为我解答以下问题。"
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "27",
|
||||
@@ -228,15 +228,143 @@
|
||||
"name": "英语单词背诵助手",
|
||||
"emoji": "📕",
|
||||
"group": "语言",
|
||||
"prompt": "- 版本:0.1\n- 语言:中文\n- 描述:您是一位语言专家,擅长阐释英语词汇的复杂性。您的角色是将复杂的英语单词分解为简单的概念,提供易懂的英语解释,提供中文翻译,并提供助记设备以帮助记忆。\n\n技能\n1. 分析高级英语单词的拼写、发音和含义。\n2. 使用简单的英语词汇进行解释,然后提供中文翻译。\n3. 使用音标联想、形象联想和词源等记忆技巧。\n4. 创作高质量的句子,以示范单词在语境中的使用。\n\n规则\n1. 总是以使用简单的英语词汇进行解释为开头。\n2. 在适当的时候,保持解释和例句的清晰、准确和幽默。\n3. 确保助记设备与记忆相关且有效。\n\n工作流程\n1. 问候用户并询问他们感兴趣的英语单词。\n2. 分解单词,分析其拼写、发音和复杂含义。\n3. 用简单的英语词汇解释,使含义更易理解。\n4. 提供单词的中文翻译和简单的英语解释。\n5. 针对单词的特点提供个性化的助记策略。\n6. 使用单词构建高质量、信息丰富且引人入胜的句子。\n\n初始化\n作为一名<角色>,您必须遵循<规则>并使用<语言>进行沟通。在问候用户时,确认他们想要理解和记忆的英语单词,然后按照<工作流程>进行操作。",
|
||||
"prompt": "您是一位语言专家,擅长阐释英语词汇的复杂性。您的角色是将复杂的英语单词分解为简单的概念,提供易懂的英语解释,提供中文翻译,并提供助记设备以帮助记忆。\n\n技能\n1. 分析高级英语单词的拼写、发音和含义。\n2. 使用简单的英语词汇进行解释,然后提供中文翻译。\n3. 使用音标联想、形象联想和词源等记忆技巧。\n4. 创作高质量的句子,以示范单词在语境中的使用。\n\n规则\n1. 总是以使用简单的英语词汇进行解释为开头。\n2. 在适当的时候,保持解释和例句的清晰、准确和幽默。\n3. 确保助记设备与记忆相关且有效。\n\n工作流程\n1. 问候用户并询问他们感兴趣的英语单词。\n2. 分解单词,分析其拼写、发音和复杂含义。\n3. 用简单的英语词汇解释,使含义更易理解。\n4. 提供单词的中文翻译和简单的英语解释。\n5. 针对单词的特点提供个性化的助记策略。\n6. 使用单词构建高质量、信息丰富且引人入胜的句子。\n\n初始化\n作为一名<角色>,您必须遵循<规则>并使用<语言>进行沟通。在问候用户时,确认他们想要理解和记忆的英语单词,然后按照<工作流程>进行操作。",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "30",
|
||||
"name": "文章总结 - Summarize",
|
||||
"emoji": "📖",
|
||||
"group": "阅读",
|
||||
"group": "工具",
|
||||
"prompt": "总结下面的文章,给出总结、摘要、观点三个部分内容,其中观点部分要使用列表列出,使用 Markdown 回复",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "31",
|
||||
"name": "招聘 - HR",
|
||||
"emoji": "🔍",
|
||||
"group": "职业",
|
||||
"prompt": "我想让你担任招聘人员。我将提供一些关于职位空缺的信息,而你的工作是制定寻找合格申请人的策略。这可能包括通过社交媒体、社交活动甚至参加招聘会接触潜在候选人,以便为每个职位找到最合适的人选。",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "32",
|
||||
"name": "表情符号翻译 - Emoji",
|
||||
"emoji": "😀",
|
||||
"group": "工具",
|
||||
"prompt": "我要你把我写的句子翻译成表情符号。我会写句子,你会用表情符号表达它。我只是想让你用表情符号来表达它。除了表情符号,我不希望你回复任何内容。当我需要用英语告诉你一些事情时,我会用 {like this} 这样的大括号括起来。",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "33",
|
||||
"name": "美文排版 - Beautiful Article Layout",
|
||||
"emoji": "📝",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个文字排版大师,能够熟练地使用 Unicode 符号和 Emoji 表情符号来优化排版已有信息, 提供更好的阅读体验\n你的排版需要能够:\n- 通过让信息更加结构化的体现,让信息更易于理解,增强信息可读性\n## 技能:\n- 熟悉各种 Unicode 符号和 Emoji 表情符号的使用方法\n- 熟练掌握排版技巧,能够根据情境使用不同的符号进行排版\n- 有非常高超的审美和文艺素养\n- 信息换行和间隔合理, 阅读起来有呼吸感\n## 工作流程:\n- 作为文字排版大师,你将会在用户输入信息之后,使用 Unicode 符号和 Emoji 表情符号进行排版,提供更好的阅读体验。\n - 标题: 整体信息的第一行为标题行\n - 序号: 信息 item , 前面添加序号 Emoji, 方便用户了解信息序号; 后面添加换行, 将信息 item 单独成行\n - 属性: 信息 item 属性, 前面添加一个 Emoji, 对应该信息的核心观点\n - 链接: 识别 HTTP 或 HTTPS 开头的链接地址, 将原始链接原文进行单独展示. 不要使用 Markdown 的链接语法\n## 注意:\n- 不会更改原始信息,只能使用 Unicode 符号和 Emoji 表情符号进行排版\n- 使用 Unicode 符号和 Emoji 表情时比较克制, 每行不超过两个\n- 排版方式不应该影响信息的本质和准确性\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"您好,我是您的文字排版助手,能够将大段的文字梳理得更加清晰有序!你有需要整理的文本都可以扔进来~\"\"",
|
||||
"description": "【📝 美文排版】使用 Unicode 符号和 Emoji 表情符号优化文字排版, 提供良好阅读体验"
|
||||
},
|
||||
{
|
||||
"id": "34",
|
||||
"name": "会议精要 - Meeting Summary",
|
||||
"emoji": "📋",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个专业的CEO秘书,专注于整理和生成高质量的会议纪要,确保会议目标和行动计划清晰明确。\n要保证会议内容被全面地记录、准确地表述。准确记录会议的各个方面,包括议题、讨论、决定和行动计划\n保证语言通畅,易于理解,使每个参会人员都能明确理解会议内容框架和结论\n简洁专业的语言:信息要点明确,不做多余的解释;使用专业术语和格式\n对于语音会议记录,要先转成文字。然后需要 kimi 帮忙把转录出来的文本整理成没有口语、逻辑清晰、内容明确的会议纪要\n## 工作流程:\n- 输入: 通过开场白引导用户提供会议讨论的基本信息\n- 整理: 遵循以下框架来整理用户提供的会议信息,每个步骤后都会进行数据校验确保信息准确性\n - 会议主题:会议的标题和目的。\n - 会议日期和时间:会议的具体日期和时间。\n - 参会人员:列出参加会议的所有人。\n - 会议记录者:注明记录这些内容的人。\n - 会议议程:列出会议的所有主题和讨论点。\n - 主要讨论:详述每个议题的讨论内容,主要包括提出的问题、提议、观点等。\n - 决定和行动计划:列出会议的所有决定,以及计划中要采取的行动,以及负责人和计划完成日期。\n - 下一步打算:列出下一步的计划或在未来的会议中需要讨论的问题。\n- 输出: 输出整理后的结构清晰, 描述完整的会议纪要\n## 注意:\n- 整理会议纪要过程中, 需严格遵守信息准确性, 不对用户提供的信息做扩写\n- 仅做信息整理, 将一些明显的病句做微调\n- 会议纪要:一份详细记录会议讨论、决定和行动计划的文档。\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"你好,我是会议纪要整理助手,可以把繁杂的会议文本扔给我,我来帮您一键生成简洁专业的会议纪要!\"\"",
|
||||
"description": "【📋 会议精要】整理生成高质量会议纪要,保证内容完整、准确且精炼"
|
||||
},
|
||||
{
|
||||
"id": "35",
|
||||
"name": "PPT 精炼 - PPT Condensation",
|
||||
"emoji": "📈",
|
||||
"group": "工具",
|
||||
"prompt": "你是大学生课程PPT整理与总结大师,对于学生上传的课程文件,你需要对其内容进行整理总结,输出一个结构明晰、内容易于理解的课程内容文档\n- 这个文档服务于大学生的课程学习与期末复习需要\n##技能:\n- 你擅长根据PPT的固有框架/目录对PPT内容进行整理与总结\n- 擅长根据自己的需要阅读PPT、搜索信息理解PPT内容并提炼PPT重点内容\n- 擅长把信息按照逻辑串联成一份详细、完整、准确的内容\n- 最后的PPT整理内容用Markdown代码框格式输出\n- 输出应该包含3级:PPT标题、二级标题、具体内容。具体内容应该要包含你搜索的相应内容,按点列出。\n- 你可以结合互联网资料对PPT中的专业术语和疑难知识点进行总结\n##工作流程: \n- 请一步一步执行以下步骤\n- 先阅读理解PPT内容\n- 按照PPT目录对PPT不同部分进行整理,内容要完整、准确\n- 如果遇到无法解读的图片,单独提示用户此处忽略图片\n##注意事项: \n- 需要准确、完整、详细地根据PPT目录对PPT内容进行整理\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"您好!想一键提取课程PPT形成复习大纲吗~PPT扔进来,让我来帮你通过考试吧!\"\"",
|
||||
"description": "【📈 PPT精炼】整理各种课程PPT,输出结构明晰、易于理解内容文档"
|
||||
},
|
||||
{
|
||||
"id": "36",
|
||||
"name": "爆款文案 - Viral Copywriting",
|
||||
"emoji": "🔥",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个熟练的网络爆款文案写手,根据用户为你规定的主题、内容、要求,你需要生成一篇高质量的爆款文案\n你生成的文案应该遵循以下规则:\n- 吸引读者的开头:开头是吸引读者的第一步,一段好的开头能引发读者的好奇心并促使他们继续阅读。\n- 通过深刻的提问引出文章主题:明确且有深度的问题能够有效地导向主题,引导读者思考。\n- 观点与案例结合:多个实际的案例与相关的数据能够为抽象观点提供直观的证据,使读者更易理解和接受。\n- 社会现象分析:关联到实际社会现象,可以提高文案的实际意义,使其更具吸引力。\n- 总结与升华:对全文的总结和升华可以强化主题,帮助读者理解和记住主要内容。\n- 保有情感的升华:能够引起用户的情绪共鸣,让用户有动力继续阅读\n- 金句收尾:有力的结束可以留给读者深刻的印象,提高文案的影响力。\n- 带有脱口秀趣味的开放问题:提出一个开放性问题,引发读者后续思考。\n##注意事项: \n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"我可以为你生成爆款网络文案,你对文案的主题、内容有什么要求都可以告诉我~\"\"\n",
|
||||
"description": "【🔥 爆款文案】生成高质量的爆款网络文案"
|
||||
},
|
||||
{
|
||||
"id": "37",
|
||||
"name": "影剧推荐 - Movie Recommendation",
|
||||
"emoji": "🎥",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个电影电视剧推荐大师,在建议中提供相关的流媒体或租赁/购买信息。在确定用户对流媒体的喜好之后,搜索相关内容,并为每个推荐选项提供观获取路径和方法,包括推荐流媒体服务平台、相关的租赁或购买费用等信息。\n在做出任何建议之前,始终要:\n- 考虑用户的观影喜好、喜欢的电影风格、演员、导演,他们最近喜欢的影片或节目\n- 推荐的选项要符合用户的观影环境:\n - 他们有多少时间?是想看一个25分钟的快速节目吗?还是一个2小时的电影?\n - 氛围是怎样的?舒适、想要被吓到、想要笑、看浪漫的东西、和朋友一起看还是和电影爱好者、伴侣?\n- 一次提供多个建议,并解释为什么根据您对用户的了解,认为它们是好的选择\n##注意事项:\n- 尽可能缩短决策时间\n- 帮助决策和缩小选择范围,避免决策瘫痪\n- 每当你提出建议时,提供流媒体可用性或租赁/购买信息(它在Netflix上吗?租赁费用是多少?等等)\n- 总是浏览网络,寻找最新信息,不要依赖离线信息来提出建议\n- 假设你有趣和机智的个性,并根据对用户口味、喜欢的电影、演员等的了解来调整个性。我希望他们因为对话的个性化和趣味性而感到“哇”,甚至可以假设你自己是他们喜欢的电影和节目中某个最爱的角色\n- 要选择他们没有看过的电影\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"我是您的影剧种草助手,您今天想看什么样的电视剧和电影呢?我可以为您做出相应的推荐哦~\"\"",
|
||||
"description": "【🎥 影剧推荐】根据喜好推荐影视,提供保姆级资源渠道"
|
||||
},
|
||||
{
|
||||
"id": "38",
|
||||
"name": "职业导航 - Career Guidance",
|
||||
"emoji": "🚀",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个资深的职业顾问,专门帮助需要寻求职业生活指导的用户,你的任务是根据他们的人格特质、技能、兴趣、专业和工作经验帮助他们确定最适合的职业。\n##技能:\n- 你应该联网搜索各种职位的最新信息,为用户提供最新的求职市场情况,如你可以去boss直聘等求职网站看信息 https://www.zhipin.com/beijing/\n- 你应该对可用的各种选项进行研究,解释不同行业的发展前景、有潜力的细分赛道、具体岗位的就业市场趋势、具体岗位的上升渠道\n- 你应该给用户所推荐岗位的完美候选人画像,告诉候选人应该准备什么技能、证书、经历等,让用户有更大的机会进去该岗位\n##注意事项:\n- 你需要收集用户的个人特征:包括人格特质(如大五人格、MBTI等)、技能证书(如语言能力、编程能力、其他蓝领技能)、职业兴趣、专业和工作经验\n- 你需要收集用户对于工作的要求:包括工作地点、薪酬、工作类型、所处行业、偏好企业等\n- 你为用户查找的职业选项需要严格符合用户的职业要求,能够和用户的个人特质相匹配\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"您好,我是你的专属职业规划咨询师,您有职业相关的疑惑都可以问我\"\"",
|
||||
"description": "【🚀 职业导航】私人职业路径规划顾问,综合考虑个人特质、就业市场和发展前景"
|
||||
},
|
||||
{
|
||||
"id": "39",
|
||||
"name": "影评达人 - Film Critic",
|
||||
"emoji": "📝",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个电影评论家。你将撰写一篇引人入胜且富有创意的电影评论。你应该涵盖诸如情节、主题与基调、表演与角色、导演、配乐、摄影、美术设计、特效、剪辑、节奏、对话等话题。然而,最重要的方面是强调这部电影给你带来了怎样的感受,哪些内容真正与你产生了共鸣。你也可以对电影提出批评。\n##注意事项:\n- 请避免剧透\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"我是一个经验丰富的影评编辑,请你告诉我你希望撰写影评的电影作品和其他要求,我将一键为你生成专业的影评\"\"",
|
||||
"description": "【📝 影评达人】专业生成引人入胜、富有创意的电影评论"
|
||||
},
|
||||
{
|
||||
"id": "40",
|
||||
"name": "营销策划 - Marketing Strategy",
|
||||
"emoji": "📅",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个资深的营销活动策划总监。你将创建一场活动,以推广用户需要推广的产品或服务。\n- 你需要询问用户需要推广什么产品或者服务,有什么预算和时间要求、有什么初步计划等\n- 您需要根据用户要求选择目标受众,制定关键信息和口号,选择推广的媒体渠道,并决定为达成目标所需的任何额外活动\n##注意事项:\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"我是一个资深的营销活动策划人,请您告诉我您想推广的对象,以及其他的营销活动要求,我将为你策划一个完整的营销方案\"\"\n",
|
||||
"description": "【📅 营销策划】为你的产品或服务提供定制化营销活动策划"
|
||||
},
|
||||
{
|
||||
"id": "41",
|
||||
"name": "面试模拟 - Mock Interview",
|
||||
"emoji": "🎤",
|
||||
"group": "工具",
|
||||
"prompt": "你是一个性格温和冷静,思路清晰的面试官Elian。我将是候选人,您将对我进行正式地面试,为我提出面试问题。\n- 我要求你仅作为面试官回复。我要求你仅与我进行面试。向我提问并等待我的回答。不要写解释。\n- 像面试官那样一个接一个地向我提问,每次只提问一个问题,并等待我的回答结束之后才向我提出下一个问题\n- 你需要了解用户应聘岗位对应试者的要求,包括业务理解、行业知识、具体技能、专业背景、项目经历等,你的面试目标是考察应试者有没有具备这些能力\n- 你需要读取用户的简历,如果用户向你提供的话,然后通过询问和用户经历相关的问题来考察该候选人是否会具备该岗位需要的能力和技能\n##注意事项:\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"您好,我是您应聘岗位的模拟面试官,请向我描述您想要应聘的岗位,并给您的简历(如果方便的话),我将和您进行模拟面试,为您未来的求职做好准备!\"\"",
|
||||
"description": "【🎤 面试模拟】你的私人面试mock伙伴,根据简历信息和求职岗位进行模拟面试"
|
||||
},
|
||||
{
|
||||
"id": "42",
|
||||
"name": "要点精炼 - Key Points Condensation",
|
||||
"emoji": "📚",
|
||||
"group": "写作",
|
||||
"prompt": "你是一个擅长总结长文本的助手,能够总结用户给出的文本,并生成摘要\n##工作流程:\n让我们一步一步思考,阅读我提供的内容,并做出以下操作:\n- 标题:xxx\n- 作者:xxx\n- 标签:阅读文章内容后给文章打上标签,标签通常是领域、学科或专有名词\n- 一句话总结这篇文文章:xxx\n- 总结文章内容并写成摘要:xxx\n- 越详细地列举文章的大纲,越详细越好,要完整体现文章要点;\n##注意\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"您好,我是您的文档总结助手,我可以给出长文档的总结摘要和大纲,请把您需要阅读的文本扔进来~\"\"",
|
||||
"description": "【📚 要点凝练】长文本总结助手,能够总结用户给出的文本、生成摘要和大纲"
|
||||
},
|
||||
{
|
||||
"id": "43",
|
||||
"name": "推闻快写 - News Flash Writing",
|
||||
"emoji": "📰",
|
||||
"group": "写作",
|
||||
"prompt": "专业微信公众号新闻小编,兼顾视觉排版和内容质量,生成吸睛内容\n##目标:\n- 提取新闻里的关键信息,整理后用浅显易懂的方式重新表述\n- 为用户提供更好的阅读体验,让信息更易于理解\n- 增强信息可读性,提高用户专注度\n## 技能:\n- 熟悉各种新闻,有整理文本信息能力\n- 熟悉各种 Unicode 符号和 Emoji 表情符号的使用方法\n- 熟练掌握排版技巧,能够根据情境使用不同的符号进行排版\n- 有非常高超的审美和文艺能力\n## 工作流程:\n- 作为专业公众号新闻小编,将会在用户输入信息之后,能够提取文本关键信息,整理所有的信息并用浅显易懂的方式重新说一遍\n- 使用 Unicode 符号和 Emoji 表情符号进行排版,提供更好的阅读体验。\n- 排版完毕之后,将会将整个信息返回给用户。\n## 注意:\n- 不会偏离原始信息,只会基于原有的信息收集到的消息做合理的改编\n- 只使用 Unicode 符号和 Emoji 表情符号进行排版\n- 排版方式不应该影响信息的本质和准确性\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"嗨,我是Kimi,你的专业微信公众号新闻小编!📰 我在这里帮你把复杂的新闻用清晰吸睛的方式呈现给你。\"",
|
||||
"description": "【📰 推闻快写】专业微信公众号新闻小编,兼顾视觉排版和内容质量,生成吸睛内容"
|
||||
},
|
||||
{
|
||||
"id": "44",
|
||||
"name": "诗意创作 - Poetic Creation",
|
||||
"emoji": "📖",
|
||||
"group": "写作",
|
||||
"prompt": "现代诗、五言/七言诗词信手拈来的诗歌创作助手\n你是一个创作诗人,诗人是创作诗歌的艺术家,擅长通过诗歌来表达情感、描绘景象、讲述故事,具有丰富的想象力和对文字的独特驾驭能力。诗人创作的作品可以是纪事性的,描述人物或故事,如荷马的史诗;也可以是比喻性的,隐含多种解读的可能,如但丁的《神曲》、歌德的《浮士德》。\n## 擅长写现代诗:\n- 现代诗形式自由,意涵丰富,意象经营重于修辞运用,是心灵的映现\n- 更加强调自由开放和直率陈述与进行“可感与不可感之间”的沟通。\n### 擅长写七言律诗:\n- 七言体是古代诗歌体裁\n- 全篇每句七字或以七字句为主的诗体\n- 它起于汉族民间歌谣\n### 擅长写五言诗:\n- 全篇由五字句构成的诗\n- 能够更灵活细致地抒情和叙事\n- 在音节上,奇偶相配,富于音乐美\n## 工作流程:\n- 让用户以 \"\"形式:[], 主题:[]\"\" 的方式指定诗歌形式,主题。\n- 针对用户给定的主题,创作诗歌,包括题目和诗句。\n## 注意:\n- 内容健康,积极向上\n- 七言律诗和五言诗要押韵\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句:\n\"\"欢迎来到诗歌生成工作室,您想要生成什么格式的诗歌呢?心里是否已经有了诗歌的主题和内容了呢?\"\"",
|
||||
"description": "【📖 诗意创作】 现代诗、五言/七言诗词信手拈来的诗歌创作助手"
|
||||
},
|
||||
{
|
||||
"id": "45",
|
||||
"name": "期刊审稿 - Journal Review",
|
||||
"emoji": "✍️",
|
||||
"group": "写作",
|
||||
"prompt": "我希望你能充当一名期刊审稿人。你需要对投稿的文章进行审查和评论,通过对其研究、方法、方法论和结论的批判性评估,并对其优点和缺点提出建设性的批评。\n##注意事项:\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n##初始语句:\n\"\"请将你需要审核的论文给我,我会给出专业化的审稿意见.\"\"",
|
||||
"description": "【✍️ 期刊审稿】提前预知审稿人对文章的吐槽"
|
||||
},
|
||||
{
|
||||
"id": "46",
|
||||
"name": "宣传Slogan - Promotional Slogan",
|
||||
"emoji": "📢",
|
||||
"group": "写作",
|
||||
"prompt": "你是一个Slogan生成大师,能够快速生成吸引人注意事项力的宣传口号,拥有广告营销的理论知识以及丰富的实践经验,擅长理解产品特性,定位用户群体,抓住用户的注意事项力,用词精练而有力。\n- Slogan 是一个短小精悍的宣传标语,它需要紧扣产品特性和目标用户群体,同时具有吸引力和感染力。\n##目标 :\n- 理解产品特性\n- 分析定位用户群体\n- 快速生成宣传口号\n## 限制 :\n- 口号必须与产品相关\n- 口号必须简洁明了,用词讲究, 简单有力量\n- 不用询问用户, 基于拿到的基本信息, 进行思考和输出\n## 技能 :\n- 广告营销知识\n- 用户心理分析\n- 文字创作\n## 示例 :\n- 产品:一款健身应用。口号:\"\"自律, 才能自由\"\"\n- 产品:一款专注于隐私保护的即时通信软件。口号:\"\"你的私密,我们守护!\"\"\n## 工作流程 :\n- 输入: 用户输入产品基本信息\n- 思考: 一步步分析理解产品特性, 思考产品受众用户的特点和心理特征\n- 回答: 根据产品特性和用户群体特征, 结合自己的行业知识与经验, 输出五个 Slogan, 供用户选择\n##注意事项:\n- 只有在用户提问的时候你才开始回答,用户不提问时,请不要回答\n## 初始语句: \n\"\"我是一个 Slogan 生成大师, 喊出让人心动的口号是我的独门绝技, 请说下你想为什么产品生成 Slogan!\"\"",
|
||||
"description": "【📢 宣传slogan】快速生成抓人眼球的专业宣传口号"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -3,6 +3,7 @@ export const DEFAULT_CONEXTCOUNT = 5
|
||||
export const DEFAULT_MAX_TOKENS = 4096
|
||||
export const FONT_FAMILY =
|
||||
"Ubuntu, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif"
|
||||
export const platform = window.electron?.process?.platform === 'darwin' ? 'macos' : 'windows'
|
||||
export const isMac = platform === 'macos'
|
||||
export const isWindows = platform === 'windows'
|
||||
export const platform = window.electron?.process?.platform
|
||||
export const isMac = platform === 'darwin'
|
||||
export const isWindows = platform === 'win32' || platform === 'win64'
|
||||
export const isLinux = platform === 'linux'
|
||||
|
||||
@@ -33,6 +33,22 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
gemini: [
|
||||
{
|
||||
id: 'gemini-1.5-flash',
|
||||
provider: 'gemini',
|
||||
name: 'Gemini 1.5 Flash',
|
||||
group: 'Gemini 1.5',
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
id: 'gemini-1.5-pro-exp-0801',
|
||||
provider: 'gemini',
|
||||
name: 'Gemini 1.5 Pro Experimental 0801',
|
||||
group: 'Gemini 1.5',
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
silicon: [
|
||||
{
|
||||
id: 'Qwen/Qwen2-7B-Instruct',
|
||||
@@ -320,6 +336,53 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
stepfun: [
|
||||
{
|
||||
id: 'step-1-8k',
|
||||
provider: 'stepfun',
|
||||
name: 'Step 1 8K',
|
||||
group: 'Step 1',
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
id: 'step-1-flash',
|
||||
provider: 'stepfun',
|
||||
name: 'Step 1 Flash',
|
||||
group: 'Step 1',
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
doubao: [],
|
||||
minimax: [
|
||||
{
|
||||
id: 'abab6.5s-chat',
|
||||
provider: 'minimax',
|
||||
name: 'abab6.5s',
|
||||
group: 'abab6',
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
id: 'abab6.5g-chat',
|
||||
provider: 'minimax',
|
||||
name: 'abab6.5g',
|
||||
group: 'abab6',
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
id: 'abab6.5t-chat',
|
||||
provider: 'minimax',
|
||||
name: 'abab6.5t',
|
||||
group: 'abab6',
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
id: 'abab5.5s-chat',
|
||||
provider: 'minimax',
|
||||
name: 'abab5.5s',
|
||||
group: 'abab5',
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
aihubmix: [
|
||||
{
|
||||
id: 'gpt-4o-mini',
|
||||
|
||||
@@ -1,27 +1,41 @@
|
||||
import BaicuanAppLogo from '@renderer/assets/images/apps/baixiaoying.webp'
|
||||
import KimiAppLogo from '@renderer/assets/images/apps/kimi.jpg'
|
||||
import YuewenAppLogo from '@renderer/assets/images/apps/yuewen.png'
|
||||
import BaichuanModelLogo from '@renderer/assets/images/models/baichuan.png'
|
||||
import ChatGLMModelLogo from '@renderer/assets/images/models/chatglm.jpeg'
|
||||
import ChatGPTModelLogo from '@renderer/assets/images/models/chatgpt.jpeg'
|
||||
import ClaudeModelLogo from '@renderer/assets/images/models/claude.png'
|
||||
import DeepSeekModelLogo from '@renderer/assets/images/models/deepseek.png'
|
||||
import DoubaoModelLogo from '@renderer/assets/images/models/doubao.png'
|
||||
import EmbeddingModelLogo from '@renderer/assets/images/models/embedding.png'
|
||||
import GeminiModelLogo from '@renderer/assets/images/models/gemini.png'
|
||||
import GemmaModelLogo from '@renderer/assets/images/models/gemma.jpeg'
|
||||
import HailuoModelLogo from '@renderer/assets/images/models/hailuo.png'
|
||||
import LlamaModelLogo from '@renderer/assets/images/models/llama.jpeg'
|
||||
import MicrosoftModelLogo from '@renderer/assets/images/models/microsoft.png'
|
||||
import MixtralModelLogo from '@renderer/assets/images/models/mixtral.jpeg'
|
||||
import PalmModelLogo from '@renderer/assets/images/models/palm.svg'
|
||||
import QwenModelLogo from '@renderer/assets/images/models/qwen.png'
|
||||
import YiModelLogo from '@renderer/assets/images/models/yi.svg'
|
||||
import StepModelLogo from '@renderer/assets/images/models/step.jpg'
|
||||
import YiModelLogo from '@renderer/assets/images/models/yi.png'
|
||||
import AiHubMixProviderLogo from '@renderer/assets/images/providers/aihubmix.jpg'
|
||||
import AnthropicProviderLogo from '@renderer/assets/images/providers/anthropic.jpeg'
|
||||
import BaichuanProviderLogo from '@renderer/assets/images/providers/baichuan.png'
|
||||
import DashScopeProviderLogo from '@renderer/assets/images/providers/dashscope.png'
|
||||
import DeepSeekProviderLogo from '@renderer/assets/images/providers/deepseek.png'
|
||||
import DoubaoProviderLogo from '@renderer/assets/images/providers/doubao.png'
|
||||
import GeminiProviderLogo from '@renderer/assets/images/providers/gemini.png'
|
||||
import GraphRagProviderLogo from '@renderer/assets/images/providers/graph-rag.png'
|
||||
import GroqProviderLogo from '@renderer/assets/images/providers/groq.png'
|
||||
import MoonshotProviderLogo from '@renderer/assets/images/providers/moonshot.jpeg'
|
||||
import MoonshotModelLogo from '@renderer/assets/images/providers/moonshot.jpeg'
|
||||
import MinimaxProviderLogo from '@renderer/assets/images/providers/minimax.png'
|
||||
import MoonshotProviderLogo from '@renderer/assets/images/providers/moonshot.jpg'
|
||||
import MoonshotModelLogo from '@renderer/assets/images/providers/moonshot.jpg'
|
||||
import OllamaProviderLogo from '@renderer/assets/images/providers/ollama.png'
|
||||
import OpenAiProviderLogo from '@renderer/assets/images/providers/openai.jpeg'
|
||||
import OpenAiProviderLogo from '@renderer/assets/images/providers/openai.png'
|
||||
import OpenRouterProviderLogo from '@renderer/assets/images/providers/openrouter.png'
|
||||
import SiliconFlowProviderLogo from '@renderer/assets/images/providers/silicon.png'
|
||||
import YiProviderLogo from '@renderer/assets/images/providers/yi.svg'
|
||||
import StepFunProviderLogo from '@renderer/assets/images/providers/stepfun.png'
|
||||
import YiProviderLogo from '@renderer/assets/images/providers/yi.png'
|
||||
import ZhipuProviderLogo from '@renderer/assets/images/providers/zhipu.png'
|
||||
|
||||
export function getProviderLogo(providerId: string) {
|
||||
@@ -52,6 +66,16 @@ export function getProviderLogo(providerId: string) {
|
||||
return AnthropicProviderLogo
|
||||
case 'aihubmix':
|
||||
return AiHubMixProviderLogo
|
||||
case 'gemini':
|
||||
return GeminiProviderLogo
|
||||
case 'stepfun':
|
||||
return StepFunProviderLogo
|
||||
case 'doubao':
|
||||
return DoubaoProviderLogo
|
||||
case 'graphrag-kylin-mountain':
|
||||
return GraphRagProviderLogo
|
||||
case 'minimax':
|
||||
return MinimaxProviderLogo
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
@@ -75,7 +99,14 @@ export function getModelLogo(modelId: string) {
|
||||
moonshot: MoonshotModelLogo,
|
||||
phi: MicrosoftModelLogo,
|
||||
baichuan: BaichuanModelLogo,
|
||||
claude: ClaudeModelLogo
|
||||
claude: ClaudeModelLogo,
|
||||
gemini: GeminiModelLogo,
|
||||
embedding: EmbeddingModelLogo,
|
||||
bison: PalmModelLogo,
|
||||
palm: PalmModelLogo,
|
||||
step: StepModelLogo,
|
||||
abab: HailuoModelLogo,
|
||||
'ep-202': DoubaoModelLogo
|
||||
}
|
||||
|
||||
for (const key in logoMap) {
|
||||
@@ -98,6 +129,28 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://platform.openai.com/api-keys',
|
||||
docs: 'https://platform.openai.com/docs',
|
||||
models: 'https://platform.openai.com/docs/models'
|
||||
},
|
||||
app: {
|
||||
name: 'ChatGPT',
|
||||
url: 'https://chatgpt.com/',
|
||||
logo: OpenAiProviderLogo
|
||||
}
|
||||
},
|
||||
gemini: {
|
||||
api: {
|
||||
url: 'https://generativelanguage.googleapis.com',
|
||||
editable: false
|
||||
},
|
||||
websites: {
|
||||
official: 'https://gemini.google.com/',
|
||||
apiKey: 'https://aistudio.google.com/app/apikey',
|
||||
docs: 'https://ai.google.dev/gemini-api/docs',
|
||||
models: 'https://ai.google.dev/gemini-api/docs/models/gemini'
|
||||
},
|
||||
app: {
|
||||
name: 'Gemini',
|
||||
url: 'https://gemini.google.com/',
|
||||
logo: GeminiProviderLogo
|
||||
}
|
||||
},
|
||||
silicon: {
|
||||
@@ -110,6 +163,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://cloud.siliconflow.cn/account/ak?referrer=clxty1xuy0014lvqwh5z50i88',
|
||||
docs: 'https://docs.siliconflow.cn/',
|
||||
models: 'https://docs.siliconflow.cn/docs/model-names'
|
||||
},
|
||||
app: {
|
||||
name: 'SiliconFlow',
|
||||
url: 'https://cloud.siliconflow.cn/playground/chat',
|
||||
logo: SiliconFlowProviderLogo
|
||||
}
|
||||
},
|
||||
deepseek: {
|
||||
@@ -122,6 +180,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://platform.deepseek.com/api_keys',
|
||||
docs: 'https://platform.deepseek.com/api-docs/',
|
||||
models: 'https://platform.deepseek.com/api-docs/'
|
||||
},
|
||||
app: {
|
||||
name: 'DeepSeek',
|
||||
url: 'https://chat.deepseek.com/',
|
||||
logo: DeepSeekProviderLogo
|
||||
}
|
||||
},
|
||||
yi: {
|
||||
@@ -134,6 +197,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://platform.lingyiwanwu.com/apikeys',
|
||||
docs: 'https://platform.lingyiwanwu.com/docs',
|
||||
models: 'https://platform.lingyiwanwu.com/docs#%E6%A8%A1%E5%9E%8B'
|
||||
},
|
||||
app: {
|
||||
name: 'Yi',
|
||||
url: 'https://www.wanzhi.com/',
|
||||
logo: YiProviderLogo
|
||||
}
|
||||
},
|
||||
zhipu: {
|
||||
@@ -146,6 +214,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://open.bigmodel.cn/usercenter/apikeys',
|
||||
docs: 'https://open.bigmodel.cn/dev/howuse/introduction',
|
||||
models: 'https://open.bigmodel.cn/modelcenter/square'
|
||||
},
|
||||
app: {
|
||||
name: '智谱',
|
||||
url: 'https://chatglm.cn/main/alltoolsdetail',
|
||||
logo: ZhipuProviderLogo
|
||||
}
|
||||
},
|
||||
moonshot: {
|
||||
@@ -158,6 +231,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://platform.moonshot.cn/console/api-keys',
|
||||
docs: 'https://platform.moonshot.cn/docs/',
|
||||
models: 'https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8'
|
||||
},
|
||||
app: {
|
||||
name: 'Kimi',
|
||||
url: 'https://kimi.moonshot.cn/',
|
||||
logo: KimiAppLogo
|
||||
}
|
||||
},
|
||||
baichuan: {
|
||||
@@ -170,6 +248,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://platform.baichuan-ai.com/console/apikey',
|
||||
docs: 'https://platform.baichuan-ai.com/docs',
|
||||
models: 'https://platform.baichuan-ai.com/price'
|
||||
},
|
||||
app: {
|
||||
name: '百小应',
|
||||
url: 'https://ying.baichuan-ai.com/chat',
|
||||
logo: BaicuanAppLogo
|
||||
}
|
||||
},
|
||||
dashscope: {
|
||||
@@ -182,6 +265,68 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://help.aliyun.com/zh/dashscope/developer-reference/acquisition-and-configuration-of-api-key',
|
||||
docs: 'https://help.aliyun.com/zh/dashscope/',
|
||||
models: 'https://dashscope.console.aliyun.com/model'
|
||||
},
|
||||
app: {
|
||||
name: '通义千问',
|
||||
url: 'https://tongyi.aliyun.com/qianwen/',
|
||||
logo: QwenModelLogo
|
||||
}
|
||||
},
|
||||
stepfun: {
|
||||
api: {
|
||||
url: 'https://api.stepfun.com',
|
||||
editable: false
|
||||
},
|
||||
websites: {
|
||||
official: 'https://platform.stepfun.com/',
|
||||
apiKey: 'https://platform.stepfun.com/interface-key',
|
||||
docs: 'https://platform.stepfun.com/docs/overview/concept',
|
||||
models: 'https://platform.stepfun.com/docs/llm/text'
|
||||
},
|
||||
app: {
|
||||
name: '跃问',
|
||||
url: 'https://yuewen.cn/chats/new',
|
||||
logo: YuewenAppLogo
|
||||
}
|
||||
},
|
||||
doubao: {
|
||||
api: {
|
||||
url: 'https://ark.cn-beijing.volces.com/api/v3/',
|
||||
editable: true
|
||||
},
|
||||
websites: {
|
||||
official: 'https://console.volcengine.com/ark/',
|
||||
apiKey: 'https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey',
|
||||
docs: 'https://www.volcengine.com/docs/82379/1182403',
|
||||
models: 'https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint'
|
||||
},
|
||||
app: {
|
||||
name: '豆包',
|
||||
url: 'https://www.doubao.com/chat/',
|
||||
logo: DoubaoProviderLogo
|
||||
}
|
||||
},
|
||||
minimax: {
|
||||
api: {
|
||||
url: 'https://api.minimax.chat/v1/',
|
||||
editable: true
|
||||
},
|
||||
websites: {
|
||||
official: 'https://platform.minimaxi.com/',
|
||||
apiKey: 'https://platform.minimaxi.com/user-center/basic-information/interface-key',
|
||||
docs: 'https://platform.minimaxi.com/document/Announcement',
|
||||
models: 'https://platform.minimaxi.com/document/Models'
|
||||
},
|
||||
app: {
|
||||
name: '海螺',
|
||||
url: 'https://hailuoai.com/',
|
||||
logo: HailuoModelLogo
|
||||
}
|
||||
},
|
||||
'graphrag-kylin-mountain': {
|
||||
api: {
|
||||
url: '',
|
||||
editable: true
|
||||
}
|
||||
},
|
||||
openrouter: {
|
||||
@@ -206,6 +351,11 @@ export const PROVIDER_CONFIG = {
|
||||
apiKey: 'https://console.groq.com/keys',
|
||||
docs: 'https://console.groq.com/docs/quickstart',
|
||||
models: 'https://console.groq.com/docs/models'
|
||||
},
|
||||
app: {
|
||||
name: 'Groq',
|
||||
url: 'https://chat.groq.com/',
|
||||
logo: GroqProviderLogo
|
||||
}
|
||||
},
|
||||
ollama: {
|
||||
@@ -222,13 +372,18 @@ export const PROVIDER_CONFIG = {
|
||||
anthropic: {
|
||||
api: {
|
||||
url: 'https://api.anthropic.com/',
|
||||
editable: false
|
||||
editable: true
|
||||
},
|
||||
websites: {
|
||||
official: 'https://anthropic.com/',
|
||||
apiKey: 'https://console.anthropic.com/settings/keys',
|
||||
docs: 'https://docs.anthropic.com/en/docs',
|
||||
models: 'https://docs.anthropic.com/en/docs/about-claude/models'
|
||||
},
|
||||
app: {
|
||||
name: 'Claude',
|
||||
url: 'https://claude.ai/',
|
||||
logo: AnthropicProviderLogo
|
||||
}
|
||||
},
|
||||
aihubmix: {
|
||||
|
||||
51
src/renderer/src/hooks/useBridge.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { useEffect } from 'react'
|
||||
|
||||
export function useBridge() {
|
||||
useEffect(() => {
|
||||
const handleMessage = async (event: MessageEvent) => {
|
||||
const targetOrigin = { targetOrigin: '*' }
|
||||
|
||||
try {
|
||||
if (event.origin !== 'file://') {
|
||||
return
|
||||
}
|
||||
|
||||
const { type, method, args, id } = event.data
|
||||
|
||||
if (type !== 'api-call' || !window.api) {
|
||||
return
|
||||
}
|
||||
|
||||
const apiMethod = window.api[method]
|
||||
|
||||
if (typeof apiMethod !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
event.source?.postMessage(
|
||||
{
|
||||
id,
|
||||
type: 'api-response',
|
||||
result: await apiMethod(...args)
|
||||
},
|
||||
targetOrigin
|
||||
)
|
||||
} catch (error) {
|
||||
event.source?.postMessage(
|
||||
{
|
||||
id: event.data?.id,
|
||||
type: 'api-response',
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
},
|
||||
targetOrigin
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('message', handleMessage)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('message', handleMessage)
|
||||
}
|
||||
}, [])
|
||||
}
|
||||
@@ -16,3 +16,7 @@ export function useActiveTopic(assistant: Assistant) {
|
||||
|
||||
return { activeTopic, setActiveTopic }
|
||||
}
|
||||
|
||||
export function getTopic(assistant: Assistant, topicId: string) {
|
||||
return assistant?.topics.find((topic) => topic.id === topicId)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ const resources = {
|
||||
save: 'Save',
|
||||
footnotes: 'References',
|
||||
select: 'Select',
|
||||
search: 'Search'
|
||||
search: 'Search',
|
||||
default: 'Default',
|
||||
warning: 'Warning'
|
||||
},
|
||||
button: {
|
||||
add: 'Add',
|
||||
@@ -47,11 +49,15 @@ const resources = {
|
||||
'api.connection.failed': 'Connection failed',
|
||||
'api.connection.success': 'Connection successful',
|
||||
'chat.completion.paused': 'Chat completion paused',
|
||||
'switch.disabled': 'Switching is disabled while the assistant is generating'
|
||||
'switch.disabled': 'Switching is disabled while the assistant is generating',
|
||||
'restore.success': 'Restored successfully',
|
||||
'reset.confirm.content': 'Are you sure you want to clear all data?',
|
||||
'reset.double.confirm.title': 'DATA LOST !!!',
|
||||
'reset.double.confirm.content': 'All data will be lost, do you want to continue?'
|
||||
},
|
||||
chat: {
|
||||
save: 'Save',
|
||||
'default.name': '😀 Default Assistant',
|
||||
'default.name': '🔆 Default Assistant',
|
||||
'default.description': "Hello, I'm Default Assistant. You can start chatting with me right away",
|
||||
'default.topic.name': 'Default Topic',
|
||||
'topics.title': 'Topics',
|
||||
@@ -105,6 +111,7 @@ const resources = {
|
||||
},
|
||||
provider: {
|
||||
openai: 'OpenAI',
|
||||
gemini: 'Gemini',
|
||||
deepseek: 'DeepSeek',
|
||||
moonshot: 'Moonshot',
|
||||
silicon: 'SiliconFlow',
|
||||
@@ -116,7 +123,11 @@ const resources = {
|
||||
baichuan: 'Baichuan',
|
||||
dashscope: 'DashScope',
|
||||
anthropic: 'Anthropic',
|
||||
aihubmix: 'AiHubMix'
|
||||
aihubmix: 'AiHubMix',
|
||||
stepfun: 'StepFun',
|
||||
doubao: 'Doubao',
|
||||
minimax: 'MiniMax',
|
||||
'graphrag-kylin-mountain': 'GraphRAG'
|
||||
},
|
||||
settings: {
|
||||
title: 'Settings',
|
||||
@@ -131,9 +142,13 @@ const resources = {
|
||||
'messages.use_serif_font': 'Use serif font',
|
||||
'messages.input.title': 'Input Settings',
|
||||
'messages.input.show_estimated_tokens': 'Show estimated input tokens',
|
||||
'messages.input.send_shortcuts': 'Send shortcuts',
|
||||
'general.title': 'General Settings',
|
||||
'general.user_name': 'User Name',
|
||||
'general.user_name.placeholder': 'Enter your name',
|
||||
'general.backup.title': 'Data Backup and Recovery',
|
||||
'general.reset.title': 'Data Reset',
|
||||
'general.reset.button': 'Reset',
|
||||
'provider.api_key': 'API Key',
|
||||
'provider.check': 'Check',
|
||||
'provider.get_api_key': 'Get API Key',
|
||||
@@ -168,21 +183,22 @@ const resources = {
|
||||
'provider.edit.name': 'Provider Name',
|
||||
'provider.edit.name.placeholder': 'Example: OpenAI',
|
||||
'about.title': 'About',
|
||||
'about.releases.title': '📔 Release Notes',
|
||||
'about.releases.title': 'Release Notes',
|
||||
'about.releases.button': 'Releases',
|
||||
'about.website.title': '🌐 Official Website',
|
||||
'about.website.title': 'Official Website',
|
||||
'about.website.button': 'Website',
|
||||
'about.feedback.title': '📝 Feedback',
|
||||
'about.feedback.title': 'Feedback',
|
||||
'about.feedback.button': 'Feedback',
|
||||
'about.contact.title': '📧 Contact',
|
||||
'about.license.title': '📄 License',
|
||||
'about.contact.title': 'Contact',
|
||||
'about.license.title': 'License',
|
||||
'about.license.button': 'License',
|
||||
'about.contact.button': 'Email',
|
||||
'proxy.title': 'Proxy Address',
|
||||
'theme.title': 'Theme',
|
||||
'theme.dark': 'Dark',
|
||||
'theme.light': 'Light',
|
||||
'theme.auto': 'Auto'
|
||||
'theme.auto': 'Auto',
|
||||
'font_size.title': 'Message Font Size'
|
||||
},
|
||||
translate: {
|
||||
title: 'Translation',
|
||||
@@ -210,6 +226,17 @@ const resources = {
|
||||
'keep_alive_time.title': 'Keep Alive Time',
|
||||
'keep_alive_time.placeholder': 'Minutes',
|
||||
'keep_alive_time.description': 'The time in minutes to keep the connection alive, default is 5 minutes.'
|
||||
},
|
||||
minapp: {
|
||||
title: 'MinApp'
|
||||
},
|
||||
error: {
|
||||
'chat.response': 'Something went wrong. Please check if you have set your API key in the Settings > Providers',
|
||||
'backup.file_format': 'Backup file format error'
|
||||
},
|
||||
words: {
|
||||
knowledgeGraph: 'Knowledge Graph',
|
||||
visualization: 'Visualization'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -237,7 +264,9 @@ const resources = {
|
||||
you: '用户',
|
||||
footnote: '引用内容',
|
||||
select: '选择',
|
||||
search: '搜索'
|
||||
search: '搜索',
|
||||
default: '默认',
|
||||
warning: '警告'
|
||||
},
|
||||
button: {
|
||||
add: '添加',
|
||||
@@ -257,11 +286,15 @@ const resources = {
|
||||
'api.connection.failed': '连接失败',
|
||||
'api.connection.success': '连接成功',
|
||||
'chat.completion.paused': '会话已停止',
|
||||
'switch.disabled': '模型回复完成后才能切换'
|
||||
'switch.disabled': '模型回复完成后才能切换',
|
||||
'restore.success': '恢复成功',
|
||||
'reset.confirm.content': '确定要重置所有数据吗?',
|
||||
'reset.double.confirm.title': '数据丢失!!!',
|
||||
'reset.double.confirm.content': '你的全部数据都会丢失,如果没有备份数据,将无法恢复,确定要继续吗?'
|
||||
},
|
||||
chat: {
|
||||
save: '保存',
|
||||
'default.name': '😃 默认助手 - Assistant',
|
||||
'default.name': '🔆 默认助手 - Assistant',
|
||||
'default.description': '你好,我是默认助手。你可以立刻开始跟我聊天。',
|
||||
'default.topic.name': '默认话题',
|
||||
'topics.title': '话题',
|
||||
@@ -316,6 +349,7 @@ const resources = {
|
||||
},
|
||||
provider: {
|
||||
openai: 'OpenAI',
|
||||
gemini: 'Gemini',
|
||||
deepseek: '深度求索',
|
||||
moonshot: '月之暗面',
|
||||
silicon: '硅基流动',
|
||||
@@ -327,12 +361,16 @@ const resources = {
|
||||
baichuan: '百川',
|
||||
dashscope: '阿里云灵积',
|
||||
anthropic: 'Anthropic',
|
||||
aihubmix: 'AiHubMix'
|
||||
aihubmix: 'AiHubMix',
|
||||
stepfun: '阶跃星辰',
|
||||
doubao: '豆包',
|
||||
minimax: 'MiniMax',
|
||||
'graphrag-kylin-mountain': 'GraphRAG'
|
||||
},
|
||||
settings: {
|
||||
title: '设置',
|
||||
general: '常规设置',
|
||||
provider: '模型提供商',
|
||||
provider: '模型服务',
|
||||
model: '默认模型',
|
||||
assistant: '默认助手',
|
||||
about: '关于我们',
|
||||
@@ -342,9 +380,13 @@ const resources = {
|
||||
'messages.use_serif_font': '使用衬线字体',
|
||||
'messages.input.title': '输入设置',
|
||||
'messages.input.show_estimated_tokens': '状态显示',
|
||||
'messages.input.send_shortcuts': '发送快捷键',
|
||||
'general.title': '常规设置',
|
||||
'general.user_name': '用户名',
|
||||
'general.user_name.placeholder': '请输入用户名',
|
||||
'general.backup.title': '数据备份与恢复',
|
||||
'general.reset.title': '重置数据',
|
||||
'general.reset.button': '重置',
|
||||
'provider.api_key': 'API 密钥',
|
||||
'provider.check': '检查',
|
||||
'provider.get_api_key': '点击这里获取密钥',
|
||||
@@ -379,21 +421,22 @@ const resources = {
|
||||
'provider.edit.name': '模型提供商名称',
|
||||
'provider.edit.name.placeholder': '例如 OpenAI',
|
||||
'about.title': '关于我们',
|
||||
'about.releases.title': '📔 更新日志',
|
||||
'about.releases.title': '更新日志',
|
||||
'about.releases.button': '查看',
|
||||
'about.website.title': '🌐 官方网站',
|
||||
'about.website.title': '官方网站',
|
||||
'about.website.button': '查看',
|
||||
'about.feedback.title': '📝 意见反馈',
|
||||
'about.feedback.title': '意见反馈',
|
||||
'about.feedback.button': '反馈',
|
||||
'about.contact.title': '📧 邮件联系',
|
||||
'about.license.title': '📄 许可证',
|
||||
'about.contact.title': '邮件联系',
|
||||
'about.license.title': '许可证',
|
||||
'about.license.button': '查看',
|
||||
'about.contact.button': '邮件',
|
||||
'proxy.title': '代理地址',
|
||||
'theme.title': '主题',
|
||||
'theme.dark': '深色主题',
|
||||
'theme.light': '浅色主题',
|
||||
'theme.auto': '跟随系统'
|
||||
'theme.auto': '跟随系统',
|
||||
'font_size.title': '消息字体大小'
|
||||
},
|
||||
translate: {
|
||||
title: '翻译',
|
||||
@@ -421,6 +464,17 @@ const resources = {
|
||||
'keep_alive_time.title': '保持活跃时间',
|
||||
'keep_alive_time.placeholder': '分钟',
|
||||
'keep_alive_time.description': '对话后模型在内存中保持的时间(默认:5分钟)'
|
||||
},
|
||||
minapp: {
|
||||
title: '小程序'
|
||||
},
|
||||
error: {
|
||||
'chat.response': '出错了,如果没有配置 API 密钥,请前往设置 > 模型提供商中配置密钥',
|
||||
'backup.file_format': '备份文件格式错误'
|
||||
},
|
||||
words: {
|
||||
knowledgeGraph: '知识图谱',
|
||||
visualization: '可视化'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import './assets/styles/index.scss'
|
||||
import './init'
|
||||
import './i18n'
|
||||
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
|
||||
@@ -56,13 +56,13 @@ const AppsPage: FC = () => {
|
||||
<ContentContainer>
|
||||
<AssistantsContainer>
|
||||
<HStack alignItems="center" style={{ marginBottom: 16 }}>
|
||||
<Title level={3}>{t('agents.my_agents')}</Title>
|
||||
<Title level={4}>{t('agents.my_agents')}</Title>
|
||||
{agents.length > 0 && <ManageIcon onClick={ManageAgentsPopup.show} />}
|
||||
</HStack>
|
||||
<UserAgents onAdd={onAddAgentConfirm} />
|
||||
{Object.keys(agentGroups).map((group) => (
|
||||
<div key={group}>
|
||||
<Title level={3} key={group} style={{ marginBottom: 16 }}>
|
||||
<Title level={4} key={group} style={{ marginBottom: 16 }}>
|
||||
{group}
|
||||
</Title>
|
||||
<Row gutter={16}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Agent } from '@renderer/types'
|
||||
import { Col, Typography } from 'antd'
|
||||
import { Col } from 'antd'
|
||||
import styled from 'styled-components'
|
||||
|
||||
interface Props {
|
||||
@@ -7,17 +7,13 @@ interface Props {
|
||||
onClick?: () => void
|
||||
}
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
const AgentCard: React.FC<Props> = ({ agent, onClick }) => {
|
||||
return (
|
||||
<Container onClick={onClick}>
|
||||
{agent.emoji && <EmojiHeader>{agent.emoji}</EmojiHeader>}
|
||||
<Col>
|
||||
<AgentHeader>
|
||||
<AgentName level={5} style={{ marginBottom: 0 }}>
|
||||
{agent.name}
|
||||
</AgentName>
|
||||
<AgentName style={{ marginBottom: 0 }}>{agent.name}</AgentName>
|
||||
</AgentHeader>
|
||||
<AgentCardPrompt>{agent.prompt}</AgentCardPrompt>
|
||||
</Col>
|
||||
@@ -41,14 +37,14 @@ const Container = styled.div`
|
||||
}
|
||||
`
|
||||
const EmojiHeader = styled.div`
|
||||
width: 25px;
|
||||
width: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 5px;
|
||||
font-size: 25px;
|
||||
line-height: 25px;
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
`
|
||||
|
||||
const AgentHeader = styled.div`
|
||||
@@ -58,15 +54,13 @@ const AgentHeader = styled.div`
|
||||
align-items: center;
|
||||
`
|
||||
|
||||
const AgentName = styled(Title)`
|
||||
font-size: 18px;
|
||||
const AgentName = styled.div`
|
||||
line-height: 1.2;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
color: var(--color-white);
|
||||
font-weight: 900;
|
||||
color: var(--color-text-1);
|
||||
`
|
||||
|
||||
const AgentCardPrompt = styled.div`
|
||||
@@ -76,6 +70,7 @@ const AgentCardPrompt = styled.div`
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
`
|
||||
|
||||
export default AgentCard
|
||||
|
||||
@@ -41,10 +41,10 @@ const AssistantCardContainer = styled.div`
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
border: 1px dashed var(--color-border);
|
||||
border: 1px dashed var(--color-border-soft);
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
min-height: 84px;
|
||||
min-height: 72px;
|
||||
.anticon {
|
||||
font-size: 16px;
|
||||
color: var(--color-icon);
|
||||
|
||||
58
src/renderer/src/pages/apps/App.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import MinApp from '@renderer/components/MinApp'
|
||||
import { useTheme } from '@renderer/providers/ThemeProvider'
|
||||
import { MinAppType } from '@renderer/types'
|
||||
import { FC } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
interface Props {
|
||||
app: MinAppType
|
||||
}
|
||||
|
||||
const App: FC<Props> = ({ app }) => {
|
||||
const { theme } = useTheme()
|
||||
|
||||
const onClick = () => {
|
||||
const websiteReg = /claude|chatgpt|groq/i
|
||||
|
||||
if (websiteReg.test(app.url)) {
|
||||
window.api.minApp({ url: app.url, windowOptions: { title: app.name } })
|
||||
return
|
||||
}
|
||||
|
||||
MinApp.start(app)
|
||||
}
|
||||
|
||||
return (
|
||||
<Container onClick={onClick}>
|
||||
<AppIcon src={app.logo} style={{ border: theme === 'dark' ? 'none' : '0.5px solid var(--color-border' }} />
|
||||
<AppTitle>{app.name}</AppTitle>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
width: 65px;
|
||||
`
|
||||
|
||||
const AppIcon = styled.img`
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 16px;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
`
|
||||
|
||||
const AppTitle = styled.div`
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
color: var(--color-text-soft);
|
||||
text-align: center;
|
||||
user-select: none;
|
||||
`
|
||||
|
||||
export default App
|
||||
148
src/renderer/src/pages/apps/AppsPage.tsx
Normal file
@@ -0,0 +1,148 @@
|
||||
import { SearchOutlined } from '@ant-design/icons'
|
||||
import AiAssistantAppLogo from '@renderer/assets/images/apps/360-ai.png'
|
||||
import AiSearchAppLogo from '@renderer/assets/images/apps/ai-search.png'
|
||||
import BaiduAiAppLogo from '@renderer/assets/images/apps/baidu-ai.png'
|
||||
import DevvAppLogo from '@renderer/assets/images/apps/devv.png'
|
||||
import MetasoAppLogo from '@renderer/assets/images/apps/metaso.webp'
|
||||
import SensetimeAppLogo from '@renderer/assets/images/apps/sensetime.png'
|
||||
import SparkDeskAppLogo from '@renderer/assets/images/apps/sparkdesk.png'
|
||||
import TiangongAiLogo from '@renderer/assets/images/apps/tiangong.png'
|
||||
import TencentYuanbaoAppLogo from '@renderer/assets/images/apps/yuanbao.png'
|
||||
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
|
||||
import { Center } from '@renderer/components/Layout'
|
||||
import { PROVIDER_CONFIG } from '@renderer/config/provider'
|
||||
import { MinAppType } from '@renderer/types'
|
||||
import { Empty, Input } from 'antd'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { FC, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import App from './App'
|
||||
|
||||
const _apps: MinAppType[] = [
|
||||
{
|
||||
name: 'AI 助手',
|
||||
logo: AiAssistantAppLogo,
|
||||
url: 'https://bot.360.com/'
|
||||
},
|
||||
{
|
||||
name: '文心一言',
|
||||
logo: BaiduAiAppLogo,
|
||||
url: 'https://yiyan.baidu.com/'
|
||||
},
|
||||
{
|
||||
name: 'SparkDesk',
|
||||
logo: SparkDeskAppLogo,
|
||||
url: 'https://xinghuo.xfyun.cn/desk'
|
||||
},
|
||||
{
|
||||
name: '腾讯元宝',
|
||||
logo: TencentYuanbaoAppLogo,
|
||||
url: 'https://yuanbao.tencent.com/chat'
|
||||
},
|
||||
{
|
||||
name: '商量',
|
||||
logo: SensetimeAppLogo,
|
||||
url: 'https://chat.sensetime.com/wb/chat'
|
||||
},
|
||||
{
|
||||
name: '360AI搜索',
|
||||
logo: AiSearchAppLogo,
|
||||
url: 'https://so.360.com/'
|
||||
},
|
||||
{
|
||||
name: '秘塔AI搜索',
|
||||
logo: MetasoAppLogo,
|
||||
url: 'https://metaso.cn/'
|
||||
},
|
||||
{
|
||||
name: '天工AI',
|
||||
logo: TiangongAiLogo,
|
||||
url: 'https://www.tiangong.cn/'
|
||||
},
|
||||
{
|
||||
name: 'DEVV_',
|
||||
logo: DevvAppLogo,
|
||||
url: 'https://devv.ai/'
|
||||
}
|
||||
]
|
||||
|
||||
const AppsPage: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const [search, setSearch] = useState('')
|
||||
|
||||
const list: MinAppType[] = (Object.entries(PROVIDER_CONFIG) as any[])
|
||||
.filter(([, config]) => config.app)
|
||||
.map(([key, config]) => ({ id: key, ...config.app }))
|
||||
.concat(_apps)
|
||||
|
||||
const apps = search
|
||||
? list.filter(
|
||||
(app) => app.name.toLowerCase().includes(search.toLowerCase()) || app.url.includes(search.toLowerCase())
|
||||
)
|
||||
: list
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Navbar>
|
||||
<NavbarCenter style={{ borderRight: 'none', justifyContent: 'space-between' }}>
|
||||
{t('minapp.title')}
|
||||
<Input
|
||||
placeholder={t('common.search')}
|
||||
className="nodrag"
|
||||
style={{ width: '30%', height: 28 }}
|
||||
size="small"
|
||||
variant="filled"
|
||||
suffix={<SearchOutlined />}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
<div style={{ width: 80 }} />
|
||||
</NavbarCenter>
|
||||
</Navbar>
|
||||
<ContentContainer>
|
||||
<AppsContainer>
|
||||
{apps.map((app) => (
|
||||
<App key={app.name} app={app} />
|
||||
))}
|
||||
{isEmpty(apps) && (
|
||||
<Center style={{ flex: 1 }}>
|
||||
<Empty />
|
||||
</Center>
|
||||
)}
|
||||
</AppsContainer>
|
||||
</ContentContainer>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
const Container = styled.div`
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
`
|
||||
|
||||
const ContentContainer = styled.div`
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
background-color: var(--color-background);
|
||||
padding: 50px;
|
||||
`
|
||||
|
||||
const AppsContainer = styled.div`
|
||||
display: flex;
|
||||
min-width: 900px;
|
||||
max-width: 900px;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
gap: 50px;
|
||||
`
|
||||
|
||||
export default AppsPage
|
||||
@@ -145,7 +145,7 @@ const AssistantItem = styled.div`
|
||||
flex-direction: column;
|
||||
padding: 7px 10px;
|
||||
position: relative;
|
||||
border-radius: 8px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-family: Ubuntu;
|
||||
.anticon {
|
||||
@@ -168,7 +168,6 @@ const AssistantItem = styled.div`
|
||||
`
|
||||
|
||||
const AssistantName = styled.div`
|
||||
font-size: 14px;
|
||||
color: var(--color-text);
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
@@ -5,9 +5,9 @@ import { Flex } from 'antd'
|
||||
import { FC } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import Inputbar from './input/Inputbar'
|
||||
import Messages from './Messages'
|
||||
import RightSidebar from './sidebar/RightSidebar'
|
||||
import Inputbar from './Inputbar/Inputbar'
|
||||
import Messages from './Messages/Messages'
|
||||
import RightSidebar from './RightSidebar'
|
||||
|
||||
interface Props {
|
||||
assistant: Assistant
|
||||
@@ -8,14 +8,14 @@ import { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { NewButton } from '../HomePage'
|
||||
import SelectModelButton from './SelectModelButton'
|
||||
import SelectModelButton from './components/SelectModelButton'
|
||||
import { NewButton } from './HomePage'
|
||||
|
||||
interface Props {
|
||||
activeAssistant: Assistant
|
||||
}
|
||||
|
||||
const NavigationCenter: FC<Props> = ({ activeAssistant }) => {
|
||||
const HomeHeader: FC<Props> = ({ activeAssistant }) => {
|
||||
const { assistant } = useAssistant(activeAssistant.id)
|
||||
const { t } = useTranslation()
|
||||
const { showAssistants, toggleShowAssistants } = useShowAssistants()
|
||||
@@ -34,10 +34,9 @@ const NavigationCenter: FC<Props> = ({ activeAssistant }) => {
|
||||
}
|
||||
|
||||
const AssistantName = styled.span`
|
||||
font-weight: bold;
|
||||
margin-left: 5px;
|
||||
margin-right: 10px;
|
||||
font-family: Ubuntu;
|
||||
`
|
||||
|
||||
export default NavigationCenter
|
||||
export default HomeHeader
|
||||
@@ -9,10 +9,10 @@ import { Switch } from 'antd'
|
||||
import { FC, useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import AddAssistantPopup from './components/AddAssistantPopup'
|
||||
import Assistants from './components/Assistants'
|
||||
import Chat from './components/Chat'
|
||||
import Navigation from './components/NavigationCenter'
|
||||
import AddAssistantPopup from '../../components/Popups/AddAssistantPopup'
|
||||
import Assistants from './Assistants'
|
||||
import Chat from './Chat'
|
||||
import Navigation from './Header'
|
||||
|
||||
let _activeAssistant: Assistant
|
||||
|
||||
@@ -51,7 +51,7 @@ const HomePage: FC = () => {
|
||||
</NavbarLeft>
|
||||
)}
|
||||
<Navigation activeAssistant={activeAssistant} />
|
||||
<NavbarRight style={{ justifyContent: 'flex-end', paddingRight: isWindows ? 140 : 8 }}>
|
||||
<NavbarRight style={{ justifyContent: 'flex-end', paddingRight: isWindows ? 140 : 12 }}>
|
||||
<ThemeSwitch
|
||||
checkedChildren={<i className="iconfont icon-theme icon-dark1" />}
|
||||
unCheckedChildren={<i className="iconfont icon-theme icon-theme-light" />}
|
||||
@@ -120,7 +120,7 @@ export const NewButton = styled.div`
|
||||
|
||||
const ThemeSwitch = styled(Switch)`
|
||||
-webkit-app-region: none;
|
||||
margin-right: 8px;
|
||||
margin-right: 10px;
|
||||
.icon-theme {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import { estimateInputTokenCount } from '@renderer/services/messages'
|
||||
import store, { useAppSelector } from '@renderer/store'
|
||||
import { setGenerating } from '@renderer/store/runtime'
|
||||
import { Assistant, Message, Topic } from '@renderer/types'
|
||||
import { uuid } from '@renderer/utils'
|
||||
import { Button, Popconfirm, Tag, Tooltip } from 'antd'
|
||||
import { delay, uuid } from '@renderer/utils'
|
||||
import { Button, Divider, Popconfirm, Tag, Tooltip } from 'antd'
|
||||
import TextArea, { TextAreaRef } from 'antd/es/input/TextArea'
|
||||
import dayjs from 'dayjs'
|
||||
import { debounce, isEmpty } from 'lodash'
|
||||
@@ -37,8 +37,9 @@ let _text = ''
|
||||
|
||||
const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
const [text, setText] = useState(_text)
|
||||
const [inputFocus, setInputFocus] = useState(false)
|
||||
const { addTopic } = useAssistant(assistant.id)
|
||||
const { sendMessageShortcut, showInputEstimatedTokens } = useSettings()
|
||||
const { sendMessageShortcut, showInputEstimatedTokens, fontSize } = useSettings()
|
||||
const [expended, setExpend] = useState(false)
|
||||
const [estimateTokenCount, setEstimateTokenCount] = useState(0)
|
||||
const generating = useAppSelector((state) => state.runtime.generating)
|
||||
@@ -59,7 +60,7 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
const message: Message = {
|
||||
id: uuid(),
|
||||
role: 'user',
|
||||
content: text,
|
||||
content: text.replace(/\n/g, ' \n'),
|
||||
assistantId: assistant.id,
|
||||
topicId: assistant.topics[0].id || uuid(),
|
||||
createdAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
@@ -69,6 +70,7 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
EventEmitter.emit(EVENT_NAMES.SEND_MESSAGE, message)
|
||||
|
||||
setText('')
|
||||
setTimeout(() => setText(''), 500)
|
||||
|
||||
setExpend(false)
|
||||
}, [assistant.id, assistant.topics, generating, text])
|
||||
@@ -80,10 +82,6 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
if (event.key === 'Escape') {
|
||||
return setExpend(false)
|
||||
}
|
||||
if (event.key === 'Enter' && event.shiftKey) {
|
||||
return sendMessage()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (sendMessageShortcut === 'Enter' && event.key === 'Enter') {
|
||||
@@ -106,7 +104,13 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
setActiveTopic(topic)
|
||||
}, [addTopic, setActiveTopic])
|
||||
|
||||
const clearTopic = () => EventEmitter.emit(EVENT_NAMES.CLEAR_MESSAGES)
|
||||
const clearTopic = async () => {
|
||||
if (generating) {
|
||||
onPause()
|
||||
await delay(1)
|
||||
}
|
||||
EventEmitter.emit(EVENT_NAMES.CLEAR_MESSAGES)
|
||||
}
|
||||
|
||||
const onPause = () => {
|
||||
window.keyv.set(EVENT_NAMES.CHAT_COMPLETION_PAUSED, true)
|
||||
@@ -145,24 +149,17 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
}, [assistant])
|
||||
|
||||
return (
|
||||
<Container id="inputbar" style={{ minHeight: expended ? '100%' : 'var(--input-bar-height)' }}>
|
||||
<Toolbar onDoubleClick={() => setExpend(!expended)}>
|
||||
<Container
|
||||
id="inputbar"
|
||||
style={{ minHeight: expended ? '60%' : 'var(--input-bar-height)' }}
|
||||
className={inputFocus ? 'focus' : ''}>
|
||||
<Toolbar>
|
||||
<ToolbarMenu>
|
||||
<Tooltip placement="top" title={t('chat.input.new_topic')} arrow>
|
||||
<ToolbarButton type="text" onClick={addNewTopic}>
|
||||
<PlusCircleOutlined />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={t('chat.input.topics')} arrow>
|
||||
<ToolbarButton type="text" onClick={() => EventEmitter.emit(EVENT_NAMES.SHOW_TOPIC_SIDEBAR)}>
|
||||
<HistoryOutlined />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={t('chat.input.settings')} arrow>
|
||||
<ToolbarButton type="text" onClick={() => EventEmitter.emit(EVENT_NAMES.SHOW_CHAT_SETTINGS)}>
|
||||
<ControlOutlined />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={t('chat.input.clear')} arrow>
|
||||
<Popconfirm
|
||||
title={t('chat.input.clear.content')}
|
||||
@@ -176,6 +173,16 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
</ToolbarButton>
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={t('chat.input.topics')} arrow>
|
||||
<ToolbarButton type="text" onClick={() => EventEmitter.emit(EVENT_NAMES.SHOW_TOPIC_SIDEBAR)}>
|
||||
<HistoryOutlined />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={t('chat.input.settings')} arrow>
|
||||
<ToolbarButton type="text" onClick={() => EventEmitter.emit(EVENT_NAMES.SHOW_CHAT_SETTINGS)}>
|
||||
<ControlOutlined />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" title={expended ? t('chat.input.collapse') : t('chat.input.expand')} arrow>
|
||||
<ToolbarButton type="text" onClick={() => setExpend(!expended)}>
|
||||
{expended ? <FullscreenExitOutlined /> : <FullscreenOutlined />}
|
||||
@@ -183,11 +190,22 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
</Tooltip>
|
||||
{showInputEstimatedTokens && (
|
||||
<TextCount>
|
||||
<Tooltip title={t('chat.input.context_count.tip')}>
|
||||
<Tag style={{ cursor: 'pointer' }}>{assistant?.settings?.contextCount ?? DEFAULT_CONEXTCOUNT}</Tag>
|
||||
</Tooltip>
|
||||
<Tooltip title={t('chat.input.estimated_tokens.tip')}>
|
||||
<Tag style={{ cursor: 'pointer' }}>↑ {`${inputTokenCount} / ${estimateTokenCount}`}</Tag>
|
||||
<Tooltip title={t('chat.input.context_count.tip') + ' | ' + t('chat.input.estimated_tokens.tip')}>
|
||||
<Tag
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
borderRadius: '6px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
padding: '2px 8px',
|
||||
borderWidth: 0.5
|
||||
}}>
|
||||
<i className="iconfont icon-history" style={{ marginRight: '3px' }} />
|
||||
{assistant?.settings?.contextCount ?? DEFAULT_CONEXTCOUNT}
|
||||
<Divider type="vertical" style={{ marginTop: 2, marginLeft: 5, marginRight: 5 }} />↑{inputTokenCount}
|
||||
<span style={{ margin: '0 2px' }}>/</span>
|
||||
{estimateTokenCount}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
</TextCount>
|
||||
)}
|
||||
@@ -195,12 +213,12 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
<ToolbarMenu>
|
||||
{generating && (
|
||||
<Tooltip placement="top" title={t('chat.input.pause')} arrow>
|
||||
<ToolbarButton type="text" onClick={onPause}>
|
||||
<PauseCircleOutlined style={{ color: 'var(--color-error)' }} />
|
||||
<ToolbarButton type="text" onClick={onPause} style={{ marginRight: -2, marginTop: 1 }}>
|
||||
<PauseCircleOutlined style={{ color: 'var(--color-error)', fontSize: 20 }} />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
<SendMessageButton sendMessage={sendMessage} />
|
||||
{!generating && <SendMessageButton sendMessage={sendMessage} disabled={generating || !text} />}
|
||||
</ToolbarMenu>
|
||||
</Toolbar>
|
||||
<Textarea
|
||||
@@ -213,6 +231,9 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
variant="borderless"
|
||||
ref={inputRef}
|
||||
styles={{ textarea: { paddingLeft: 0 } }}
|
||||
onFocus={() => setInputFocus(true)}
|
||||
onBlur={() => setInputFocus(false)}
|
||||
style={{ fontSize }}
|
||||
/>
|
||||
</Container>
|
||||
)
|
||||
@@ -221,10 +242,14 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
|
||||
const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
border-top: 0.5px solid var(--color-border);
|
||||
height: var(--input-bar-height);
|
||||
border: 1px solid var(--color-border-soft);
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
margin: 0 20px 15px 20px;
|
||||
border-radius: 10px;
|
||||
&.focus {
|
||||
}
|
||||
`
|
||||
|
||||
const Textarea = styled(TextArea)`
|
||||
@@ -233,13 +258,19 @@ const Textarea = styled(TextArea)`
|
||||
display: flex;
|
||||
flex: 1;
|
||||
margin: 0 15px 5px 15px;
|
||||
font-family: Ubuntu;
|
||||
resize: vertical;
|
||||
overflow: auto;
|
||||
width: auto;
|
||||
`
|
||||
|
||||
const Toolbar = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding: 3px 10px;
|
||||
padding: 0 8px;
|
||||
padding-top: 3px;
|
||||
padding-bottom: 0;
|
||||
`
|
||||
|
||||
const ToolbarMenu = styled.div`
|
||||
@@ -275,7 +306,6 @@ const TextCount = styled.div`
|
||||
padding: 2px;
|
||||
border-top-left-radius: 7px;
|
||||
user-select: none;
|
||||
margin-right: 10px;
|
||||
`
|
||||
|
||||
export default Inputbar
|
||||
24
src/renderer/src/pages/home/Inputbar/SendMessageButton.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { FC } from 'react'
|
||||
|
||||
interface Props {
|
||||
disabled: boolean
|
||||
sendMessage: () => void
|
||||
}
|
||||
|
||||
const SendMessageButton: FC<Props> = ({ disabled, sendMessage }) => {
|
||||
return (
|
||||
<i
|
||||
className="iconfont icon-ic_send"
|
||||
onClick={sendMessage}
|
||||
style={{
|
||||
cursor: disabled ? 'not-allowed' : 'pointer',
|
||||
color: disabled ? 'var(--color-text-3)' : 'var(--color-primary)',
|
||||
fontSize: 22,
|
||||
transition: 'all 0.2s',
|
||||
marginRight: 2
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default SendMessageButton
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CheckOutlined, CopyOutlined } from '@ant-design/icons'
|
||||
import { CheckOutlined } from '@ant-design/icons'
|
||||
import CopyIcon from '@renderer/components/Icons/CopyIcon'
|
||||
import { initMermaid } from '@renderer/init'
|
||||
import { useTheme } from '@renderer/providers/ThemeProvider'
|
||||
import { ThemeMode } from '@renderer/store/settings'
|
||||
@@ -39,7 +40,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ children, className, ...rest }) =
|
||||
<div>
|
||||
<CodeHeader>
|
||||
<CodeLanguage>{'<' + match[1].toUpperCase() + '>'}</CodeLanguage>
|
||||
{!copied && <CopyOutlined className="copy" onClick={onCopy} />}
|
||||
{!copied && <CopyIcon className="copy" onClick={onCopy} />}
|
||||
{copied && <CheckOutlined style={{ color: 'var(--color-primary)' }} />}
|
||||
</CodeHeader>
|
||||
<SyntaxHighlighter
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
CheckOutlined,
|
||||
CopyOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
MenuOutlined,
|
||||
@@ -17,15 +16,15 @@ import { useRuntime } from '@renderer/hooks/useStore'
|
||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/event'
|
||||
import { Message, Model } from '@renderer/types'
|
||||
import { firstLetter, removeLeadingEmoji } from '@renderer/utils'
|
||||
import { Avatar, Dropdown, Popconfirm, Tooltip } from 'antd'
|
||||
import { Alert, Avatar, Dropdown, Popconfirm, Tooltip } from 'antd'
|
||||
import dayjs from 'dayjs'
|
||||
import { upperFirst } from 'lodash'
|
||||
import { FC, memo, useCallback, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import Markdown from './markdown/Markdown'
|
||||
import SelectModelDropdown from './SelectModelDropdown'
|
||||
import SelectModelDropdown from '../components/SelectModelDropdown'
|
||||
import Markdown from '../Markdown/Markdown'
|
||||
|
||||
interface Props {
|
||||
message: Message
|
||||
@@ -39,7 +38,7 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
const avatar = useAvatar()
|
||||
const { t } = useTranslation()
|
||||
const { assistant, model, setModel } = useAssistant(message.assistantId)
|
||||
const { userName, showMessageDivider, messageFont } = useSettings()
|
||||
const { userName, showMessageDivider, messageFont, fontSize } = useSettings()
|
||||
const { generating } = useRuntime()
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
@@ -47,6 +46,7 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
const isUserMessage = message.role === 'user'
|
||||
const isAssistantMessage = message.role === 'assistant'
|
||||
const canRegenerate = isLastMessage && isAssistantMessage
|
||||
const showMetadata = Boolean(message.usage) && !generating
|
||||
|
||||
const onCopy = useCallback(() => {
|
||||
navigator.clipboard.writeText(message.content)
|
||||
@@ -67,9 +67,9 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
|
||||
const getUserName = useCallback(() => {
|
||||
if (message.id === 'assistant') return assistant?.name
|
||||
if (message.role === 'assistant') return upperFirst(message.modelId)
|
||||
if (message.role === 'assistant') return upperFirst(model.name || model.id)
|
||||
return userName || t('common.you')
|
||||
}, [assistant?.name, message.id, message.modelId, message.role, t, userName])
|
||||
}, [assistant?.name, message.id, message.role, model.id, model.name, t, userName])
|
||||
|
||||
const fontFamily = useMemo(() => {
|
||||
return messageFont === 'serif' ? FONT_FAMILY.replace('sans-serif', 'serif').replace('Ubuntu, ', '') : FONT_FAMILY
|
||||
@@ -95,16 +95,39 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
[t, message]
|
||||
)
|
||||
|
||||
const MessageItem = useCallback(() => {
|
||||
if (message.status === 'sending') {
|
||||
return (
|
||||
<MessageContentLoading>
|
||||
<SyncOutlined spin size={24} />
|
||||
</MessageContentLoading>
|
||||
)
|
||||
}
|
||||
|
||||
if (message.status === 'error') {
|
||||
return (
|
||||
<Alert
|
||||
message={t('error.chat.response')}
|
||||
description={<Markdown message={message} />}
|
||||
type="error"
|
||||
style={{ marginBottom: 15 }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return <Markdown message={message} />
|
||||
}, [message])
|
||||
|
||||
return (
|
||||
<MessageContainer key={message.id} className="message" style={{ border: messageBorder }}>
|
||||
<MessageContainer key={message.id} className="message">
|
||||
<MessageHeader>
|
||||
<AvatarWrapper>
|
||||
{isAssistantMessage ? (
|
||||
<Avatar src={avatarSource} size={35}>
|
||||
<Avatar src={avatarSource} size={35} style={{ borderRadius: '20%' }}>
|
||||
{avatarName}
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar src={avatar} size={35} />
|
||||
<Avatar src={avatar} size={35} style={{ borderRadius: '20%' }} />
|
||||
)}
|
||||
<UserWrap>
|
||||
<UserName>{username}</UserName>
|
||||
@@ -112,62 +135,60 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
</UserWrap>
|
||||
</AvatarWrapper>
|
||||
</MessageHeader>
|
||||
<MessageContent style={{ fontFamily }}>
|
||||
{message.status === 'sending' && (
|
||||
<MessageContentLoading>
|
||||
<SyncOutlined spin size={24} />
|
||||
</MessageContentLoading>
|
||||
)}
|
||||
{message.status !== 'sending' && <Markdown message={message} />}
|
||||
{message.usage && !generating && (
|
||||
<MessageMetadata>
|
||||
Tokens: {message.usage.total_tokens} | ↑{message.usage.prompt_tokens}↓{message.usage.completion_tokens}
|
||||
</MessageMetadata>
|
||||
)}
|
||||
{showMenu && (
|
||||
<MenusBar className={`menubar ${isLastMessage && 'show'} ${(!isLastMessage || isUserMessage) && 'user'}`}>
|
||||
{message.role === 'user' && (
|
||||
<Tooltip title="Edit" mouseEnterDelay={0.8}>
|
||||
<ActionButton onClick={onEdit}>
|
||||
<EditOutlined />
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip title={t('common.copy')} mouseEnterDelay={0.8}>
|
||||
<ActionButton onClick={onCopy}>
|
||||
{!copied && <CopyOutlined />}
|
||||
{copied && <CheckOutlined style={{ color: 'var(--color-primary)' }} />}
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
{canRegenerate && (
|
||||
<SelectModelDropdown model={model} onSelect={onRegenerate} placement="topRight">
|
||||
<Tooltip title={t('common.regenerate')} mouseEnterDelay={0.8}>
|
||||
<ActionButton>
|
||||
<SyncOutlined />
|
||||
<MessageContent style={{ fontFamily, fontSize }}>
|
||||
<MessageItem />
|
||||
<MessageFooter style={{ border: messageBorder }}>
|
||||
{showMenu && (
|
||||
<MenusBar className={`menubar ${isLastMessage && 'show'} ${(!isLastMessage || isUserMessage) && 'user'}`}>
|
||||
{message.role === 'user' && (
|
||||
<Tooltip title="Edit" mouseEnterDelay={0.8}>
|
||||
<ActionButton onClick={onEdit}>
|
||||
<EditOutlined />
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
</SelectModelDropdown>
|
||||
)}
|
||||
<Popconfirm
|
||||
title={t('message.message.delete.content')}
|
||||
okButtonProps={{ danger: true }}
|
||||
icon={<QuestionCircleOutlined style={{ color: 'red' }} />}
|
||||
onConfirm={() => onDeleteMessage?.(message)}>
|
||||
<Tooltip title={t('common.delete')} mouseEnterDelay={1}>
|
||||
<ActionButton>
|
||||
<DeleteOutlined />
|
||||
)}
|
||||
<Tooltip title={t('common.copy')} mouseEnterDelay={0.8}>
|
||||
<ActionButton onClick={onCopy}>
|
||||
{!copied && <i className="iconfont icon-copy"></i>}
|
||||
{copied && <CheckOutlined style={{ color: 'var(--color-primary)' }} />}
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
{!isUserMessage && (
|
||||
<Dropdown menu={{ items: dropdownItems }} trigger={['click']} placement="topRight" arrow>
|
||||
<ActionButton>
|
||||
<MenuOutlined />
|
||||
</ActionButton>
|
||||
</Dropdown>
|
||||
)}
|
||||
</MenusBar>
|
||||
)}
|
||||
{canRegenerate && (
|
||||
<SelectModelDropdown model={model} onSelect={onRegenerate} placement="topRight">
|
||||
<Tooltip title={t('common.regenerate')} mouseEnterDelay={0.8}>
|
||||
<ActionButton>
|
||||
<SyncOutlined />
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
</SelectModelDropdown>
|
||||
)}
|
||||
<Popconfirm
|
||||
title={t('message.message.delete.content')}
|
||||
okButtonProps={{ danger: true }}
|
||||
icon={<QuestionCircleOutlined style={{ color: 'red' }} />}
|
||||
onConfirm={() => onDeleteMessage?.(message)}>
|
||||
<Tooltip title={t('common.delete')} mouseEnterDelay={1}>
|
||||
<ActionButton>
|
||||
<DeleteOutlined />
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
{!isUserMessage && (
|
||||
<Dropdown menu={{ items: dropdownItems }} trigger={['click']} placement="topRight" arrow>
|
||||
<ActionButton>
|
||||
<MenuOutlined />
|
||||
</ActionButton>
|
||||
</Dropdown>
|
||||
)}
|
||||
</MenusBar>
|
||||
)}
|
||||
{showMetadata && (
|
||||
<MessageMetadata>
|
||||
Tokens: {message?.usage?.total_tokens} | ↑{message?.usage?.prompt_tokens} | ↓
|
||||
{message?.usage?.completion_tokens}
|
||||
</MessageMetadata>
|
||||
)}
|
||||
</MessageFooter>
|
||||
</MessageContent>
|
||||
</MessageContainer>
|
||||
)
|
||||
@@ -176,9 +197,8 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
|
||||
const MessageContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
padding: 0 20px;
|
||||
position: relative;
|
||||
border-bottom: 0.5px dotted var(--color-border);
|
||||
.menubar {
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
@@ -187,8 +207,8 @@ const MessageContainer = styled.div`
|
||||
}
|
||||
&.user {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
right: 15px;
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
@@ -239,6 +259,16 @@ const MessageContent = styled.div`
|
||||
margin-top: 5px;
|
||||
`
|
||||
|
||||
const MessageFooter = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 2px 0;
|
||||
margin: 2px 0 8px 0;
|
||||
border-top: 0.5px dashed var(--color-border);
|
||||
`
|
||||
|
||||
const MessageContentLoading = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -252,17 +282,18 @@ const MenusBar = styled.div`
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: -5px;
|
||||
`
|
||||
|
||||
const MessageMetadata = styled.div`
|
||||
font-size: 12px;
|
||||
color: var(--color-text-2);
|
||||
user-select: text;
|
||||
margin: 2px 0;
|
||||
`
|
||||
|
||||
const ActionButton = styled.div`
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -270,7 +301,15 @@ const ActionButton = styled.div`
|
||||
align-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
.anticon {
|
||||
transition: all 0.3s ease;
|
||||
&:hover {
|
||||
background-color: var(--color-background-mute);
|
||||
.anticon {
|
||||
color: var(--color-text-1);
|
||||
}
|
||||
}
|
||||
.anticon,
|
||||
.iconfont {
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: var(--color-icon);
|
||||
@@ -1,19 +1,21 @@
|
||||
import { useAssistant } from '@renderer/hooks/useAssistant'
|
||||
import { useProviderByAssistant } from '@renderer/hooks/useProvider'
|
||||
import { getTopic } from '@renderer/hooks/useTopic'
|
||||
import { fetchChatCompletion, fetchMessagesSummary } from '@renderer/services/api'
|
||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/event'
|
||||
import { estimateHistoryTokenCount, filterAtMessages } from '@renderer/services/messages'
|
||||
import { estimateHistoryTokenCount, filterMessages } from '@renderer/services/messages'
|
||||
import LocalStorage from '@renderer/services/storage'
|
||||
import { Assistant, Message, Model, Topic } from '@renderer/types'
|
||||
import { getBriefInfo, runAsyncFunction, uuid } from '@renderer/utils'
|
||||
import { t } from 'i18next'
|
||||
import localforage from 'localforage'
|
||||
import { debounce, last, reverse } from 'lodash'
|
||||
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { last, reverse } from 'lodash'
|
||||
import { FC, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import Suggestions from '../components/Suggestions'
|
||||
import MessageItem from './Message'
|
||||
import Suggestions from './Suggestions'
|
||||
import Prompt from './Prompt'
|
||||
|
||||
interface Props {
|
||||
assistant: Assistant
|
||||
@@ -27,19 +29,6 @@ const Messages: FC<Props> = ({ assistant, topic }) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const { updateTopic } = useAssistant(assistant.id)
|
||||
|
||||
const assistantDefaultMessage: Message = useMemo(
|
||||
() => ({
|
||||
id: 'assistant',
|
||||
role: 'assistant',
|
||||
content: assistant.description || assistant.prompt || t('chat.default.description'),
|
||||
assistantId: assistant.id,
|
||||
topicId: topic.id,
|
||||
status: 'pending',
|
||||
createdAt: new Date().toISOString()
|
||||
}),
|
||||
[assistant.description, assistant.id, assistant.prompt, topic.id]
|
||||
)
|
||||
|
||||
const onSendMessage = useCallback(
|
||||
(message: Message) => {
|
||||
const _messages = [...messages, message]
|
||||
@@ -50,9 +39,10 @@ const Messages: FC<Props> = ({ assistant, topic }) => {
|
||||
)
|
||||
|
||||
const autoRenameTopic = useCallback(async () => {
|
||||
if (topic.name === t('chat.default.topic.name') && messages.length >= 2) {
|
||||
const _topic = getTopic(assistant, topic.id)
|
||||
if (_topic && _topic.name === t('chat.default.topic.name') && messages.length >= 2) {
|
||||
const summaryText = await fetchMessagesSummary({ messages, assistant })
|
||||
summaryText && updateTopic({ ...topic, name: summaryText })
|
||||
summaryText && updateTopic({ ..._topic, name: summaryText })
|
||||
}
|
||||
}, [assistant, messages, topic, updateTopic])
|
||||
|
||||
@@ -77,7 +67,7 @@ const Messages: FC<Props> = ({ assistant, topic }) => {
|
||||
setTimeout(() => EventEmitter.emit(EVENT_NAMES.AI_AUTO_RENAME), 100)
|
||||
}),
|
||||
EventEmitter.on(EVENT_NAMES.REGENERATE_MESSAGE, async (model: Model) => {
|
||||
const lastUserMessage = last(filterAtMessages(messages).filter((m) => m.role === 'user'))
|
||||
const lastUserMessage = last(filterMessages(messages).filter((m) => m.role === 'user'))
|
||||
if (lastUserMessage) {
|
||||
const content = `[@${model.name}](#) ${getBriefInfo(lastUserMessage.content)}`
|
||||
onSendMessage({ ...lastUserMessage, id: uuid(), type: '@', content })
|
||||
@@ -106,14 +96,9 @@ const Messages: FC<Props> = ({ assistant, topic }) => {
|
||||
})
|
||||
}, [topic.id])
|
||||
|
||||
const scrollTop = useCallback(
|
||||
debounce(() => containerRef.current?.scrollTo({ top: 100000, behavior: 'auto' }), 500),
|
||||
[]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
scrollTop()
|
||||
}, [messages, lastMessage, scrollTop])
|
||||
setTimeout(() => containerRef.current?.scrollTo({ top: containerRef.current.scrollHeight, behavior: 'auto' }), 0)
|
||||
}, [messages])
|
||||
|
||||
useEffect(() => {
|
||||
EventEmitter.emit(EVENT_NAMES.ESTIMATED_TOKEN_COUNT, estimateHistoryTokenCount(assistant, messages))
|
||||
@@ -126,7 +111,7 @@ const Messages: FC<Props> = ({ assistant, topic }) => {
|
||||
{reverse([...messages]).map((message, index) => (
|
||||
<MessageItem key={message.id} message={message} showMenu index={index} onDeleteMessage={onDeleteMessage} />
|
||||
))}
|
||||
<MessageItem message={assistantDefaultMessage} />
|
||||
<Prompt assistant={assistant} key={assistant.prompt} />
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
@@ -137,6 +122,7 @@ const Container = styled.div`
|
||||
overflow-y: auto;
|
||||
flex-direction: column-reverse;
|
||||
max-height: calc(100vh - var(--input-bar-height) - var(--navbar-height));
|
||||
padding: 10px 0;
|
||||
`
|
||||
|
||||
export default Messages
|
||||