mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 19:52:10 +08:00
28 lines
625 B
JavaScript
28 lines
625 B
JavaScript
const { app } = require('electron');
|
|
const { LOGIN_SETTING_OPTIONS } = require('./Constant').AutoLaunch;
|
|
|
|
class AutoLaunch {
|
|
enable () {
|
|
const enabled = app.getLoginItemSettings(LOGIN_SETTING_OPTIONS).openAtLogin;
|
|
if (enabled) {
|
|
return true;
|
|
}
|
|
app.setLoginItemSettings({
|
|
...LOGIN_SETTING_OPTIONS,
|
|
openAtLogin: true
|
|
})
|
|
return true;
|
|
}
|
|
|
|
disable () {
|
|
app.setLoginItemSettings({ openAtLogin: false })
|
|
return true;
|
|
}
|
|
|
|
isEnabled () {
|
|
const enabled = app.getLoginItemSettings(LOGIN_SETTING_OPTIONS).openAtLogin;
|
|
return enabled;
|
|
}
|
|
}
|
|
|
|
module.exports = AutoLaunch; |