本文整理汇总了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());
}
});
示例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;
}
}
});
示例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]);
};
示例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)
})
示例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