refactor(api):重构API服务接口与实现

- 移除多余的接口定义文件,简化依赖关系- 更新控制器和服务实现类的注入方式-优化请求参数处理逻辑
- 统一响应数据结构格式- 调整方法签名以提高一致性
- 删除冗余注释和无用代码- 修改系统API调用路径引用位置
- 简化认证服务实现并移除不必要的抽象层
- 优化Excel文件解析相关功能
- 清理无用的工具类和配置项
- 调整错误上报机制的依赖注入方式
- 更新跟卖精灵服务的实现细节- 优化HTTP请求工具函数结构
- 移除废弃的缓存管理服务接口定义
- 调整设备配额检查逻辑复用性
- 优化订单服务的数据返回格式
- 更新产品服务中的数据处理方式
- 重构客户端账户控制器中的设备限制检查逻辑
This commit is contained in:
2025-10-21 10:15:33 +08:00
parent 17f03c3ade
commit 281ae6a846
29 changed files with 237 additions and 599 deletions

View File

@@ -2,6 +2,7 @@
import { ref, computed, onMounted, defineAsyncComponent, inject } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { amazonApi } from '../../api/amazon'
import { systemApi } from '../../api/system'
import { handlePlatformFileExport } from '../../utils/settings'
const TrialExpiredDialog = defineAsyncComponent(() => import('../common/TrialExpiredDialog.vue'))
@@ -21,6 +22,7 @@ const progressVisible = ref(false) // 进度条是否显示(完成后仍保留
const localProductData = ref<any[]>([]) // 本地产品数据
const currentAsin = ref('') // 当前处理的ASIN
const genmaiLoading = ref(false) // Genmai Spirit加载状态
let abortController: AbortController | null = null // 请求取消控制器
// 分页配置
const currentPage = ref(1)
@@ -130,7 +132,7 @@ async function batchGetProductInfo(asinList: string[]) {
currentAsin.value = `正在处理第${i + 1}/${totalBatches}批 (${batchAsins.join(', ')})`
try {
const result = await amazonApi.getProductsBatch(batchAsins, batchId, region.value)
const result = await amazonApi.getProductsBatch(batchAsins, batchId, region.value, abortController?.signal)
if (result?.data?.products?.length > 0) {
localProductData.value.push(...result.data.products)
@@ -142,7 +144,8 @@ async function batchGetProductInfo(asinList: string[]) {
const actualCount = result?.data?.products?.length || 0
failedCount += Math.max(0, expectedCount - actualCount)
} catch (error) {
} catch (error: any) {
if (error.name === 'AbortError') break
failedCount += batchAsins.length
console.error(`批次${i + 1}失败:`, error)
}
@@ -164,8 +167,10 @@ async function batchGetProductInfo(asinList: string[]) {
} catch (error: any) {
showMessage(error.message || '批量获取产品信息失败', 'error')
currentAsin.value = '处理失败'
if (error.name !== 'AbortError') {
showMessage(error.message || '批量获取产品信息失败', 'error')
currentAsin.value = '处理失败'
}
} finally {
tableLoading.value = false
}
@@ -177,6 +182,7 @@ async function startQueuedFetch() {
showMessage('请先导入ASIN列表', 'warning')
return
}
abortController = new AbortController()
loading.value = true
progressVisible.value = true
tableLoading.value = true
@@ -185,6 +191,7 @@ async function startQueuedFetch() {
} finally {
tableLoading.value = false
loading.value = false
abortController = null
}
}
@@ -240,12 +247,13 @@ function isOutOfStock(product: any) {
// 停止获取操作
function stopFetch() {
abortController?.abort()
abortController = null
loading.value = false
currentAsin.value = '已停止'
showMessage('已停止获取产品数据', 'info')
}
// 打开Genmai Spirit工具
async function openGenmaiSpirit() {
try {
await ElMessageBox.confirm('打开跟卖精灵会关闭所有谷歌浏览器进程,是否继续?', '提示', {
@@ -255,7 +263,7 @@ async function openGenmaiSpirit() {
})
genmaiLoading.value = true
try {
await amazonApi.openGenmaiSpirit()
await systemApi.openGenmaiSpirit()
} catch (error: any) {
showMessage(error.message || '打开跟卖精灵失败', 'error')
} finally {