diff --git a/packages/neuron-wallet/src/controllers/app/menu.ts b/packages/neuron-wallet/src/controllers/app/menu.ts index b55a7cffe4..7d9e795948 100644 --- a/packages/neuron-wallet/src/controllers/app/menu.ts +++ b/packages/neuron-wallet/src/controllers/app/menu.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import { app, shell, BrowserWindow, dialog, MenuItemConstructorOptions, Menu } from 'electron' +import { app, shell, clipboard, BrowserWindow, dialog, MenuItemConstructorOptions, Menu } from 'electron' import { t } from 'i18next' import { Subject } from 'rxjs' import { throttleTime } from 'rxjs/operators' @@ -31,7 +31,8 @@ enum ExternalURL { Website = 'https://www.nervos.org/', Repository = 'https://github.com/nervosnetwork/neuron', Issues = 'https://github.com/nervosnetwork/neuron/issues', - Doc = 'https://docs.nervos.org/docs/basics/tools#neuron-wallet' + Doc = 'https://docs.nervos.org/docs/basics/tools#neuron-wallet', + MailUs = 'neuron@magickbase.com' } const separator: MenuItemConstructorOptions = { @@ -400,6 +401,53 @@ const updateApplicationMenu = (mainWindow: BrowserWindow | null) => { shell.openExternal(ExternalURL.Issues) } }, + { + label: t('application-menu.help.contact-us'), + click: async () => { + const { response: methodId } = await dialog.showMessageBox(BrowserWindow.getFocusedWindow()!, { + type: 'info', + message: t(`messageBox.mail-us.message`), + buttons: [ + t(`messageBox.button.discard`), + t(`messageBox.mail-us.copy-mail-addr`), + t(`messageBox.mail-us.open-client`) + ], + defaultId: 1, + cancelId: 0 + }) + + switch (methodId) { + case 1: { + clipboard.writeText(ExternalURL.MailUs) + return + } + case 2: { + try { + await shell.openExternal( + `mailto:${ExternalURL.MailUs}?body=${encodeURIComponent( + t('application-menu.help.contact-us-message') as string + )}` + ) + } catch { + const { response: subMethodId } = await dialog.showMessageBox(BrowserWindow.getFocusedWindow()!, { + type: 'info', + message: t(`messageBox.mail-us.fail-message`), + buttons: [t(`messageBox.button.discard`), t(`messageBox.mail-us.copy-mail-addr`)], + defaultId: 1, + cancelId: 0 + }) + if (subMethodId === 1) { + clipboard.writeText(ExternalURL.MailUs) + } + } + return + } + default: { + return + } + } + } + }, { label: t('application-menu.help.export-debug-info'), click: () => { diff --git a/packages/neuron-wallet/src/locales/en.ts b/packages/neuron-wallet/src/locales/en.ts index bcbe3ea9d0..482fe0dc5a 100644 --- a/packages/neuron-wallet/src/locales/en.ts +++ b/packages/neuron-wallet/src/locales/en.ts @@ -50,6 +50,9 @@ export default { 'nervos-website': 'Nervos Website', 'source-code': 'Source Code', 'report-issue': 'Report Issue', + 'contact-us': 'Contact Us', + 'contact-us-message': + '> Please append debug information exported by "Menu" -> "Help" -> "Export Debug Information".', documentation: 'Documentation', settings: 'Settings', 'export-debug-info': 'Export Debug Information' @@ -195,6 +198,13 @@ export default { 'hard-fork-migrate': { message: 'In order to adapt to the latest version of CKB, Neuron will resynchronize the data on the chain, and the whole synchronization may take a long time.' + }, + 'mail-us': { + message: 'Please mail us with debug information exported by "Menu" -> "Help" -> "Export Debug Information".', + 'open-client': 'Open Mail Client', + 'fail-message': + 'Unable to launch mail client, please copy the mail address, append debug information exported by "Menu" -> "Help" -> "Export Debug Information" and send us.', + 'copy-mail-addr': 'Copy mail address' } }, prompt: { diff --git a/packages/neuron-wallet/src/locales/zh-tw.ts b/packages/neuron-wallet/src/locales/zh-tw.ts index 3143d774b9..a55529586c 100644 --- a/packages/neuron-wallet/src/locales/zh-tw.ts +++ b/packages/neuron-wallet/src/locales/zh-tw.ts @@ -50,6 +50,8 @@ export default { 'nervos-website': 'Nervos 官方網站', 'source-code': '原始程式碼', 'report-issue': '回報問題', + 'contact-us': '聯繫我們', + 'contact-us-message': '> 請通過 "菜單" -> "幫助" -> "導出調試信息" 獲得 Neuron 的調試信息並附在郵件中.', documentation: '使用說明', settings: '設定', 'export-debug-info': '導出除錯信息' @@ -185,6 +187,13 @@ export default { }, 'hard-fork-migrate': { message: '為適配最新版本的 CKB 節點,Neuron 將會重新同步鏈上數據,整個同步可能時間較長' + }, + 'mail-us': { + message: '請將問題及調試信息通過郵件發給我們, 調試信息可以通過 "菜單" -> "幫助" -> "導出調試信息" 獲得', + 'open-client': '打開郵件客戶端', + 'fail-message': + '未能打開郵件客戶端, 請複製郵件地址, 並通過 "菜單" -> "幫助" -> "導出調試信息" 獲得 Neuron 的調試信息附在郵件中發送給我們', + 'copy-mail-addr': '複製郵件地址' } }, prompt: { diff --git a/packages/neuron-wallet/src/locales/zh.ts b/packages/neuron-wallet/src/locales/zh.ts index d2de00cb4a..86a2a59832 100644 --- a/packages/neuron-wallet/src/locales/zh.ts +++ b/packages/neuron-wallet/src/locales/zh.ts @@ -50,6 +50,8 @@ export default { 'nervos-website': 'Nervos 网站', 'source-code': '源代码', 'report-issue': '报告问题', + 'contact-us': '联系我们', + 'contact-us-message': '> 请通过 "菜单" -> "帮助" -> "导出调试信息" 获得 Neuron 的调试信息并附在邮件中.', documentation: '使用文档', settings: '设置', 'export-debug-info': '导出调试信息' @@ -186,6 +188,13 @@ export default { }, 'hard-fork-migrate': { message: '为适配最新版本的 CKB 节点,Neuron 将会重新同步链上数据,整个同步可能时间较长' + }, + 'mail-us': { + message: '请将问题及调试信息通过邮件发给我们, 调试信息可以通过 "菜单" -> "帮助" -> "导出调试信息" 获得', + 'open-client': '打开邮件客户端', + 'fail-message': + '未能打开邮件客户端, 请复制邮件地址, 并通过 "菜单" -> "帮助" -> "导出调试信息" 获得 Neuron 的调试信息附在邮件中发送给我们', + 'copy-mail-addr': '复制邮件地址' } }, prompt: {