diff --git a/package.json b/package.json index 116b28f2..dc17c286 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "rollup-plugin-visualizer": "^5.12.0", "sass": "^1.77.2", "shiki": "^1.22.2", + "string-width": "^7.2.0", "styled-components": "^6.1.11", "tinycolor2": "^1.6.0", "typescript": "^5.6.2", diff --git a/src/main/services/KnowledgeService.ts b/src/main/services/KnowledgeService.ts index a1fa8104..43b11ebe 100644 --- a/src/main/services/KnowledgeService.ts +++ b/src/main/services/KnowledgeService.ts @@ -42,20 +42,20 @@ class KnowledgeService { .setEmbeddingModel( apiVersion ? new AzureOpenAiEmbeddings({ - azureOpenAIApiKey: apiKey, - azureOpenAIApiVersion: apiVersion, - azureOpenAIApiDeploymentName: model, - azureOpenAIApiInstanceName: getInstanceName(baseURL), - dimensions, - batchSize - }) + azureOpenAIApiKey: apiKey, + azureOpenAIApiVersion: apiVersion, + azureOpenAIApiDeploymentName: model, + azureOpenAIApiInstanceName: getInstanceName(baseURL), + dimensions, + batchSize + }) : new OpenAiEmbeddings({ - model, - apiKey, - configuration: { baseURL }, - dimensions, - batchSize - }) + model, + apiKey, + configuration: { baseURL }, + dimensions, + batchSize + }) ) .setVectorDatabase(new LibSqlDb({ path: path.join(this.storageDir, id) })) .build() diff --git a/src/renderer/src/components/Layout/index.ts b/src/renderer/src/components/Layout/index.ts index f3ff7203..2e5a0b60 100644 --- a/src/renderer/src/components/Layout/index.ts +++ b/src/renderer/src/components/Layout/index.ts @@ -95,14 +95,14 @@ export const Box = styled.div` box-sizing: border-box; border: ${(props) => props?.border || 'none'}; gap: ${(p) => (p.gap ? getElementValue(p.gap) : 0)}; - margin: ${(props) => (props.m || props.margin ? props.m ?? props.margin : 'none')}; + margin: ${(props) => (props.m || props.margin ? (props.m ?? props.margin) : 'none')}; margin-top: ${(props) => (props.mt || props.marginTop ? getElementValue(props.mt || props.marginTop) : 'default')}; margin-bottom: ${(props) => props.mb || props.marginBottom ? getElementValue(props.mb ?? props.marginBottom) : 'default'}; margin-left: ${(props) => (props.ml || props.marginLeft ? getElementValue(props.ml ?? props.marginLeft) : 'default')}; margin-right: ${(props) => props.mr || props.marginRight ? getElementValue(props.mr ?? props.marginRight) : 'default'}; - padding: ${(props) => (props.p || props.padding ? props.p ?? props.padding : 'none')}; + padding: ${(props) => (props.p || props.padding ? (props.p ?? props.padding) : 'none')}; padding-top: ${(props) => (props.pt || props.paddingTop ? getElementValue(props.pt ?? props.paddingTop) : 'auto')}; padding-bottom: ${(props) => props.pb || props.paddingBottom ? getElementValue(props.pb ?? props.paddingBottom) : 'auto'}; diff --git a/src/renderer/src/pages/home/Messages/MessageContent.tsx b/src/renderer/src/pages/home/Messages/MessageContent.tsx index bf03a1c8..63b29aa3 100644 --- a/src/renderer/src/pages/home/Messages/MessageContent.tsx +++ b/src/renderer/src/pages/home/Messages/MessageContent.tsx @@ -150,11 +150,11 @@ const CitationLink = styled.a` line-height: 1.6; text-decoration: none; color: var(--color-text-1); - + .hostname { color: var(--color-link); } - + &:hover { text-decoration: underline; } diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index d3338e1c..fdbdda99 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -5,7 +5,8 @@ import { EditOutlined, FolderOutlined, PushpinOutlined, - UploadOutlined} from '@ant-design/icons' + UploadOutlined +} from '@ant-design/icons' import DragableList from '@renderer/components/DragableList' import PromptPopup from '@renderer/components/Popups/PromptPopup' import Scrollbar from '@renderer/components/Scrollbar' @@ -149,7 +150,7 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic key: 'markdown', onClick: () => exportTopicAsMarkdown(topic) }, - + { label: t('chat.topics.export.word'), key: 'word', @@ -162,7 +163,7 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic label: t('chat.topics.export.notion'), key: 'notion', onClick: () => exportTopicToNotion(topic) - }, + } ] } ] @@ -219,9 +220,9 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic className="menu" onClick={(e) => { e.stopPropagation() - if (assistant.topics.length === 1) { - return onClearMessages() - } + if (assistant.topics.length === 1) { + return onClearMessages() + } onDeleteTopic(topic) }}> diff --git a/src/renderer/src/store/runtime.ts b/src/renderer/src/store/runtime.ts index 8c47f981..0f1359c2 100644 --- a/src/renderer/src/store/runtime.ts +++ b/src/renderer/src/store/runtime.ts @@ -86,8 +86,7 @@ const runtimeSlice = createSlice({ }, setExportState: (state, action: PayloadAction>) => { state.export = { ...state.export, ...action.payload } - }, - + } } }) diff --git a/src/renderer/src/utils/export.ts b/src/renderer/src/utils/export.ts index c6804fe1..d00f95c4 100644 --- a/src/renderer/src/utils/export.ts +++ b/src/renderer/src/utils/export.ts @@ -49,20 +49,20 @@ export const exportTopicToNotion = async (topic: Topic) => { return } try { - const notion = new Client({ auth: notionApiKey }); - const markdown = await topicToMarkdown(topic); + const notion = new Client({ auth: notionApiKey }) + const markdown = await topicToMarkdown(topic) const requestBody = JSON.stringify({ md: markdown }) const res = await fetch('https://md2notion.hilars.dev', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: requestBody - }); + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: requestBody + }) - const data = await res.json(); - const notionBlocks = data; + const data = await res.json() + const notionBlocks = data const response = await notion.pages.create({ parent: { database_id: notionDatabaseID }, @@ -72,12 +72,11 @@ export const exportTopicToNotion = async (topic: Topic) => { } }, children: notionBlocks // 使用转换后的块 - }); + }) window.message.success({ content: i18n.t('message.success.notion.export'), key: 'notion-success' }) return response - - } catch (error:any) { + } catch (error: any) { window.message.error({ content: i18n.t('message.error.notion.export'), key: 'notion-error' }) return null } finally { @@ -85,4 +84,4 @@ export const exportTopicToNotion = async (topic: Topic) => { isExporting: false }) } -}; +} diff --git a/yarn.lock b/yarn.lock index 773699ba..e5f54689 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3072,6 +3072,7 @@ __metadata: rollup-plugin-visualizer: "npm:^5.12.0" sass: "npm:^1.77.2" shiki: "npm:^1.22.2" + string-width: "npm:^7.2.0" styled-components: "npm:^6.1.11" tinycolor2: "npm:^1.6.0" tokenx: "npm:^0.4.1" @@ -5405,6 +5406,13 @@ __metadata: languageName: node linkType: hard +"emoji-regex@npm:^10.3.0": + version: 10.4.0 + resolution: "emoji-regex@npm:10.4.0" + checksum: 10c0/a3fcedfc58bfcce21a05a5f36a529d81e88d602100145fcca3dc6f795e3c8acc4fc18fe773fbf9b6d6e9371205edb3afa2668ec3473fa2aa7fd47d2a9d46482d + languageName: node + linkType: hard + "emoji-regex@npm:^8.0.0": version: 8.0.0 resolution: "emoji-regex@npm:8.0.0" @@ -6558,6 +6566,13 @@ __metadata: languageName: node linkType: hard +"get-east-asian-width@npm:^1.0.0": + version: 1.3.0 + resolution: "get-east-asian-width@npm:1.3.0" + checksum: 10c0/1a049ba697e0f9a4d5514c4623781c5246982bdb61082da6b5ae6c33d838e52ce6726407df285cdbb27ec1908b333cf2820989bd3e986e37bb20979437fdf34b + languageName: node + linkType: hard + "get-intrinsic@npm:^1.2.4, get-intrinsic@npm:^1.2.5, get-intrinsic@npm:^1.2.6, get-intrinsic@npm:^1.2.7": version: 1.2.7 resolution: "get-intrinsic@npm:1.2.7" @@ -13016,6 +13031,17 @@ __metadata: languageName: node linkType: hard +"string-width@npm:^7.2.0": + version: 7.2.0 + resolution: "string-width@npm:7.2.0" + dependencies: + emoji-regex: "npm:^10.3.0" + get-east-asian-width: "npm:^1.0.0" + strip-ansi: "npm:^7.1.0" + checksum: 10c0/eb0430dd43f3199c7a46dcbf7a0b34539c76fe3aa62763d0b0655acdcbdf360b3f66f3d58ca25ba0205f42ea3491fa00f09426d3b7d3040e506878fc7664c9b9 + languageName: node + linkType: hard + "string.prototype.matchall@npm:^4.0.12": version: 4.0.12 resolution: "string.prototype.matchall@npm:4.0.12" @@ -13131,7 +13157,7 @@ __metadata: languageName: node linkType: hard -"strip-ansi@npm:^7.0.1": +"strip-ansi@npm:^7.0.1, strip-ansi@npm:^7.1.0": version: 7.1.0 resolution: "strip-ansi@npm:7.1.0" dependencies: