当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript app.isReady方法代码示例

本文整理汇总了TypeScript中electron.app.isReady方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.isReady方法的具体用法?TypeScript app.isReady怎么用?TypeScript app.isReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.app的用法示例。


在下文中一共展示了app.isReady方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: makeDefaultConfig

 fs.readFile(file, 'utf8', (err, json) => {
     if (err) {
         log.info('Configuration file was not found, will create:', file);
         const onSaved = (saveErr: Error) => {
             if (saveErr) {
                 log.error('Failed to write configuration file:', file, saveErr);
             } else {
                 log.info('Configuration file was created at', file);
             }
         };
         const default_config = makeDefaultConfig();
         // Note:
         // If calling writeFile() directly here, it tries to create config file before Electron
         // runtime creates data directory. As the result, writeFile() would fail to create a file.
         if (app.isReady()) {
             fs.writeFile(file, JSON.stringify(default_config, null, 2), onSaved);
         } else {
             app.once('ready', () => fs.writeFile(file, JSON.stringify(default_config, null, 2), onSaved));
         }
         return resolve(default_config);
     }
     try {
         const config = JSON.parse(json);
         if (config.hot_key && config.hot_key.startsWith('mod+')) {
             config.hot_key = `CmdOrCtrl+${config.hot_key.slice(4)}`;
         }
         log.debug('Configuration was loaded successfully', config);
         resolve(config);
     } catch (e) {
         log.error('Error on loading JSON file, will load default configuration:', e.message);
         resolve(makeDefaultConfig());
     }
 });
开发者ID:rhysd,项目名称:Tui,代码行数:33,代码来源:config.ts

示例2: function

 app.on("open-file", function(event, path) {
     event.preventDefault();
     if (path.toLowerCase().endsWith(".eez-project")) {
         if (app.isReady()) {
             openFile(path);
         } else {
             projectFilePath = path;
         }
     }
 });
开发者ID:eez-open,项目名称:studio,代码行数:10,代码来源:main.ts

示例3: handlePotentialProtocolLaunch

const handlePotentialProtocolLaunch = (url: string) => {
  if (!app.isReady()) {
    app.once('ready', () => handlePotentialProtocolLaunch(url));
    return;
  }
  const parsed = nodeUrl.parse(url.replace(/\/$/, ''));
  if (!parsed.pathname) return;
  const pathParts = parsed.pathname.split('/');
  if (pathParts.length <= 0 || pathParts.length > 2) return;

  ipcMainManager.send(IpcEvents.LOAD_GIST_REQUEST, [parsed.pathname]);
};
开发者ID:cocoflan,项目名称:fiddle-electron,代码行数:12,代码来源:protocol.ts

示例4: it

 it('becomes fulfilled if the app is already ready', async () => {
   expect(app.isReady()).to.equal(true)
   await expect(app.whenReady()).to.be.eventually.fulfilled.equal(undefined)
 })
开发者ID:malept,项目名称:electron,代码行数:4,代码来源:api-app-spec.ts

示例5: Proxy

import { app, session } from 'electron'

// Global protocol APIs.
const protocol = process.atomBinding('protocol')

// Fallback protocol APIs of default session.
Object.setPrototypeOf(protocol, new Proxy({}, {
  get (target, property) {
    if (!app.isReady()) return

    const protocol = session.defaultSession!.protocol
    if (!Object.getPrototypeOf(protocol).hasOwnProperty(property)) return

    // Returning a native function directly would throw error.
    return (...args: any[]) => (protocol[property as keyof Electron.Protocol] as Function)(...args)
  },

  ownKeys () {
    if (!app.isReady()) return []

    return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession!.protocol))
  },

  getOwnPropertyDescriptor (target) {
    return { configurable: true, enumerable: true }
  }
}))

export default protocol
开发者ID:vwvww,项目名称:electron,代码行数:29,代码来源:protocol.ts


注:本文中的electron.app.isReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。