This commit is contained in:
Cheney 2025-02-28 15:06:44 +08:00
commit 8ff1cdbd15
2 changed files with 26 additions and 0 deletions

8
hourglass.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="GENERAL_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

18
src/index.js Normal file
View File

@ -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,
});
});