handleEvents() { // 定义用于创建打开设置的函数 const createOpenSettings = ({ event, sameWindow }) => { const targetWindow = event ? this.atomWindowForEvent(event) : this.focusedWindow(); return { devMode: targetWindow ? targetWindow.devMode : false, safeMode: targetWindow ? targetWindow.safeMode : false, window: sameWindow && targetWindow ? targetWindow : null }; };

// 注册各种事件处理函数
this.on('application:quit', () => app.quit()); // 退出应用
this.on('application:new-window', () =>
  this.openPath(createOpenSettings({})) // 新建窗口并打开路径
);
this.on('application:new-file', () =>
  (this.focusedWindow() || this).openPath() // 新建文件
);
this.on('application:open-dev', () =>
  this.promptForPathToOpen('all', { devMode: true }) // 打开开发者模式
);
this.on('application:open-safe', () =>
  this.promptForPathToOpen('all', { safeMode: true }) // 打开安全模式
);
this.on('application:inspect', ({ x, y, atomWindow }) => {
  if (!atomWindow) atomWindow = this.focusedWindow();
  if (atomWindow) atomWindow.browserWindow.inspectElement(x, y); // 检查元素
});

this.on('application:open-documentation', () =>
  shell.openExternal('http://flight-manual.atom.io') // 打开 Atom 文档
);
this.on('application:open-discussions', () =>
  shell.openExternal('https://github.com/atom/atom/discussions') // 打开 Atom 讨论
);
this.on('application:open-faq', () =>
  shell.openExternal('https://atom.io/faq') // 打开 Atom 常见问题
);
this.on('application:open-terms-of-use', () =>
  shell.openExternal('https://atom.io/terms') // 打开 Atom 使用条款
);
this.on('application:report-issue', () =>
  shell.openExternal(
    'https://github.com/atom/atom/blob/master/CONTRIBUTING.md#reporting-bugs'
  ) // 报告问题
);
this.on('application:search-issues', () =>
  shell.openExternal('https://github.com/search?q=+is%3Aissue+user%3Aatom') // 搜索问题
);

this.on('application:install-update', () => {
  this.quitting = true;
  this.quittingForUpdate = true;
  this.autoUpdateManager.install(); // 安装更新
});

this.on('application:check-for-update', () =>
  this.autoUpdateManager.check() // 检查更新
);

if (process.platform === 'darwin') {
  // macOS 系统下的事件处理函数
  this.on('application:reopen-projec

原文地址: http://www.cveoy.top/t/topic/htk5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录