This commit is contained in:
limengnan 2025-12-12 18:18:29 +08:00
commit b014088d22
6 changed files with 6569 additions and 14 deletions

Binary file not shown.

View File

@ -233,7 +233,7 @@ def copy_data_files():
data_dir = os.path.join('dist', 'BodyBalanceBackend', 'data') data_dir = os.path.join('dist', 'BodyBalanceBackend', 'data')
# 数据库文件列表 - 这些文件会在程序首次运行时自动创建 # 数据库文件列表 - 这些文件会在程序首次运行时自动创建
db_files = ['body_balance.db'] db_files = ['body_balance.db','common_items.json']
# 检查是否存在现有数据库文件,如果存在则复制 # 检查是否存在现有数据库文件,如果存在则复制
copied_count = 0 copied_count = 0

View File

@ -11,6 +11,7 @@ cors_origins = *
[DATABASE] [DATABASE]
path = D:/BodyCheck/data/body_balance.db path = D:/BodyCheck/data/body_balance.db
common_items_path = D:/BodyCheck/data/common_items.json
backup_interval = 24 backup_interval = 24
max_backups = 7 max_backups = 7

View File

@ -385,10 +385,12 @@ class AppServer:
@self.app.route('/api/common-items', methods=['GET']) @self.app.route('/api/common-items', methods=['GET'])
def get_common_items(): def get_common_items():
try: try:
base_dir = os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)) # 从配置读取通用项文件路径支持相对backend目录
data_dir = os.path.join(base_dir, 'data') fpath = self.config_manager.get_config_value('DATABASE', 'common_items_path', 'data/common_items.json') if self.config_manager else 'data/common_items.json'
os.makedirs(data_dir, exist_ok=True) if not os.path.isabs(fpath):
fpath = os.path.join(data_dir, 'common_items.json') base_dir = os.path.dirname(os.path.abspath(__file__))
fpath = os.path.join(base_dir, fpath)
os.makedirs(os.path.dirname(fpath), exist_ok=True)
if not os.path.exists(fpath): if not os.path.exists(fpath):
with open(fpath, 'w', encoding='utf-8') as f: with open(fpath, 'w', encoding='utf-8') as f:
json.dump({'treatment': [], 'suggestion': []}, f, ensure_ascii=False) json.dump({'treatment': [], 'suggestion': []}, f, ensure_ascii=False)
@ -406,10 +408,12 @@ class AppServer:
label = str(payload.get('label', '')).strip() label = str(payload.get('label', '')).strip()
if itype not in ['treatment', 'suggestion'] or not label: if itype not in ['treatment', 'suggestion'] or not label:
return jsonify({'success': False, 'error': '参数无效'}), 400 return jsonify({'success': False, 'error': '参数无效'}), 400
base_dir = os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)) # 从配置读取通用项文件路径支持相对backend目录
data_dir = os.path.join(base_dir, 'data') fpath = self.config_manager.get_config_value('DATABASE', 'common_items_path', 'data/common_items.json') if self.config_manager else 'data/common_items.json'
os.makedirs(data_dir, exist_ok=True) if not os.path.isabs(fpath):
fpath = os.path.join(data_dir, 'common_items.json') base_dir = os.path.dirname(os.path.abspath(__file__))
fpath = os.path.join(base_dir, fpath)
os.makedirs(os.path.dirname(fpath), exist_ok=True)
data = {'treatment': [], 'suggestion': []} data = {'treatment': [], 'suggestion': []}
if os.path.exists(fpath): if os.path.exists(fpath):
try: try:
@ -436,10 +440,12 @@ class AppServer:
label = str(payload.get('label', '')).strip() label = str(payload.get('label', '')).strip()
if itype not in ['treatment', 'suggestion'] or not label: if itype not in ['treatment', 'suggestion'] or not label:
return jsonify({'success': False, 'error': '参数无效'}), 400 return jsonify({'success': False, 'error': '参数无效'}), 400
base_dir = os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)) # 从配置读取通用项文件路径支持相对backend目录
data_dir = os.path.join(base_dir, 'data') fpath = self.config_manager.get_config_value('DATABASE', 'common_items_path', 'data/common_items.json') if self.config_manager else 'data/common_items.json'
os.makedirs(data_dir, exist_ok=True) if not os.path.isabs(fpath):
fpath = os.path.join(data_dir, 'common_items.json') base_dir = os.path.dirname(os.path.abspath(__file__))
fpath = os.path.join(base_dir, fpath)
os.makedirs(os.path.dirname(fpath), exist_ok=True)
data = {'treatment': [], 'suggestion': []} data = {'treatment': [], 'suggestion': []}
if os.path.exists(fpath): if os.path.exists(fpath):
try: try:
@ -1190,7 +1196,7 @@ class AppServer:
}), 400 }), 400
# 验证数据格式 # 验证数据格式
supported_devices = ['camera', 'femtobolt','imu','pressure'] supported_devices = ['camera1','camera2', 'femtobolt','imu','pressure']
for device_name in data.keys(): for device_name in data.keys():
if device_name not in supported_devices: if device_name not in supported_devices:
return jsonify({ return jsonify({

6547
frontend/src/renderer/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.1.0",
"axios": "^1.5.0", "axios": "^1.5.0",
"echarts": "^5.4.3", "echarts": "^5.4.3",
"element-china-area-data": "^6.1.0",
"element-plus": "^2.3.9", "element-plus": "^2.3.9",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"jspdf": "^3.0.4", "jspdf": "^3.0.4",