diff --git a/README.md b/README.md index 2922c92..8f9635d 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,39 @@ -# 🍅 tomato-timer-widget :) +# 🍅 番茄钟小部件 -[中文说明](README_CN.md) +Trilium 的番茄钟插件在原作者基础上进行了改进 -Please stand up and stretch your body for a while if you see this :) +1.允许控制显示/隐藏 +2.美化ui -[![Support Me on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/nriver) + -**✨ Enhance Your Productivity** -Try out the Pomodoro Technique with the Trilium Notes widget. Don't forget to take breaks for yourself! -Learn more about the [Pomodoro Technique](https://en.wikipedia.org/wiki/Pomodoro_Technique) if you're unfamiliar with -it. +# 📥 安装方法 -# 📸 ScreenShots +1. 从[发布页面](https://github.com/Userwei0418/tomato-timer-widget/releases)下载 zip 文件。 +2. 在 Trilium 中右键单击笔记树,然后点击导入,取消选中“安全导入”。 +3. 执行脚本“启动器”,将会在左侧边栏添加一个控制按钮,用于控制显示与隐藏。 +4. 重新启动 Trilium Notes,或者使用 `ctrl+r` 重新加载界面。 +5. 打开任何笔记,你会看到一个计时器条。 +6. 祝你玩得愉快。 -## 🖼️ Overall Look (Subject to Change) +# 💡 提示 -![overall look](docs/at%20a%20glance.gif) +1. 你可以调整 `config` 子笔记中的配置。比如把语言 `lang` 改成 `cn` 再重启就是中文。 +2. 支持国际化,查看 `translations` 子笔记里有翻译文本。 +3. 会有通知提醒你休息 :) +4. 按钮带有声音效果,还有通知闹铃音效。 -## 🧘 Work with zen mode +# 🎵 关于音频文件 -I recently find out that this tomato timer can work with [Zen Mode](https://github.com/Nriver/awesome-trilium/issues/44) very well. You should try it :) +该项目中使用的音频来自 Pixabay,这是一个充满活力的创作者社区,共享免版税的图像、视频、音频和其他媒体。感谢他们的贡献和这一资源的可用性。以下是与音频内容相关的信息: -![work with zen mode](docs/work%20with%20zen%20mode.png) +https://pixabay.com/sound-effects/button-124476/ +https://pixabay.com/sound-effects/ding-47489/ -## ⏸️ Break Time! +此内容是根据 Pixabay 内容许可使用的,该许可允许对内容进行免费使用、修改和改编以创建新作品。但是,某些限制适用,并且用户有责任遵守许可条款。请查阅完整的内容许可协议以获取更多详细信息。 -![break](docs/take%20a%20break.gif) - -## 🔔 System Notifications - -* Windows: - -![windows](docs/notification%20windows.gif) - -* Linux desktop: - -![linux](docs/notification%20linux.gif) - -## 🌐 Multi-language support - -English - -![english](docs/ui%20english.png) - -简体中文 Chinese Simplified - -![chinese](docs/ui%20chinese.png) - -# 📥 How to install - -1. Download the zip file from [release page](https://github.com/Nriver/tomato-timer-widget/releases). -2. Right click note tree in Trilium and click import, uncheck `Safe Import`. -3. Restart Trilium Notes or use `ctrl+r` to reload the interface. -4. Open any note, you will see a timer bar underneath. -5. Have fun. - -# 💡 Hints - -1. You can tweak configs in the `config` subnote. -2. i18n support, check the `translations` subnote for the translated texts. -3. There will be a notification tells you to rest :) -4. Buttons comes with sound effects so does the notification alarm. - -# 🤔 Why I made this? - -I was diagnosed with lumbar disc herniation in October 2023. According to the doctors, the herniation is huge. Although -the chief physician strongly suggested that I undergo surgery immediately, I refused it, at least for now. - -I'm currently undergoing conservative treatment and hoping for improvement. I understand that this is a long-term battle -and that there are many measures I need to take. According to my physical therapist, I should stand up and stretch every -30 minutes after sitting. It occurred to me later that -the [Pomodoro Technique](https://en.wikipedia.org/wiki/Pomodoro_Technique) follows a similar schedule: 25 minutes of -work followed by a 5-minute break. This approach aligns perfectly with my treatment plan. - -I use Trilium Notes throughout the day, so creating a Pomodoro timer for Trilium seemed like a natural idea. I've been -using this timer actively during my treatment. I believe it's important to take breaks and rest your body after -prolonged periods of sitting. - -Hopefully, this can help prevent others from developing lumbar disc herniation. - -# 🎵 About the audio files - -The audio used in this project is obtained from Pixabay, a vibrant community of creators sharing royalty-free images, video, audio, and other media. I appreciate their contribution and the availability of this resource. Below is the information related to the audio content: - -https://pixabay.com/sound-effects/button-124476/ - -https://pixabay.com/sound-effects/ding-47489/ - -This content is used in accordance with the Pixabay Content License, which allows for free use, modification, and adaptation of the content into new works. However, certain restrictions apply, and it is the user's responsibility to adhere to the terms of the license. Please refer to the full Content License for more details. - -I respect the work of creators and encourage others to do the same. - -# 💖 Donation - -Hello! If you appreciate my creations, kindly consider backing me. Your support is greatly appreciated. Thank you! - -Ko-fi: -[![Support Me on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/nriver) - -Alipay: -![Alipay](https://github.com/Nriver/trilium-translation/raw/main/docs/alipay.png) - -Wechat Pay: -![Wechat Pay](https://github.com/Nriver/trilium-translation/raw/main/docs/wechat_pay.png) - -# 🙏 Thanks - -Thanks `Tinkerer` for donating 10.0 USD! \ No newline at end of file +我尊重创作者的工作,并鼓励他人也这样做。 diff --git a/README_CN.md b/README_CN.md deleted file mode 100644 index 7c160ea..0000000 --- a/README_CN.md +++ /dev/null @@ -1,100 +0,0 @@ -# 🍅 番茄钟小部件 :) - -如果你看到这个,请站起来伸展一下 :) - -[![在Ko-fi上支持我](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/nriver) - -**✨ 提高你的工作效率** - -Trilium Notes 的番茄工作法小部件。别忘了给自己休息的时间! - -如果你对番茄工作法不熟悉,可以参考[百度百科](https://baike.baidu.com/item/番茄工作法/6353502)了解更多信息。 - -# 📸 屏幕截图 - -## 🖼️ 整体外观(后续可能会有所变化) - -![整体外观](docs/at%20a%20glance.gif) - -## 🧘 在禅模式下工作 - -我最近发现这个番茄计时器可以与[禅模式](https://github.com/Nriver/awesome-trilium/issues/44)非常好地配合。你应该试试它 :) - -![与禅模式配合工作](docs/work%20with%20zen%20mode.png) - -## 🍵 休息时间! - -![休息](docs/take%20a%20break.gif) - -## 🔔 系统通知 - -* Windows: - -![Windows](docs/notification%20windows.gif) - -* Linux 桌面: - -![Linux](docs/notification%20linux.gif) - -## 🌐 多语言支持 - -英语 - -![英文](docs/ui%20english.png) - -简体中文 - -![中文](docs/ui%20chinese.png) - -# 📥 安装方法 - -1. 从[发布页面](https://github.com/Nriver/tomato-timer-widget/releases)下载 zip 文件。 -2. 在 Trilium 中右键单击笔记树,然后点击导入,取消选中“安全导入”。 -3. 重新启动 Trilium Notes,或者使用 `ctrl+r` 重新加载界面。 -4. 打开任何笔记,你会看到一个计时器条。 -5. 祝你玩得愉快。 - -# 💡 提示 - -1. 你可以调整 `config` 子笔记中的配置。比如把语言 `lang` 改成 `cn` 再重启就是中文。 -2. 支持国际化,查看 `translations` 子笔记里有翻译文本。 -3. 会有通知提醒你休息 :) -4. 按钮带有声音效果,还有通知闹铃音效。 - -# 🤔 我为什么制作这个? - -我在 2023 年 10 月被诊断出腰椎间盘突出。主治医生说突出情况很严重,属于巨大突出。尽管医生强烈建议我立即进行手术,但我拒绝了,至少暂时不希望手术。 - -我目前正在积极接受保守治疗,希望能有所改善。我知道这是一场长期的战斗,需要采取很多措施。根据我的物理治疗师的建议,我应该每隔 30 分钟站起来伸展一下。后来我想到,[番茄工作法](https://en.wikipedia.org/wiki/Pomodoro_Technique)遵循类似的时间安排:25 分钟工作,5 分钟休息。这种方法与我的治疗计划完美契合。 - -我整天都在使用 Trilium Notes,所以就想着给它整一个番茄钟。在我的治疗过程中一直在积极使用这个计时器。我相信在长时间坐着之后,休息一下并休息身体是很重要的。 - -希望这可以帮助防止其他人患上腰椎间盘突出。 - -# 🎵 关于音频文件 - -该项目中使用的音频来自 Pixabay,这是一个充满活力的创作者社区,共享免版税的图像、视频、音频和其他媒体。感谢他们的贡献和这一资源的可用性。以下是与音频内容相关的信息: - -https://pixabay.com/sound-effects/button-124476/ -https://pixabay.com/sound-effects/ding-47489/ - -此内容是根据 Pixabay 内容许可使用的,该许可允许对内容进行免费使用、修改和改编以创建新作品。但是,某些限制适用,并且用户有责任遵守许可条款。请查阅完整的内容许可协议以获取更多详细信息。 - -我尊重创作者的工作,并鼓励他人也这样做。 - -# 💖 捐赠 - -你好!如果你喜欢我的作品,请考虑支持我。非常感谢你的支持。谢谢! - -支付宝: -![Alipay](https://github.com/Nriver/trilium-translation/raw/main/docs/alipay.png) - -微信: -![Wechat Pay](https://github.com/Nriver/trilium-translation/raw/main/docs/wechat_pay.png) - -在 Ko-fi 上支持我: -[![在Ko-fi上支持我](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/nriver) - -# 🙏 感谢 - -感谢 `Tinkerer` 赞助的 10.0 美元! \ No newline at end of file diff --git a/docs/at a glance.gif b/docs/at a glance.gif deleted file mode 100644 index 3e45af9..0000000 Binary files a/docs/at a glance.gif and /dev/null differ diff --git a/docs/notification linux.gif b/docs/notification linux.gif deleted file mode 100644 index 0167ced..0000000 Binary files a/docs/notification linux.gif and /dev/null differ diff --git a/docs/notification windows.gif b/docs/notification windows.gif deleted file mode 100644 index d86a9bc..0000000 Binary files a/docs/notification windows.gif and /dev/null differ diff --git a/docs/take a break.gif b/docs/take a break.gif deleted file mode 100644 index 498a069..0000000 Binary files a/docs/take a break.gif and /dev/null differ diff --git a/docs/ui chinese.png b/docs/ui chinese.png deleted file mode 100644 index 5da7bfe..0000000 Binary files a/docs/ui chinese.png and /dev/null differ diff --git a/docs/ui english.png b/docs/ui english.png deleted file mode 100644 index 67d9b29..0000000 Binary files a/docs/ui english.png and /dev/null differ diff --git a/docs/work with zen mode.png b/docs/work with zen mode.png deleted file mode 100644 index 8e3acee..0000000 Binary files a/docs/work with zen mode.png and /dev/null differ diff --git "a/docs/\346\274\224\347\244\272.mp4" "b/docs/\346\274\224\347\244\272.mp4" new file mode 100644 index 0000000..0c8aec3 Binary files /dev/null and "b/docs/\346\274\224\347\244\272.mp4" differ diff --git "a/docs/\346\274\224\347\244\272\350\247\206\351\242\221\345\260\201\351\235\242.png" "b/docs/\346\274\224\347\244\272\350\247\206\351\242\221\345\260\201\351\235\242.png" new file mode 100644 index 0000000..afb9af0 Binary files /dev/null and "b/docs/\346\274\224\347\244\272\350\247\206\351\242\221\345\260\201\351\235\242.png" differ diff --git a/tomato.js b/tomato.js index 35b3423..a22b8b9 100644 --- a/tomato.js +++ b/tomato.js @@ -16,8 +16,10 @@ const TPL = `
-
` + i18n('working') + `
-
--:--
+ + +
` + i18n('working') + `
+
--:--
@@ -30,43 +32,63 @@ const styles = ` #tomato-bar { display: flex; align-items: center; - gap: 4px; - padding: 4px; + gap: 8px; + padding: 6px 12px; border-top: 1px solid #555555; border-bottom: 1px solid #555555; + background: linear-gradient(to bottom, #2a2a2a, #1a1a1a); contain: none; white-space: nowrap; + height: 40px; } #status { - font-size: 18px; - width: auto; - padding-left: 10px; - padding-right: 10px; + font-size: 12px; font-weight: bold; + color: #FF6347; + text-transform: uppercase; + letter-spacing: 1px; } #timer { - font-size: 24px; - width: 70px; + font-size: 22px; + padding: 2px 10px; border: 2px solid #FF6347; - background-color: #transparent; - border-radius: 10px; + background-color: rgba(0, 0, 0, 0.3); + border-radius: 6px; + text-align: center; + font-weight: bold; + color: #FF6347; + font-family: 'Courier New', monospace; + min-width: 60px; + white-space: nowrap; } .tomato button { background-color: #a52a2a; border-radius: 5px; border: none; - padding: 10px 20px; - font-size: 16px; + padding: 8px 14px; + font-size: 12px; cursor: pointer; - transition: background-color 0.3s; + transition: all 0.3s; color: #ffffff; + font-weight: 500; + white-space: nowrap; + height: 28px; + display: flex; + align-items: center; + justify-content: center; } .tomato button:hover { background-color: #800000; + transform: translateY(-1px); + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); +} + +.tomato button:active { + transform: translateY(0); } #workButton { @@ -84,7 +106,6 @@ const styles = ` #restButton:hover { background-color: #45a049; } - `; var isInit = true; @@ -135,6 +156,9 @@ class TomatoWidget extends api.NoteContextAwareWidget { const startButton = document.getElementById('startButton'); const pauseButton = document.getElementById('pauseButton'); const resetButton = document.getElementById('resetButton'); + const hideButton = document.getElementById('hideButton'); + const showButton = document.getElementById('showButton'); + const tomatoBar = document.getElementById('tomato-bar'); const workButton = document.getElementById('workButton'); const restButton = document.getElementById('restButton'); @@ -255,6 +279,21 @@ class TomatoWidget extends api.NoteContextAwareWidget { workButton.addEventListener('click', workTimer); restButton.addEventListener('click', restTimer); + // 隐藏按钮点击事件 + hideButton.addEventListener('click', () => { + playButtonSound(); + localStorage.setItem('tomatoVisible', 'false'); + tomatoBar.style.display = 'none'; + api.showMessage(i18n('hidden'), 2000); + }); + + // 显示按钮点击事件 + showButton.addEventListener('click', () => { + playButtonSound(); + localStorage.setItem('tomatoVisible', 'true'); + tomatoBar.style.display = 'flex'; + api.showMessage(i18n('shown'), 2000); + }); // auto start timer when startup if (config.autoStartCountDown){ @@ -268,4 +307,4 @@ class TomatoWidget extends api.NoteContextAwareWidget { } -module.exports = new TomatoWidget(); +module.exports = new TomatoWidget(); \ No newline at end of file diff --git a/tomato/Toggle Tomato.js b/tomato/Toggle Tomato.js new file mode 100644 index 0000000..28de974 --- /dev/null +++ b/tomato/Toggle Tomato.js @@ -0,0 +1,34 @@ +// 这个脚本可以快速切换番茄时钟的显示/隐藏 +// 建议将其设置为工具栏按钮或快捷键 + +async function toggleTomatoVisibility() { + // 获取当前状态 + const isHidden = localStorage.getItem('tomatoVisible') === 'false'; + + // 切换状态 + if (isHidden) { + localStorage.setItem('tomatoVisible', 'true'); + api.showMessage('🍅 番茄时钟已显示', 2000); + } else { + localStorage.setItem('tomatoVisible', 'false'); + api.showMessage('🍅 番茄时钟已隐藏', 2000); + } + + // 查找 tomato 按钮并触发点击 + const showButton = document.getElementById('showButton'); + const hideButton = document.getElementById('hideButton'); + + if (isHidden && showButton) { + // 隐藏状态,现在要显示,点击 show 按钮 + showButton.click(); + await new Promise(resolve => setTimeout(resolve, 100)); + api.triggerCommand('reloadFrontend'); + } else if (!isHidden && hideButton) { + // 显示状态,现在要隐藏,点击 hide 按钮 + hideButton.click(); + await new Promise(resolve => setTimeout(resolve, 100)); + api.triggerCommand('reloadFrontend'); + } +} + +await toggleTomatoVisibility(); \ No newline at end of file diff --git a/tomato/config.js b/tomato/config.js index 4fc10ee..2690a10 100644 --- a/tomato/config.js +++ b/tomato/config.js @@ -1,13 +1,13 @@ // Please do not modify the name of this note. // Change language name to anyone you like in the translations file. For example, 'cn' for Chinese, 'en' for english. -var lang = 'en'; +var lang = 'cn'; // Set true to enable sound effects, false to disable it. var enableSound = true; // Start count down automatically when you open Trilium. var autoStartCountDown = true; -const WORK_TIME = 1500; //1500s = 25min +const WORK_TIME = 1200; //1500s = 25min const BREAK_TIME = 300; // 300s = 5min // Don't forget to expose configs to the main js file diff --git a/tomato/translations.js b/tomato/translations.js index b01c2d7..4fd9672 100644 --- a/tomato/translations.js +++ b/tomato/translations.js @@ -13,7 +13,11 @@ const trans = { workNotificationTitle: '休息好了吗?', workNotificationBody: "干点活吧", takeBreakMessage: '休息一会儿.', - timeToDoSomething: '该做点什么了.' + timeToDoSomething: '该做点什么了.', + hide: "隐藏", + show: "显示", + hidden: "已隐藏", + shown: "已显示" }, 'en': { working: 'Working', @@ -28,22 +32,11 @@ const trans = { workNotificationTitle: 'Rest well?', workNotificationBody: "Let's do some work", takeBreakMessage: 'Take a break.', - timeToDoSomething: 'Time to do something.' - }, - 'de': { - working: 'Arbeiten', - resting: 'Pause', - doWork: 'Arbeit erledigen', - takeBreak: 'Pause machen', - start: 'Start', - pause: 'Pause', - reset: 'Zurücksetzen', - restNotificationTitle: 'Entspannen Sie sich', - restNotificationBody: 'Zeit für eine Pause~', - workNotificationTitle: 'Gut ausgeruht?', - workNotificationBody: "Lass uns etwas Arbeit erledigen", - takeBreakMessage: 'Mache eine Pause.', - timeToDoSomething: 'Zeit, etwas zu tun.' + timeToDoSomething: 'Time to do something.', + hide: "Hide", + show: "Show", + hidden: "Hidden", + shown: "Shown" }, 'pt-br': { working: 'Trabalhando', @@ -58,10 +51,13 @@ const trans = { workNotificationTitle: 'Descansado?', workNotificationBody: "Mãos à massa! De volta ao trabalho.", takeBreakMessage: 'Faça uma pausa', - timeToDoSomething: 'De volta a ativa' + timeToDoSomething: 'De volta a ativa', + hide: "Ocultar", + show: "Mostrar", + hidden: "Oculto", + shown: "Mostrado" }, }; - module.exports = { trans -} +} \ No newline at end of file diff --git "a/tomato/\345\220\257\345\212\250\345\231\250.js" "b/tomato/\345\220\257\345\212\250\345\231\250.js" new file mode 100644 index 0000000..9006412 --- /dev/null +++ "b/tomato/\345\220\257\345\212\250\345\231\250.js" @@ -0,0 +1,10 @@ +// will add a launcher to the left sidebar +api.createOrUpdateLauncher({ + id: 'Tomato', + type: 'script', + title: 'Show/Hide Tomato', + icon: 'bx-timer', + keyboardShortcut: 'alt+z', + scriptNoteId: api.currentNote.getRelationValue('ToggleTomato'), + isVisible: true +}); \ No newline at end of file