mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
824a8540ff
This improves the app updater so that it doesn't rely on unreliable system notifications. Now, a banner in the tab bar will display when an update is available. Clicking this will prompt the user to restart the app and complete the installation. This also updates the tab bar to move to the smaller tab size earlier so we don't need to make the tab bar scrollable as much. ![image](https://github.com/user-attachments/assets/79e24617-d609-4554-bdb2-979f810a9b66)
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
// Copyright 2024, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
const { contextBridge, ipcRenderer } = require("electron");
|
|
|
|
contextBridge.exposeInMainWorld("api", {
|
|
getIsDev: () => ipcRenderer.sendSync("getIsDev"),
|
|
getPlatform: () => ipcRenderer.sendSync("getPlatform"),
|
|
getCursorPoint: () => ipcRenderer.sendSync("getCursorPoint"),
|
|
openNewWindow: () => ipcRenderer.send("openNewWindow"),
|
|
showContextMenu: (menu, position) => ipcRenderer.send("contextmenu-show", menu, position),
|
|
onContextMenuClick: (callback) => ipcRenderer.on("contextmenu-click", (_event, id) => callback(id)),
|
|
downloadFile: (filePath) => ipcRenderer.send("download", { filePath }),
|
|
openExternal: (url) => {
|
|
if (url && typeof url === "string") {
|
|
ipcRenderer.send("open-external", url);
|
|
} else {
|
|
console.error("Invalid URL passed to openExternal:", url);
|
|
}
|
|
},
|
|
getEnv: (varName) => ipcRenderer.sendSync("getEnv", varName),
|
|
onFullScreenChange: (callback) =>
|
|
ipcRenderer.on("fullscreen-change", (_event, isFullScreen) => callback(isFullScreen)),
|
|
onUpdaterStatusChange: (callback) => ipcRenderer.on("app-update-status", (_event, status) => callback(status)),
|
|
getUpdaterStatus: () => ipcRenderer.sendSync("get-app-update-status"),
|
|
installAppUpdate: () => ipcRenderer.send("install-app-update"),
|
|
});
|
|
|
|
// Custom event for "new-window"
|
|
ipcRenderer.on("webview-new-window", (e, webContentsId, details) => {
|
|
const event = new CustomEvent("new-window", { detail: details });
|
|
document.getElementById("webview").dispatchEvent(event);
|
|
});
|