打卡工具
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const { app, BrowserWindow, ipcMain } = require('electron');
  2. const path = require('path');
  3. const Store = require('electron-store');
  4. const store = new Store();
  5. // 设置 Playwright 浏览器路径
  6. if (app.isPackaged) {
  7. process.env.PLAYWRIGHT_BROWSERS_PATH = path.join(process.resourcesPath, 'ms-playwright');
  8. } else {
  9. process.env.PLAYWRIGHT_BROWSERS_PATH = path.join(process.env.LOCALAPPDATA, 'ms-playwright');
  10. }
  11. let mainWindow;
  12. function createWindow() {
  13. mainWindow = new BrowserWindow({
  14. width: 800,
  15. height: 600,
  16. webPreferences: {
  17. nodeIntegration: true,
  18. contextIsolation: false
  19. }
  20. });
  21. mainWindow.loadFile('index.html');
  22. }
  23. // 处理 IPC 消息
  24. ipcMain.handle('get-credentials', async () => {
  25. return store.get('credentials');
  26. });
  27. ipcMain.handle('save-credentials', async (event, credentials) => {
  28. store.set('credentials', credentials);
  29. });
  30. app.whenReady().then(createWindow);
  31. app.on('window-all-closed', () => {
  32. if (process.platform !== 'darwin') {
  33. app.quit();
  34. }
  35. });
  36. app.on('activate', () => {
  37. if (BrowserWindow.getAllWindows().length === 0) {
  38. createWindow();
  39. }
  40. });