Discuz! Board

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

MailSpring源码分析--数据库相关

[复制链接]

1272

主题

2067

帖子

7964

积分

认证用户组

Rank: 5Rank: 5

积分
7964
跳转到指定楼层
楼主
发表于 2020-9-27 17:33:52 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
本帖最后由 Qter 于 2020-9-27 17:38 编辑

在没有任何账号的情况 下会查询下面加红的表
app\src\browser\application.ts
this.windowManager = new WindowManager({


app\src\browser\window-manager.ts
this.windowLauncher = new WindowLauncher({


app\src\browser\window-launcher.ts
this.hotWindow = new MailspringWindow(this._hotWindowOpts());

app\src\browser\mailspring-window.ts
this.browserWindow = new BrowserWindow(browserWindowOptions);
this.browserWindow.loadURL(this.getURL(loadSettings)); ---/static/index.html


/static/index.html
  <script src="index.js"></script>

app\static\index.js

function setupWindow(loadSettings) {
  require(loadSettings.bootstrapScript);
}



loadSettings {"bootstrapScript":"\app\\src\\secondary-window-bootstrap.ts"}

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

app\src\app-env.ts
constructor() {
   require('mailspring-observables');
   require('mailspring-exports');
   this.actionBridge = new ActionBridge(ipcRenderer);
    this.mailsyncBridge = new MailsyncBridge();
}

app/src/flux/mailsync-bridge.ts
import TaskQueue from './stores/task-queue';


app\src\flux\stores\category-store.ts
  constructor() {
      Categories.forAllAccounts()   ---程序启动默认查询Label Folder表
      .sort()
      .subscribe(this._onCategoriesChanged);

forAllAccounts() {
    const folders = Rx.Observable.fromQuery<Folder[]>(DatabaseStore.findAll<Folder>(Folder));
    const labels = Rx.Observable.fromQuery(DatabaseStore.findAll<Label>(Label));
    const joined = Rx.Observable.combineLatest<Category[], Category[], Category[]>(
      folders,
      labels,
      (f, l) => [].concat(f, l)
    );

======================
app\src\flux\stores\task-queue.ts
  constructor() {
    super();
    Rx.Observable.fromQuery(DatabaseStore.findAll<Task>(Task)).subscribe(  ---程序启动默认查询Task表
      this._onQueueChangedDebounced
    );
  }

app\src\global\mailspring-observables.ts
Rx.Observable.fromQuery = <T>(query: ModelQuery<T>) => {
  return Rx.Observable.create(observer => {
    const unsubscribe = QuerySubscriptionPool.add(query, result => observer.onNext(result));
    return Rx.Disposable.create(unsubscribe);
  });
};


app\src\flux\models\query-subscription-pool.ts
add(query: ModelQuery<any>, callback) {
subscription = new QuerySubscription(query);


app\src\flux\models\query-subscription.ts
QuerySubscription 构造函数
this.update();

update({ mustRefetchEntireRange }: { mustRefetchEntireRange?: boolean } = {}) {
this._fetchRange(desiredRange, {
        version: this._queryVersion,
        fetchEntireModels: haveNoModels,
      });

_fetchRange(range, { version, fetchEntireModels }) {
DatabaseStore.run

app\src\flux\stores\database-store.ts
  _query(query: SQLString, values: SQLValue[] = [], background: boolean = false) {


回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

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