mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 21:42:15 +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 assetPath from "../services/asset_path.js";
|
||||||
import appPath from "../services/app_path.js";
|
import appPath from "../services/app_path.js";
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
|
import BNote from "../becca/entities/bnote.js";
|
||||||
|
|
||||||
function index(req: Request, res: Response) {
|
function index(req: Request, res: Response) {
|
||||||
const options = optionService.getOptionMap();
|
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.
|
// The page is restored from cache, but the API call fail.
|
||||||
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
|
|
||||||
|
const theme = options.theme;
|
||||||
|
const themeNote = attributeService.getNoteWithLabel('appTheme', theme);
|
||||||
|
|
||||||
const isElectron = utils.isElectron();
|
const isElectron = utils.isElectron();
|
||||||
res.render(view, {
|
res.render(view, {
|
||||||
csrfToken: csrfToken,
|
csrfToken: csrfToken,
|
||||||
themeCssUrl: getThemeCssUrl(options.theme),
|
themeCssUrl: getThemeCssUrl(theme, themeNote),
|
||||||
|
themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") === "next",
|
||||||
headingStyle: options.headingStyle,
|
headingStyle: options.headingStyle,
|
||||||
layoutOrientation: options.layoutOrientation,
|
layoutOrientation: options.layoutOrientation,
|
||||||
platform: process.platform,
|
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') {
|
if (theme === 'light') {
|
||||||
// light theme is always loaded as baseline
|
// light theme is always loaded as baseline
|
||||||
return false;
|
return false;
|
||||||
@ -63,11 +68,8 @@ function getThemeCssUrl(theme: string) {
|
|||||||
return `${assetPath}/stylesheets/theme-dark.css`;
|
return `${assetPath}/stylesheets/theme-dark.css`;
|
||||||
} else if (theme === "next") {
|
} else if (theme === "next") {
|
||||||
return `${assetPath}/stylesheets/theme-next.css`;
|
return `${assetPath}/stylesheets/theme-next.css`;
|
||||||
} else if (!process.env.TRILIUM_SAFE_MODE) {
|
} else if (!process.env.TRILIUM_SAFE_MODE && themeNote) {
|
||||||
const themeNote = attributeService.getNoteWithLabel('appTheme', theme);
|
|
||||||
if (themeNote) {
|
|
||||||
return `api/notes/download/${themeNote.noteId}`;
|
return `api/notes/download/${themeNote.noteId}`;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// baseline light theme
|
// baseline light theme
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,6 +76,10 @@
|
|||||||
<link href="<%= themeCssUrl %>" rel="stylesheet">
|
<link href="<%= themeCssUrl %>" rel="stylesheet">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<% if (themeUseNextAsBase) { %>
|
||||||
|
<link href="<%= assetPath %>/stylesheets/theme-next.css" rel="stylesheet">
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<link href="<%= assetPath %>/stylesheets/style.css" rel="stylesheet">
|
<link href="<%= assetPath %>/stylesheets/style.css" rel="stylesheet">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user