Skip to content

feat: 增加 Windows 定时关机功能 - #482

Merged
ihmily merged 2 commits into
ihmily:mainfrom
SRiftX:feat/scheduled-shutdown
Aug 5, 2026
Merged

ihmily merged 2 commits into
ihmily:mainfrom
SRiftX:feat/scheduled-shutdown

Conversation

@SRiftX

@SRiftX SRiftX commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

功能说明

本 PR 为 StreamCap 的 Windows 桌面端增加定时关机功能,适合长时间录制、无人值守监控或挂机任务完成后自动关闭电脑,减少用户等待和不必要的设备运行时间。

修改内容

  • 在“基础设置”中新增单行“定时关机”入口,可启用每日固定时间关机并通过时间选择器设置关机时间。
  • 增加快捷关机设置,支持输入 1–168 小时后的延时关机,例如 3 小时、100 小时或一周后关机。
  • 快捷关机在执行前显示确认窗口,并明确展示预计关机时间,防止误操作。
  • 每日定时任务触发后使用 Windows 原生关机命令启动 60 秒倒计时,倒计时窗口中可取消本次关机。
  • 快捷关机可通过界面调用 Windows shutdown /a 取消,并在取消后恢复每日定时任务。
  • 定时任务会在配置变更、恢复默认设置和程序启动时自动重新调度,并在程序退出时清理内部异步任务。
  • 增加简体中文和英文界面文案;该功能默认关闭。
  • 仅在 Windows 桌面端显示,Web 端及其他操作系统不会出现该设置,也不会执行系统关机命令。

使用方式

  1. 打开“设置”→“录制设置”→“基础设置”。
  2. 开启“定时关机”并选择每日关机时间,即可每天在指定时间启动关机倒计时。
  3. 点击该设置行末尾的进入按钮,可设置 1–168 小时后的快捷关机。
  4. 已启动的快捷关机可在同一窗口中取消。

安全性设计

  • 功能默认关闭,不会改变现有用户行为。
  • 快捷关机必须经过二次确认。
  • 每日关机触发后保留 60 秒取消时间。
  • 所有系统命令均限制在 Windows 桌面环境中执行。
  • 快捷关机与每日定时任务互斥,避免同时提交多个关机计划。

验证

  • python -m compileall -q app main.py
  • 默认配置及中英文语言 JSON 解析检查
  • git diff --check
  • 本地完成 9 项时间计算、范围校验及关机命令参数测试,均通过
  • 已实际启动 StreamCap 验证设置加载,验证过程中未提交真实关机计划

按照维护者要求,本 PR 未提交 tests/ 文件夹、.idea 文件夹或其他无关文件。

@SRiftX

SRiftX commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

单纯个人使用中 有时候会用到这个功能 但是没有 自己添加的一个小功能

@ihmily
ihmily merged commit be8c281 into ihmily:main Aug 5, 2026
2 checks passed
creky added a commit to creky/StreamCap that referenced this pull request Sep 12, 2026
commit e1e8dbf
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sat Aug 8 16:52:03 2026 +0800

    revert locales files

