同步插件源代码并补齐标准项目文件

This commit is contained in:
XIGE
2026-11-26 15:05:31 +08:00
commit 649a451165
14 changed files with 4455 additions and 0 deletions

29
.gitignore vendored Normal file
View File

@@ -0,0 +1,29 @@
# Dependencies and build output
node_modules/
vendor/
dist/
build/
out/
main.js
*.apk
# Build tools and IDE
.gradle/
.idea/
*.iml
gradle/
gradlew
gradlew.bat
# Environment and secrets
.env
.env.*
keystore.properties
*.jks
credentials*.json
# Runtime data and backups
data/
备份/
*.log
.DS_Store

7
CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
# 变更记录
## 2026-11-26 · 初始同步
- 同步插件源代码到新 Gitea 仓库。
- 补齐 README、LICENSE、.gitignore、CONTRIBUTING 等标准项目文件。
- 本仓库仅包含插件实现代码与必要资源,排除依赖、构建工具、编译产物、环境配置与备份数据。

19
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,19 @@
# 贡献指南
欢迎对本插件提出改进建议或提交代码。
## 提交前检查
- 仅提交插件实现代码、资源与必要文档,不提交依赖目录、编译产物、运行时数据或备份文件。
- 保持现有目录结构;如新增平台适配代码,请在 `README.md` 的目录结构中说明。
- 涉及对外服务或凭据的配置不要写入代码或文档。
## 提交流程
1. Fork 仓库并创建功能分支。
2. 完成修改后提交 Pull Request,说明改动目的与影响范围。
3. 重要功能变更请同步更新 `CHANGELOG.md`。
## 问题反馈
请通过仓库 Issue 反馈问题,并尽可能提供插件类型、版本与复现步骤。

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 XIGE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
README.md Normal file
View File

@@ -0,0 +1,32 @@
# Mail Desk
> 仓库:`obsidian-mail-desk` · 类型:Obsidian 插件 · 版本:`1.1.9` · 作者:XIGE
侧边栏邮件客户端:多账户收发、定时收信、桌面提醒,支持 QQ、126 等 IMAP 邮箱。
本仓库同步自本地插件源码,**仅包含插件实现代码与必要资源**;不包含依赖、构建工具、编译产物、环境配置或备份数据。
## 目录结构
- `main.ts`
- `manifest.json`
- `src/`
- `styles.css`
## 安装与使用
1. 本仓库仅包含插件源代码,未包含依赖与构建工具;请先按 Obsidian 插件标准流程构建生成 `main.js`。
2. 将 `manifest.json`、构建后的 `main.js`、`styles.css` 及源码目录放入 `<Vault>/.obsidian/plugins/<插件 id>/`。
3. 在 Obsidian「设置 → 第三方插件」中启用该插件。
## 开发与贡献
详见 [CONTRIBUTING.md](CONTRIBUTING.md)。
## 授权
授权条款见 [LICENSE](LICENSE)(MIT License)。第三方组件版权归各自作者所有。
## 变更记录
详见 [CHANGELOG.md](CHANGELOG.md)。

609
main.ts Normal file

File diff suppressed because it is too large Load Diff

9
manifest.json Normal file
View File

@@ -0,0 +1,9 @@
{
"id": "obsidian-mail-desk",
"name": "Mail Desk",
"version": "1.1.9",
"minAppVersion": "1.11.4",
"description": "侧边栏邮件客户端:多账户收发、定时收信、桌面提醒。支持 QQ、126 等 IMAP 邮箱。",
"author": "XIGE",
"isDesktopOnly": true
}

188
src/compose.ts Normal file
View File

