Files
halo_theme_terminal/templates/modules/layout.html
T
2025-11-16 21:01:07 +08:00

105 lines
4.0 KiB
HTML

<!DOCTYPE html>
<html
xmlns:th="https://www.thymeleaf.org"
th:lang="${#locale.toLanguageTag}"
th:fragment="html (header, content, footer)">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title th:text="${title}"></title>
<script no-pjax th:inline="javascript">
let system_font = /*[[${theme.config.style.system_font}]]*/;
document.documentElement.setAttribute("system_font", system_font);
</script>
<script no-pjax th:inline="javascript">
let dark_theme = /*[[${theme.config.style.dark_color_scheme}]]*/;
let light_theme = /*[[${theme.config.style.light_color_scheme}]]*/;
const default_mode = /*[[${theme.config.style.default_scheme_mode}]]*/;
if (dark_theme === 'custom') {
dark_theme = /*[[${theme.config.style.custom_dark}]]*/
}
if (light_theme === 'custom') {
light_theme = /*[[${theme.config.style.custom_light}]]*/
}
let storedMode = localStorage.getItem("theme-mode");
function getSystemScheme() {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
function applyTheme(mode) {
const actualMode = mode === 'system' ? getSystemScheme() : mode;
const targetTheme = actualMode === "light" ? light_theme : dark_theme;
document.documentElement.setAttribute("data-color-scheme", actualMode);
document.documentElement.setAttribute("theme-color-scheme", targetTheme);
}
if (default_mode === 'system' || !storedMode) {
localStorage.setItem("theme-mode", default_mode);
storedMode = default_mode;
}
applyTheme(storedMode);
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (localStorage.getItem("theme-mode") === "system") {
applyTheme("system");
}
});
</script>
<script no-pjax>
const pixel_status = [[${theme.config.style.pixel_style}]];
let storedStatus = localStorage.getItem("pixel_style");
if (!storedStatus) {
localStorage.setItem("pixel_style", pixel_status);
storedStatus = pixel_status.toString();
}
document.documentElement.setAttribute("pixel_style", storedStatus);
</script>
<link no-pjax rel="stylesheet" th:href="@{/assets/dist/main.css?v={version}(version=${theme.spec.version})}"/>
<script no-pjax type="module" th:src="@{/assets/dist/main.js?v={version}(version=${theme.spec.version})}"></script>
<script no-pjax type="module" th:if="${theme.config.basic.pjax}"
th:src="@{/assets/dist/libs/pjax.js?v={version}(version=${theme.spec.version})}"></script>
<script no-pjax th:inline="javascript">
function applyRawCss(text) {
const style = document.createElement('style');
style.textContent = text;
document.head.appendChild(style);
}
const custom = /*[[${theme.config.style.custom}]]*/;
applyRawCss(custom);
</script>
</head>
<body>
<div class="page">
<header role="banner">
<div id="header-slot" aria-hidden="true"></div>
</header>
<div class="wrapper">
<aside class="sidebar-left">
</aside>
<main class="container" role="main">
<header class="header">
<th:block th:replace="~{modules/header :: header(isHome = true)}"/>
</header>
<div class="content">
<th:block th:replace="${content}"/>
</div>
</main>
<aside class="sidebar-right">
</aside>
</div>
<footer class="footer" role="contentinfo">
<div id="footer-slot-head" aria-hidden="true"></div>
<th:block th:replace="~{modules/footer}"/>
<div id="footer-slot-tail" aria-hidden="true"></div>
</footer>
</div>
</body>
</html>