From a7f48305beb6e92f15c89815b1b71616b807ed1b Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Sun, 7 Dec 2025 20:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=92=8C=E6=A1=A3=E6=A1=88=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/config.ini | 6 +- backend/devices/utils/license_manager.py | 89 ++++++------ backend/utils.py | 11 +- frontend/src/renderer/src/services/api.js | 18 +-- frontend/src/renderer/src/views/Dashboard.vue | 19 ++- frontend/src/renderer/src/views/Detection.vue | 48 +++++-- .../renderer/src/views/DiagnosticMessage.vue | 20 ++- .../src/renderer/src/views/PatientCreate.vue | 130 ++++++++++++++---- .../src/renderer/src/views/PatientProfile.vue | 75 +++++++--- .../renderer/src/views/PatientProfile2.vue | 14 +- frontend/src/renderer/src/views/ViewUser.vue | 25 ++-- 11 files changed, 301 insertions(+), 154 deletions(-) diff --git a/backend/config.ini b/backend/config.ini index 70efd622..08a01276 100644 --- a/backend/config.ini +++ b/backend/config.ini @@ -29,7 +29,7 @@ backend = directshow [CAMERA2] enabled = True -device_index = 2 +device_index = 3 width = 1280 height = 720 fps = 30 @@ -50,12 +50,12 @@ synchronized_images_only = False [DEVICES] imu_enabled = True -imu_device_type = mock +imu_device_type = ble imu_port = COM9 imu_mac_address = ef:3c:1a:0a:fe:02 imu_baudrate = 9600 pressure_enabled = True -pressure_device_type = mock +pressure_device_type = real pressure_use_mock = False pressure_port = COM5 pressure_baudrate = 115200 diff --git a/backend/devices/utils/license_manager.py b/backend/devices/utils/license_manager.py index 2052b502..99dd8c2e 100644 --- a/backend/devices/utils/license_manager.py +++ b/backend/devices/utils/license_manager.py @@ -58,85 +58,82 @@ class LicenseManager: """生成机器硬件指纹""" if self._machine_id: return self._machine_id - try: - # 收集硬件信息 - hardware_info = [] - - # CPU信息 + core_info = [] + aux_info = [] try: if platform.system() == "Windows": - result = subprocess.run(['wmic', 'cpu', 'get', 'ProcessorId', '/value'], - capture_output=True, text=True, timeout=10) + result = subprocess.run(['wmic', 'cpu', 'get', 'ProcessorId', '/value'], capture_output=True, text=True, timeout=10) for line in result.stdout.split('\n'): if 'ProcessorId=' in line: cpu_id = line.split('=')[1].strip() if cpu_id: - hardware_info.append(f"CPU:{cpu_id}") + core_info.append(f"CPU:{cpu_id}") break - else: - # Linux/Mac 可以使用其他方法获取CPU信息 - pass except Exception as e: logger.warning(f"获取CPU信息失败: {e}") - - # 主板信息 try: if platform.system() == "Windows": - result = subprocess.run(['wmic', 'baseboard', 'get', 'SerialNumber', '/value'], - capture_output=True, text=True, timeout=10) + result = subprocess.run(['wmic', 'baseboard', 'get', 'SerialNumber', '/value'], capture_output=True, text=True, timeout=10) for line in result.stdout.split('\n'): if 'SerialNumber=' in line: board_serial = line.split('=')[1].strip() if board_serial and board_serial != "To be filled by O.E.M.": - hardware_info.append(f"BOARD:{board_serial}") + core_info.append(f"BOARD:{board_serial}") break except Exception as e: logger.warning(f"获取主板信息失败: {e}") - - # 磁盘信息 try: if platform.system() == "Windows": - result = subprocess.run(['wmic', 'diskdrive', 'get', 'SerialNumber', '/value'], - capture_output=True, text=True, timeout=10) + # 获取磁盘信息并过滤掉USB/可移动介质,收集所有内部磁盘序列号 + result = subprocess.run( + ['wmic', 'path', 'Win32_DiskDrive', 'get', 'SerialNumber,InterfaceType,PNPDeviceID,MediaType', '/value'], + capture_output=True, text=True, timeout=10 + ) + block = {} for line in result.stdout.split('\n'): - if 'SerialNumber=' in line: - disk_serial = line.split('=')[1].strip() - if disk_serial: - hardware_info.append(f"DISK:{disk_serial}") - break + line = line.strip() + if not line: + # 结束一个块 + serial = (block.get('SerialNumber') or '').strip() + iface = (block.get('InterfaceType') or '').strip().upper() + pnp = (block.get('PNPDeviceID') or '').strip().upper() + media = (block.get('MediaType') or '').strip().upper() + if serial and iface != 'USB' and not pnp.startswith('USBSTOR') and 'REMOVABLE' not in media: + core_info.append(f"DISK:{serial}") + block = {} + continue + if '=' in line: + k, v = line.split('=', 1) + block[k] = v + # 处理最后一个块 + if block: + serial = (block.get('SerialNumber') or '').strip() + iface = (block.get('InterfaceType') or '').strip().upper() + pnp = (block.get('PNPDeviceID') or '').strip().upper() + media = (block.get('MediaType') or '').strip().upper() + if serial and iface != 'USB' and not pnp.startswith('USBSTOR') and 'REMOVABLE' not in media: + core_info.append(f"DISK:{serial}") except Exception as e: logger.warning(f"获取磁盘信息失败: {e}") - - # MAC地址 try: import uuid - mac = ':'.join(['{:02x}'.format((uuid.getnode() >> elements) & 0xff) - for elements in range(0,2*6,2)][::-1]) - hardware_info.append(f"MAC:{mac}") + mac = ':'.join(['{:02x}'.format((uuid.getnode() >> elements) & 0xff) for elements in range(0, 2 * 6, 2)][::-1]) + aux_info.append(f"MAC:{mac}") except Exception as e: logger.warning(f"获取MAC地址失败: {e}") - - # 系统信息作为补充 - hardware_info.append(f"OS:{platform.system()}") - hardware_info.append(f"MACHINE:{platform.machine()}") - - # 如果没有获取到足够的硬件信息,使用系统信息作为fallback - if len(hardware_info) < 2: - hardware_info.append(f"NODE:{platform.node()}") - hardware_info.append(f"PROCESSOR:{platform.processor()}") - - # 生成指纹哈希 - combined_info = "|".join(sorted(hardware_info)) + aux_info.append(f"OS:{platform.system()}") + aux_info.append(f"MACHINE:{platform.machine()}") + if len(core_info) < 1: + core_info.append(f"NODE:{platform.node()}") + core_info.append(f"PROCESSOR:{platform.processor()}") + combined_info = "|".join(sorted(core_info)) machine_id = hashlib.sha256(combined_info.encode('utf-8')).hexdigest()[:16].upper() - self._machine_id = f"W10-{machine_id}" logger.info(f"生成机器指纹: {self._machine_id}") return self._machine_id - except Exception as e: logger.error(f"生成机器指纹失败: {e}") - # 使用fallback方案 fallback_info = f"{platform.system()}-{platform.node()}-{platform.machine()}" fallback_id = hashlib.md5(fallback_info.encode('utf-8')).hexdigest()[:12].upper() self._machine_id = f"FB-{fallback_id}" @@ -429,4 +426,4 @@ class LicenseManager: except Exception as e: logger.error(f"生成激活请求失败: {e}") - raise \ No newline at end of file + raise diff --git a/backend/utils.py b/backend/utils.py index 9f4fe47f..c81b7ce0 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -218,17 +218,8 @@ class DataValidator: name = data['name'].strip() if len(name) < 2 or len(name) > 50: errors.append('姓名长度应在2-50个字符之间') - data['name'] = name + data['name'] = name - # 性别验证 - if data.get('gender'): - # 支持中文和英文性别值 - gender_map = {'男': 'male', '女': 'female', 'male': 'male', 'female': 'female'} - gender_value = data['gender'].strip() - if gender_value in gender_map: - data['gender'] = gender_map[gender_value] - else: - errors.append('性别值无效,应为:男、女、male、female') # 出生日期验证 if data.get('birth_date'): diff --git a/frontend/src/renderer/src/services/api.js b/frontend/src/renderer/src/services/api.js index f29d76b3..3e9f35d8 100644 --- a/frontend/src/renderer/src/services/api.js +++ b/frontend/src/renderer/src/services/api.js @@ -13,7 +13,7 @@ api.interceptors.request.use( if (window.electronAPI) { config.baseURL = window.electronAPI.getBackendUrl() } else { - config.baseURL = 'http://192.168.1.62:5000' + config.baseURL = 'http://localhost:5000' } // 为需要发送数据的请求设置Content-Type(避免覆盖FormData) @@ -187,22 +187,12 @@ export const patientAPI = { // 创建患者 createPatient(data) { return api.post('/api/patients', data) - }, - - // 创建患者(别名方法) - create(data) { - return this.createPatient(data) - }, + }, // 更新患者 updatePatient(id, data) { return api.put(`/api/patients/${id}`, data) - }, - - // 更新患者(别名方法) - update(id, data) { - return this.updatePatient(id, data) - }, + }, // 删除患者 deletePatient(id) { @@ -675,7 +665,7 @@ export const getBackendUrl = () => { if (window.electronAPI) { return window.electronAPI.getBackendUrl() } else { - return 'http://192.168.1.62:5000' + return 'http://localhost:5000' } } diff --git a/frontend/src/renderer/src/views/Dashboard.vue b/frontend/src/renderer/src/views/Dashboard.vue index 8004c370..70cf66c9 100644 --- a/frontend/src/renderer/src/views/Dashboard.vue +++ b/frontend/src/renderer/src/views/Dashboard.vue @@ -10,7 +10,7 @@