當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。