Changes: for windows build
This commit is contained in:
parent
7b88ff1928
commit
20f76e2061
8 changed files with 20 additions and 14 deletions
|
|
@ -3,10 +3,12 @@ import { baseDir, downloadsDir } from "../utils/constants";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { showFileDownloadedDialog } from "../utils/dialog";
|
||||
import { sanitizeFilename } from "../utils";
|
||||
|
||||
|
||||
export function setupExportHandlers() {
|
||||
ipcMain.handle("file-downloaded", async (_, filePath: string): Promise<IPCStatus> => {
|
||||
const fileName = path.basename(filePath);
|
||||
const fileName = sanitizeFilename(path.basename(filePath));
|
||||
const destinationPath = path.join(downloadsDir, fileName);
|
||||
|
||||
await fs.promises.rename(filePath, destinationPath);
|
||||
|
|
@ -42,7 +44,8 @@ export function setupExportHandlers() {
|
|||
margins: { top: 0, right: 0, bottom: 0, left: 0 }
|
||||
});
|
||||
browser.close();
|
||||
const destinationPath = path.join(downloadsDir, `${title}.pdf`);
|
||||
const sanitizedTitle = sanitizeFilename(title);
|
||||
const destinationPath = path.join(downloadsDir, `${sanitizedTitle}.pdf`);
|
||||
await fs.promises.writeFile(destinationPath, pdfBuffer);
|
||||
|
||||
const success = await showFileDownloadedDialog(destinationPath);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export function setupSlideMetadataHandlers() {
|
|||
try {
|
||||
browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: isDev ? undefined : path.join(baseDir, "dependencies/chrome-headless-shell/win_build/chrome-headless-shell.exe"),
|
||||
executablePath: path.join(baseDir, "dependencies/chrome-headless-shell/win_build/chrome-headless-shell.exe"),
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -77,3 +77,7 @@ export async function findUnusedPorts(startPort: number = 40000, count: number =
|
|||
return ports;
|
||||
}
|
||||
|
||||
export function sanitizeFilename(filename: string): string {
|
||||
// Replace invalid characters with underscores
|
||||
return filename.replace(/[<>:"/\\|?*]/g, '_');
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import http from "http";
|
|||
|
||||
// @ts-ignore
|
||||
import handler from "serve-handler";
|
||||
import path from "path";
|
||||
|
||||
export async function startFastApiServer(
|
||||
directory: string,
|
||||
|
|
@ -13,10 +14,10 @@ export async function startFastApiServer(
|
|||
) {
|
||||
// Start FastAPI server
|
||||
const startCommand = isDev ? [
|
||||
".venv/Scripts/python.exe",
|
||||
path.join(directory, ".venv/Scripts/python.exe"),
|
||||
["server_autoreload.py", "--port", port.toString()],
|
||||
] : [
|
||||
"./fastapi", ["--port", port.toString()],
|
||||
path.join(directory, "fastapi"), ["--port", port.toString()],
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -27,6 +28,8 @@ export async function startFastApiServer(
|
|||
cwd: directory,
|
||||
stdio: ["inherit", "pipe", "pipe"],
|
||||
env: { ...process.env, ...env },
|
||||
shell: true,
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
fastApiProcess.stdout.on("data", (data: any) => {
|
||||
|
|
@ -58,7 +61,7 @@ export async function startNextJsServer(
|
|||
stdio: ["inherit", "pipe", "pipe"],
|
||||
env: { ...process.env, ...env },
|
||||
shell: true,
|
||||
windowsHide: true
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
nextjsProcess.stdout.on("data", (data: any) => {
|
||||
|
|
|
|||
6
build.js
6
build.js
|
|
@ -10,15 +10,11 @@ const config = {
|
|||
"resources",
|
||||
"app_dist",
|
||||
"node_modules",
|
||||
"dependencies/chrome-headless-shell/win_build",
|
||||
"NOTICE",
|
||||
],
|
||||
// linux: {
|
||||
// target: ["AppImage"],
|
||||
// icon: "resources/ui/assets/images/presenton_short_filled.png",
|
||||
// },
|
||||
win: {
|
||||
target: ["nsis"],
|
||||
files: "dependencies/chrome-headless-shell/win_build",
|
||||
icon: "resources/ui/assets/images/presenton_short_filled.png"
|
||||
},
|
||||
nsis: {
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ if __name__ == "__main__":
|
|||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
uvicorn.run("api.main:app", host="0.0.0.0", port=args.port, log_level="info")
|
||||
uvicorn.run("api.main:app", host="127.0.0.1", port=args.port, log_level="info")
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ if __name__ == "__main__":
|
|||
args = parser.parse_args()
|
||||
|
||||
uvicorn.run(
|
||||
"api.main:app", host="0.0.0.0", port=args.port, log_level="info", reload=True
|
||||
"api.main:app", host="127.0.0.1", port=args.port, log_level="info", reload=True
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ load_dotenv()
|
|||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
"api.main:app", host="0.0.0.0", port=8000, log_level="info", reload=True
|
||||
"api.main:app", host="127.0.0.1", port=8000, log_level="info", reload=True
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue