koishi-plugin-mail-manager 1.0.0

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.
Files changed (66) hide show
  1. package/client/api.ts +141 -0
  2. package/client/components/AccountEditModal.vue +644 -0
  3. package/client/components/ForwardModal.vue +492 -0
  4. package/client/components/Icon.vue +226 -0
  5. package/client/components/MailIcon.vue +6 -0
  6. package/client/components/RuleEditModal.vue +854 -0
  7. package/client/components/Select.vue +343 -0
  8. package/client/index.ts +21 -0
  9. package/client/pages/AccountsView.vue +555 -0
  10. package/client/pages/MailsView.vue +1047 -0
  11. package/client/pages/PreviewView.vue +596 -0
  12. package/client/pages/RulesView.vue +386 -0
  13. package/client/pages/index.vue +115 -0
  14. package/client/shims-vue.d.ts +5 -0
  15. package/client/styles/_components.scss +331 -0
  16. package/client/styles/_forms.scss +337 -0
  17. package/client/styles/_layout.scss +206 -0
  18. package/client/styles/_mail-list.scss +601 -0
  19. package/client/styles/_modal.scss +414 -0
  20. package/client/styles/_pages.scss +390 -0
  21. package/client/styles/_preview.scss +91 -0
  22. package/client/styles/_responsive.scss +285 -0
  23. package/client/styles/_variables.scss +130 -0
  24. package/client/styles/main.scss +27 -0
  25. package/client/tsconfig.json +21 -0
  26. package/client/types.ts +200 -0
  27. package/dist/index.js +110 -0
  28. package/dist/style.css +1 -0
  29. package/lib/api.d.ts +8 -0
  30. package/lib/cleanup.d.ts +35 -0
  31. package/lib/commands.d.ts +9 -0
  32. package/lib/config.d.ts +16 -0
  33. package/lib/core/accounts.d.ts +15 -0
  34. package/lib/core/forward.d.ts +41 -0
  35. package/lib/core/index.d.ts +16 -0
  36. package/lib/core/mails.d.ts +56 -0
  37. package/lib/core/rules.d.ts +41 -0
  38. package/lib/core/state.d.ts +46 -0
  39. package/lib/core.d.ts +11 -0
  40. package/lib/database.d.ts +6 -0
  41. package/lib/html2image.d.ts +42 -0
  42. package/lib/imap.d.ts +198 -0
  43. package/lib/index.d.ts +14 -0
  44. package/lib/index.js +5381 -0
  45. package/lib/logger.d.ts +61 -0
  46. package/lib/parser.d.ts +77 -0
  47. package/lib/providers/base.d.ts +168 -0
  48. package/lib/providers/gmail.d.ts +48 -0
  49. package/lib/providers/icloud.d.ts +15 -0
  50. package/lib/providers/index.d.ts +37 -0
  51. package/lib/providers/netease.d.ts +19 -0
  52. package/lib/providers/outlook.d.ts +15 -0
  53. package/lib/providers/qq.d.ts +15 -0
  54. package/lib/providers/yahoo.d.ts +14 -0
  55. package/lib/render.d.ts +36 -0
  56. package/lib/service.d.ts +42 -0
  57. package/lib/styles.d.ts +16 -0
  58. package/lib/types.d.ts +547 -0
  59. package/lib/utils/common.d.ts +45 -0
  60. package/lib/utils/constants.d.ts +31 -0
  61. package/lib/utils/crypto.d.ts +74 -0
  62. package/lib/utils/dns.d.ts +180 -0
  63. package/lib/utils/errors.d.ts +63 -0
  64. package/lib/utils/index.d.ts +7 -0
  65. package/package.json +56 -0
  66. package/readme.md +148 -0
