mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-19 14:20:51 +08:00
feat(desktop): desktop settings
This commit is contained in:
@@ -382,6 +382,33 @@ function registerWindowIpc() {
|
||||
const win = getWin(event);
|
||||
return !!win?.isMaximized();
|
||||
});
|
||||
|
||||
ipcMain.handle("app:getAutoLaunch", () => {
|
||||
try {
|
||||
const settings = app.getLoginItemSettings();
|
||||
return !!(settings?.openAtLogin || settings?.executableWillLaunchAtLogin);
|
||||
} catch (err) {
|
||||
logMain(`[main] getAutoLaunch failed: ${err?.message || err}`);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("app:setAutoLaunch", (_event, enabled) => {
|
||||
const on = !!enabled;
|
||||
try {
|
||||
app.setLoginItemSettings({ openAtLogin: on });
|
||||
} catch (err) {
|
||||
logMain(`[main] setAutoLaunch(${on}) failed: ${err?.message || err}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const settings = app.getLoginItemSettings();
|
||||
return !!(settings?.openAtLogin || settings?.executableWillLaunchAtLogin);
|
||||
} catch {
|
||||
return on;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -5,5 +5,7 @@ contextBridge.exposeInMainWorld("wechatDesktop", {
|
||||
toggleMaximize: () => ipcRenderer.invoke("window:toggleMaximize"),
|
||||
close: () => ipcRenderer.invoke("window:close"),
|
||||
isMaximized: () => ipcRenderer.invoke("window:isMaximized"),
|
||||
});
|
||||
|
||||
getAutoLaunch: () => ipcRenderer.invoke("app:getAutoLaunch"),
|
||||
setAutoLaunch: (enabled) => ipcRenderer.invoke("app:setAutoLaunch", !!enabled),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user