firemail

标题: MailSpring源码分析--界面窗口 [打印本页]

作者: Qter    时间: 2020-9-29 10:58
标题: MailSpring源码分析--界面窗口




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,
  });

}






欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3