Compare commits

..

5 Commits

Author SHA1 Message Date
Timothy Jaeryang Baek 2a223e62b6 refac 2025-07-29 14:16:54 +04:00
Timothy Jaeryang Baek eb2ebd2c1d refac 2025-07-29 14:15:34 +04:00
Timothy Jaeryang Baek a6a944c847 refac 2025-07-29 14:14:34 +04:00
Timothy Jaeryang Baek 03fea4a7cc refac 2025-07-29 14:09:52 +04:00
Timothy Jaeryang Baek 6b159246d1 refac: styling 2025-07-29 13:44:42 +04:00
4 changed files with 78 additions and 36 deletions
+8
View File
@@ -125,6 +125,14 @@ function createWindow(show = true): void {
uninstallHandler();
},
},
{
label: "Reset",
click: async () => {
await stopServerHandler();
await resetApp();
},
},
],
});
const updatedMenu = Menu.buildFromTemplate(menuTemplate);
+30 -33
View File
@@ -249,7 +249,7 @@ export const getPythonDownloadPath = (): string => {
return downloadPath;
};
export const getPythonInstallationPath = (): string => {
export const getPythonInstallationDir = (): string => {
const installDir = path.join(app.getPath("userData"), "python");
if (!fs.existsSync(installDir)) {
@@ -311,7 +311,7 @@ const checkInternet = async () => {
};
export const installPython = async (
installationPath?: string
installationDir?: string
): Promise<boolean> => {
let pythonDownloadPath = getPythonDownloadPath();
if (!isPythonDownloaded()) {
@@ -326,9 +326,6 @@ export const installPython = async (
log.info(
`Downloading Python: ${progress.toFixed(2)}% (${downloaded} of ${total} bytes)`
);
log.info(
`Downloading Python: ${progress.toFixed(2)}% (${downloaded} of ${total} bytes)`
);
});
}
if (!fs.existsSync(pythonDownloadPath)) {
@@ -336,8 +333,8 @@ export const installPython = async (
return false;
}
installationPath = installationPath || getPythonInstallationPath();
log.info(installationPath, pythonDownloadPath);
installationDir = installationDir || getPythonInstallationDir();
log.info(installationDir, pythonDownloadPath);
try {
const userDataPath = getUserDataPath();
@@ -351,8 +348,8 @@ export const installPython = async (
}
// Get the path to the installed Python binary
if (isPythonInstalled(installationPath)) {
const pythonPath = getPythonPath(installationPath);
if (isPythonInstalled(installationDir)) {
const pythonPath = getPythonPath(installationDir);
execFileSync(pythonPath, ["-m", "pip", "install", "uv"], {
encoding: "utf-8",
@@ -382,14 +379,14 @@ export const getPythonExecutablePath = (envPath: string) => {
}
};
export const getPythonPath = (installationPath?: string) => {
export const getPythonPath = (installationDir?: string) => {
return path.normalize(
getPythonExecutablePath(installationPath || getPythonInstallationPath())
getPythonExecutablePath(installationDir || getPythonInstallationDir())
);
};
export const isPythonInstalled = (installationPath?: string) => {
const pythonPath = getPythonPath(installationPath);
export const isPythonInstalled = (installationDir?: string) => {
const pythonPath = getPythonPath(installationDir);
if (!fs.existsSync(pythonPath)) {
log.error("Python binary not found in install path");
@@ -416,8 +413,8 @@ export const isPythonInstalled = (installationPath?: string) => {
}
};
export const isUvInstalled = (installationPath?: string) => {
const pythonPath = getPythonPath(installationPath);
export const isUvInstalled = (installationDir?: string) => {
const pythonPath = getPythonPath(installationDir);
try {
// Check if uv is installed by running the command
const result = execFileSync(pythonPath, ["-m", "uv", "--version"], {
@@ -441,16 +438,17 @@ export const isUvInstalled = (installationPath?: string) => {
}
};
export const uninstallPython = (installationPath?: string): boolean => {
installationPath = installationPath || getPythonInstallationPath();
export const uninstallPython = (installationDir?: string): boolean => {
installationDir = installationDir || getPythonInstallationDir();
if (!fs.existsSync(installationPath)) {
if (!fs.existsSync(installationDir)) {
log.error("Python installation not found");
return false;
}
try {
fs.rmSync(installationPath, { recursive: true });
fs.rmSync(installationDir, { recursive: true, force: true });
log.info("Python installation removed successfully:", installationDir);
} catch (error) {
log.error("Failed to remove Python installation", error);
return false;
@@ -471,17 +469,6 @@ export const resetApp = async (): Promise<void> => {
await uninstallPython();
log.info("Uninstalled Python environment");
// remove /data folder
const dataPath = getOpenWebUIDataPath();
if (fs.existsSync(dataPath)) {
try {
fs.rmSync(dataPath, { recursive: true });
log.info("Removed data directory:", dataPath);
} catch (error) {
log.error("Failed to remove data directory:", error);
}
}
// remove config file
const configPath = path.join(getUserDataPath(), "config.json");
if (fs.existsSync(configPath)) {
@@ -503,6 +490,17 @@ export const resetApp = async (): Promise<void> => {
log.error("Failed to remove secret key file:", error);
}
}
// remove /data folder
const dataPath = getOpenWebUIDataPath();
if (fs.existsSync(dataPath)) {
try {
fs.rmSync(dataPath, { recursive: true, force: true });
log.info("Removed data directory:", dataPath);
} catch (error) {
log.error("Failed to remove data directory:", error);
}
}
};
////////////////////////////////////////////////
@@ -670,16 +668,15 @@ export const startServer = async (
const pythonPath = getPythonPath();
log.info(`Using Python at: ${pythonPath}`);
const openWebUIPath = path.join(path.dirname(pythonPath), "open-webui");
let commandArgs: string[];
commandArgs = ["-m", "uv", "run", "open-webui", "serve", "--host", host];
const dataDir = path.join(app.getPath("userData"), "data");
const dataDir = getOpenWebUIDataPath();
const secretKey = getSecretKey();
if (!fs.existsSync(dataDir)) {
fs.mkdirSync(dataDir, { recursive: true });
}
process.env.DATA_DIR = dataDir;
process.env.WEBUI_SECRET_KEY = secretKey;
+37 -1
View File
@@ -154,7 +154,6 @@ html {
.scrollbar-hidden:hover::-webkit-scrollbar-thumb {
visibility: visible;
}
.scrollbar-hidden::-webkit-scrollbar-thumb {
visibility: hidden;
}
@@ -162,3 +161,40 @@ html {
.scrollbar-hidden::-webkit-scrollbar-corner {
display: none;
}
.scrollbar-none::-webkit-scrollbar {
display: none; /* for Chrome, Safari and Opera */
}
.scrollbar-none::-webkit-scrollbar-corner {
display: none;
}
.scrollbar-none {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
::-webkit-scrollbar-thumb {
--tw-border-opacity: 1;
background-color: rgba(215, 215, 215, 0.8);
border-color: rgba(255, 255, 255, var(--tw-border-opacity));
border-radius: 9999px;
border-width: 1px;
}
/* Dark theme scrollbar styles */
.dark ::-webkit-scrollbar-thumb {
background-color: rgba(67, 67, 67, 0.8); /* Darker color for dark theme */
border-color: rgba(0, 0, 0, var(--tw-border-opacity));
}
::-webkit-scrollbar {
height: 0.6rem;
width: 0.4rem;
}
::-webkit-scrollbar-track {
background-color: transparent;
border-radius: 9999px;
}
@@ -59,8 +59,9 @@
await window.electronAPI.resetApp();
toast.success("App has been reset successfully.");
// refresh the page to apply changes
window.location.reload();
setTimeout(() => {
window.location.reload();
}, 1000);
} catch (error) {
toast.error("Failed to reset the app");
}