@@ -0,0 +1,188 @@
// ---------------------------------------------------------------------------
// 写信 / 回复 / 转发 弹窗
// ---------------------------------------------------------------------------
import { App, Modal, Notice, Setting } from "obsidian";
import type MailDeskPlugin from "../main";
import type { MailAccount, MailDetail } from "./types";
export type ComposeMode =
| { kind: "new" }
| { kind: "reply"; account: MailAccount; mail: MailDetail; all: boolean }
| { kind: "forward"; account: MailAccount; mail: MailDetail };
export class ComposeModal extends Modal {
private to = "";
private cc = "";
private subject = "";
private body = "";
private account: MailAccount | null = null;
private files: File[] = [];
private inReplyTo?: string;
private references?: string;
private sending = false;
private sendBtn!: HTMLButtonElement;
constructor(
app: App,
private plugin: MailDeskPlugin,
private mode: ComposeMode,
) {
super(app);
const accounts = plugin.settings.accounts.filter((a) => a.enabled);
const first = mode.kind === "new" ? accounts[0] : mode.account;
if (!first) {
queueMicrotask(() => {
new Notice("请先添加一个启用的邮箱账户,再写邮件");
this.close();
});
return;
}
this.account = first;
if (mode.kind === "reply") {
const m = mode.mail;
this.to = m.from;
this.subject = m.subject.startsWith("Re:") ? m.subject : "Re: " + m.subject;
this.inReplyTo = m.uid + "@" + m.accountId;
this.references = this.inReplyTo;
const quoted = `\n\n---------- 原邮件 ----------\n发件人: ${m.fromName} <${m.from}>\n时间: ${new Date(m.date).toLocaleString()}\n主题: ${m.subject}\n\n${(m.text || m.html.replace(/<[^>]*>/g, " ")).slice(0, 2000)}`;
this.body = quoted;
if (mode.all && m.to) this.cc = m.to;
} else if (mode.kind === "forward") {
const m = mode.mail;
this.subject = m.subject.startsWith("Fwd:") ? m.subject : "Fwd: " + m.subject;
this.body = `\n\n---------- 转发邮件 ----------\n发件人: ${m.fromName} <${m.from}>\n时间: ${new Date(m.date).toLocaleString()}\n主题: ${m.subject}\n\n${(m.text || m.html.replace(/<[^>]*>/g, " ")).slice(0, 2000)}`;
}
}
onOpen(): void {
if (!this.account) return;
const { contentEl } = this;
contentEl.empty();
contentEl.addClass("maildesk-compose");
contentEl.createEl("h2", { text: this.mode.kind === "new" ? "写邮件" : this.mode.kind === "reply" ? "回复邮件" : "转发邮件" });
// 新建邮件时恢复上次未发完的草稿
if (this.mode.kind === "new") {
const draft = this.plugin.settings.draft;
if (draft) {
this.to = draft.to || "";
this.cc = draft.cc || "";
this.subject = draft.subject || "";
this.body = draft.body || "";
}
}
new Setting(contentEl).setName("发件账户").addDropdown((d) => {
this.plugin.settings.accounts.filter((a) => a.enabled).forEach((a) => d.addOption(a.id, a.email));
d.setValue(this.account!.id).onChange((v) => {
this.account = this.plugin.settings.accounts.find((a) => a.id === v) ?? this.account;
});
});
new Setting(contentEl).setName("收件人").addText((t) =>
t.setValue(this.to).setPlaceholder("多个用逗号分隔").onChange((v) => this.to = v));
new Setting(contentEl).setName("抄送").addText((t) =>
t.setValue(this.cc).setPlaceholder("可选").onChange((v) => this.cc = v));
new Setting(contentEl).setName("主题").addText((t) =>
t.setValue(this.subject).onChange((v) => this.subject = v));
const bodyWrap = contentEl.createDiv("maildesk-compose-body-wrap");
const bodyEl = bodyWrap.createEl("textarea", { cls: "maildesk-compose-body" });
bodyEl.value = this.body;
bodyEl.placeholder = "正文…";
bodyEl.oninput = () => this.body = bodyEl.value;
new Setting(contentEl).setName("附件").addButton((b) => b
.setButtonText("选择文件")
.onClick(() => {
const input = document.createElement("input");
input.type = "file";
input.multiple = true;
input.onchange = () => {
if (input.files) {
this.files.push(...Array.from(input.files));
new Notice(`已添加 ${input.files.length} 个附件`);
this.renderAttachmentList(contentEl);
}
};
input.click();
}));
this.attachmentListEl = contentEl.createDiv("maildesk-compose-attachments");
this.renderAttachmentList(contentEl);
const footer = contentEl.createDiv("maildesk-compose-footer");
const cancel = footer.createEl("button", { text: "取消" });
cancel.onclick = () => this.close();
this.sendBtn = footer.createEl("button", { cls: "mod-cta", text: "发送" });
this.sendBtn.onclick = () => this.send();
}
private attachmentListEl!: HTMLDivElement;
private renderAttachmentList(container: HTMLElement) {
if (!this.attachmentListEl) return;
this.attachmentListEl.empty();
this.files.forEach((f, i) => {
const row = this.attachmentListEl.createDiv("maildesk-att-row");
row.createSpan({ text: `${f.name} (${(f.size / 1024).toFixed(0)} KB)` });
row.createEl("button", { text: "×", cls: "maildesk-att-remove" })
.onclick = () => { this.files.splice(i, 1); this.renderAttachmentList(container); };
});
}
private async send() {
if (!this.account || this.sending) return;
if (!this.to.trim()) { new Notice("请填写收件人"); return; }
if (!this.subject.trim()) { new Notice("请填写主题"); return; }
this.sending = true;
this.sendBtn.disabled = true;
this.sendBtn.setText("发送中…");
const body = this.body.trim();
try {
const attachments = await Promise.all(this.files.map(async (f) => ({
filename: f.name,
content: Buffer.from(await f.arrayBuffer()),
contentType: f.type || "application/octet-stream",
})));
await this.plugin.mail.send(this.account, {
to: this.to,
cc: this.cc || undefined,
subject: this.subject,
text: body,
attachments,
inReplyTo: this.inReplyTo,
references: this.references,
});
// 发送成功,清空草稿(仅新建邮件)
if (this.mode.kind === "new") {
this.plugin.settings.draft = null;
this.plugin.saveSettings();
}
new Notice("✓ 邮件已发送");
this.close();
} catch (e) {
new Notice("发送失败:" + (e instanceof Error ? e.message : String(e)), 8000);
this.sending = false;
this.sendBtn.disabled = false;
this.sendBtn.setText("发送");
}
}
onClose(): void {
// 关闭时若还有内容,存为草稿(仅新建邮件)
if (!this.sending && this.mode.kind === "new" && (this.to || this.subject || this.body.trim())) {
this.plugin.settings.draft = {
to: this.to,
cc: this.cc,
subject: this.subject,
body: this.body,
savedAt: Date.now(),
};
this.plugin.saveSettings();
}
this.contentEl.empty();
}
}

