commit 8ff1cdbd15f424afbea683ccac52ba8b80d4769c Author: Cheney Date: Fri Feb 28 15:06:44 2025 +0800 V1.0 diff --git a/hourglass.iml b/hourglass.iml new file mode 100644 index 0000000..3d48a82 --- /dev/null +++ b/hourglass.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0aeee3c --- /dev/null +++ b/src/index.js @@ -0,0 +1,18 @@ +const notifier = require('node-notifier'); +const cron = require('node-cron'); +const dayjs = require('dayjs'); + +// 定义整点触发的任务 +cron.schedule('0 * * * *', () => { + // 获取当前时间 + const currentDate = dayjs(); + const date = currentDate.format('YYYYMMDD'); + const time = currentDate.format('HH:mm'); + + notifier.notify({ + title: '整点报时', + subtitle : "当前日期 " + date, + message: '当前时间 ' + time, + }); +}); +