Compare commits
3 Commits
master
...
auto-49153
Author | SHA1 | Date | |
---|---|---|---|
c4703eb5ba | |||
c8c60e693f | |||
f2aa5bdcf2 |
17
main.js
17
main.js
@ -331,6 +331,8 @@ let avatarCache = {};
|
||||
let avatarPlaceholder = `${__dirname}/src/assets/images/user-fallback.png`;
|
||||
const icon = `${__dirname}/src/assets/images/dock.png`;
|
||||
|
||||
|
||||
|
||||
async function getIcon(cookies, userid, src) {
|
||||
var cached = avatarCache[userid];
|
||||
var icon;
|
||||
@ -477,11 +479,20 @@ function createMenu() {
|
||||
mainWindow.setMenu(menu);
|
||||
}
|
||||
}
|
||||
// 实现单例,在启动第二个实例后,激活主窗口,然后退出第二个实例
|
||||
const shouldQuit = app.makeSingleInstance(() => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
}
|
||||
})
|
||||
|
||||
shouldQuit && app.quit()
|
||||
|
||||
const createMainWindow = () => {
|
||||
var mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 745,
|
||||
defaultHeight: 450,
|
||||
defaultWidth: 1300,
|
||||
defaultHeight: 700,
|
||||
});
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
@ -703,7 +714,6 @@ const createMainWindow = () => {
|
||||
mainWindow.webContents.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8');
|
||||
createMenu();
|
||||
};
|
||||
|
||||
app.setName(pkg.name);
|
||||
app.dock && app.dock.setIcon(icon);
|
||||
|
||||
@ -712,6 +722,7 @@ app.on('before-quit', () => {
|
||||
// Fix issues #14
|
||||
forceQuit = true;
|
||||
});
|
||||
|
||||
app.on('activate', e => {
|
||||
if (!mainWindow.isVisible()) {
|
||||
mainWindow.show();
|
||||
|
Loading…
Reference in New Issue
Block a user