C++课程设计:3.1-注册登录

Home Doc Changelog Download About

Prompt

我设计了一个程序,用于项目管理。功能是记录并统计项目执行时间,最终可视化呈现在日历上,以监视我的项目执行时间分布。

这个程序将运行在我的服务器上,最终打包为程序,因此需要通过账号注册登录来管理,同步数据。

nav 栏包括左侧的Logo+程序名称,点击后进入默认视图(登陆后为所有,未登录则为注册/登录页),右侧为:

  • 未登录
    • register:点击跳转到register.html注册页
    • login:点击跳转到login.html登录页
  • 登录后
    • 用户名:点击跳转到profile.html查看修改用户信息
    • logout :点击退出登录

注册登录后直接进入数据看板,顶部有所有,日,周,月,年五个视图按钮和一个新建按钮,登录后默认为所有视图,并可通过nav跳转到其他视图。视图以排行榜降序的形式呈现数据,左侧为执行/停止执行按钮,中间为proj_name,右侧为对应视图的统计持续时间。点击新建按钮后跳转到create.html,用以新建项目,填写一个表单后将项目数据添加到数据库

  • project_name
  • id:自动生成,项目的唯一代表
  • status:复选框,共有:进行中,暂停,已完成,取消四个状态选项
  • note:文本备注,可以是任何内容

新建后排行榜底部应该出现一个时长为0的新项目。点击执行按钮后开始一次计时record,记录recordstart_time,按钮变成停止执行,点击停止执行后,记录recordend_time,按钮变回执行,并自动计算lasting_time=end_time-start_time,作为这个projectrecords中的一个record数据。更新project的当日,当周,当月,当年,总计数据,加上这个新的record的时长数据。在打开不同视图时读取每一个项目对应的时长参数并排序降序渲染为排行榜。默认展示“所有”视图。

下面是整个项目的文件树,使用python-flask+html+css+javascript+SQLite实现。

# 2023-08-12
├── ATimer
│   ├── __init__.py
│   ├── db.py
│   ├── views.py      # 处理不同URL的逻辑,渲染html模板展示数据。
│   ├── auth.py       # register & login & profile
│   ├── models.py     # 定义User,Project和record三个模型类,用于对数据库进行CRUD操作
│   ├── config.py     
│   ├── schema.sql    
│   ├── static
│   │   ├── css
│   │   │   └── style.css
│   │   └── js
│   │       └── script.js
│   └── templates
│       ├── auth
│       │   ├── register.html
│       │   ├── login.html
│       │   └── profile.html
│       ├── views
│       │   ├── all.html
│       │   ├── day.html
│       │   ├── week.html
│       │   ├── month.html
│       │   └── year.html
│       ├── create.html
│       ├── index.html
│       └── base.html          # 使用Jinja2模板引擎生成,作为基模板,其他页面继承它。
├── MANIFEST.in
├── requirements.txt
├── .env
├── .gitignore
└── setup.py                   # python setup.py install


#auth.py is a blueprint for the authentication system of the app. It handles the login, logout and register pages.

#db.py is a blueprint for the database system of the app. It handles the database connection and initialization.

#views.py is a blueprint for the views of the app. It handles the main pages of the app.

#models.py is a blueprint for the models of the app. It handles the database models of the app.

#The __init__.py file is a blueprint for the app itself. It handles the app creation and configuration.
  • 项目布局 应用工厂

  • 使用 SQLite 数据库

  • 使用PickleType存储键值对字典。

  • session g current_user

  • 一键导出目录下所有代码为一个文本喂给GPT