Skip to content

Slice 2: 触发行为扩展 停止/退出 + 行为选择 UI + 生命周期清理 #3

Description

@Znfooe

Parent

#1 feat: 睡眠定时器 (Sleep Timer)

What to build

扩展睡眠定时器的触发行为,除暂停外支持「停止播放」和「退出应用」两种行为,并在 UI 中提供选择。

端到端路径:

  1. 主进程 — SleepTimerService:

    • SleepTimerAction 类型扩展为 'pause' | 'stop' | 'quit'
    • start() 的 action 参数支持三种值
    • action === 'stop' 时调用 AudioSession.stop()(完全清理)
    • action === 'quit' 时调用 app.quit()(触发已有优雅退出流程)
  2. 主进程 — 生命周期集成:

    • 在 lifecycle.ts 的 cleanupBeforeQuit() 中添加 sleepTimerService.cancel()
    • 确保应用退出时不残留定时器回调导致异常
  3. UI — Popover 行为选择:

    • 在预设时长按钮上方增加单选组:( ) 暂停 ( ) 停止 ( ) 退出
    • 默认选中"暂停"
    • 选择行为后点击时长按钮才生效

Acceptance criteria

  • Popover 中可选择三种触发行为(暂停/停止/退出)
  • 选择"停止"时,到期后完全停止播放(清空当前曲目和进度)
  • 选择"退出"时,到期后走完整优雅退出流程(12 子系统有序关闭)
  • 应用被手动关闭时,定时器被正确清除(无残留回调报错)
  • 默认行为为"暂停"

Blocked by

#2 (Slice 1: MVP 核心定时器)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, AFK-ready an agent can pick it up with no human context

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions