mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
50 lines
950 B
JavaScript
50 lines
950 B
JavaScript
const { BrowserWindow } = require('electron');
|
|
const path = require('path');
|
|
|
|
const { REACT_PATH } = require('../constants/paths');
|
|
const { getPreference } = require('../libs/preferences');
|
|
|
|
const mainWindow = require('./main');
|
|
|
|
let win;
|
|
|
|
const get = () => win;
|
|
|
|
const create = () => {
|
|
const attachToMenubar = getPreference('attachToMenubar');
|
|
|
|
win = new BrowserWindow({
|
|
width: 400,
|
|
height: 180,
|
|
resizable: false,
|
|
maximizable: false,
|
|
minimizable: false,
|
|
fullscreenable: false,
|
|
autoHideMenuBar: true,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
preload: path.join(__dirname, '..', 'preload', 'custom-user-agent.js'),
|
|
},
|
|
parent: attachToMenubar ? null : mainWindow.get(),
|
|
});
|
|
|
|
win.loadURL(REACT_PATH);
|
|
|
|
win.on('closed', () => {
|
|
win = null;
|
|
});
|
|
};
|
|
|
|
const show = () => {
|
|
if (win == null) {
|
|
create();
|
|
} else {
|
|
win.show();
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
get,
|
|
create,
|
|
show,
|
|
};
|