feat(device): 更新设备管理功能并优化错误处理- 修改设备更新接口路径从 /updateExpire 到 /update- 添加设备注册时获取计算机名称功能

- 优化设备配额检查逻辑,增加账号存在性验证- 更新前端设备列表刷新逻辑,使用保存的用户名参数
- 修改账号编辑表单,禁用已存在账号的用户名和账号名编辑
-优化跟卖精灵打开功能的错误提示和异常处理- 添加页面刷新 IPC通信功能
- 限制用户名输入只能包含字母、数字和下划线
- 移除冗余的本地 IP 获取函数- 升级 erp_client_sb 模块版本至 2.4.9
This commit is contained in:
2025-10-22 14:18:28 +08:00
parent 17b6a7b9f9
commit 5468dc53fc
15 changed files with 115 additions and 96 deletions

View File

@@ -804,6 +804,9 @@ ipcMain.handle('set-launch-config', (event, launchConfig: { autoLaunch: boolean;
return { success: true };
});
// 刷新页面
ipcMain.handle('reload', () => mainWindow?.webContents.reload());
async function getFileSize(url: string): Promise<number> {
return new Promise((resolve) => {

View File

@@ -34,6 +34,9 @@ const electronAPI = {
getLaunchConfig: () => ipcRenderer.invoke('get-launch-config'),
setLaunchConfig: (config: { autoLaunch: boolean; launchMinimized: boolean }) => ipcRenderer.invoke('set-launch-config', config),
// 刷新页面 API
reload: () => ipcRenderer.invoke('reload'),
onDownloadProgress: (callback: (progress: any) => void) => {
ipcRenderer.removeAllListeners('download-progress')
ipcRenderer.on('download-progress', (event, progress) => callback(progress))

View File

@@ -150,7 +150,7 @@ function goForward() {
}
function reloadPage() {
window.location.reload()
window.electronAPI.reload()
}
function handleMenuSelect(key: string) {

View File

@@ -14,18 +14,6 @@ export interface DeviceQuota {
used: number
}
/**
* 获取本机内网IP地址
*/
async function getLocalIP(): Promise<string> {
try {
const res = await http.get<{ data: string }>('/api/system/local-ip')
return res.data
} catch {
return '127.0.0.1'
}
}
export const deviceApi = {
getQuota(username: string) {
return http.get<{ data: DeviceQuota }>('/monitor/device/quota', { username })
@@ -36,8 +24,15 @@ export const deviceApi = {
},
async register(payload: { username: string; deviceId: string; os?: string }) {
const ip = await getLocalIP()
return http.post('/monitor/device/register', { ...payload, ip })
const [ipRes, nameRes] = await Promise.all([
http.get<{ data: string }>('/api/system/local-ip'),
http.get<{ data: string }>('/api/system/computer-name')
])
return http.post('/monitor/device/register', {
...payload,
ip: ipRes.data,
computerName: nameRes.data
})
},
remove(payload: { deviceId: string; username: string }) {

View File

@@ -1,5 +1,4 @@
export type HttpMethod = 'GET' | 'POST' | 'DELETE';
export const CONFIG = {
CLIENT_BASE: 'http://localhost:8081',
RUOYI_BASE: 'http://8.138.23.49:8085',

View File

@@ -259,8 +259,10 @@ async function openGenmaiSpirit() {
genmaiLoading.value = true
try {
await systemApi.openGenmaiSpirit()
showMessage('跟卖精灵已打开', 'success')
} catch (error: any) {
showMessage(error.message || '打开跟卖精灵失败', 'error')
const errorMsg = error?.msg || error?.message || '打开跟卖精灵失败'
showMessage(errorMsg, 'error')
} finally {
genmaiLoading.value = false
}

View File

@@ -35,6 +35,10 @@ const canRegister = computed(() => {
usernameCheckResult.value === true
})
function filterUsername(value: string) {
registerForm.value.username = value.replace(/[^a-zA-Z0-9_]/g, '')
}
async function checkUsernameAvailability() {
if (!registerForm.value.username) {
usernameCheckResult.value = null
@@ -123,10 +127,11 @@ function backToLogin() {
<el-input
v-model="registerForm.username"
placeholder="请输入用户名"
placeholder="请输入用户名(字母、数字、下划线)"
size="large"
style="margin-bottom: 15px;"
:disabled="registerLoading"
@input="filterUsername"
@blur="checkUsernameAvailability">
</el-input>