Electron Desktop App Development · Ders

Birden Çok Pencereyi Yönetme

Birden çok BrowserWindow örneği oluşturmayı, bunları eşgüdümlemeyi ve aralarında iletişim kurmayı öğrenin; bu, ana süreç ve IPC temelleri üzerine doğrudan inşa edilen temel bir beceridir.

4. ders / 413 adım

Birden Çok Pencereyi Yönetme, CoddyKit'te ücretsiz bir Electron Desktop App Development dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Electron Desktop App Development öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Electron Desktop App Development kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Beyond a Single Window

Real desktop apps often need multiple windows: a main editor, a settings panel, a preview. The main process owns and tracks all of them.

Creating a Window

Each window is a BrowserWindow instance created in the main process.

const { BrowserWindow } = require('electron');
function createWindow() {
  const win = new BrowserWindow({ width: 600, height: 400 });
  win.loadFile('index.html');
  return win;
}

Keeping References

If you do not keep a reference, the window can be garbage collected. Store windows in a variable or array.

let windows = [];
function track(win) {
  windows.push(win);
  win.on('closed', () => {
    windows = windows.filter(w => w !== win);
  });
}

Parent and Child Windows

You can make one window the parent of another. Child windows move with the parent and can be modal.

new BrowserWindow({
  parent: mainWindow,
  modal: true,
  width: 300,
  height: 200
});

Window-to-Window Messaging

Windows do not share memory. They communicate through the main process using IPC as a relay.

ipcMain.on('to-other', (e, msg) => {
  otherWindow.webContents.send('from-main', msg);
});

Identifying Windows

Each window has a unique id. Use it to target a specific window when relaying messages.

function findWindow(id, list) {
  return list.find(w => w.id === id);
}
console.log(findWindow(2, [{ id: 1 }, { id: 2 }]));

Showing Windows Gracefully

Avoid a white flash by creating windows hidden and showing them once ready.

const win = new BrowserWindow({ show: false });
win.once('ready-to-show', () => win.show());

Managing Focus

Use focus() and the blur event to know which window the user is interacting with, useful for save prompts.

Closing and Cleanup

Listen for close to prompt for unsaved changes, and closed to release references.

win.on('close', (e) => {
  if (hasUnsaved) {
    e.preventDefault();
  }
});

Single Instance Lock

Use app.requestSingleInstanceLock() to focus the existing window instead of opening duplicates.

Coordinating State

Centralize shared state in the main process so every window reads from one source of truth, avoiding drift.

Quick Check

Test your window management knowledge.

Recap

You learned to create and track multiple BrowserWindow instances, manage parent/child relationships, relay messages via the main process, and clean up references properly.

Başlamak ücretsiz

Yapay zeka eğitmeniyle JavaScript öğren — ücretsiz

Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.

Kurslar
12
Dersler
47

Sıkça Sorulan Sorular

“Birden Çok Pencereyi Yönetme” dersi ücretsiz mi?

Evet — “Birden Çok Pencereyi Yönetme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Electron Desktop App Development kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Electron Desktop App Development kursu toplamda 4 dersten oluşur.

“Birden Çok Pencereyi Yönetme” dersinde ne öğreneceğim?

Birden çok BrowserWindow örneği oluşturmayı, bunları eşgüdümlemeyi ve aralarında iletişim kurmayı öğrenin; bu, ana süreç ve IPC temelleri üzerine doğrudan inşa edilen temel bir beceridir. Electron Desktop App Development ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Electron Desktop App Development öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Electron Desktop App Development, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Birden Çok Pencereyi Yönetme” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Electron Desktop App Development dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Electron Desktop App Development dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Ana ve İşleyici Süreç
  2. Süreçler Arası İletişim (IPC)
  3. Electron Uygulamanızı Paketleme
  4. Birden Çok Pencereyi Yönetme
← Electron Desktop App Development Sayfasına Dön