PlainApp
API 参考

番茄钟

通过 app.capabilities 判断功能支持,通过 app.access 和宿主权限判断访问授权。示例使用合成数据,调用前请替换路径、ID、输入和筛选条件。

类型定义

graphql
type Subscription {
  pomodoroSettingsChanged: Boolean!
  pomodoroAction: PomodoroAction!
}

type Mutation {
  pausePomodoro: PomodoroToday!
  setPomodoroRemainingTime(remainingSec: Int!): PomodoroToday!
  startPomodoro(durationSec: Int!): PomodoroToday!
  stopPomodoro: PomodoroToday!
}

type Query {
  pomodoroSettings: PomodoroSettings!
  pomodoroToday: PomodoroToday!
}

scalar Instant

type PomodoroAction {
	today: PomodoroToday!
	completedState: PomodoroState
}

type PomodoroSettings {
	workDurationMin: Int!
	shortBreakDurationMin: Int!
	longBreakDurationMin: Int!
	pomodorosBeforeLongBreak: Int!
	showNotification: Boolean!
	playSoundOnComplete: Boolean!
	soundPath: String!
	originalSoundName: String!
}

enum PomodoroState {
	WORK
	SHORT_BREAK
	LONG_BREAK
}

type PomodoroToday {
	date: Instant!
	completedCount: Int!
	currentRound: Int!
	timeLeftSec: Int!
	totalTimeSec: Int!
	isRunning: Boolean!
	isPaused: Boolean!
	state: PomodoroState!
}

操作

subscription

pomodoroSettingsChanged

接收番茄钟设置变更信号。

graphql
subscription pomodoroSettingsChanged {
  pomodoroSettingsChanged
}
subscription

pomodoroAction

接收番茄钟计时动作更新。

graphql
subscription pomodoroAction {
  pomodoroAction { completedState }
}
mutation

pausePomodoro

暂停正在运行的番茄钟。

graphql
mutation pausePomodoro {
  pausePomodoro { date completedCount currentRound timeLeftSec totalTimeSec isRunning isPaused state }
}
mutation

setPomodoroRemainingTime

设置正在运行或已暂停的计时器剩余秒数,范围为 0 到当前轮次时长。

graphql
mutation setPomodoroRemainingTime($remainingSec: Int!) {
  setPomodoroRemainingTime(remainingSec: $remainingSec) { date completedCount currentRound timeLeftSec totalTimeSec isRunning isPaused state }
}
mutation

startPomodoro

按指定秒数启动番茄钟。

graphql
mutation startPomodoro($durationSec: Int!) {
  startPomodoro(durationSec: $durationSec) { date completedCount currentRound timeLeftSec totalTimeSec isRunning isPaused state }
}
mutation

stopPomodoro

停止番茄钟并重置当前轮次。

graphql
mutation stopPomodoro {
  stopPomodoro { date completedCount currentRound timeLeftSec totalTimeSec isRunning isPaused state }
}
query

pomodoroSettings

获取已存储的番茄钟设置,包括时长、自动启动标志和轮次数。

graphql
query pomodoroSettings {
  pomodoroSettings { workDurationMin shortBreakDurationMin longBreakDurationMin pomodorosBeforeLongBreak showNotification playSoundOnComplete soundPath originalSoundName }
}
query

pomodoroToday

获取今日运行信息,包括已完成轮次、当前阶段、剩余时间和运行状态。

graphql
query pomodoroToday {
  pomodoroToday { date completedCount currentRound timeLeftSec totalTimeSec isRunning isPaused state }
}