Discuz! Board

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

MailSpring源码分析--界面窗口

[复制链接]

1272

主题

2067

帖子

7964

积分

认证用户组

Rank: 5Rank: 5

积分
7964
跳转到指定楼层
楼主
发表于 2020-9-29 10:58:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式




app\src\browser\application.ts
openWindowsForTokenState() {
    if (hasAccount && hasIdentity) {
      this.windowManager.ensureWindow(WindowManager.MAIN_WINDOW);
    } else {
      this.windowManager.ensureWindow(WindowManager.ONBOARDING_WINDOW, {
        title: localized('Welcome to Firemail'),
      });
    }

    ONBOARDING_WINDOW 打开向导窗口

窗口组件的注册
app\internal_packages\onboarding\lib\main.ts
ComponentRegistry.register(OnboardingRoot, {
    location: WorkspaceStore.Location.Center,
  });

windowManager如何管理注册的组件窗口

app\src\browser\mailspring-window.ts
//getURL中这两个参数是不同的windowType[emptyWindow onboarding]  windowKey [onboarding]
    this.browserWindow.loadURL(this.getURL(loadSettings));
app\static\index.js
文件中解析上面的url
window.onload = function() {
// Skip "?loadSettings=".
   var rawLoadSettings = decodeURIComponent(window.location.search.substr(14));
   loadSettings = JSON.parse(rawLoadSettings);
   {"frame":true,"toolbar":true,"hidden":false,"devMode":true,"safeMode":false,"resizable":true,"windowType":"emptyWindow","bootstrapScript":"\app\\src\\secondary-window-bootstrap.ts","resourcePath":"\app","configDirPath":"\\AppData\\Roaming\\Firemail-dev","appVersion":"1.0.0-COMMIT_INSERTED_DURING_PACKAGING","shellLoadTime":873}"
   {"frame":false,"toolbar":false,"hidden":true,"devMode":true,"safeMode":false,"resizable":false,"windowType":"onboarding","bootstrapScript":"\app\\src\\secondary-window-bootstrap.ts","resourcePath":"\app","configDirPath":"\\AppData\\Roaming\\Firemail-dev","windowKey":"onboarding","title":"Welcome to Firemail","width":900,"height":600,"appVersion":"1.0.0-COMMIT_INSERTED_DURING_PACKAGING"}"
   setupWindow(loadSettings);
   {
   require(loadSettings.bootstrapScript);
   }
}

app\src\secondary-window-bootstrap.ts
window.AppEnv = new AppEnvClass();
AppEnv.startSecondaryWindow();

app\src\app-env.ts
async startSecondaryWindow() {
await this.startWindow();
}  

async startWindow() {
激活组件包
this.packages.activatePackages(windowType);onboarding
{pkg.activate();}
}

app\internal_packages\onboarding\lib\main.ts
export function activate() {
WorkspaceStore.defineSheet('Main', { root: true }, { list: ['Center'] });
ComponentRegistry.register(OnboardingRoot, {
    location: WorkspaceStore.Location.Center,
  });

}

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-26 18:39 , Processed in 0.055844 second(s), 20 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

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