本文整理匯總了TypeScript中electron.app.dock類的典型用法代碼示例。如果您正苦於以下問題:TypeScript app.dock類的具體用法?TypeScript app.dock怎麽用?TypeScript app.dock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了app.dock類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: windowBounds
app.on("ready", () => {
const bounds = windowBounds();
let options: Electron.BrowserWindowConstructorOptions = {
webPreferences: {
experimentalFeatures: true,
experimentalCanvasFeatures: true,
},
titleBarStyle: "hidden",
resizable: true,
minWidth: 500,
minHeight: 300,
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: bounds.y,
show: false,
};
const browserWindow = new BrowserWindow(options);
if (app.dock) {
app.dock.setIcon(nativeImage.createFromPath("build/icon.png"));
} else {
browserWindow.setIcon(nativeImage.createFromPath("build/icon.png"));
}
browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
browserWindow.webContents.on("did-finish-load", () => {
browserWindow.show();
browserWindow.focus();
});
app.on("open-file", (_event, file) => browserWindow.webContents.send("change-working-directory", file));
});
示例2: createWindow
loading.then((loaded: [Config, WatchDog]) => {
const [config, dog] = loaded;
global.config = config;
const icon_path = path.join(__dirname, '..', '..', 'images', 'shibainu.png');
let win = createWindow(config, icon_path);
win.once('closed', function() {
win = null;
});
const html = 'file://' + path.join(__dirname, '..', '..', 'static', 'index.html');
win.loadURL(html);
dog.wakeup(win.webContents);
win.webContents.on('will-navigate', function(e: Event, url: string) {
e.preventDefault();
shell.openExternal(url);
});
menu.build(win);
if (process.argv[0].endsWith('Electron') && process.platform === 'darwin') {
// Note:
// If Shiba is run as npm package, replace dock app icon
app.dock.setIcon(icon_path);
}
if (process.env.NODE_ENV === 'development') {
win.webContents.once('devtools-opened', () => setImmediate(() => win.focus()));
win.webContents.openDevTools({mode: 'detach'});
}
}).catch(e => {
示例3:
ipc.on('unread-count', (_: any, unreadCount: number) => {
if (is.macos) {
app.dock.setBadge(unreadCount ? unreadCount.toString() : '')
}
if ((is.linux || is.windows) && tray) {
const icon = unreadCount ? 'tray-icon-unread.png' : 'tray-icon.png'
const iconPath = path.join(__dirname, '..', 'static', icon)
tray.setImage(iconPath)
}
})
示例4:
item.once('done', (e, state) => {
if (!mainWindow.isDestroyed()) {
mainWindow.setProgressBar(-1);
}
if (state === 'interrupted') {
mainWindow.webContents.send(DOWNLOAD, { type: 'error' });
}
if (state === 'completed') {
mainWindow.webContents.send(DOWNLOAD, { type: 'success', filePath });
app.dock.downloadFinished(filePath);
}
});
示例5: sendAction
ipcMain.on('conversations', (_event: ElectronEvent, conversations: Conversation[]) => {
if (conversations.length === 0) {
return;
}
const items = conversations.map(({label, icon}, index) => {
return {
label: `${label}`,
icon: nativeImage.createFromDataURL(icon),
click: () => {
mainWindow.show();
sendAction('jump-to-conversation', index + 1);
}
};
});
app.dock.setMenu(Menu.buildFromTemplate([firstItem, {type: 'separator'}, ...items]));
});
示例6: memoize
const setTrayMenu = memoize(1, function(
template: IMenuTemplate,
store: IStore
) {
const fleshedOut = fleshOutTemplate(
"root",
store,
currentRuntime(),
template
);
const menu = Menu.buildFromTemplate(fleshedOut);
if (os.platform() === "darwin") {
// don't have a tray icon on macOS, we just live in the dock
app.dock.setMenu(menu);
} else {
getTray(store).setContextMenu(menu);
}
});
示例7: updateBadge
function updateBadge(conversations: Conversation[]): void {
// Ignore `Sindre messaged you` blinking
if (!Array.isArray(conversations)) {
return;
}
const messageCount = conversations.filter(({unread}) => unread).length;
if (is.macos || is.linux) {
if (config.get('showUnreadBadge')) {
app.setBadgeCount(messageCount);
}
if (is.macos && config.get('bounceDockOnMessage') && prevMessageCount !== messageCount) {
app.dock.bounce('informational');
prevMessageCount = messageCount;
}
}
if (is.linux || is.windows) {
if (config.get('showUnreadBadge')) {
tray.setBadge(messageCount > 0);
}
if (config.get('flashWindowOnMessage')) {
mainWindow.flashFrame(messageCount !== 0);
}
}
if (is.windows) {
if (config.get('showUnreadBadge')) {
if (messageCount === 0) {
mainWindow.setOverlayIcon(null, '');
} else {
// Delegate drawing of overlay icon to renderer process
mainWindow.webContents.send('render-overlay-icon', messageCount);
}
}
}
}
示例8:
browserWindow.on("focus", () => app.dock && app.dock.setBadge(""));
示例9: it
it('should not throw', () => {
app.dock.hide()
expect(app.dock.isVisible()).to.equal(false)
})