package/client/api.ts ADDED
@@ -0,0 +1,141 @@
1
+ /**
2
+ * 邮件管理插件 - API 封装
3
+ */
4
+
5
+ import { send } from '@koishijs/client'
6
+ import type {
7
+ MailAccount,
8
+ StoredMail,
9
+ ForwardRule,
10
+ ForwardElement,
11
+ ForwardTarget,
12
+ ForwardMode,
13
+ RenderConfig,
14
+ PaginatedResponse,
15
+ ForwardPreviewResponse,
16
+ ConnectionTestResult,
17
+ Stats,
18
+ ForwardResult,
19
+ } from './types'
20
+
21
+ /** 通用 API 调用封装 */
22
+ function call<T>(event: string, ...args: unknown[]): Promise<T> {
23
+ // @ts-ignore - send 函数的类型声明不完整,但实际可以传递多个参数
24
+ return send(event, ...args) as Promise<T>
25
+ }
26
+
27
+ // ============ 账号 API ============
28
+
29
+ export const accountApi = {
30
+ /** 获取所有账号 */
31
+ list: () => call<MailAccount[]>('mail-manager/accounts/list'),
32
+
33
+ /** 获取单个账号 */
34
+ get: (id: number) => call<MailAccount>('mail-manager/accounts/get', id),
35
+
36
+ /** 创建账号 */
37
+ create: (data: Partial<MailAccount>) => call<MailAccount>('mail-manager/accounts/create', data),
38
+
39
+ /** 更新账号 */
40
+ update: (id: number, data: Partial<MailAccount>) =>
41
+ call<MailAccount>('mail-manager/accounts/update', id, data),
42
+
43
+ /** 删除账号 */
44
+ delete: (id: number) => call<void>('mail-manager/accounts/delete', id),
45
+
46
+ /** 测试连接 */
47
+ test: (id: number) => call<ConnectionTestResult>('mail-manager/accounts/test', id),
48
+
49
+ /** 连接账号 */
50
+ connect: (id: number) => call<void>('mail-manager/accounts/connect', id),
51
+
52
+ /** 断开账号 */
53
+ disconnect: (id: number) => call<void>('mail-manager/accounts/disconnect', id),
54
+
55
+ /** 同步邮件 */
56
+ sync: (id: number, days?: number) =>
57
+ call<{ total: number; new: number; existing: number }>('mail-manager/accounts/sync', id, days),
58
+ }
59
+
60
+ // ============ 邮件 API ============
61
+
62
+ export interface MailListParams {
63
+ accountId?: number
64
+ page?: number
65
+ pageSize?: number
66
+ isRead?: boolean
67
+ isForwarded?: boolean
68
+ keyword?: string
69
+ startDate?: string
70
+ endDate?: string
71
+ }
72
+
73
+ export const mailApi = {
74
+ /** 获取邮件列表 */
75
+ list: (params: MailListParams = {}) =>
76
+ call<PaginatedResponse<StoredMail>>('mail-manager/mails/list', params),
77
+
78
+ /** 获取邮件详情 */
79
+ get: (id: number) => call<StoredMail>('mail-manager/mails/get', id),
80
+
81
+ /** 删除邮件 */
82
+ delete: (id: number) => call<void>('mail-manager/mails/delete', id),
83
+
84
+ /** 标记已读 */
85
+ markAsRead: (id: number) => call<void>('mail-manager/mails/read', id),
86
+
87
+ /** 手动转发 */
88
+ forward: (mailId: number, ruleId?: number) =>
89
+ call<ForwardResult>('mail-manager/mails/forward', mailId, ruleId),
90
+
91
+ /** 批量删除邮件 */
92
+ batchDelete: (accountId?: number, days?: number) =>
93
+ call<{ deleted: number }>('mail-manager/mails/batch-delete', accountId, days),
94
+ }
95
+
96
+ // ============ 规则 API ============
97
+
98
+ export const ruleApi = {
99
+ /** 获取所有规则 */
100
+ list: () => call<ForwardRule[]>('mail-manager/rules/list'),
101
+
102
+ /** 获取规则详情 */
103
+ get: (id: number) => call<ForwardRule>('mail-manager/rules/get', id),
104
+
105
+ /** 创建规则 */
106
+ create: (data: Partial<ForwardRule>) => call<ForwardRule>('mail-manager/rules/create', data),
107
+
108
+ /** 更新规则 */
109
+ update: (id: number, data: Partial<ForwardRule>) =>
110
+ call<ForwardRule>('mail-manager/rules/update', id, data),
111
+
112
+ /** 删除规则 */
113
+ delete: (id: number) => call<void>('mail-manager/rules/delete', id),
114
+ }
115
+
116
+ // ============ 预览 API ============
117
+
118
+ export interface PreviewParams {
119
+ mailId: number
120
+ ruleId?: number
121
+ elements?: ForwardElement[]
122
+ customCss?: string
123
+ renderConfig?: Partial<RenderConfig>
124
+ forwardMode?: ForwardMode
125
+ }
126
+
127
+ export const previewApi = {
128
+ /** 获取转发预览 */
129
+ generate: (params: PreviewParams) =>
130
+ call<ForwardPreviewResponse>('mail-manager/preview', params),
131
+ }
132
+
133
+ // ============ 其他 API ============
134
+
135
+ export const commonApi = {
136
+ /** 获取可用转发目标 */
137
+ getTargets: () => call<ForwardTarget[]>('mail-manager/targets'),
138
+
139
+ /** 获取统计信息 */
140
+ getStats: () => call<Stats>('mail-manager/stats'),
141
+ }