mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-26 01:21:34 +08:00
this values cannot change during runtime, => there is no need to have these checks as dynamic function, instead just export the boolean value directly
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
"use strict";
|
|
|
|
import sqlInit from "../services/sql_init.js";
|
|
import setupService from "../services/setup.js";
|
|
import { isElectron } from "../services/utils.js";
|
|
import assetPath from "../services/asset_path.js";
|
|
import appPath from "../services/app_path.js";
|
|
import type { Request, Response } from "express";
|
|
|
|
function setupPage(req: Request, res: Response) {
|
|
if (sqlInit.isDbInitialized()) {
|
|
if (isElectron) {
|
|
handleElectronRedirect();
|
|
} else {
|
|
res.redirect(".");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// we got here because DB is not completely initialized, so if schema exists,
|
|
// it means we're in "sync in progress" state.
|
|
const syncInProgress = sqlInit.schemaExists();
|
|
|
|
if (syncInProgress) {
|
|
// trigger sync if it's not already running
|
|
setupService.triggerSync();
|
|
}
|
|
|
|
res.render("setup", {
|
|
syncInProgress: syncInProgress,
|
|
assetPath: assetPath,
|
|
appPath: appPath
|
|
});
|
|
}
|
|
|
|
async function handleElectronRedirect() {
|
|
const windowService = (await import("../services/window.js")).default;
|
|
const { app } = await import("electron");
|
|
windowService.createMainWindow(app);
|
|
windowService.closeSetupWindow();
|
|
}
|
|
|
|
export default {
|
|
setupPage
|
|
};
|