-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
97 lines (86 loc) · 2.84 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { app, screen, Menu, BrowserWindow } from 'electron';
import menu from './menu';
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
// const server = "https://hazel-inky.now.sh/"
// const feed = `${server}/update/${process.platform}/${app.getVersion()}`
// autoUpdater.setFeedURL({
// url: feed
// });
const MAIN_WIDTH = 320;
const MAIN_HEIGHT = 350;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
// if (!app.isInApplicationsFolder()) {
// app.moveToApplicationsFolder({
// conflictHandler: (conflictType) => {
// if (conflictType === 'exists' || conflictType === 'existsAndRunning') {
// return dialog.showMessageBoxSync({
// type: 'question',
// buttons: ['取消', '继续'],
// defaultId: 0,
// message: '这个名字的App已经存在'
// }) === 1
// }
// }
// })
// }
const createWindow = (): void => {
// Create the browser window.
const display = screen.getPrimaryDisplay();
const { width, height } = display.bounds;
const mainWindow = new BrowserWindow({
height: MAIN_HEIGHT,
width: MAIN_WIDTH,
title: 'kanban',
hasShadow: false,
transparent: true,
resizable: app.isPackaged ? false : true,
x: width - MAIN_WIDTH,
y: height - MAIN_HEIGHT,
frame: false,
focusable: true,
alwaysOnTop: true,
webPreferences: {
devTools: app.isPackaged ? false : true,
nodeIntegration: true
}
});
// and load the index.html of the app.
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
// Open the DevTools.
// mainWindow.webContents.openDevTools();
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
Menu.setApplicationMenu(menu);
createWindow();
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
app.setAboutPanelOptions({
copyright: 'copyright 2020',
credits: `
APP内所有模型、图片版权均属于原作者,仅供研究学习,不得用于商业用途\n
stevenjoezhang https://github.com/stevenjoezhang
fghrsh https://github.com/fghrsh\n
`
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.