Skip to content

Commit

Permalink
feat: 1.准备增加【重复番茄钟】功能
Browse files Browse the repository at this point in the history
  • Loading branch information
JuckZ committed Apr 20, 2023
1 parent dcfdead commit 99ecdea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default {
totalTime: 'Total time',
noTimeLine: 'No timeline content',
startTask: '🚀 Start',
repeatTask: '🚀 Repeat',
stopTask: '⏸️ Stop',
finishTask: '✅ Finish',
cancelTask: '❎ Cancel',
Expand Down
1 change: 1 addition & 0 deletions src/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default {
totalTime: '总专注时长',
noTimeLine: '无时间线内容',
startTask: '🚀 开始',
repeatTask: '🚀 重复',
stopTask: '⏸️ 暂停',
finishTask: '✅ 完成',
cancelTask: '❎ 取消',
Expand Down
19 changes: 6 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
}

async addPomodoro(task: string) {
task = task.replace('- [x] ', '');
task = task.replace('- [ ] ', '').trim();
if (!task) {
task = t.menu.defaultTask + Date.now();
}
const createTime = moment().format('YYYY-MM-DD HH:mm:ss');
const tags: string[] = getTagsFromTask(task);
const content: string = getTaskContentFromTask(task);
Expand Down Expand Up @@ -213,12 +218,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
title: t.menu.planPomodoro,
icon: 'send',
clickFn: async (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
let task = EditorUtils.getCurrentSelection(editor);
task = task.replace('- [x] ', '');
task = task.replace('- [ ] ', '').trim();
if (!task) {
task = t.menu.defaultTask + Date.now();
}
const task = EditorUtils.getCurrentSelection(editor);
this.addPomodoro(task);
},
},
Expand All @@ -236,13 +236,6 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
);
},
},
{
title: 'Reveal current file in navigation',
icon: 'navigation',
clickFn: async (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
this.app.commands.executeCommandById('file-explorer:reveal-active-file');
},
},
];
}

Expand Down
14 changes: 11 additions & 3 deletions src/ui/TimeLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ const getOptions = currentStatus => {
key: 'cancelled',
show: !['done', 'cancelled'].contains(currentStatus),
},
{
label: t.info.repeatTask,
key: 'repeat',
show: ['done', 'cancelled'].contains(currentStatus),
},
{
label: t.info.deleteTask,
key: 'deleted',
Expand All @@ -147,18 +151,22 @@ const getOptions = currentStatus => {
];
};
const handleSelect = (
targetStatus: 'ing' | 'done' | 'todo' | 'cancelled' | 'break' | 'deleted',
targetStatus: 'ing' | 'done' | 'todo' | 'cancelled' | 'break' | 'repeat' | 'deleted',
pomodoro: Pomodoro,
) => {
if (targetStatus != 'deleted') {
const ps = new PomodoroStatus(pomodoro);
if (targetStatus == 'ing') {
if (targetStatus === 'ing') {
const ingPomodoro = pomodoroList.value.find(item => item.status === 'ing');
if (ingPomodoro) {
message.error(`${t.info.handleThisFirst + ingPomodoro.task}`);
return;
}
}
if (targetStatus === 'repeat') {
console.log('TODO, add a quick add pomodoro method');
// usePomodoroStore().addPomodoro();
}
const changed = ps.changeState(targetStatus);
if (changed) {
usePomodoroStore().updatePomodoro(pomodoro);
Expand Down

0 comments on commit 99ecdea

Please sign in to comment.