system-toast/README.md

72 lines
1.5 KiB
Markdown
Raw Normal View History

2025-12-04 17:05:34 +08:00
# location-notice
本地提醒小程序
## 功能介绍
这是一个用Go语言开发的本地提醒功能可以通过命令行参数传入消息然后调用系统通知接口弹出系统消息。
## 支持平台
- Windows
- macOS
- Linux
## 安装和运行
### 前提条件
需要安装Go语言环境1.21或更高版本)
### 编译运行
```bash
# 直接运行
go run main.go -message "你的提醒消息" -title "提醒标题"
# 编译为可执行文件
go build -o location-notice main.go
# 运行编译后的程序
./location-notice -message "你的提醒消息" -title "提醒标题"
```
## 使用方法
### 基本用法
```bash
go run main.go -message "该喝水了!"
```
### 指定标题
```bash
go run main.go -message "会议时间到了" -title "工作提醒"
```
### 参数说明
- `-message`: 通知消息内容(必需)
- `-title`: 通知标题(可选,默认为"提醒"
## 示例
```bash
# 健康提醒
go run main.go -message "站起来活动一下,保护你的腰部" -title "健康提醒"
# 工作提醒
go run main.go -message "15分钟后有重要会议" -title "会议提醒"
# 生活提醒
go run main.go -message "记得今天要交水电费" -title "生活提醒"
```
## 技术实现
- 使用Go标准库的`flag`包解析命令行参数
- 根据不同操作系统调用相应的系统通知命令:
- Windows: 使用PowerShell的Toast通知
- macOS: 使用osascript调用系统通知
- Linux: 使用notify-send命令