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:
parent
28c5231741
commit
2ca0a62efa
@ -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']
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|||||||
@ -85,6 +85,7 @@
|
|||||||
"npx-scope-finder": "^1.2.0",
|
"npx-scope-finder": "^1.2.0",
|
||||||
"officeparser": "^4.1.1",
|
"officeparser": "^4.1.1",
|
||||||
"p-queue": "^8.1.0",
|
"p-queue": "^8.1.0",
|
||||||
|
"socks-proxy-agent": "^8.0.3",
|
||||||
"tar": "^7.4.3",
|
"tar": "^7.4.3",
|
||||||
"tokenx": "^0.4.1",
|
"tokenx": "^0.4.1",
|
||||||
"undici": "^7.4.0",
|
"undici": "^7.4.0",
|
||||||
|
|||||||
@ -16,7 +16,8 @@ async function downloadWithRedirects(url, destinationPath) {
|
|||||||
const proxyAgent = new SocksProxyAgent(proxyUrl)
|
const proxyAgent = new SocksProxyAgent(proxyUrl)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const request = (url) => {
|
const request = (url) => {
|
||||||
https.get(url, { agent: proxyAgent }, (response) => {
|
https
|
||||||
|
.get(url, { agent: proxyAgent }, (response) => {
|
||||||
if (response.statusCode == 301 || response.statusCode == 302) {
|
if (response.statusCode == 301 || response.statusCode == 302) {
|
||||||
request(response.headers.location)
|
request(response.headers.location)
|
||||||
return
|
return
|
||||||
@ -28,7 +29,8 @@ async function downloadWithRedirects(url, destinationPath) {
|
|||||||
const file = fs.createWriteStream(destinationPath)
|
const file = fs.createWriteStream(destinationPath)
|
||||||
response.pipe(file)
|
response.pipe(file)
|
||||||
file.on('finish', () => resolve())
|
file.on('finish', () => resolve())
|
||||||
}).on('error', (err) => {
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||||
import { app, ipcMain } from 'electron'
|
|
||||||
import { replaceDevtoolsFont } from '@main/utils/windowUtil'
|
import { replaceDevtoolsFont } from '@main/utils/windowUtil'
|
||||||
|
import { app, ipcMain } from 'electron'
|
||||||
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
||||||
|
|
||||||
import { registerIpc } from './ipc'
|
import { registerIpc } from './ipc'
|
||||||
|
|||||||
@ -28,31 +28,6 @@ const initialState: MessagesState = {
|
|||||||
error: null
|
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(
|
export const prepareTopicMessages = createAsyncThunk(
|
||||||
'messages/prepareTopic',
|
'messages/prepareTopic',
|
||||||
@ -144,7 +119,7 @@ const messagesSlice = createSlice({
|
|||||||
if (message) {
|
if (message) {
|
||||||
Object.assign(message, updates)
|
Object.assign(message, updates)
|
||||||
db.topics.update(topicId, {
|
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 = (
|
const handleResponseMessageUpdate = (
|
||||||
|
|||||||
@ -3411,6 +3411,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"
|
||||||
|
socks-proxy-agent: "npm:^8.0.3"
|
||||||
string-width: "npm:^7.2.0"
|
string-width: "npm:^7.2.0"
|
||||||
styled-components: "npm:^6.1.11"
|
styled-components: "npm:^6.1.11"
|
||||||
tar: "npm:^7.4.3"
|
tar: "npm:^7.4.3"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user