commit 250512527e0803748028916c9d0ca8302db19b3d Author: leimingsheng Date: Thu Aug 28 17:53:25 2025 +0800 init repo diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9110312 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# 编译时文件夹忽略 +build/ +dist/ +# 运行时缓存文件夹忽略 +onekeydiag_cache/ + +# 可能存在的压缩包文件忽略 +*.gz +*.tar +*.zip \ No newline at end of file diff --git a/distruibution.spec b/distruibution.spec new file mode 100644 index 0000000..e69de29 diff --git a/docs/D01_环境部署.md b/docs/D01_环境部署.md new file mode 100644 index 0000000..d7d4f74 --- /dev/null +++ b/docs/D01_环境部署.md @@ -0,0 +1 @@ +# D01_环境部署 \ No newline at end of file diff --git a/docs/D02_工程结构.md b/docs/D02_工程结构.md new file mode 100644 index 0000000..17c45d8 --- /dev/null +++ b/docs/D02_工程结构.md @@ -0,0 +1 @@ +# D02_工程结构 \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..afa82c6 --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ +# OneKeyLog Diag Program V2 + +## 简介 + +## 开发指北 + +## 使用指南 \ No newline at end of file diff --git a/resource/favicon.ico b/resource/favicon.ico new file mode 100644 index 0000000..c83210e Binary files /dev/null and b/resource/favicon.ico differ diff --git a/src/app/main.py b/src/app/main.py new file mode 100644 index 0000000..18f3a41 --- /dev/null +++ b/src/app/main.py @@ -0,0 +1,11 @@ +import os, sys +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from common.app_logger import record_log +from common.cache_mgmt import app_cache_create + +if __name__ == "__main__": + # Project Entry + app_cache_create() + record_log("INFO", "Start App") + \ No newline at end of file diff --git a/src/backend/.gitignore b/src/backend/.gitignore new file mode 100644 index 0000000..7070e9f --- /dev/null +++ b/src/backend/.gitignore @@ -0,0 +1,2 @@ +# 外网开源, 项目级敏感代码忽略 +proj_ZiJin/ \ No newline at end of file diff --git a/src/backend/__init__.py b/src/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/back_service.py b/src/backend/back_service.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/proj_app/__init__.py b/src/backend/proj_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/common/.gitignore b/src/common/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/src/common/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/src/common/__init__.py b/src/common/__init__.py new file mode 100644 index 0000000..8207b8c --- /dev/null +++ b/src/common/__init__.py @@ -0,0 +1,8 @@ +from ._globals import ( + cache_dir +) + +def init_package_coomon(): + pass + +init_package_coomon() \ No newline at end of file diff --git a/src/common/_globals.py b/src/common/_globals.py new file mode 100644 index 0000000..59ae9e2 --- /dev/null +++ b/src/common/_globals.py @@ -0,0 +1,9 @@ +""" common 包中的全局变量 + +""" + +import os + +source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +proj_dir = os.path.dirname(source_dir) +cache_dir = os.path.join(proj_dir, "onekeydiag_cache") \ No newline at end of file diff --git a/src/common/app_logger.py b/src/common/app_logger.py new file mode 100644 index 0000000..280e368 --- /dev/null +++ b/src/common/app_logger.py @@ -0,0 +1,32 @@ +import os +import time + +from . import cache_dir + +LOG_FILE = os.path.join(cache_dir, "running.log") + +def record_log(log_level, log_description): + """ + 记录日志到指定路径的函数 + + 参数: + log_level (str): 日志等级,如"INFO", "WARNING", "ERROR", "CRITICAL"等 + log_description (str): 日志的具体描述内容 + """ + try: + + # 日志时间格式:YYYY-MM-DD HH:MM:SS + current_time = time.strftime("%Y-%m-%d %H:%M:%S") + + # 构建日志内容 + log_entry = f"[{current_time}] [{log_level.upper()}] {log_description}\n" + + # 追加写入日志 + with open(LOG_FILE, "a", encoding="utf-8") as f: + f.write(log_entry) + + return True + + except Exception as e: + print(f"日志记录失败: {str(e)}") + return False \ No newline at end of file diff --git a/src/common/cache_mgmt.py b/src/common/cache_mgmt.py new file mode 100644 index 0000000..a4fae80 --- /dev/null +++ b/src/common/cache_mgmt.py @@ -0,0 +1,12 @@ +import os + +from . import cache_dir +from app_logger import LOG_FILE + +def app_cache_create(): + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + +def clean_running_log(): + if os.path.exists(LOG_FILE): + os.remove(LOG_FILE) \ No newline at end of file diff --git a/src/common/file_tool.py b/src/common/file_tool.py new file mode 100644 index 0000000..e69de29 diff --git a/src/frontend/__init__.py b/src/frontend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/frontend/onekeydiag_ui.py b/src/frontend/onekeydiag_ui.py new file mode 100644 index 0000000..e69de29 diff --git a/version b/version new file mode 100644 index 0000000..e69de29