1. 生图包适配,修复部分任务无法获取图片的问题。 2. 新增聚合推文原创重置功能,直接重置GPT提示词、合并提示词、出图等。 3. 优化加载界面,提升用户体验。 4. 优化主页显示,优化UI界面,提升用户体验。
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
import { ipcMain } from 'electron'
|
|
import axios from 'axios'
|
|
import { DEFINE_STRING } from '../../define/define_string'
|
|
|
|
function AxiosIpc() {
|
|
// 通用 GET 请求
|
|
ipcMain.handle(DEFINE_STRING.AXIOS.HTTP_GET, async (_, url, config = {}) => {
|
|
try {
|
|
const response = await axios.get(url, config)
|
|
return {
|
|
success: true,
|
|
data: response.data,
|
|
status: response.status
|
|
}
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
message: error.message,
|
|
status: error.response?.status,
|
|
data: error.response?.data
|
|
}
|
|
}
|
|
})
|
|
|
|
// 通用 POST 请求
|
|
ipcMain.handle(DEFINE_STRING.AXIOS.HTTP_POST, async (_, url, data = {}, config = {}) => {
|
|
try {
|
|
const response = await axios.post(url, data, config)
|
|
return {
|
|
success: true,
|
|
data: response.data,
|
|
status: response.status
|
|
}
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
message: error.message,
|
|
status: error.response?.status,
|
|
data: error.response?.data
|
|
}
|
|
}
|
|
})
|
|
|
|
// 通用 PUT 请求
|
|
ipcMain.handle(DEFINE_STRING.AXIOS.HTTP_PUT, async (_, url, data = {}, config = {}) => {
|
|
try {
|
|
const response = await axios.put(url, data, config)
|
|
return {
|
|
success: true,
|
|
data: response.data,
|
|
status: response.status
|
|
}
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
status: error.response?.status,
|
|
data: error.response?.data
|
|
}
|
|
}
|
|
})
|
|
|
|
// 通用 DELETE 请求
|
|
ipcMain.handle(DEFINE_STRING.AXIOS.HTTP_DELETE, async (_, url, config = {}) => {
|
|
try {
|
|
const response = await axios.delete(url, config)
|
|
return {
|
|
success: true,
|
|
data: response.data,
|
|
status: response.status
|
|
}
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
status: error.response?.status,
|
|
data: error.response?.data
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
export default AxiosIpc
|