style: code format

This commit is contained in:
kangfenmao 2025-02-13 11:40:55 +08:00
parent c6f136caa2
commit b9affe3eb8
8 changed files with 66 additions and 40 deletions

View File

@ -143,6 +143,7 @@
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.2", "sass": "^1.77.2",
"shiki": "^1.22.2", "shiki": "^1.22.2",
"string-width": "^7.2.0",
"styled-components": "^6.1.11", "styled-components": "^6.1.11",
"tinycolor2": "^1.6.0", "tinycolor2": "^1.6.0",
"typescript": "^5.6.2", "typescript": "^5.6.2",

View File

@ -42,20 +42,20 @@ class KnowledgeService {
.setEmbeddingModel( .setEmbeddingModel(
apiVersion apiVersion
? new AzureOpenAiEmbeddings({ ? new AzureOpenAiEmbeddings({
azureOpenAIApiKey: apiKey, azureOpenAIApiKey: apiKey,
azureOpenAIApiVersion: apiVersion, azureOpenAIApiVersion: apiVersion,
azureOpenAIApiDeploymentName: model, azureOpenAIApiDeploymentName: model,
azureOpenAIApiInstanceName: getInstanceName(baseURL), azureOpenAIApiInstanceName: getInstanceName(baseURL),
dimensions, dimensions,
batchSize batchSize
}) })
: new OpenAiEmbeddings({ : new OpenAiEmbeddings({
model, model,
apiKey, apiKey,
configuration: { baseURL }, configuration: { baseURL },
dimensions, dimensions,
batchSize batchSize
}) })
) )
.setVectorDatabase(new LibSqlDb({ path: path.join(this.storageDir, id) })) .setVectorDatabase(new LibSqlDb({ path: path.join(this.storageDir, id) }))
.build() .build()

View File

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

View File

@ -5,7 +5,8 @@ import {
EditOutlined, EditOutlined,
FolderOutlined, FolderOutlined,
PushpinOutlined, PushpinOutlined,
UploadOutlined} from '@ant-design/icons' UploadOutlined
} from '@ant-design/icons'
import DragableList from '@renderer/components/DragableList' import DragableList from '@renderer/components/DragableList'
import PromptPopup from '@renderer/components/Popups/PromptPopup' import PromptPopup from '@renderer/components/Popups/PromptPopup'
import Scrollbar from '@renderer/components/Scrollbar' import Scrollbar from '@renderer/components/Scrollbar'
@ -162,7 +163,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
label: t('chat.topics.export.notion'), label: t('chat.topics.export.notion'),
key: 'notion', key: 'notion',
onClick: () => exportTopicToNotion(topic) onClick: () => exportTopicToNotion(topic)
}, }
] ]
} }
] ]
@ -219,9 +220,9 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
className="menu" className="menu"
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
if (assistant.topics.length === 1) { if (assistant.topics.length === 1) {
return onClearMessages() return onClearMessages()
} }
onDeleteTopic(topic) onDeleteTopic(topic)
}}> }}>
<CloseOutlined /> <CloseOutlined />

View File

@ -86,8 +86,7 @@ const runtimeSlice = createSlice({
}, },
setExportState: (state, action: PayloadAction<Partial<ExportState>>) => { setExportState: (state, action: PayloadAction<Partial<ExportState>>) => {
state.export = { ...state.export, ...action.payload } state.export = { ...state.export, ...action.payload }
}, }
} }
}) })

View File

@ -49,20 +49,20 @@ export const exportTopicToNotion = async (topic: Topic) => {
return return
} }
try { try {
const notion = new Client({ auth: notionApiKey }); const notion = new Client({ auth: notionApiKey })
const markdown = await topicToMarkdown(topic); const markdown = await topicToMarkdown(topic)
const requestBody = JSON.stringify({ md: markdown }) const requestBody = JSON.stringify({ md: markdown })
const res = await fetch('https://md2notion.hilars.dev', { const res = await fetch('https://md2notion.hilars.dev', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: requestBody body: requestBody
}); })
const data = await res.json(); const data = await res.json()
const notionBlocks = data; const notionBlocks = data
const response = await notion.pages.create({ const response = await notion.pages.create({
parent: { database_id: notionDatabaseID }, parent: { database_id: notionDatabaseID },
@ -72,12 +72,11 @@ export const exportTopicToNotion = async (topic: Topic) => {
} }
}, },
children: notionBlocks // 使用转换后的块 children: notionBlocks // 使用转换后的块
}); })
window.message.success({ content: i18n.t('message.success.notion.export'), key: 'notion-success' }) window.message.success({ content: i18n.t('message.success.notion.export'), key: 'notion-success' })
return response return response
} catch (error: any) {
} catch (error:any) {
window.message.error({ content: i18n.t('message.error.notion.export'), key: 'notion-error' }) window.message.error({ content: i18n.t('message.error.notion.export'), key: 'notion-error' })
return null return null
} finally { } finally {
@ -85,4 +84,4 @@ export const exportTopicToNotion = async (topic: Topic) => {
isExporting: false isExporting: false
}) })
} }
}; }

View File

@ -3072,6 +3072,7 @@ __metadata:
rollup-plugin-visualizer: "npm:^5.12.0" rollup-plugin-visualizer: "npm:^5.12.0"
sass: "npm:^1.77.2" sass: "npm:^1.77.2"
shiki: "npm:^1.22.2" shiki: "npm:^1.22.2"
string-width: "npm:^7.2.0"
styled-components: "npm:^6.1.11" styled-components: "npm:^6.1.11"
tinycolor2: "npm:^1.6.0" tinycolor2: "npm:^1.6.0"
tokenx: "npm:^0.4.1" tokenx: "npm:^0.4.1"
@ -5405,6 +5406,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "emoji-regex@npm:^8.0.0":
version: 8.0.0 version: 8.0.0
resolution: "emoji-regex@npm:8.0.0" resolution: "emoji-regex@npm:8.0.0"
@ -6558,6 +6566,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "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 version: 1.2.7
resolution: "get-intrinsic@npm:1.2.7" resolution: "get-intrinsic@npm:1.2.7"
@ -13016,6 +13031,17 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "string.prototype.matchall@npm:^4.0.12":
version: 4.0.12 version: 4.0.12
resolution: "string.prototype.matchall@npm:4.0.12" resolution: "string.prototype.matchall@npm:4.0.12"
@ -13131,7 +13157,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"strip-ansi@npm:^7.0.1": "strip-ansi@npm:^7.0.1, strip-ansi@npm:^7.1.0":
version: 7.1.0 version: 7.1.0
resolution: "strip-ansi@npm:7.1.0" resolution: "strip-ansi@npm:7.1.0"
dependencies: dependencies: