firemail
标题:
MailSpring源码分析--向导窗口
[打印本页]
作者:
Qter
时间:
2020-10-9 16:26
标题:
MailSpring源码分析--向导窗口
本帖最后由 Qter 于 2020-10-12 15:16 编辑
test.png
(30.02 KB, 下载次数: 593)
下载附件
2020-10-9 16:26 上传
app\internal_packages\onboarding\lib\onboarding-actions.ts
export const finishAndAddAccount = Reflux.createAction('finishAndAddAccount');
finishAndAddAccount.sync = true;
app\internal_packages\onboarding\lib\onboarding-store.ts
this.listenTo(OnboardingActions.finishAndAddAccount, this._onFinishAndAddAccount);
_onFinishAndAddAccount = async account => {
try {
"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)
AccountStore.addAccount(account);
}
}
app\src\flux\stores\account-store.ts
addAccount = async account => {
const cleanAccount = await KeyManager.extractAccountSecrets(account);
this._loadAccounts();
this._save();
}
app\internal_packages\onboarding\lib\decorators\create-page-for-form.tsx
_renderButton() {
onClick={this.onSubmit}
}
this.onConnect();
console.log("create-page-for-form account:" + JSON.stringify(account));
finalizeAndValidateAccount(account)
.then(validated => {
OnboardingActions.moveToPage('account-onboarding-success');
OnboardingActions.finishAndAddAccount(validated);
})
app\internal_packages\onboarding\lib\onboarding-helpers.ts
export async function finalizeAndValidateAccount(account: Account) {
console.log("onboarding-helpers finalizeAndValidateAccount set:" + JSON.stringify(AppEnv.getLoadSettings()));
const proc = new MailsyncProcess(AppEnv.getLoadSettings());
proc.identity = IdentityStore.identity();
proc.account = account;
await proc.test();
}
app\src\mailsync-process.ts
test() {
return this._spawnAndWait('test');
}
_spawnAndWait(mode, { onData }: { onData?: (data: any) => void } = {}) {
this._spawnProcess(mode);
this._proc.stdout.on('data', data => {
console.log("_spawnAndWait on stdout data:" + data)
buffer += data;
if (onData) onData(data);
});
}
_spawnProcess(mode) {
console.log("_spawnProcess : " + this.binaryPath + " args:"+ JSON.stringify(args) + " env:" + JSON.stringify(env))
this._proc = spawn(this.binaryPath, args, { env });
}
复制代码
作者:
Qter
时间:
2020-10-12 15:14
然后会打开主窗口中
app\internal_packages\onboarding\lib\page-initial-preferences.tsx
_onFinished = () => {
require('electron').ipcRenderer.send('account-setup-successful');
}
app\src\browser\application.ts
ipcMain.on('account-setup-successful', () => {
this.windowManager.ensureWindow(WindowManager.MAIN_WINDOW);
const onboarding = this.windowManager.get(WindowManager.ONBOARDING_WINDOW);
if (onboarding) {
onboarding.close();
}
});
复制代码
欢迎光临 firemail (http://firemail.wang:8088/)
Powered by Discuz! X3