@puwenhui/dsh-email 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,6 +38,8 @@ dsh plugin --profile web add file:<本插件目录>
38
38
 
39
39
  **重要新邮件提醒**:后台每 60 秒轮询同步,新邮件按规则(发件人白名单 / 主题关键词 / 全部开关)判定,命中即**浏览器桌面通知 + 页内横幅**;水位去重,同一封只提醒一次。
40
40
 
41
+ **垃圾邮件处理**:「垃圾邮件」文件夹默认纳入同步(搜索可及,结果标注来源),**但永不触发提醒**——被邮箱误判的正常邮件能找回,又不被垃圾弹窗骚扰;移回收件箱等整理操作请用 Foxmail。
42
+
41
43
  **模型工具**(对话中由 AI 调用):
42
44
 
43
45
  | 工具 | 说明 |
package/USAGE.zh.md CHANGED
@@ -130,6 +130,9 @@ DSH 邮件助手让你**在对话里直接处理邮件**:查邮件、找附件
130
130
  **Q:老邮件的附件列表是空的?**
131
131
  插件只对近期同步过的邮件建立附件索引;翻不到就告诉我那封邮件的主题,我(管理员)可以重建索引。
132
132
 
133
+ **Q:怀疑邮件被扔进垃圾箱了,怎么找?**
134
+ 直接说:「**垃圾邮件里最近有什么**」「搜一下垃圾箱里张三发来的信」。垃圾箱的邮件插件会正常同步和搜索(结果会标注来自垃圾邮件),但**不会弹提醒**——翻到被误判的邮件后想移回收件箱,去 Foxmail 操作。
135
+
133
136
  **Q:没收到重要邮件提醒?**
134
137
  检查三处:① 设置 → 插件 → 邮件 卡里「开启重要新邮件提醒」是否打开;② 白名单/关键词是否填了;③ 页面右上角是否点过「开启桌面通知」。
135
138
 
package/lib/plugin.mjs CHANGED
@@ -10,6 +10,12 @@ function loadLocal() {
10
10
  }
11
11
  return {};
12
12
  }
13
+ // 用户数据根(宿主规范:$DSH_HOME,缺省 ~/.dsh):相对路径的索引库与附件都落在 storages/dsh-email/,
14
+ // 与包安装目录解耦——升级/重装插件不丢数据
15
+ var dshHome = process.env.DSH_HOME && process.env.DSH_HOME.trim() !== '' ? process.env.DSH_HOME : path.join(process.env.USERPROFILE ?? process.env.HOME ?? '.', '.dsh');
16
+ function resolveDataPath(rel) {
17
+ return path.isAbsolute(rel) ? rel : path.join(dshHome, 'storages', 'dsh-email', rel);
18
+ }
13
19
  function resolveConfig(overrides = {}) {
14
20
  const env = process.env;
15
21
  const local = loadLocal();
@@ -109,7 +115,11 @@ CREATE TABLE IF NOT EXISTS sync_state(
109
115
  var Store = class {
110
116
  db;
111
117
  constructor(dbPath) {
112
- const resolved = dbPath === ":memory:" ? ":memory:" : path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", dbPath);
118
+ let resolved;
119
+ if (dbPath === ':memory:') resolved = ':memory:';
120
+ else if (path.isAbsolute(dbPath)) resolved = dbPath;
121
+ else resolved = resolveDataPath(dbPath);
122
+ if (resolved !== ':memory:') fs.mkdirSync(path.dirname(resolved), { recursive: true });
113
123
  this.db = new DatabaseSync(resolved);
114
124
  this.db.exec("PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON;");
115
125
  this.db.exec(SCHEMA);
@@ -768,7 +778,7 @@ var EmailService = class {
768
778
  const list = parsed.attachments ?? [];
769
779
  const hit = list.find((a) => String(a.partId ?? "") === att.part_id) ?? list[0];
770
780
  if (!hit?.content) throw new Error("附件内容解析失败");
771
- const dir = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..", saveDirOverride || this.cfg.attachmentDir);
781
+ const dir = resolveDataPath(saveDirOverride || this.cfg.attachmentDir);
772
782
  fs.mkdirSync(dir, { recursive: true });
773
783
  const safe = String(hit.filename || att.filename || `attachment-${id}`).replace(/[\\/:*?"<>|]/g, "_");
774
784
  const file = path.join(dir, `${att.mailbox}-${att.uid}-${safe}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puwenhui/dsh-email",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "DSH 邮件助手插件:IMAP 同步 + 全文索引 + 会话归并 + 10 个模型工具 + 设置配置卡 + 重要新邮件桌面提醒",
5
5
  "repository": {
6
6
  "type": "git",