399
src/mail-service.ts Normal file

File diff suppressed because it is too large Load Diff

180
src/notifier.ts Normal file
View File

@@ -0,0 +1,180 @@
// ---------------------------------------------------------------------------
// 提醒模块:系统通知 / 应用内 Notice / 侧边栏角标 / 状态栏计数
// ---------------------------------------------------------------------------
import { Notice } from "obsidian";
import type MailDeskPlugin from "../main";
import type { MailSummary } from "./types";
export class Notifier {
private statusBarEl: HTMLElement | null = null;
private permission: NotificationPermission = "default";
private refreshTimer: number | null = null;
/** 已提醒过的邮件幂等键:accountId|folder|uid。防止同一封邮件被重复通知 */
private notifiedKeys = new Set<string>();
constructor(private plugin: MailDeskPlugin) {}
/** 请求系统通知权限 */
async requestPermission(): Promise<NotificationPermission> {
if (typeof Notification === "undefined") return "denied";
try {
if (Notification.permission === "granted") {
this.permission = "granted";
return this.permission;
}
this.permission = await Notification.requestPermission();
return this.permission;
} catch {
return "denied";
}
}
getStatus(): NotificationPermission {
return this.permission;
}
/** 邮件唯一键:账户 + 文件夹 + UID */
private keyOf(m: MailSummary): string {
return `${m.accountId}|${m.folder}|${m.uid}`;
}
/**
* 有新邮件时触发所有已启用的提醒渠道。
* 去重分两层:① 已经 seen 的不提醒;② 本会话已提醒过的幂等键不重复提醒。
* 这样即使 fetchNew 因基线重建/重复拉取返回旧邮件,也不会再次弹通知。
*/
async notifyNew(mails: MailSummary[]): Promise<void> {
if (!mails.length) return;
const s = this.plugin.settings;
// 幂等过滤:已读 + 本会话已提醒过的,直接剔除
const fresh = mails.filter((m) => {
if (m.seen) return false;
const key = this.keyOf(m);
if (this.notifiedKeys.has(key)) return false;
this.notifiedKeys.add(key);
return true;
});
if (!fresh.length) {
this.updateBadges();
return;
}
// 应用内 Notice
if (s.notifyNotice) {
if (s.aggregateNotification) {
const sample = fresh[0];
const title = fresh.length === 1
? `新邮件:${sample.fromName || sample.from} — ${sample.subject}`
: `${fresh.length} 封新邮件`;
new Notice(title, 6000);
} else {
for (const m of fresh.slice(0, 5)) {
new Notice(`新邮件:${m.fromName || m.from} — ${m.subject}`, 6000);
}
}
}
// 系统桌面通知
if (s.notifySystem && typeof Notification !== "undefined") {
const permission = await this.requestPermission();
if (permission === "granted") {
const title = fresh.length === 1
? `${fresh[0].fromName || fresh[0].from}`
: `${fresh.length} 封新邮件`;
const body = fresh.length === 1
? fresh[0].subject
: fresh.slice(0, 3).map((m) => m.subject).join("\n");
try {
const n = new Notification("Mail Desk · " + title, { body, silent: false });
n.onclick = () => {
try { n.close(); } catch { /* ignore */ }
try { window.focus(); } catch { /* ignore */ }
this.plugin.openMailView();
// 点击通知即视为已处理:把这批邮件标记已读,避免再次提醒
void this.markSeen(fresh);
};
setTimeout(() => n.close(), 8000);
} catch { /* 某些环境不支持构造,忽略 */ }
}
}
// 角标 + 状态栏
this.updateBadges();
}
/** 点击通知/打开邮件后,把这批邮件在服务器和本地缓存都标记已读 */
async markSeen(mails: MailSummary[]): Promise<void> {
for (const m of mails) {
const acc = this.plugin.settings.accounts.find((a) => a.id === m.accountId);
if (!acc) continue;
try {
await this.plugin.mail.setSeen(acc, m.folder, m.uid, true);
} catch (e) {
// 服务器标记失败不影响本地状态更新
const st = this.plugin.settings.states[m.accountId];
const cached = st?.mails.find((x) => x.accountId === m.accountId && x.folder === m.folder && x.uid === m.uid);
if (cached) cached.seen = true;
this.plugin.scheduleSave();
}
}
this.updateBadges();
}
/** 更新功能区角标和状态栏计数 */
updateBadges(): void {
const s = this.plugin.settings;
const unread = Object.values(s.states).reduce(
(sum, st) => sum + (st?.mails?.filter((m) => !m.seen).length ?? 0),
0,
);
// 侧边栏图标角标
const icon = this.plugin.ribbonIconEl;
if (icon) {
const existing = icon.querySelector(".maildesk-badge");
if (existing) existing.remove();
if (s.notifyBadge && unread > 0) {
const badge = document.createElement("span");
badge.className = "maildesk-badge";
badge.textContent = unread > 99 ? "99+" : String(unread);
icon.appendChild(badge);
}
}
// 状态栏
if (s.notifyStatusBar) {
if (!this.statusBarEl) {
this.statusBarEl = this.plugin.addStatusBarItem();
this.statusBarEl.addClass("maildesk-statusbar");
this.statusBarEl.onclick = () => this.plugin.openMailView();
}
this.statusBarEl.toggleClass("maildesk-statusbar-has-unread", unread > 0);
this.statusBarEl.setText(unread > 0 ? `✉ ${unread} 封未读` : "✉ 无未读");
} else if (this.statusBarEl) {
this.statusBarEl.remove();
this.statusBarEl = null;
}
// 通知视图刷新角标(节流,避免 updateBadges 被频繁调用时反复重绘)
if (this.refreshTimer !== null) window.clearTimeout(this.refreshTimer);
this.refreshTimer = window.setTimeout(() => {
this.plugin.refreshView();
this.refreshTimer = null;
}, 60);
}
dispose(): void {
if (this.refreshTimer !== null) {
window.clearTimeout(this.refreshTimer);
this.refreshTimer = null;
}
if (this.statusBarEl) {
this.statusBarEl.remove();
this.statusBarEl = null;
}
if (this.plugin.ribbonIconEl) {
this.plugin.ribbonIconEl.querySelector(".maildesk-badge")?.remove();
}
}
}

