diff --git a/.gitignore b/.gitignore index a7450567..a38c9c13 100644 --- a/.gitignore +++ b/.gitignore @@ -19,12 +19,6 @@ lerna-debug.log* *.sln *.sw? -# NPM -npm/*/* -!npm/*/dist -!npm/*/package.json -!npm/*/*.js - # Yarn .pnp.* .yarn/* diff --git a/npm/artifacts/README.md b/npm/artifacts/README.md new file mode 100644 index 00000000..944e8916 --- /dev/null +++ b/npm/artifacts/README.md @@ -0,0 +1 @@ +# Cherry Studio Artifacts diff --git a/npm/artifacts/package.json b/npm/artifacts/package.json new file mode 100644 index 00000000..9adacafa --- /dev/null +++ b/npm/artifacts/package.json @@ -0,0 +1,19 @@ +{ + "name": "@cherry-studio/artifacts", + "version": "0.1.0", + "description": "Cherry Studio Artifacts", + "main": "index.js", + "homepage": "https://github.com/kangfenmao/cherry-studio/blob/main/npm/artifacts", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "artifacts" + ], + "author": "kangfenmao", + "license": "ISC" +} diff --git a/npm/artifacts/statics/word-explanation-card.css b/npm/artifacts/statics/word-explanation-card.css new file mode 100644 index 00000000..fadf5800 --- /dev/null +++ b/npm/artifacts/statics/word-explanation-card.css @@ -0,0 +1,108 @@ +:root { + /* 莫兰迪色系:使用柔和、低饱和度的颜色 */ + --primary-color: #b6b5a7; /* 莫兰迪灰褐色,用于背景文字 */ + --secondary-color: #9a8f8f; /* 莫兰迪灰棕色,用于标题背景 */ + --accent-color: #c5b4a0; /* 莫兰迪淡棕色,用于强调元素 */ + --background-color: #e8e3de; /* 莫兰迪米色,用于页面背景 */ + --text-color: #5b5b5b; /* 莫兰迪深灰色,用于主要文字 */ + --light-text-color: #8c8c8c; /* 莫兰迪中灰色,用于次要文字 */ + --divider-color: #d1cbc3; /* 莫兰迪浅灰色,用于分隔线 */ +} +body, +html { + margin: 0; + padding: 0; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + background-color: var(--background-color); /* 使用莫兰迪米色作为页面背景 */ + font-family: 'Noto Sans SC', sans-serif; + color: var(--text-color); /* 使用莫兰迪深灰色作为主要文字颜色 */ +} +.card { + width: 300px; + height: 500px; + background-color: #f2ede9; /* 莫兰迪浅米色,用于卡片背景 */ + border-radius: 20px; + box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1); + overflow: hidden; + position: relative; + display: flex; + flex-direction: column; +} +.header { + background-color: var(--secondary-color); /* 使用莫兰迪灰棕色作为标题背景 */ + color: #f2ede9; /* 浅色文字与深色背景形成对比 */ + padding: 20px; + text-align: left; + position: relative; + z-index: 1; +} +h1 { + font-family: 'Noto Serif SC', serif; + font-size: 20px; + margin: 0; + font-weight: 700; +} +.content { + padding: 30px 20px; + display: flex; + flex-direction: column; + flex-grow: 1; +} +.word { + text-align: left; + margin-bottom: 20px; +} +.word-main { + font-family: 'Noto Serif SC', serif; + font-size: 36px; + color: var(--text-color); /* 使用莫兰迪深灰色作为主要词汇颜色 */ + margin-bottom: 10px; + position: relative; +} +.word-main::after { + content: ''; + position: absolute; + left: 0; + bottom: -5px; + width: 50px; + height: 3px; + background-color: var(--accent-color); /* 使用莫兰迪淡棕色作为下划线 */ +} +.word-sub { + font-size: 14px; + color: var(--light-text-color); /* 使用莫兰迪中灰色作为次要文字颜色 */ + margin: 5px 0; +} +.divider { + width: 100%; + height: 1px; + background-color: var(--divider-color); /* 使用莫兰迪浅灰色作为分隔线 */ + margin: 20px 0; +} +.explanation { + font-size: 18px; + line-height: 1.6; + text-align: left; + flex-grow: 1; + display: flex; + flex-direction: column; + justify-content: center; +} +.quote { + position: relative; + padding-left: 20px; + border-left: 3px solid var(--accent-color); /* 使用莫兰迪淡棕色作为引用边框 */ +} +.background-text { + position: absolute; + font-size: 150px; + color: rgba(182, 181, 167, 0.15); /* 使用莫兰迪灰褐色的透明版本作为背景文字 */ + z-index: 0; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-weight: bold; +} diff --git a/package.json b/package.json index b50de592..69fbab82 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "homepage": "https://github.com/kangfenmao/cherry-studio", "workspaces": { "packages": [ - "local" + "local", + "npm/*" ] }, "scripts": { diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index c0a4cc0c..030473a2 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -9,7 +9,6 @@ import Sidebar from './components/app/Sidebar' import TopViewContainer from './components/TopView' import AntdProvider from './context/AntdProvider' import { ThemeProvider } from './context/ThemeProvider' -import AgentEditPage from './pages/agents/AgentEditPage' import AgentsPage from './pages/agents/AgentsPage' import AppsPage from './pages/apps/AppsPage' import FilesPage from './pages/files/FilesPage' @@ -31,7 +30,6 @@ function App(): JSX.Element { } /> } /> } /> - } /> } /> } /> } /> diff --git a/src/renderer/src/assets/styles/scrollbar.scss b/src/renderer/src/assets/styles/scrollbar.scss index e4c9e7c5..c7549a91 100644 --- a/src/renderer/src/assets/styles/scrollbar.scss +++ b/src/renderer/src/assets/styles/scrollbar.scss @@ -10,7 +10,6 @@ ::-webkit-scrollbar-thumb { background: var(--color-scrollbar-thumb); - border-radius: 4px; &:hover { background: var(--color-scrollbar-thumb-hover); } diff --git a/src/renderer/src/components/AssistantSettings/AssistantMessagesSettings.tsx b/src/renderer/src/components/AssistantSettings/AssistantMessagesSettings.tsx new file mode 100644 index 00000000..219efbe4 --- /dev/null +++ b/src/renderer/src/components/AssistantSettings/AssistantMessagesSettings.tsx @@ -0,0 +1,158 @@ +import { DeleteOutlined, PlusOutlined } from '@ant-design/icons' +import { Assistant, AssistantMessage, AssistantSettings } from '@renderer/types' +import { Button, Card, Col, Divider, Form as FormAntd, FormInstance, Row, Space, Switch } from 'antd' +import TextArea from 'antd/es/input/TextArea' +import { FC, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' +import styled from 'styled-components' + +interface Props { + assistant: Assistant + updateAssistant: (assistant: Assistant) => void + updateAssistantSettings: (settings: Partial) => void +} + +const AssistantMessagesSettings: FC = ({ assistant, updateAssistant, updateAssistantSettings }) => { + const { t } = useTranslation() + const [form] = Form.useForm() + const formRef = useRef(null) + const [messages, setMessagess] = useState(assistant?.messages || []) + const [hideMessages, setHideMessages] = useState(assistant?.settings?.hideMessages || false) + + const onSave = () => { + // 检查是否有空对话组 + for (let i = 0; i < messages.length; i += 2) { + const userContent = messages[i].content.trim() + const assistantContent = messages[i + 1]?.content.trim() + if (userContent === '' || assistantContent === '') { + window.modal.error({ + centered: true, + content: t('agents.edit.message.empty.content') + }) + return + } + } + + // 过滤掉空消息并将消息分组 + const filteredMessagess = messages.reduce((acc, conv, index) => { + if (index % 2 === 0) { + const userContent = conv.content.trim() + const assistantContent = messages[index + 1]?.content.trim() + if (userContent !== '' || assistantContent !== '') { + acc.push({ role: 'user', content: userContent }, { role: 'assistant', content: assistantContent }) + } + } + return acc + }, [] as AssistantMessage[]) + + updateAssistant({ + ...assistant, + messages: filteredMessagess + }) + + window.message.success({ content: t('message.save.success.title'), key: 'save-messages' }) + } + + const addMessages = () => { + setMessagess([...messages, { role: 'user', content: '' }, { role: 'assistant', content: '' }]) + } + + const updateMessages = (index: number, role: 'user' | 'assistant', content: string) => { + const newMessagess = [...messages] + newMessagess[index] = { role, content } + setMessagess(newMessagess) + } + + const deleteMessages = (index: number) => { + const newMessagess = [...messages] + newMessagess.splice(index, 2) // 删除用户和助手的对话 + setMessagess(newMessagess) + } + + return ( + +
+ + { + setHideMessages(checked) + updateAssistantSettings({ hideMessages: checked }) + }} + /> + + + + {messages.map( + (_, index) => + index % 2 === 0 && ( + } type="text" danger onClick={() => deleteMessages(index)} />}> + + + + + +