Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1669|回复: 1
打印 上一主题 下一主题

MailSpring源码分析--向导窗口

[复制链接]

1272

主题

2067

帖子

7964

积分

认证用户组

Rank: 5Rank: 5

积分
7964
跳转到指定楼层
楼主
发表于 2020-10-9 16:26:18 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Qter 于 2020-10-12 15:16 编辑



  1. app\internal_packages\onboarding\lib\onboarding-actions.ts
  2. export const finishAndAddAccount = Reflux.createAction('finishAndAddAccount');
  3. finishAndAddAccount.sync = true;

  4. app\internal_packages\onboarding\lib\onboarding-store.ts
  5. this.listenTo(OnboardingActions.finishAndAddAccount, this._onFinishAndAddAccount);
  6. _onFinishAndAddAccount = async account => {
  7. try {
  8.   "onboarding-store _onFinishAndAddAccount account: {"id":"b800a344","metadata":[],"name":"15313159857","provider":"imap","emailAddress":"15313159857@139.com","settings":{"imap_host":"imap.139.com","imap_port":143,"imap_username":"15313159857@139.com","imap_password":"1111","imap_security":"none","imap_allow_insecure_ssl":false,"smtp_host":"smtp.139.com","smtp_port":25,"smtp_username":"15313159857@139.com","smtp_password":"1111","smtp_security":"none","smtp_allow_insecure_ssl":false},"label":"15313159857@139.com","autoaddress":{"type":"bcc","value":""},"aliases":[],"syncState":"ok","authedAt":1602299324.14,"__cls":"Account"}", source: /F:/github/office/Mailspring/app/internal_packages/onboarding/lib/onboarding-store.ts (73)
  9.       AccountStore.addAccount(account);
  10.     }

  11. }

  12. app\src\flux\stores\account-store.ts

  13. addAccount = async account => {
  14. const cleanAccount = await KeyManager.extractAccountSecrets(account);
  15.     this._loadAccounts();
  16.     this._save();
  17. }



  18. app\internal_packages\onboarding\lib\decorators\create-page-for-form.tsx
  19. _renderButton() {
  20. onClick={this.onSubmit}
  21. }

  22. this.onConnect();
  23. console.log("create-page-for-form account:" + JSON.stringify(account));

  24.   finalizeAndValidateAccount(account)
  25.         .then(validated => {
  26.           OnboardingActions.moveToPage('account-onboarding-success');
  27.           OnboardingActions.finishAndAddAccount(validated);
  28.         })
  29.         
  30. app\internal_packages\onboarding\lib\onboarding-helpers.ts
  31. export async function finalizeAndValidateAccount(account: Account) {
  32.   console.log("onboarding-helpers finalizeAndValidateAccount set:" + JSON.stringify(AppEnv.getLoadSettings()));
  33.   const proc = new MailsyncProcess(AppEnv.getLoadSettings());
  34.   proc.identity = IdentityStore.identity();
  35.   proc.account = account;
  36.   await proc.test();
  37. }

  38. app\src\mailsync-process.ts
  39.   test() {
  40.     return this._spawnAndWait('test');
  41.   }
  42.   
  43.    _spawnAndWait(mode, { onData }: { onData?: (data: any) => void } = {}) {
  44.     this._spawnProcess(mode);
  45.     this._proc.stdout.on('data', data => {
  46.           console.log("_spawnAndWait on stdout data:" + data)
  47.           buffer += data;
  48.           if (onData) onData(data);
  49.         });
  50.    }
  51.    
  52.   _spawnProcess(mode) {
  53.      console.log("_spawnProcess : " + this.binaryPath + " args:"+ JSON.stringify(args) + " env:" + JSON.stringify(env))
  54.     this._proc = spawn(this.binaryPath, args, { env });
  55.   }
复制代码
回复

使用道具 举报

1272

主题

2067

帖子

7964

积分

认证用户组

Rank: 5Rank: 5

积分
7964
沙发
 楼主| 发表于 2020-10-12 15:14:18 | 只看该作者
然后会打开主窗口中
  1. app\internal_packages\onboarding\lib\page-initial-preferences.tsx
  2. _onFinished = () => {
  3. require('electron').ipcRenderer.send('account-setup-successful');
  4. }

  5. app\src\browser\application.ts

  6.     ipcMain.on('account-setup-successful', () => {
  7.       this.windowManager.ensureWindow(WindowManager.MAIN_WINDOW);
  8.       const onboarding = this.windowManager.get(WindowManager.ONBOARDING_WINDOW);
  9.       if (onboarding) {
  10.         onboarding.close();
  11.       }
  12.     });
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-11-26 12:37 , Processed in 0.065559 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表