feat: update ESLint config and add socks-proxy-agent dependency

- Added 'local/**' to ESLint ignores
- Included 'socks-proxy-agent' package in dependencies
- Refactored download function to improve readability and maintainability
- Cleaned up unused code in messages state management
This commit is contained in:
kangfenmao 2025-03-21 11:26:45 +08:00
parent 28c5231741
commit 2ca0a62efa
7 changed files with 61 additions and 95 deletions

View File

@ -53,6 +53,6 @@ export default defineConfig([
}
],
{
ignores: ['node_modules/**', 'dist/**', 'out/**', '.gitignore', 'scripts/cloudflare-worker.js']
ignores: ['node_modules/**', 'dist/**', 'out/**', 'local/**', '.gitignore', 'scripts/cloudflare-worker.js']
}
])

View File

@ -85,6 +85,7 @@
"npx-scope-finder": "^1.2.0",
"officeparser": "^4.1.1",
"p-queue": "^8.1.0",
"socks-proxy-agent": "^8.0.3",
"tar": "^7.4.3",
"tokenx": "^0.4.1",
"undici": "^7.4.0",

View File

@ -16,7 +16,8 @@ async function downloadWithRedirects(url, destinationPath) {
const proxyAgent = new SocksProxyAgent(proxyUrl)
return new Promise((resolve, reject) => {
const request = (url) => {
https.get(url, { agent: proxyAgent }, (response) => {
https
.get(url, { agent: proxyAgent }, (response) => {
if (response.statusCode == 301 || response.statusCode == 302) {
request(response.headers.location)
return
@ -28,7 +29,8 @@ async function downloadWithRedirects(url, destinationPath) {
const file = fs.createWriteStream(destinationPath)
response.pipe(file)
file.on('finish', () => resolve())
}).on('error', (err) => {
})
.on('error', (err) => {
reject(err)
})
}

View File

@ -1,6 +1,6 @@
import { electronApp, optimizer } from '@electron-toolkit/utils'
import { app, ipcMain } from 'electron'
import { replaceDevtoolsFont } from '@main/utils/windowUtil'
import { app, ipcMain } from 'electron'
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
import { registerIpc } from './ipc'

View File

@ -28,31 +28,6 @@ const initialState: MessagesState = {
error: null
}
// const MAX_RECENT_TOPICS = 10
// // 只初始化最近的会话消息
// export const initializeMessagesState = createAsyncThunk('messages/initialize', async () => {
// try {
// // 获取所有会话的基本信息
// const recentTopics = await TopicManager.getTopicLimit(MAX_RECENT_TOPICS)
// console.log('recentTopics', recentTopics)
// const messagesByTopic: Record<string, Message[]> = {}
// // 只加载最近会话的消息
// for (const topic of recentTopics) {
// if (topic.messages && topic.messages.length > 0) {
// const messages = topic.messages.map((msg) => ({ ...msg }))
// messagesByTopic[topic.id] = messages
// }
// }
// return messagesByTopic
// } catch (error) {
// console.error('Failed to initialize recent messages:', error)
// return {}
// }
// })
// 新增准备会话消息的函数,实现懒加载机制
export const prepareTopicMessages = createAsyncThunk(
'messages/prepareTopic',
@ -144,7 +119,7 @@ const messagesSlice = createSlice({
if (message) {
Object.assign(message, updates)
db.topics.update(topicId, {
messages: topicMessages.map((m) => (m.id === message.id ? cloneDeep(message) : m))
messages: topicMessages.map((m) => (m.id === message.id ? cloneDeep(message) : cloneDeep(m)))
})
}
}
@ -210,19 +185,6 @@ const messagesSlice = createSlice({
}
}
}
// extraReducers: (builder) => {
// builder
// .addCase(initializeMessagesState.pending, (state) => {
// state.error = null
// })
// .addCase(initializeMessagesState.fulfilled, (state, action) => {
// console.log('initializeMessagesState.fulfilled', action.payload)
// state.messagesByTopic = action.payload
// })
// .addCase(initializeMessagesState.rejected, (state, action) => {
// state.error = action.error.message || 'Failed to load messages'
// })
// }
})
const handleResponseMessageUpdate = (

View File

@ -3411,6 +3411,7 @@ __metadata:
rollup-plugin-visualizer: "npm:^5.12.0"
sass: "npm:^1.77.2"
shiki: "npm:^1.22.2"
socks-proxy-agent: "npm:^8.0.3"
string-width: "npm:^7.2.0"
styled-components: "npm:^6.1.11"
tar: "npm:^7.4.3"