Skip to content

A lightweight mini-program built with C++ and WebView that tracks your coding time and generates a Code-Time Badge.

License

Notifications You must be signed in to change notification settings

Haruko386-UnOffical/Code-Time-Counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⏱️ Code Time Counter

A modern, lightweight, and beautiful coding time tracker for Windows. Built with C++ and Web Technologies.

Code Time Counter 是一个运行在 Windows 平台上的极简代码时长统计工具。它在后台运行,自动检测你是否正在使用 IDE 或开发工具,并累计你的编程时间,自动生成 Shields.io 格式的 Badge.


✨ 功能特性 (Features)

  • 🎯 智能自动计时:自动检测当前活动窗口。只要你在使用 Visual Studio, VS Code, JetBrains 系列, 浏览器 (查阅文档) 或 终端工具,它就会自动开始计时。
  • ☁️ Badge 生成:实时更新本地的 badge.md 文件,包含 markdown 格式的时间统计徽章,可直接复制到 GitHub Readme。
  • 🔋 轻量级:使用 C++ 编写,资源占用低。
  • 💾 数据持久化:自动保存统计数据和 UI 配置(背景图路径、模糊度、窗口位置)。

🛠️ 技术栈 (Tech Stack)

  • Core: C++17 (MinGW-w64)
  • GUI Engine: webview (Edge/Chromium 内核)
  • Frontend: HTML5, CSS3 (Flexbox, Backdrop-Filter), JavaScript (ES6+)
  • System API: Windows API (Win32), DWM API (Rounded Corners), Shell API (Tray Icon)

📸 预览


🚀 快速开始 (Getting Started)

1. 环境依赖

确保你的开发环境安装了以下工具:

  • MinGW-w64 (带 g++ 支持 C++17)
  • WebView2 Runtime (Windows 10/11 通常自带,如无请安装 Edge)

2. 项目结构

确保你的源码目录结构如下:

CodeTracker/
├── include/        # 头文件 (tracker.h, webview.h)
├── src/            # 源代码 (main.cpp, tracker.cpp, etc.)
├── resources/      # 资源文件 (图标, manifest)
├── ui/             # 前端界面 (index.html)
├── static/         # 静态资源 (图标文件)
└── build.bat       # 编译脚本

3. 编译

项目自带一键编译脚本。双击运行根目录下的 build.bat 即可:

./build.bat

编译成功后,可执行文件将生成在 bin/CodeTracker.exe


📖 使用说明

  1. 启动:运行 bin/CodeTracker.exe
  2. 计时:打开你常用的开发软件(如 VS Code),程序会自动检测并开始计时,状态变为 "Tracking"。
  3. 个性化设置
  • 点击左上角的 ☰ 菜单
  • Upload Background:选择一张你喜欢的图片作为背景(图片会自动保存到 bin/bg/ 目录)。
  • Blur Intensity:拖动滑块调整界面的模糊程度。
  1. 最小化:点击右上角的 ×,程序会隐藏到系统托盘。
  2. 退出:在左上角菜单中选择 "Exit Application",或右键点击托盘图标选择 "Exit Completely"。

📊 获取 Badge

程序运行时会在 bin/ 目录下生成一个 badge.md 文件。 内容示例如下:

Code Time


📝 配置文件

程序会自动在同级目录下生成以下文件,请勿随意删除:

  • code_time.dat: 存储累计的总秒数。
  • config.ini: 存储 UI 配置(窗口位置、背景路径、模糊度)。

Todo

  • 置顶按钮
  • 置顶后左键操作时忽略窗口
  • Github action 自动生成badge

🎫 License

Important

本项目遵循 MIT License © Haruko386

About

A lightweight mini-program built with C++ and WebView that tracks your coding time and generates a Code-Time Badge.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages