mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-20 23:22:05 +08:00
chore: fix vite warning on dynamic imports (#7852)
This commit is contained in:
parent
19e9ba773f
commit
1ebf546b70
@ -1,22 +1,12 @@
|
|||||||
|
import { linter } from '@codemirror/lint' // statically imported by @uiw/codemirror-extensions-basic-setup
|
||||||
import { useCodeStyle } from '@renderer/context/CodeStyleProvider'
|
import { useCodeStyle } from '@renderer/context/CodeStyleProvider'
|
||||||
import { Extension } from '@uiw/react-codemirror'
|
import { Extension } from '@uiw/react-codemirror'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
let linterPromise: Promise<any> | null = null
|
|
||||||
function importLintPackage() {
|
|
||||||
if (!linterPromise) {
|
|
||||||
linterPromise = import('@codemirror/lint').then((mod) => mod.linter)
|
|
||||||
}
|
|
||||||
return linterPromise
|
|
||||||
}
|
|
||||||
|
|
||||||
// 语言对应的 linter 加载器
|
// 语言对应的 linter 加载器
|
||||||
const linterLoaders: Record<string, () => Promise<any>> = {
|
const linterLoaders: Record<string, () => Promise<any>> = {
|
||||||
json: async () => {
|
json: async () => {
|
||||||
const [linter, jsonParseLinter] = await Promise.all([
|
const jsonParseLinter = await import('@codemirror/lang-json').then((mod) => mod.jsonParseLinter)
|
||||||
importLintPackage(),
|
|
||||||
import('@codemirror/lang-json').then((mod) => mod.jsonParseLinter)
|
|
||||||
])
|
|
||||||
return linter(jsonParseLinter())
|
return linter(jsonParseLinter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
|
||||||
import { useRuntime } from '@renderer/hooks/useRuntime'
|
import { useRuntime } from '@renderer/hooks/useRuntime'
|
||||||
import { useSettings } from '@renderer/hooks/useSettings' // 使用设置中的值
|
import { useSettings } from '@renderer/hooks/useSettings' // 使用设置中的值
|
||||||
import { useAppDispatch } from '@renderer/store'
|
import { useAppDispatch } from '@renderer/store'
|
||||||
@ -74,12 +75,10 @@ export const useMinappPopup = () => {
|
|||||||
/** Open a minapp by id (look up the minapp in DEFAULT_MIN_APPS) */
|
/** Open a minapp by id (look up the minapp in DEFAULT_MIN_APPS) */
|
||||||
const openMinappById = useCallback(
|
const openMinappById = useCallback(
|
||||||
(id: string, keepAlive: boolean = false) => {
|
(id: string, keepAlive: boolean = false) => {
|
||||||
import('@renderer/config/minapps').then(({ DEFAULT_MIN_APPS }) => {
|
const app = DEFAULT_MIN_APPS.find((app) => app?.id === id)
|
||||||
const app = DEFAULT_MIN_APPS.find((app) => app?.id === id)
|
if (app) {
|
||||||
if (app) {
|
openMinapp(app, keepAlive)
|
||||||
openMinapp(app, keepAlive)
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
[openMinapp]
|
[openMinapp]
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import db from '@renderer/databases'
|
import db from '@renderer/databases'
|
||||||
import i18n from '@renderer/i18n'
|
import i18n from '@renderer/i18n'
|
||||||
|
import { fetchMessagesSummary } from '@renderer/services/ApiService'
|
||||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
||||||
import { deleteMessageFiles } from '@renderer/services/MessagesService'
|
import { deleteMessageFiles } from '@renderer/services/MessagesService'
|
||||||
import store from '@renderer/store'
|
import store from '@renderer/store'
|
||||||
@ -133,8 +134,6 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) =>
|
|||||||
if (topic && topic.name === i18n.t('chat.default.topic.name') && topic.messages.length >= 2) {
|
if (topic && topic.name === i18n.t('chat.default.topic.name') && topic.messages.length >= 2) {
|
||||||
try {
|
try {
|
||||||
startTopicRenaming(topicId)
|
startTopicRenaming(topicId)
|
||||||
|
|
||||||
const { fetchMessagesSummary } = await import('@renderer/services/ApiService')
|
|
||||||
const summaryText = await fetchMessagesSummary({ messages: topic.messages, assistant })
|
const summaryText = await fetchMessagesSummary({ messages: topic.messages, assistant })
|
||||||
if (summaryText) {
|
if (summaryText) {
|
||||||
const data = { ...topic, name: summaryText }
|
const data = { ...topic, name: summaryText }
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import { fetchWebContents } from '@renderer/utils/fetch'
|
|||||||
import { consolidateReferencesByUrl, selectReferences } from '@renderer/utils/websearch'
|
import { consolidateReferencesByUrl, selectReferences } from '@renderer/utils/websearch'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { LRUCache } from 'lru-cache'
|
import { LRUCache } from 'lru-cache'
|
||||||
|
import { sliceByTokens } from 'tokenx'
|
||||||
|
|
||||||
import { getKnowledgeBaseParams } from './KnowledgeService'
|
import { getKnowledgeBaseParams } from './KnowledgeService'
|
||||||
import { getKnowledgeSourceUrl, searchKnowledgeBase } from './KnowledgeService'
|
import { getKnowledgeSourceUrl, searchKnowledgeBase } from './KnowledgeService'
|
||||||
@ -384,9 +385,6 @@ class WebSearchService {
|
|||||||
|
|
||||||
const perResultLimit = Math.max(1, Math.floor(config.cutoffLimit / rawResults.length))
|
const perResultLimit = Math.max(1, Math.floor(config.cutoffLimit / rawResults.length))
|
||||||
|
|
||||||
// 动态导入 tokenx
|
|
||||||
const { sliceByTokens } = await import('tokenx')
|
|
||||||
|
|
||||||
return rawResults.map((result) => {
|
return rawResults.map((result) => {
|
||||||
if (config.cutoffUnit === 'token') {
|
if (config.cutoffUnit === 'token') {
|
||||||
// 使用 token 截断
|
// 使用 token 截断
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user