From 52ce0e1969ace55be73ce80ce1940100aa1c1b30 Mon Sep 17 00:00:00 2001 From: ZiJIe <17738440858@163.com> Date: Tue, 30 Sep 2025 17:16:11 +0800 Subject: [PATCH] 1 --- .idea/workspace.xml | 465 ------------------ electron-vue-template/src/main/main.ts | 49 +- electron-vue-template/src/main/preload.ts | 2 + electron-vue-template/src/renderer/App.vue | 156 +++--- .../src/renderer/api/auth.ts | 106 +--- .../src/renderer/api/device.ts | 45 +- .../src/renderer/api/rakuten.ts | 40 +- .../src/renderer/api/shopee.ts | 15 - .../src/renderer/api/update.ts | 11 + .../src/renderer/api/zebra.ts | 82 +-- .../components/amazon/AmazonDashboard.vue | 39 +- .../renderer/components/auth/LoginDialog.vue | 7 +- .../components/auth/RegisterDialog.vue | 14 +- .../components/common/SettingsDialog.vue | 332 +++++++++++++ .../components/common/UpdateDialog.vue | 173 ++++--- .../components/rakuten/RakutenDashboard.vue | 14 +- .../components/zebra/ZebraDashboard.vue | 6 +- erp_client_sb/pom.xml | 2 +- .../tashow/erp/ErpClientSbApplication.java | 26 +- .../erp/entity/AmazonProductEntity.java | 3 + .../repository/AmazonProductRepository.java | 6 +- .../impl/AmazonScrapingServiceImpl.java | 60 +-- .../controller/monitor/VersionController.java | 13 +- .../web/controller/tool/FileController.java | 3 - ruoyi-ui/src/views/monitor/version/index.vue | 9 +- 25 files changed, 689 insertions(+), 989 deletions(-) delete mode 100644 .idea/workspace.xml delete mode 100644 electron-vue-template/src/renderer/api/shopee.ts create mode 100644 electron-vue-template/src/renderer/api/update.ts create mode 100644 electron-vue-template/src/renderer/components/common/SettingsDialog.vue diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 63c653b..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,465 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - "customColor": "", - "associatedIndex": 0 -} - - - - - - { - "keyToString": { - "Maven.erp_client_sb [clean].executor": "Run", - "Maven.erp_client_sb [install].executor": "Run", - "Maven.erp_client_sb [verify].executor": "Run", - "Maven.ruoyi [clean].executor": "Run", - "Maven.ruoyi [install].executor": "Run", - "ModuleVcsDetector.initialDetectionPerformed": "true", - "RequestMappingsPanelOrder0": "0", - "RequestMappingsPanelOrder1": "1", - "RequestMappingsPanelWidth0": "75", - "RequestMappingsPanelWidth1": "75", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", - "RunOnceActivity.git.unshallow": "true", - "Spring Boot.ErpClientSbApplication.executor": "Debug", - "Spring Boot.RuoYiApplication.executor": "Debug", - "Spring Boot.未命名.executor": "Debug", - "git-widget-placeholder": "master", - "last_opened_file_path": "C:/Users/ZiJIe/Desktop/wox/RuoYi-Vue/electron-vue-template/public", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "npm.build.executor": "Run", - "npm.build:win.executor": "Run", - "npm.run.executor": "Run", - "settings.editor.selected.configurable": "com.intellij.platform.ide.impl.presentationAssistant.PresentationAssistantConfigurable", - "ts.external.directory.path": "C:\\Users\\ZiJIe\\Desktop\\wox\\RuoYi-Vue\\electron-vue-template\\node_modules\\typescript\\lib", - "vue.rearranger.settings.migration": "true" - } -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1758509443816 - - - 1758509443816 - - - - - - - - - - - - - - - - - - 1758511833782 - - - - 1758511833782 - - - - 1758512348322 - - - - 1758512348322 - - - - 1758521046022 - - - - 1758521046022 - - - - 1758522202417 - - - - 1758522202417 - - - - 1758522758523 - - - - 1758522758523 - - - - 1758523822682 - - - - 1758523822682 - - - - 1758524938236 - - - - 1758524938236 - - - - 1758525299299 - - - - 1758525299299 - - - - 1758525500986 - - - - 1758525500986 - - - - 1758526085800 - - - - 1758526085800 - - - - 1758528696003 - - - - 1758528696003 - - - - 1758529627894 - - - - 1758529627894 - - - - 1758619260259 - - - - 1758619260259 - - - - 1758619552979 - - - - 1758619552979 - - - - 1758683139068 - - - - 1758683139068 - - - - 1758683285305 - - - - 1758683285305 - - - - 1758683484212 - - - - 1758683484212 - - - - 1758787441900 - - - - 1758787441900 - - - - 1758787531138 - - - - 1758787531138 - - - - 1758787581342 - - - - 1758787581342 - - - - 1758787954763 - - - - 1758787954763 - - - - 1758788061529 - - - - 1758788061529 - - - - 1758795230077 - - - - 1758795230077 - - - - 1758875248722 - - - - 1758875248722 - - - - 1758877545022 - - - - 1758877545022 - - - - 1758953146637 - - - - 1758953146637 - - - - 1758966134103 - - - - 1758966134103 - - - - 1759129266815 - - - - 1759129266815 - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/electron-vue-template/src/main/main.ts b/electron-vue-template/src/main/main.ts index a7f5e2d..6b342b0 100644 --- a/electron-vue-template/src/main/main.ts +++ b/electron-vue-template/src/main/main.ts @@ -57,26 +57,43 @@ function getJavaExecutablePath(): string { return 'java'; } +function findJarFile(directory: string): string { + if (!existsSync(directory)) return ''; + + const files = require('fs').readdirSync(directory); + const jarFile = files.find((f: string) => f.startsWith('erp_client_sb-') && f.endsWith('.jar')); + + return jarFile ? join(directory, jarFile) : ''; +} + +function extractVersionFromJar(jarPath: string): string { + if (!jarPath) return ''; + const match = require('path').basename(jarPath).match(/erp_client_sb-(\d+\.\d+\.\d+)\.jar/); + return match?.[1] || ''; +} + function getJarFilePath(): string { if (process.env.NODE_ENV === 'development') { - return join(__dirname, '../../public/erp_client_sb-2.4.7.jar'); + return findJarFile(join(__dirname, '../../public')); } - // 生产环境:需要将JAR包从asar提取到临时位置 const tempDir = join(app.getPath('temp'), 'erp-client'); - const tempJarPath = join(tempDir, 'erp_client_sb-2.4.7.jar'); + if (!existsSync(tempDir)) mkdirSync(tempDir, { recursive: true }); - // 确保临时目录存在 - if (!existsSync(tempDir)) { - mkdirSync(tempDir, { recursive: true }); + const asarJarPath = findJarFile(join(__dirname, '../assets')); + if (!asarJarPath) return ''; + + const asarFileName = require('path').basename(asarJarPath); + const tempJarPath = join(tempDir, asarFileName); + + // 如果临时目录版本不同,删除旧版本并复制新版本 + const existingJar = findJarFile(tempDir); + if (existingJar && require('path').basename(existingJar) !== asarFileName) { + require('fs').unlinkSync(existingJar); } - // 如果临时JAR不存在,从asar中复制 if (!existsSync(tempJarPath)) { - const asarJarPath = join(__dirname, '../assets/erp_client_sb-2.4.7.jar'); - if (existsSync(asarJarPath)) { - copyFileSync(asarJarPath, tempJarPath); - } + copyFileSync(asarJarPath, tempJarPath); } return tempJarPath; @@ -213,7 +230,7 @@ function startSpringBoot() { } } -//startSpringBoot(); +startSpringBoot(); function stopSpringBoot() { if (!springProcess) return; @@ -299,9 +316,9 @@ app.whenReady().then(() => { } //11111 - setTimeout(() => { - openAppIfNotOpened(); - }, 2000); + // setTimeout(() => { + // openAppIfNotOpened(); + // }, 2000); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { @@ -323,6 +340,8 @@ ipcMain.on('message', (event, message) => { console.log(message); }); +ipcMain.handle('get-jar-version', () => extractVersionFromJar(getJarFilePath())); + function checkPendingUpdate() { try { const updateFilePath = join(process.resourcesPath, 'app.asar.update'); diff --git a/electron-vue-template/src/main/preload.ts b/electron-vue-template/src/main/preload.ts index 00e7400..ae932cd 100644 --- a/electron-vue-template/src/main/preload.ts +++ b/electron-vue-template/src/main/preload.ts @@ -3,6 +3,8 @@ import { contextBridge, ipcRenderer } from 'electron' const electronAPI = { sendMessage: (message: string) => ipcRenderer.send('message', message), + getJarVersion: () => ipcRenderer.invoke('get-jar-version'), + downloadUpdate: (downloadUrl: string) => ipcRenderer.invoke('download-update', downloadUrl), getDownloadProgress: () => ipcRenderer.invoke('get-download-progress'), installUpdate: () => ipcRenderer.invoke('install-update'), diff --git a/electron-vue-template/src/renderer/App.vue b/electron-vue-template/src/renderer/App.vue index df838ff..2bf4d81 100644 --- a/electron-vue-template/src/renderer/App.vue +++ b/electron-vue-template/src/renderer/App.vue @@ -134,56 +134,43 @@ function handleMenuSelect(key: string) { async function handleLoginSuccess(data: { token: string; permissions?: string }) { isAuthenticated.value = true showAuthDialog.value = false - showRegDialog.value = false // 确保注册对话框也关闭 + showRegDialog.value = false try { - // 保存token到本地数据库 await authApi.saveToken(data.token) - const username = getUsernameFromToken(data.token) currentUsername.value = username userPermissions.value = data?.permissions || '' await deviceApi.register({username}) - - // 建立SSE连接 SSEManager.connect() } catch (e: any) { - // 设备注册失败时回滚登录状态 isAuthenticated.value = false showAuthDialog.value = true await authApi.deleteTokenCache() - ElMessage({ - message: e?.message || '设备注册失败,请重试', - type: 'error' - }) + ElMessage.error(e?.message || '设备注册失败') } } async function logout() { - // 主动设置设备离线 try { const deviceId = await getClientIdFromToken() - if (deviceId) { - await deviceApi.offline({ deviceId }) - } + if (deviceId) await deviceApi.offline({ deviceId }) } catch (error) { console.warn('离线通知失败:', error) } - const token = await authApi.getToken() - if (token) { - await authApi.logout(token) - } + try { + const tokenRes: any = await authApi.getToken() + const token = typeof tokenRes === 'string' ? tokenRes : tokenRes?.data + if (token) await authApi.logout(token) + } catch {} await authApi.deleteTokenCache() - // 清理前端状态 isAuthenticated.value = false currentUsername.value = '' userPermissions.value = '' showAuthDialog.value = true showDeviceDialog.value = false - - // 关闭SSE连接 SSEManager.disconnect() } @@ -199,12 +186,8 @@ async function handleUserClick() { cancelButtonText: '取消' }) await logout() - ElMessage({ - message: '已退出登录', - type: 'success' - }) - } catch { - } + ElMessage.success('已退出登录') + } catch {} } function showRegisterDialog() { @@ -218,26 +201,23 @@ function backToLogin() { } async function checkAuth() { - const authRequiredMenus = ['rakuten', 'amazon', 'zebra', 'shopee'] - try { await authApi.sessionBootstrap().catch(() => undefined) - const token = await authApi.getToken() + const tokenRes: any = await authApi.getToken() + const token = typeof tokenRes === 'string' ? tokenRes : tokenRes?.data + if (token) { - const response = await authApi.verifyToken(token) - if (response?.success) { - isAuthenticated.value = true - currentUsername.value = getUsernameFromToken(token) || '' - SSEManager.connect() - return - } - await authApi.deleteTokenCache() + await authApi.verifyToken(token) + isAuthenticated.value = true + currentUsername.value = getUsernameFromToken(token) || '' + SSEManager.connect() + return } } catch { - // 忽略 + await authApi.deleteTokenCache() } - if (authRequiredMenus.includes(activeMenu.value)) { + if (['rakuten', 'amazon', 'zebra', 'shopee'].includes(activeMenu.value)) { showAuthDialog.value = true } } @@ -246,11 +226,11 @@ async function getClientIdFromToken(token?: string) { try { let t = token if (!t) { - t = await authApi.getToken() + const tokenRes: any = await authApi.getToken() + t = typeof tokenRes === 'string' ? tokenRes : tokenRes?.data } if (!t) return '' - - const payload = JSON.parse(atob(t.split('.')[1] || '')) + const payload = JSON.parse(atob(t.split('.')[1])) return payload.clientId || '' } catch { return '' @@ -259,7 +239,7 @@ async function getClientIdFromToken(token?: string) { function getUsernameFromToken(token: string) { try { - const payload = JSON.parse(atob(token.split('.')[1] || '')) + const payload = JSON.parse(atob(token.split('.')[1])) return payload.username || '' } catch { return '' @@ -273,21 +253,24 @@ const SSEManager = { if (this.connection) return try { - const token = await authApi.getToken() - if (!token) return + const tokenRes: any = await authApi.getToken() + const token = typeof tokenRes === 'string' ? tokenRes : tokenRes?.data + if (!token) { + console.warn('SSE连接失败: 没有有效的 token') + return + } const clientId = await getClientIdFromToken(token) - if (!clientId) return + if (!clientId) { + console.warn('SSE连接失败: 无法从 token 获取 clientId') + return + } let sseUrl = 'http://192.168.1.89:8080/monitor/account/events' try { const resp = await fetch('/api/config/server') - if (resp.ok) { - const config = await resp.json() - sseUrl = config.sseUrl || sseUrl - } - } catch { - } + if (resp.ok) sseUrl = (await resp.json()).sseUrl || sseUrl + } catch {} const src = new EventSource(`${sseUrl}?clientId=${clientId}&token=${token}`) this.connection = src @@ -296,15 +279,13 @@ const SSEManager = { src.onerror = () => this.handleError() } catch (e: any) { console.warn('SSE连接失败:', e?.message || e) + this.disconnect() } }, handleMessage(e: MessageEvent) { try { - // 处理ping心跳 - if (e.type === 'ping') { - return // ping消息自动保持连接,无需处理 - } + if (e.type === 'ping') return console.log('SSE消息:', e.data) const payload = JSON.parse(e.data) @@ -314,17 +295,11 @@ const SSEManager = { break case 'DEVICE_REMOVED': logout() - ElMessage({ - message: '您的设备已被移除,请重新登录', - type: 'warning' - }) + ElMessage.warning('您的设备已被移除,请重新登录') break case 'FORCE_LOGOUT': logout() - ElMessage({ - message: '会话已失效,请重新登录', - type: 'warning' - }) + ElMessage.warning('会话已失效,请重新登录') break case 'PERMISSIONS_UPDATED': checkAuth() @@ -336,18 +311,16 @@ const SSEManager = { }, handleError() { - this.disconnect() - setTimeout(() => this.connect(), 3000) + if (!this.connection) return + try { this.connection.close() } catch {} + this.connection = null + console.warn('SSE连接失败,已断开') }, disconnect() { - if (this.connection) { - try { - this.connection.close() - } catch { - } - this.connection = null - } + if (!this.connection) return + try { this.connection.close() } catch {} + this.connection = null }, } @@ -366,26 +339,22 @@ function openSettings() { async function fetchDeviceData() { if (!currentUsername.value) { - ElMessage({ - message: '未获取到用户名,请重新登录', - type: 'warning' - }) + ElMessage.warning('未获取到用户名,请重新登录') return } try { deviceLoading.value = true - const [quota, list] = await Promise.all([ + const [quotaRes, listRes] = await Promise.all([ deviceApi.getQuota(currentUsername.value), deviceApi.list(currentUsername.value), - ]) - deviceQuota.value = quota || {limit: 0, used: 0} + ]) as any[] + + deviceQuota.value = quotaRes?.data || quotaRes || {limit: 0, used: 0} const clientId = await getClientIdFromToken() - devices.value = (list || []).map(d => ({...d, isCurrent: d.deviceId === clientId})) as any + const list = listRes?.data || listRes || [] + devices.value = list.map(d => ({...d, isCurrent: d.deviceId === clientId})) } catch (e: any) { - ElMessage({ - message: e?.message || '获取设备列表失败', - type: 'error' - }) + ElMessage.error(e?.message || '获取设备列表失败') } finally { deviceLoading.value = false } @@ -403,21 +372,12 @@ async function confirmRemoveDevice(row: DeviceItem & { isCurrent?: boolean }) { devices.value = devices.value.filter(d => d.deviceId !== row.deviceId) deviceQuota.value.used = Math.max(0, (deviceQuota.value.used || 0) - 1) - // 如果是本机设备被移除,执行logout const clientId = await getClientIdFromToken() - if (row.deviceId === clientId) { - await logout() - } + if (row.deviceId === clientId) await logout() - ElMessage({ - message: '已移除设备', - type: 'success' - }) + ElMessage.success('已移除设备') } catch (e: any) { - ElMessage({ - message: '移除设备失败: ' + ((e as any)?.message || '未知错误'), - type: 'error' - }) + if (e !== 'cancel') ElMessage.error('移除设备失败: ' + (e?.message || '未知错误')) } } diff --git a/electron-vue-template/src/renderer/api/auth.ts b/electron-vue-template/src/renderer/api/auth.ts index cc8e125..c4eadae 100644 --- a/electron-vue-template/src/renderer/api/auth.ts +++ b/electron-vue-template/src/renderer/api/auth.ts @@ -1,113 +1,39 @@ -import { http } from './http'; - -// 统一响应处理函数 - 适配ERP客户端格式 -function unwrap(res: any): T { - if (res && typeof res.success === 'boolean') { - if (!res.success) { - const message: string = res.message || res.msg || '请求失败'; - throw new Error(message); - } - return res as T; - } - // 兼容标准格式 - if (res && typeof res.code === 'number') { - if (res.code !== 0) { - const message: string = res.msg || '请求失败'; - throw new Error(message); - } - return (res.data as T) ?? ({} as T); - } - return res as T; -} - -// 认证相关类型定义 -interface LoginRequest { - username: string; - password: string; -} - -interface RegisterRequest { - username: string; - password: string; -} - -interface LoginResponse { - success: boolean; - token: string; - permissions: string[]; - username: string; - message?: string; -} - -interface RegisterResponse { - success: boolean; - message?: string; -} +import { http } from './http' export const authApi = { - // 用户登录 - login(params: LoginRequest) { - return http - .post('/api/login', params) - .then(res => unwrap(res)); + login(params: { username: string; password: string }) { + return http.post('/api/login', params) }, - // 用户注册 - register(params: RegisterRequest) { - return http - .post('/api/register', params) - .then(res => unwrap(res)); + register(params: { username: string; password: string }) { + return http.post('/api/register', params) }, - // 检查用户名可用性 checkUsername(username: string) { - return http - .get('/api/check-username', { username }) - .then(res => { - if (res && res.code === 200) { - return { available: res.data }; - } - throw new Error(res?.msg || '检查用户名失败'); - }); + return http.get('/api/check-username', { username }) }, - // 验证token有效性 verifyToken(token: string) { - return http - .post('/api/verify', { token }) - .then(res => unwrap<{ success: boolean }>(res)); + return http.post('/api/verify', { token }) }, - // 用户登出 logout(token: string) { - return http.postVoid('/api/logout', { token }); + return http.postVoid('/api/logout', { token }) }, - // 删除token缓存 deleteTokenCache() { - return http.postVoid('/api/cache/delete?key=token'); + return http.postVoid('/api/cache/delete?key=token') }, - // 保存token到本地数据库 + saveToken(token: string) { - return http.postVoid('/api/cache/save', { key: 'token', value: token }); + return http.postVoid('/api/cache/save', { key: 'token', value: token }) }, - // 从本地数据库获取token - getToken(): Promise { - return http.get('/api/cache/get?key=token').then((res: any) => { - if (typeof res === 'string') return res; - if (res && typeof res === 'object') { - if (typeof res.code === 'number') { - return res.code === 0 ? (res.data as string | undefined) : undefined; - } - if (typeof (res as any).data === 'string') return (res as any).data as string; - } - return undefined; - }); + getToken() { + return http.get('/api/cache/get?key=token') }, - // 会话引导:检查并恢复会话(返回体各异,这里保持 any) sessionBootstrap() { - return http.get('/api/session/bootstrap'); - }, -}; \ No newline at end of file + return http.get('/api/session/bootstrap') + } +} \ No newline at end of file diff --git a/electron-vue-template/src/renderer/api/device.ts b/electron-vue-template/src/renderer/api/device.ts index 02c73ab..b46e089 100644 --- a/electron-vue-template/src/renderer/api/device.ts +++ b/electron-vue-template/src/renderer/api/device.ts @@ -1,52 +1,27 @@ import { http } from './http' -// 与老版保持相同的接口路径与参数 -const base = '/api/device' - -export interface DeviceQuota { - limit: number - used: number -} - -export interface DeviceItem { - deviceId: string - name?: string - status?: 'online' | 'offline' - lastActiveAt?: string -} - -// 统一处理AjaxResult格式 -function handleAjaxResult(res: any) { - if (res?.code !== 200) { - throw new Error(res?.msg || '操作失败') - } - return res.data -} - export const deviceApi = { - getQuota(username: string): Promise { - return http.get(`${base}/quota`, { username }).then(handleAjaxResult) + getQuota(username: string) { + return http.get('/api/device/quota', { username }) }, - list(username: string): Promise { - return http.get(`${base}/list`, { username }).then(handleAjaxResult) + list(username: string) { + return http.get('/api/device/list', { username }) }, register(payload: { username: string }) { - return http.post(`${base}/register`, payload).then(handleAjaxResult) + return http.post('/api/device/register', payload) }, remove(payload: { deviceId: string }) { - return http.post(`${base}/remove`, payload).then(handleAjaxResult) + return http.post('/api/device/remove', payload) }, heartbeat(payload: { username: string; deviceId: string; version?: string }) { - return http.post(`${base}/heartbeat`, payload).then(handleAjaxResult) + return http.post('/api/device/heartbeat', payload) }, offline(payload: { deviceId: string }) { - return http.post(`${base}/offline`, payload).then(handleAjaxResult) - }, -} - - + return http.post('/api/device/offline', payload) + } +} \ No newline at end of file diff --git a/electron-vue-template/src/renderer/api/rakuten.ts b/electron-vue-template/src/renderer/api/rakuten.ts index 6e1192d..eb1c80f 100644 --- a/electron-vue-template/src/renderer/api/rakuten.ts +++ b/electron-vue-template/src/renderer/api/rakuten.ts @@ -1,33 +1,21 @@ -import { http } from './http'; - -function unwrap(res: any): T { - if (res && typeof res.code === 'number') { - if (res.code !== 0) { - const message: string = res.msg || '请求失败'; - throw new Error(message); - } - return (res.data as T) ?? ({} as T); - } - return res as T; -} +import { http } from './http' export const rakutenApi = { - // 上传 Excel 或按店铺名查询 getProducts(params: { file?: File; shopName?: string; batchId?: string }) { - const formData = new FormData(); - if (params.file) formData.append('file', params.file); - if (params.batchId) formData.append('batchId', params.batchId); - if (params.shopName) formData.append('shopName', params.shopName); - return http - .upload('/api/rakuten/products', formData) - .then(res => unwrap<{ products: any[]; total?: number; sessionId?: string }>(res)); + const formData = new FormData() + if (params.file) formData.append('file', params.file) + if (params.batchId) formData.append('batchId', params.batchId) + if (params.shopName) formData.append('shopName', params.shopName) + return http.upload('/api/rakuten/products', formData) }, + search1688(imageUrl: string, sessionId?: string) { - const payload: Record = { imageUrl }; - if (sessionId) payload.sessionId = sessionId; - return http.post('/api/rakuten/search1688', payload).then(res => unwrap(res)); + const payload: Record = { imageUrl } + if (sessionId) payload.sessionId = sessionId + return http.post('/api/rakuten/search1688', payload) }, + getLatestProducts() { - return http.get('/api/rakuten/products/latest').then(res => unwrap<{ products: any[] }>(res)); - }, -}; + return http.get('/api/rakuten/products/latest') + } +} \ No newline at end of file diff --git a/electron-vue-template/src/renderer/api/shopee.ts b/electron-vue-template/src/renderer/api/shopee.ts deleted file mode 100644 index aa17da9..0000000 --- a/electron-vue-template/src/renderer/api/shopee.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { http } from './http'; - -export const shopeeApi = { - getAdHosting(params: Record = {}) { - return http.get('/api/shopee/ad-hosting', params); - }, - getReviews(params: Record = {}) { - return http.get('/api/shopee/reviews', params); - }, - exportData(exportParams: Record = {}) { - return http.post('/api/shopee/export', exportParams); - }, -}; - - diff --git a/electron-vue-template/src/renderer/api/update.ts b/electron-vue-template/src/renderer/api/update.ts new file mode 100644 index 0000000..9dafd8c --- /dev/null +++ b/electron-vue-template/src/renderer/api/update.ts @@ -0,0 +1,11 @@ +import { http } from './http' + +export const updateApi = { + getVersion() { + return http.get('/api/update/version') + }, + + checkUpdate(currentVersion: string) { + return http.get(`/system/version/check?currentVersion=${currentVersion}`) + } +} \ No newline at end of file diff --git a/electron-vue-template/src/renderer/api/zebra.ts b/electron-vue-template/src/renderer/api/zebra.ts index 219f676..f83ec96 100644 --- a/electron-vue-template/src/renderer/api/zebra.ts +++ b/electron-vue-template/src/renderer/api/zebra.ts @@ -1,79 +1,39 @@ -// 斑马订单模型(根据页面所需字段精简定义) -export interface ZebraOrder { - orderedAt?: string; - productImage?: string; - productTitle?: string; - shopOrderNumber?: string; - timeSinceOrder?: string; - priceJpy?: number; - productQuantity?: number; - shippingFeeJpy?: number; - serviceFee?: string; - productNumber?: string; - poNumber?: string; - shippingFeeCny?: number; - internationalShippingFee?: number; - poLogisticsCompany?: string; - poTrackingNumber?: string; - internationalTrackingNumber?: string; - trackInfo?: string; -} +import { http } from './http' -export interface ZebraOrdersResp { - orders: ZebraOrder[]; - total?: number; - totalPages?: number; -} - -import { http } from './http'; - -export interface BanmaAccount { - id?: number; - name?: string; - username?: string; - password?: string; - token?: string; - tokenExpireAt?: string | number; - isDefault?: number; - status?: number; - remark?: string; -} - -// 斑马 API:与原 zebra-api.js 对齐的接口封装 export const zebraApi = { - // 账号管理(ruoyi-admin) getAccounts() { - return http.get<{ code?: number; msg?: string; data: BanmaAccount[] }>('/tool/banma/accounts'); + return http.get('/tool/banma/accounts') }, - saveAccount(body: BanmaAccount) { - return http.post<{ id: number }>('/tool/banma/accounts', body); + + saveAccount(body: any) { + return http.post('/tool/banma/accounts', body) }, + removeAccount(id: number) { - // 用 postVoid 也可,但这里前端未用到,保留以备将来 - return http.delete(`/tool/banma/accounts/${id}`); + return http.delete(`/tool/banma/accounts/${id}`) }, - // 业务采集 getShops(params?: { accountId?: number }) { - return http.get<{ data?: { list?: Array<{ id: string; shopName: string }> } }>( - '/api/banma/shops', params as unknown as Record - ); - }, - getOrders(params: { accountId?: number; startDate?: string; endDate?: string; page?: number; pageSize?: number; shopIds?: string; batchId: string }) { - return http.get('/api/banma/orders', params as unknown as Record); + return http.get('/api/banma/shops', params as Record) + }, + + getOrders(params: any) { + return http.get('/api/banma/orders', params as Record) }, - // 其他功能(客户端微服务) getOrdersByBatch(batchId: string) { - return http.get(`/api/banma/orders/batch/${batchId}`); + return http.get(`/api/banma/orders/batch/${batchId}`) }, + getLatestOrders() { - return http.get('/api/banma/orders/latest'); + return http.get('/api/banma/orders/latest') }, + getOrderStats() { - return http.get('/api/banma/orders/stats'); + return http.get('/api/banma/orders/stats') }, + searchOrders(searchParams: Record) { - return http.get('/api/banma/orders/search', searchParams); - }, -}; + return http.get('/api/banma/orders/search', searchParams) + } +} \ No newline at end of file diff --git a/electron-vue-template/src/renderer/components/amazon/AmazonDashboard.vue b/electron-vue-template/src/renderer/components/amazon/AmazonDashboard.vue index ee53faa..cf93629 100644 --- a/electron-vue-template/src/renderer/components/amazon/AmazonDashboard.vue +++ b/electron-vue-template/src/renderer/components/amazon/AmazonDashboard.vue @@ -295,6 +295,17 @@ onMounted(async () => { - {{ genmaiLoading ? '启动中...' : '跟卖精灵' }} @@ -453,14 +463,25 @@ onMounted(async () => { + + diff --git a/electron-vue-template/src/renderer/components/common/UpdateDialog.vue b/electron-vue-template/src/renderer/components/common/UpdateDialog.vue index 28ab8b7..460eb2f 100644 --- a/electron-vue-template/src/renderer/components/common/UpdateDialog.vue +++ b/electron-vue-template/src/renderer/components/common/UpdateDialog.vue @@ -2,15 +2,18 @@ v{{ version || '-' }} - + - + 新版本的"{{ appName }}"已经发布 - {{ appName }} {{ info.latestVersion }} 可供安装,您现在的版本是 {{ version }},要现在安装吗? + {{ appName }} {{ info.latestVersion }} 可供安装,您现在的版本是 {{ + version + }},要现在安装吗? 更新信息 @@ -20,7 +23,7 @@ class="notes-box" :rows="6" readonly - resize="none" /> + resize="none"/> @@ -41,7 +44,7 @@ - + @@ -52,7 +55,7 @@ :percentage="prog.percentage" :show-text="false" :stroke-width="6" - color="#409EFF" /> + color="#409EFF"/> {{ prog.current }} / {{ prog.total }} 取消 @@ -64,7 +67,7 @@ - + 更新完成 更新文件已下载,将在重启后自动应用 @@ -77,7 +80,7 @@ :percentage="100" :show-text="false" :stroke-width="6" - color="#67C23A" /> + color="#67C23A"/> @@ -90,9 +93,9 @@
新版本的"{{ appName }}"已经发布
{{ appName }} {{ info.latestVersion }} 可供安装,您现在的版本是 {{ version }},要现在安装吗?
{{ appName }} {{ info.latestVersion }} 可供安装,您现在的版本是 {{ + version + }},要现在安装吗?
更新文件已下载,将在重启后自动应用