454
src/settings.ts Normal file

File diff suppressed because it is too large Load Diff

245
src/types.ts Normal file
View File

@@ -0,0 +1,245 @@
// ---------------------------------------------------------------------------
// 类型定义
// ---------------------------------------------------------------------------
/** 邮箱服务商预设 */
export interface ProviderPreset {
name: string;
imapHost: string;
imapPort: number;
smtpHost: string;
smtpPort: number;
/** true = 隐式 SSL/TLS(993/465),false = STARTTLS(143/587) */
secure: boolean;
helpUrl: string;
/** 授权码获取说明 */
authHint: string;
}
/** 单个邮箱账户配置(授权码不存这里,只存 secretStorage 的 id) */
export interface MailAccount {
id: string;
/** 显示名称 */
name: string;
/** 完整邮箱地址 */
email: string;
/** 发件人显示名 */
senderName: string;
imapHost: string;
imapPort: number;
smtpHost: string;
smtpPort: number;
/** IMAP 是否隐式 SSL/TLS(993=true,143=false) */
secure: boolean;
/** SMTP 是否隐式 SSL/TLS(465=true,587=false 即 STARTTLS);旧配置缺省时回退到 secure */
smtpSecure?: boolean;
/** secretStorage 中授权码的 id,值本身不落盘 */
secretId: string;
/** 只拉取最近 N 天的邮件,0 = 不限。QQ 官方建议 30 */
fetchDays: number;
enabled: boolean;
}
/** 邮件摘要(列表用) */
export interface MailSummary {
accountId: string;
folder: string;
uid: number;
subject: string;
from: string;
fromName: string;
to: string;
date: string;
snippet: string;
seen: boolean;
hasAttachment: boolean;
attachmentCount: number;
}
/** 邮件正文详情 */
export interface MailDetail extends MailSummary {
html: string;
text: string;
attachments: AttachmentInfo[];
}
export interface AttachmentInfo {
filename: string;
contentType: string;
size: number;
}
/** 本地缓存的某个账户的收信状态 */
export interface AccountState {
/** 已经提醒过 / 已入库的最大 UID,用于增量拉取 */
lastUid: number;
/** 是否已完成首次同步(首次只记基线不提醒) */
initialized: boolean;
/** 缓存的邮件列表 */
mails: MailSummary[];
/** 从服务器缓存的文件夹列表 */
folders?: string[];
lastSync: number;
lastError: string;
}
/** 未发送完的草稿(仅存文字,不含附件) */
export interface ComposeDraft {
to: string;
cc: string;
subject: string;
body: string;
savedAt: number;
}
/** 插件设置(存 data.json,不含任何密钥) */
export interface MailDeskSettings {
accounts: MailAccount[];
states: Record<string, AccountState>;
/** 轮询间隔(分钟),0 = 不自动收信 */
pollInterval: number;
/** 启动 Obsidian 时是否立即收信 */
syncOnStartup: boolean;
/** 提醒开关 */
notifySystem: boolean;
notifyNotice: boolean;
notifyBadge: boolean;
notifyStatusBar: boolean;
/** 系统通知是否只在后台时弹出(前台用 Notice) */
systemNotificationOnlyWhenBackground: boolean;
/** 每封新信都弹通知,还是汇总一条 */
aggregateNotification: boolean;
/** 邮件列表默认文件夹 */
defaultFolder: string;
/** 列表默认只显示未读 */
showUnreadOnly: boolean;
/** 打开邮件后是否自动存一份笔记到库 */
autoSaveNote: boolean;
/** 账户/文件夹栏宽度(px),可拖拽 */
sidebarWidth: number;
/** 邮件列表栏宽度(px),可拖拽 */
listWidth: number;
/**
* 打开邮件面板时,是否把 Obsidian 左侧栏临时加宽到能同时显示三栏。
* v1.1.6 起恢复该能力,但与旧实现(write 死 1060px 且关闭不回滚)不同:
* 只在邮件面板可见期间加宽,面板关闭 / 切到别的面板 / 插件卸载时精确还原原始宽度。
*/
dockAutoFit: boolean;
/** 自动加宽的目标宽度(px);实际会再按窗口宽度约 62% 上限封顶 */
dockFitWidth: number;
/**
* 右侧栏「健康宽度」记录(px),自动维护,不需要用户设置。
* 用途:加宽左栏时 Obsidian 的 flex 会把右栏一起压窄(并写进 workspace.json),
* 导致其它插件的右栏内容挤乱;下次打开时按这个值把右栏恢复回来。
*/
rightDockWidth?: number;
/** 上次未发完的草稿 */
draft: ComposeDraft | null;
/** 布局设置版本号,用于迁移默认宽度 */
layoutVersion?: number;
/** debug 日志 */
debug: boolean;
}
export const PROVIDERS: ProviderPreset[] = [
{
name: "QQ 邮箱",
imapHost: "imap.qq.com",
imapPort: 993,
smtpHost: "smtp.qq.com",
smtpPort: 465,
secure: true,
helpUrl: "https://help.mail.qq.com/detail/0/1088",
authHint: "网页版 QQ 邮箱 → 设置 → 账号与安全 → 开启 IMAP/SMTP 服务 → 生成 16 位授权码。密码栏填授权码,不是 QQ 密码。",
},
{
name: "126 邮箱",
imapHost: "imap.126.com",
imapPort: 993,
smtpHost: "smtp.126.com",
smtpPort: 465,
secure: true,
helpUrl: "https://mail.126.com",
authHint: "网页版 126 邮箱 → 设置 → POP3/SMTP/IMAP → 开启 IMAP/SMTP → 短信验证 → 获取客户端授权码。密码栏填授权码。",
},
{
name: "163 邮箱",
imapHost: "imap.163.com",
imapPort: 993,
smtpHost: "smtp.163.com",
smtpPort: 465,
secure: true,
helpUrl: "https://mail.163.com",
authHint: "网页版 163 邮箱 → 设置 → POP3/SMTP/IMAP → 开启服务并获取授权码。",
},
{
name: "Gmail",
imapHost: "imap.gmail.com",
imapPort: 993,
smtpHost: "smtp.gmail.com",
smtpPort: 465,
secure: true,
helpUrl: "https://myaccount.google.com/apppasswords",
authHint: "Google 账号 → 两步验证 → 应用专用密码。密码栏填 16 位应用专用密码。",
},
{
name: "Outlook / Hotmail",
imapHost: "outlook.office365.com",
imapPort: 993,
smtpHost: "smtp.office365.com",
smtpPort: 587,
secure: false,
helpUrl: "https://account.microsoft.com/security",
authHint: "微软账户自 2024 年 9 月起第三方客户端拒绝普通密码,需应用专用密码。基础认证可能被禁用,建议用企业邮箱或应用密码。",
},
{
name: "自定义 IMAP",
imapHost: "",
imapPort: 993,
smtpHost: "",
smtpPort: 465,
secure: true,
helpUrl: "",
authHint: "手动填写 IMAP / SMTP 服务器地址、端口及加密方式。",
},
];
export const DEFAULT_SETTINGS: MailDeskSettings = {
accounts: [],
states: {},
pollInterval: 5,
syncOnStartup: true,
notifySystem: true,
notifyNotice: true,
notifyBadge: true,
notifyStatusBar: true,
systemNotificationOnlyWhenBackground: false,
aggregateNotification: true,
defaultFolder: "INBOX",
showUnreadOnly: false,
autoSaveNote: false,
sidebarWidth: 132,
listWidth: 250,
dockAutoFit: true,
dockFitWidth: 1100,
rightDockWidth: 344,
draft: null,
layoutVersion: 3,
debug: false,
};
/** 生成账户 id */
export function makeAccountId(): string {
return "acct-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 7);
}
/** 根据邮箱地址猜测服务商预设 */
export function guessProvider(email: string): ProviderPreset | undefined {
const domain = email.split("@")[1]?.toLowerCase() ?? "";
if (domain === "qq.com" || domain === "foxmail.com") return PROVIDERS[0];
if (domain === "126.com") return PROVIDERS[1];
if (domain === "163.com" || domain === "yeah.net") return PROVIDERS[2];
if (domain === "gmail.com" || domain === "googlemail.com") return PROVIDERS[3];
if (domain === "outlook.com" || domain === "hotmail.com" || domain === "live.com") return PROVIDERS[4];
return undefined;
}

1276
src/view.ts Normal file

File diff suppressed because it is too large Load Diff

987
styles.css Normal file

File diff suppressed because it is too large Load Diff