Skip to content

Commit

Permalink
feat: 1.状态栏展示番茄钟剩余时间和番茄钟名称 #20
Browse files Browse the repository at this point in the history
  • Loading branch information
JuckZ committed Apr 18, 2023
1 parent cf6a7e2 commit ec46f9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
LoggerUtil.error('Update failed', pomodoro);
}
}
if (pomodoroStatus.getState() === 'ing') {
const statusBar = document.querySelector('#obsidian-manager-pomodoro-status-bar');
statusBar?.setAttr('title', pomodoro.task);
// TODO 控制titlebar的宽度,使用省略号
const remainTime = moment.duration(pomodoroStatus.getRemainTime(), 'milliseconds');
statusBar?.setText(
`🍅 ${pomodoroStatus.getPomodoro().task} ${moment
.utc(remainTime.asMilliseconds())
.format('HH:mm:ss')}`,
);
}
}, 1 * 1000),
);
}
Expand Down Expand Up @@ -513,6 +524,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
obsidianManagerPomodoroStatusBar.createEl('span', {
text: '🍅',
attr: {
id: 'obsidian-manager-pomodoro-status-bar',
style: 'cursor: pointer',
},
});
Expand Down
6 changes: 6 additions & 0 deletions src/utils/pomotodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class PomodoroStatus {
return spend;
}

getRemainTime() {
const realSpend = this.getRealSpend();
const expectedTime = parseInt(this.pomodoro.expectedTime);
return expectedTime - realSpend;
}

setSpend() {
this.pomodoro.spend = this.getRealSpend().toString();
}
Expand Down

0 comments on commit ec46f9b

Please sign in to comment.