feat(ui): 统一管理IUP控件名称常量,增强可维护性

refactor(core): 移除未使用的get_app_context函数
refactor(os_env): 修改backup_registry函数以返回错误码并备份到指定目录
refactor(path_manager): 增强路径管理函数的错误处理
This commit is contained in:
2026-04-28 21:01:52 +08:00
parent 86792012e2
commit ea3d678d22
11 changed files with 229 additions and 178 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ typedef enum {
ERR_INVALID_FORMAT = -6, // 无效格式
ERR_REGISTRY_FAILED = -7, // 注册表操作失败
ERR_NOT_FOUND = -8, // 未找到
ERR_EXISTS = -9 // 已存在
ERR_EXISTS = -9, // 已存在
ERR_INVALID_INDEX = -10 // 无效索引
} ErrorCode;
const char* error_code_to_string(ErrorCode code);
+3 -1
View File
@@ -1,6 +1,8 @@
#ifndef OS_ENV_H
#define OS_ENV_H
#include "utils/error_code.h"
// 检查是否以管理员权限运行
int check_admin(void);
@@ -8,6 +10,6 @@ int check_admin(void);
int is_path_valid(const char *path);
// 备份注册表
void backup_registry(void);
ErrorCode backup_registry(void);
#endif // OS_ENV_H
+38
View File
@@ -0,0 +1,38 @@
#ifndef UI_CONSTANTS_H
#define UI_CONSTANTS_H
// 缓冲区大小常量
#define PATH_BUFFER_SIZE 4096
// 控件名称常量 - 统一管理所有IUP控件名称字符串
// 使用这些常量替代硬编码字符串,便于维护和减少拼写错误
// 列表控件
#define CTRL_LIST_SYS "LIST_SYS"
#define CTRL_LIST_USER "LIST_USER"
// 选项卡
#define CTRL_TABS_MAIN "TABS_MAIN"
// 搜索框
#define CTRL_TXT_SEARCH "TXT_SEARCH"
// 状态标签
#define CTRL_LBL_STATUS "LBL_STATUS"
// 操作按钮
#define CTRL_BTN_NEW "BTN_NEW"
#define CTRL_BTN_EDIT "BTN_EDIT"
#define CTRL_BTN_BROWSE "BTN_BROWSE"
#define CTRL_BTN_DEL "BTN_DEL"
#define CTRL_BTN_UP "BTN_UP"
#define CTRL_BTN_DOWN "BTN_DOWN"
#define CTRL_BTN_CLEAN "BTN_CLEAN"
#define CTRL_BTN_IMPORT "BTN_IMPORT"
#define CTRL_BTN_EXPORT "BTN_EXPORT"
#define CTRL_BTN_OK "BTN_OK"
#define CTRL_BTN_CANCEL "BTN_CANCEL"
#define CTRL_BTN_HELP "BTN_HELP"
#define CTRL_BTN_LANG "BTN_LANG"
#endif // UI_CONSTANTS_H