remove unnecessary logs

This commit is contained in:
frankthwang 2025-07-08 10:08:07 +08:00
parent 785bb904aa
commit 69f0f5d4a5
10 changed files with 23 additions and 23 deletions

View file

@ -6,7 +6,7 @@ A text block timing tool designed for Obsidian, allowing you to add a **count-up
## Features
![Demo](https://github.com/wth461694678/text-block-timer/blob/main/demo.gif)
![Demo](https://github.com/wth461694678/text-block-timer/blob/main/demo/demo.gif)
- Add timers to any text line, supporting multiple timers running simultaneously (stopwatch function).
- ▶️/⏸️ Start, pause, and resume timing for tasks.
@ -22,14 +22,14 @@ A text block timing tool designed for Obsidian, allowing you to add a **count-up
2. When the cursor is on a text block, press the shortcut key to start, pause, or resume.
3. The timer will be displayed in the format `【⏳00:00:00 】` at the beginning of the text line.
![Command Shortcut](https://github.com/wth461694678/text-block-timer/blob/main/command_shortcut.gif)
![Command Shortcut](https://github.com/wth461694678/text-block-timer/blob/main/demo/command_shortcut.gif)
### 2. Mouse Operations
1. Right-click on a text line.
2. Select "Start Timer," "Pause Timer," or "Resume Timer."
![Right Click](https://github.com/wth461694678/text-block-timer/blob/main/right_click.gif)
![Right Click](https://github.com/wth461694678/text-block-timer/blob/main/demo/right_click.gif)
## Custom Settings
@ -41,22 +41,22 @@ Users can freely choose whether to continue the timing after closing the file or
#### 1.1 never stops unless the user stops manually
After a user closes a file or exits Obsidian, the timer will still "time in the background". When the file is opened next time, the time spent during the closure period will be counted as the timer time and the timing will automatically resume.
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_never.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_never.gif" width="100%" alt="">
#### 1.2 auto-stop only when exiting Obsidian. Background timing continues when closing files (recommended, default option)
After the user closes a file, the timer will still "time in the background". When the file is opened next time, the time spent during the closing period will be counted as the timer time and the timing will automatically resume.
However, once the user exits Obsidian, all timers will stop immediately to prevent significant data errors caused by the user forgetting to manually close the timers.
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_quit.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_quit.gif" width="100%" alt="">
#### 1.3 auto-stop immediately when closing a file
After the user closes a file, all timers will stop immediately. However, if a file is closed by mistake, it may cause the timer to pause.
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_close.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_close.gif" width="100%" alt="">
### 2. Timer insert position
Users can choose to insert a timer label either before or after the text block.
<img src="https://github.com/wth461694678/text-block-timer/blob/main/insert_position.png" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/insert_position.png" width="100%" alt="">
## Version Log:

View file

@ -6,7 +6,7 @@
## 功能特性
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/demo.gif" width="100%" alt="">
- 为任意文本行添加计时器,支持同时执行多个计时器(正计时)
- ▶️/⏸️ 支持开始、暂停、继续计时,支持任务分段耗时累计
@ -21,13 +21,13 @@
1. 为命令 "Text Block Timer: Toggle timer" 配置快捷键,方便快速使用
2. 当光标在某个文本块时按下快捷键即可实现timer的开始、暂停、继续操作
3. 计时器会以 `【⏳00:00:00 】`格式显示在文本块的行首
<img src="https://github.com/wth461694678/text-block-timer/blob/main/command_shortcut.gif" width="80%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/command_shortcut.gif" width="80%" alt="">
### 2. 鼠标操作
1. 在文本行上右键点击
2. 选择"开始计时"、"暂停计时"或"继续计时"
<img src="https://github.com/wth461694678/text-block-timer/blob/main/right_click.gif" width="80%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/right_click.gif" width="80%" alt="">
## 自定义设置
@ -39,23 +39,23 @@
#### 1.1 从不停止,除非用户手动停止
用户关闭文件、退出Obsidian后计时器依然会“后台计时”在下次打开文件时会讲关闭期间的耗时计入计时器耗时并自动恢复计时。
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_never.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_never.gif" width="100%" alt="">
#### 1.2 仅退出Obsidian时停止关闭文件依然后台计时推荐默认选项
用户关闭文件后,计时器依然会“后台计时”,在下次打开文件时,会讲关闭期间的耗时计入计时器耗时,并自动恢复计时。
然而用户退出Obsidian后所有计时器会立即停止防止用户忘记手动关闭计时器导致数据产生重大误差。
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_quit.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_quit.gif" width="100%" alt="">
#### 1.3 关闭文件时立即停止
用户关闭文件后,所有计时器会立即停止,但在误关文件时,可能导致计时暂停。
<img src="https://github.com/wth461694678/text-block-timer/blob/main/settings_close.gif" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/settings_close.gif" width="100%" alt="">
### 2. 插入位置
用户可以选择在文本块的前面或后面插入计时器标签。
<img src="https://github.com/wth461694678/text-block-timer/blob/main/insert_position.png" width="100%" alt="">
<img src="https://github.com/wth461694678/text-block-timer/blob/main/demo/insert_position.png" width="100%" alt="">
## 版本日志:

View file

Before

Width:  |  Height:  |  Size: 1,011 KiB

After

Width:  |  Height:  |  Size: 1,011 KiB

View file

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View file

Before

Width:  |  Height:  |  Size: 572 KiB

After

Width:  |  Height:  |  Size: 572 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

18
main.js
View file

@ -62,7 +62,7 @@ class TimerManager {
if (this.timers.has(timerId)) return;
const id = setInterval(() => tickCallback(timerId), UPDATE_INTERVAL);
this.timers.set(timerId, id);
console.log('start timerId:', timerId);
// console.log('start timerId:', timerId);
}
stop(timerId) {
@ -70,7 +70,7 @@ class TimerManager {
if (id) {
clearInterval(id);
this.timers.delete(timerId);
console.log('stop timerId:', timerId);
// console.log('stop timerId:', timerId);
}
}
@ -463,27 +463,27 @@ class TimerPlugin extends obsidian.Plugin {
if (olcheckboxLen > 0) {
var textleft
textleft = lineText.slice(olcheckboxLen);
console.log('textleft after olcheckbox:', textleft);
// console.log('textleft after olcheckbox:', textleft);
before = after = olcheckboxLen;
} else if (ulcheckboxLen > 0) {
var textleft
textleft = lineText.slice(ulcheckboxLen);
console.log('textleft after checkbox:', textleft);
// console.log('textleft after checkbox:', textleft);
before = after = ulcheckboxLen;
} else if (orderedListLen > 0) {
var textleft
textleft = lineText.slice(orderedListLen);
console.log('textleft after ol:', textleft);
// console.log('textleft after ol:', textleft);
before = after = orderedListLen;
} else if (ulLen > 0) {
var textleft
textleft = lineText.slice(ulLen);
console.log('textleft after ul:', textleft);
// console.log('textleft after ul:', textleft);
before = after = ulLen;
} else if (headerLen > 0) {
var textleft
textleft = lineText.slice(headerLen);
console.log('textleft after header:', textleft);
// console.log('textleft after header:', textleft);
before = after = headerLen;
} else {
before = after = 0;
@ -497,7 +497,7 @@ class TimerPlugin extends obsidian.Plugin {
editor.replaceRange(
newSpan, { line: lineNum, ch: before }, { line: lineNum, ch: after }
);
console.log('lineNum:', lineNum, 'before:', before, 'after:', after);
// console.log('lineNum:', lineNum, 'before:', before, 'after:', after);
return data.timerId;
}
@ -553,7 +553,7 @@ class TimerPlugin extends obsidian.Plugin {
this.handleRestore(parsed, editor, i);
} else if (this.settings.autoStopTimers === 'quit') {
// 对于状态为Running且timerId不在this.manager中的计时器如果计时器的本次启动时间 等于 当前插件启动时间,则继续,否则强行暂停
console.log('PLT:', parsed.PLT, 'pluginLoadTime:', this.pluginLoadTime);
// console.log('PLT:', parsed.PLT, 'pluginLoadTime:', this.pluginLoadTime);
if (parsed.PLT === this.pluginLoadTime) {
this.handleRestore(parsed, editor, i);
} else {