本文整理汇总了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));
});
开发者ID:sunyton,项目名称:upterm,代码行数:35,代码来源:Main.ts
示例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 => {
开发者ID:Sheshouzuo,项目名称:Shiba,代码行数:33,代码来源:mainu.ts
示例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)
}
})
开发者ID:,项目名称:,代码行数:12,代码来源:
示例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);
}
});
开发者ID:SteveTannnnng,项目名称:Mob,代码行数:14,代码来源:main.ts
示例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]));
});
开发者ID:kusamakura,项目名称:caprine,代码行数:17,代码来源:index.ts
示例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);
}
});
开发者ID:HorrerGames,项目名称:itch,代码行数:19,代码来源:tray.ts
示例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);
}
}
}
}
开发者ID:kusamakura,项目名称:caprine,代码行数:40,代码来源:index.ts
示例8:
browserWindow.on("focus", () => app.dock && app.dock.setBadge(""));
开发者ID:admix,项目名称:black-screen,代码行数:1,代码来源:Main.ts
示例9: it
it('should not throw', () => {
app.dock.hide()
expect(app.dock.isVisible()).to.equal(false)
})
开发者ID:malept,项目名称:electron,代码行数:4,代码来源:api-app-spec.ts
注:本文中的electron.app.dock类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论