mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-09-22 01:48:03 +00:00
example: 演示插件 onRemove 清理补齐(memo/rss/weather)
- memo: 卸载时删除 memos.json 数据文件 - rss: 卸载时清理 .homeagent/rss 订阅数据目录 - weather: 卸载时清理 .homeagent/weather 缓存目录 - 与 calendar(events.json)一致:仅删除触发、重载不触发; files(filesDir 为用户配置的访问根目录)、bili/qq(用户下载资产)、 ocr(临时目录函数内自清理)按语义不加入删除回调
This commit is contained in:
@ -113,6 +113,9 @@ func (p *Plugin) Start(s *sdk.PluginSDK) error {
|
||||
os.MkdirAll(p.dataDir, 0755)
|
||||
p.loadData()
|
||||
|
||||
// 卸载(删除)时清理订阅数据目录;重载不触发
|
||||
s.RegisterOnRemoveHandler(p.cleanupData)
|
||||
|
||||
s.Settings().RegisterDef(sdk.ConfigDef{
|
||||
Key: "poll_interval", Default: "30", Type: "string",
|
||||
DisplayName: "Poll Interval", Description: "Default polling interval in minutes (default: 30)",
|
||||
@ -437,4 +440,11 @@ func (p *Plugin) saveData() {
|
||||
os.WriteFile(p.dataFile(), b, 0644)
|
||||
}
|
||||
|
||||
// cleanupData 卸载时清理订阅数据目录(feeds.json 等)
|
||||
func (p *Plugin) cleanupData() {
|
||||
if p.dataDir != "" {
|
||||
os.RemoveAll(p.dataDir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user