commit 8f83097
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Aug 8 16:38:04 2026 +0800

    ⬆ update cachetools requirement from >=7.1.4 to >=7.1.6 (ihmily#476)

    Updates the requirements on [cachetools](https://github.com/tkem/cachetools) to permit the latest version.
    - [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
    - [Commits](tkem/cachetools@v7.1.4...v7.1.6)

    ---
    updated-dependencies:
    - dependency-name: cachetools
      dependency-version: 7.1.6
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit d58cb2d
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Aug 8 16:37:36 2026 +0800

    ⬆ update ruff requirement from ~0.15.20 to ~0.16.0 (ihmily#479)

    Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
    - [Release notes](https://github.com/astral-sh/ruff/releases)
    - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
    - [Commits](astral-sh/ruff@0.15.20...0.16.0)

    ---
    updated-dependencies:
    - dependency-name: ruff
      dependency-version: 0.16.0
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 2de671c
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sat Aug 8 16:33:04 2026 +0800

    Add custom video bitrate support

commit be8c281
Author: lsr-05 <780400372@qq.com>
Date:   Wed Aug 5 14:48:13 2026 +0800

    feat: 增加 Windows 定时关机功能 (ihmily#482)

commit 6841442
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Fri Jul 24 18:43:44 2026 +0800

    fix: support CHZZK fMP4 HLS streams in FFmpeg 8

commit db436d4
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jul 24 17:24:08 2026 +0800

    ⬆ update ruff requirement from ~0.15.15 to ~0.15.20 (ihmily#460)

    Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
    - [Release notes](https://github.com/astral-sh/ruff/releases)
    - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
    - [Commits](astral-sh/ruff@0.15.15...0.15.20)

    ---
    updated-dependencies:
    - dependency-name: ruff
      dependency-version: 0.15.20
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 7767ed8
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 18:51:33 2026 +0800

    fix: avoid blocking event loop during email delivery

commit 1ca8f83
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 18:31:23 2026 +0800

    fix: prevent language observer memory leaks

commit 766224e
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 18:21:10 2026 +0800

    fix: prevent ffmpeg stderr pipe deadlocks

commit 8d198e1
Merge: 3b3f4c9 2bee85e
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 17:53:55 2026 +0800

    Merge branch 'main' of https://github.com/ihmily/StreamCap

commit 3b3f4c9
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 17:52:59 2026 +0800

    fix: secure video paths and stream range responses

commit 2bee85e
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 17:32:16 2026 +0800

    refactor:  adjusting window setup scaling and minimum dimensions

commit c9ef45d
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 15:54:18 2026 +0800

    feat: enhance sidebar branding and move theme color settings

commit 589248f
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Sun Jul 12 14:34:38 2026 +0800

    Fix async call for launching URL in browser

commit aceccd1
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 05:56:55 2026 +0800

    Update DMG window position in create_macos_dmg.sh

    Adjusted the position of the DMG window by changing the left and top coordinates.

commit 3e8bbe2
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 05:38:02 2026 +0800

    Update DMG window position parameters

    Adjusted the positioning of the DMG window.

commit be7f4d4
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 05:27:40 2026 +0800

    update window bounds in DMG creation script

commit 7492afc
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 05:13:50 2026 +0800

    adjust DMG window positioning in create_macos_dmg.sh

    Updated the script to dynamically position the DMG window based on desktop dimensions.

commit 0421d5e
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 04:58:00 2026 +0800

    Fix lint issues

commit d709c07
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 04:50:07 2026 +0800

    Fix Windows artifact packaging and recording path

commit 3799329
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 04:14:34 2026 +0800

    use _internal layout for Windows builds

commit f136b97
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 03:51:18 2026 +0800

    fix: adjust DMG window height and path bar visibility

    Increased the height of the DMG window from 480 to 540 pixels and updated the visibility of the path bar.

commit c993830
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 03:42:39 2026 +0800

    Use variable for Finder background image

    Updated the Finder window layout configuration to use a variable for the background image.

commit add553e
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 03:39:01 2026 +0800

    Refactor DMG creation script for mount directory handling

    Removed MOUNT_DIR initialization and adjusted hdiutil attach command to not specify mountpoint. Updated MOUNT_DIR assignment to derive from attach output.

commit 0b52dd4
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 03:35:26 2026 +0800

    Refactor DMG creation script for layout customization

commit 97cf224
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 03:06:45 2026 +0800

    ci: fix macOS DMG image creation

commit c8fc43c
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 02:57:03 2026 +0800

    ci: harden macOS DMG packaging

commit 584c47a
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 02:40:01 2026 +0800

    ci: fix macOS DMG script line endings

commit 4122b4b
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 02:25:35 2026 +0800

    ci: fix Windows desktop build arguments

commit b511596
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 02:21:19 2026 +0800

    ci: add macOS DMG installer layout

commit 6ab5a64
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 01:57:39 2026 +0800

    ci: add desktop app build workflow

commit eb3a313
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 00:53:58 2026 +0800

    fix: add macOS file picker entitlement

commit 06ba3d8
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon Jul 6 00:28:09 2026 +0800

    feat: add desktop packaging scripts

commit f529820
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 14:36:00 2026 +0800

    fix: optimize responsive layout of cards

commit 53515aa
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 13:41:23 2026 +0800

    fix: window display center on startup

commit 8d25ce2
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 12:27:36 2026 +0800

    feat: support save paths with spaces for macOS and Windows

commit ac3d32d
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 11:32:53 2026 +0800

    style: fix lint issues

commit 56c61f2
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 11:23:25 2026 +0800

    feat: preserve Windows paths with spaces

commit 5f14041
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Jun 17 10:19:38 2026 +0800

    fix: add no cdn for web mode

commit 9a30298
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue Jun 16 17:51:38 2026 +0800

    fix: hide window on startup

commit 0201cd2
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue Jun 16 17:26:57 2026 +0800

    update requirements

commit 61a2484
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jun 16 16:51:34 2026 +0800

    ⬆ update cachetools requirement from >=7.1.1 to >=7.1.4 (ihmily#434)

    Updates the requirements on [cachetools](https://github.com/tkem/cachetools) to permit the latest version.
    - [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
    - [Commits](tkem/cachetools@v7.1.1...v7.1.4)

    ---
    updated-dependencies:
    - dependency-name: cachetools
      dependency-version: 7.1.4
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit ebaa0a7
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jun 16 16:50:45 2026 +0800

    ⬆ update ruff requirement from ~0.15.12 to ~0.15.15 (ihmily#431)

    Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
    - [Release notes](https://github.com/astral-sh/ruff/releases)
    - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
    - [Commits](astral-sh/ruff@0.15.12...0.15.15)

    ---
    updated-dependencies:
    - dependency-name: ruff
      dependency-version: 0.15.15
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 22fc04a
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon May 25 22:18:45 2026 +0800

    refactor: separate UI logic from business layer in recording management

commit c95e03c
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon May 25 16:59:31 2026 +0800

    fix: change response status code check logic

commit d1fb600
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon May 25 16:48:56 2026 +0800

    style: fix lint issues

commit 56075cc
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon May 25 16:45:13 2026 +0800

    fix: handle HTTP redirect (302) in direct stream downloader

commit 241ed18
Author: DealsBeam <brigade12@gmail.com>
Date:   Mon May 25 04:29:18 2026 -0400

    ⚡ Bolt: optimize direct download I/O and regex compilation (ihmily#415)

commit 95b5942
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 20 16:12:05 2026 +0800

    fix(recording): replace page.run_task with run_task_safe to handle closed web session gracefully

commit e0e5efd
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Fri May 15 17:28:12 2026 +0800

    fix: resolve session.connection.loop None error

commit ba9f1e6
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 13 18:51:23 2026 +0800

    refactor: extract FLET_VIEW_PATH bundled setup into runtime module

commit 1a77035
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 13 15:07:25 2026 +0800

    Update .gitignore

commit ffe0cc3
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 13 15:04:10 2026 +0800

    fix: adapt to v0.85.0 changes

commit 42bc84e
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 13 13:41:22 2026 +0800

    choreu: update flet dependencies from v0.84.0 to v0.85.0

commit 01d003c
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed May 13 10:08:35 2026 +0800

    fix: resolve batch recording errors

commit 2aea665
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 18:54:45 2026 +0800

    fix: update restore window method

commit 8cfc058
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 14:17:42 2026 +0800

    feat: update version display file

commit 2678c45
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 12:14:08 2026 +0800

    update readme

commit d46ff4c
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 11:42:55 2026 +0800

    fix: update window destroy apply from sync to async

commit 90bbb5a
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 11:40:17 2026 +0800

    revert: update douyin PC web profile link record

commit 9be34bc
Author: Hmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 11:22:07 2026 +0800

    fix: update douyin PC web profile link record

commit ba2f3d9
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 10:57:46 2026 +0800

    update dependencies

commit f63eab2
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Tue May 12 10:23:01 2026 +0800

    feat: update and mark some invalid platforms

commit ca28516
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Mon May 11 19:55:24 2026 +0800

    fix: update recording diglog

commit ca47051
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Thu May 7 11:04:23 2026 +0800

    update readme

commit 20fb0a9
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu May 7 10:29:55 2026 +0800

    ⬆ Update ruff requirement from ~0.15.8 to ~0.15.12 (ihmily#396)

    Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
    - [Release notes](https://github.com/astral-sh/ruff/releases)
    - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
    - [Commits](astral-sh/ruff@0.15.8...0.15.12)

    ---
    updated-dependencies:
    - dependency-name: ruff
      dependency-version: 0.15.12
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit bf210a8
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu May 7 10:29:39 2026 +0800

    ⬆ Update cachetools requirement from >=5.5.2 to >=7.1.1 (ihmily#395)

    Updates the requirements on [cachetools](https://github.com/tkem/cachetools) to permit the latest version.
    - [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
    - [Commits](tkem/cachetools@v5.5.2...v7.1.1)

    ---
    updated-dependencies:
    - dependency-name: cachetools
      dependency-version: 7.1.0
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 2e086ec
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu May 7 10:26:58 2026 +0800

    ⬆ Update python-dotenv requirement from ~1.2.1 to ~1.2.2 (ihmily#394)

    Updates the requirements on [python-dotenv](https://github.com/theskumar/python-dotenv) to permit the latest version.
    - [Release notes](https://github.com/theskumar/python-dotenv/releases)
    - [Changelog](https://github.com/theskumar/python-dotenv/blob/main/CHANGELOG.md)
    - [Commits](theskumar/python-dotenv@v1.2.1...v1.2.2)

    ---
    updated-dependencies:
    - dependency-name: python-dotenv
      dependency-version: 1.2.2
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 33e822e
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Thu Apr 30 16:02:17 2026 +0800

    fix: update button field

commit 2e1f60f
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Thu Apr 30 15:39:39 2026 +0800

    fix: update snackbar message color

commit 6f99fbd
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Apr 29 18:40:47 2026 +0800

    fix: resolve LanguageManager observer registration failure

commit d0ab490
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Apr 29 16:34:59 2026 +0800

    fix: update time picker open

commit 4b86281
Author: ihmily <114978440+ihmily@users.noreply.github.com>
Date:   Wed Apr 29 15:39:52 2026 +0800

    refactor: migrate flet from v0.27.6 to v0.84.0

    - Update deprecated APIs
    - Adapt breaking changes in flet 0.80+
    - Test UI components compatibility

# Conflicts:
#	app/__init__.py
#	app/app_manager.py
#	app/core/media/direct_downloader.py
#	app/core/media/ffmpeg_builders/base.py
#	app/core/media/ffmpeg_builders/video/mp4.py
#	app/core/recording/record_manager.py
#	app/core/recording/stream_manager.py
#	app/lifecycle/app_close_handler.py
#	app/messages/message_pusher.py
#	app/models/recording/recording_model.py
#	app/ui/components/business/recording_card.py
#	app/ui/components/business/recording_dialog.py
#	app/ui/views/recordings_view.py
#	app/ui/views/settings_view.py
#	main.py
#	pyproject.toml
#	requirements-web.txt
#	requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants