refactor: 重构项目为 MVC 架构并移除全局变量

- 将原有扁平目录结构重构为 MVC 分层架构:
  * src/core/: 核心业务逻辑(Model),完全独立于 UI 框架
  * src/ui/: 界面组件构建(View),负责纯视觉展示
  * src/controller/: 用户交互处理(Controller),连接数据与界面
  * src/utils/: 底层工具函数,专注于系统调用和字符串处理
- 引入 AppContext 结构体统一管理应用状态,替代原有的全局变量模式
- 重命名并重新组织头文件,按功能模块划分到对应子目录
- 更新 CMakeLists.txt 以适配新的目录结构
- 同步更新 README.md 文档,说明新的架构设计
This commit is contained in:
2026-03-19 20:58:41 +08:00
parent 6509ef98e4
commit a769a6b9b3
30 changed files with 1351 additions and 1243 deletions
+13
View File
@@ -0,0 +1,13 @@
#ifndef OS_ENV_H
#define OS_ENV_H
// 检查是否以管理员权限运行
int check_admin(void);
// 检查路径是否有效
int is_path_valid(const char *path);
// 备份注册表
void backup_registry(void);
#endif // OS_ENV_H
+24
View File
@@ -0,0 +1,24 @@
#ifndef STRING_EXT_H
#define STRING_EXT_H
#include <wchar.h>
// 简单字符串列表结构
typedef struct
{
char **items;
int count;
int capacity;
} StringList;
// 字符串列表
void init_string_list(StringList *list);
void add_string_list(StringList *list, const char *str);
void clear_string_list(StringList *list);
// 字符串转换函数
char *wide_to_utf8(const wchar_t *wstr);
wchar_t *utf8_to_wide(const char *str);
char *stristr(const char *haystack, const char *needle);
#endif // STRING_EXT_H