mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-31 11:49:01 +08:00
feat(theme): allow using next as base theme
This commit is contained in:
parent
43567525e3
commit
b2b41edd61
@ -12,6 +12,7 @@ import packageJson from "../../package.json" with { type: "json" };
|
||||
import assetPath from "../services/asset_path.js";
|
||||
import appPath from "../services/app_path.js";
|
||||
import { Request, Response } from 'express';
|
||||
import BNote from "../becca/entities/bnote.js";
|
||||
|
||||
function index(req: Request, res: Response) {
|
||||
const options = optionService.getOptionMap();
|
||||
@ -28,10 +29,14 @@ function index(req: Request, res: Response) {
|
||||
// The page is restored from cache, but the API call fail.
|
||||
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
|
||||
const theme = options.theme;
|
||||
const themeNote = attributeService.getNoteWithLabel('appTheme', theme);
|
||||
|
||||
const isElectron = utils.isElectron();
|
||||
res.render(view, {
|
||||
csrfToken: csrfToken,
|
||||
themeCssUrl: getThemeCssUrl(options.theme),
|
||||
themeCssUrl: getThemeCssUrl(theme, themeNote),
|
||||
themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") === "next",
|
||||
headingStyle: options.headingStyle,
|
||||
layoutOrientation: options.layoutOrientation,
|
||||
platform: process.platform,
|
||||
@ -55,7 +60,7 @@ function index(req: Request, res: Response) {
|
||||
});
|
||||
}
|
||||
|
||||
function getThemeCssUrl(theme: string) {
|
||||
function getThemeCssUrl(theme: string, themeNote: BNote | null) {
|
||||
if (theme === 'light') {
|
||||
// light theme is always loaded as baseline
|
||||
return false;
|
||||
@ -63,11 +68,8 @@ function getThemeCssUrl(theme: string) {
|
||||
return `${assetPath}/stylesheets/theme-dark.css`;
|
||||
} else if (theme === "next") {
|
||||
return `${assetPath}/stylesheets/theme-next.css`;
|
||||
} else if (!process.env.TRILIUM_SAFE_MODE) {
|
||||
const themeNote = attributeService.getNoteWithLabel('appTheme', theme);
|
||||
if (themeNote) {
|
||||
return `api/notes/download/${themeNote.noteId}`;
|
||||
}
|
||||
} else if (!process.env.TRILIUM_SAFE_MODE && themeNote) {
|
||||
return `api/notes/download/${themeNote.noteId}`;
|
||||
} else {
|
||||
// baseline light theme
|
||||
return false;
|
||||
|
@ -76,6 +76,10 @@
|
||||
<link href="<%= themeCssUrl %>" rel="stylesheet">
|
||||
<% } %>
|
||||
|
||||
<% if (themeUseNextAsBase) { %>
|
||||
<link href="<%= assetPath %>/stylesheets/theme-next.css" rel="stylesheet">
|
||||
<% } %>
|
||||
|
||||
<link href="<%= assetPath %>/stylesheets/style.css" rel="stylesheet">
|
||||
|
||||
<script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user