2022-01-07 15:18:11 +00:00
|
|
|
const Storage = require("store2")
|
|
|
|
const { DARK_MODE, THEME, AUTO_MODE } = require("./config.js")
|
2021-12-29 21:50:13 +00:00
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
|
let lstore = Storage.namespace(THEME)
|
|
|
|
let currentMode = lstore.get("color-mode")
|
|
|
|
let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)")
|
|
|
|
let primaryColor = "#ececff"
|
|
|
|
let darkMode = false
|
|
|
|
|
|
|
|
if (currentMode === DARK_MODE || (currentMode === AUTO_MODE && darkModeQuery.matches)) {
|
|
|
|
primaryColor = "#6C617E"
|
|
|
|
darkMode = true
|
|
|
|
}
|
|
|
|
|
|
|
|
import("mermaid")
|
|
|
|
.then(({ default: md }) => {
|
|
|
|
md.initialize({
|
|
|
|
flowchart: { useMaxWidth: true },
|
|
|
|
theme: "base",
|
|
|
|
themeVariables: {
|
|
|
|
darkMode: darkMode,
|
|
|
|
primaryColor: primaryColor
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((error) => console.error(error))
|
|
|
|
})
|