2022-01-07 15:18:11 +00:00
|
|
|
const Storage = require("store2")
|
2022-06-02 12:01:56 +00:00
|
|
|
const { COLOR_THEME_DARK, THEME, COLOR_THEME_AUTO } = require("./config.js")
|
2021-12-29 21:50:13 +00:00
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
|
let lstore = Storage.namespace(THEME)
|
2022-12-21 10:29:15 +00:00
|
|
|
let currentColorTheme = lstore.get("color-theme") || COLOR_THEME_AUTO
|
2021-12-29 21:50:13 +00:00
|
|
|
let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)")
|
|
|
|
let darkMode = false
|
2022-05-30 19:49:13 +00:00
|
|
|
let theme = "default"
|
2021-12-29 21:50:13 +00:00
|
|
|
|
2022-06-02 12:01:56 +00:00
|
|
|
if (
|
|
|
|
currentColorTheme === COLOR_THEME_DARK ||
|
|
|
|
(currentColorTheme === COLOR_THEME_AUTO && darkModeQuery.matches)
|
|
|
|
) {
|
2021-12-29 21:50:13 +00:00
|
|
|
darkMode = true
|
2022-05-30 19:49:13 +00:00
|
|
|
theme = "dark"
|
2021-12-29 21:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
import("mermaid")
|
|
|
|
.then(({ default: md }) => {
|
|
|
|
md.initialize({
|
|
|
|
flowchart: { useMaxWidth: true },
|
2022-05-30 19:49:13 +00:00
|
|
|
theme: theme,
|
2021-12-29 21:50:13 +00:00
|
|
|
themeVariables: {
|
2022-05-30 19:49:13 +00:00
|
|
|
darkMode: darkMode
|
2021-12-29 21:50:13 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((error) => console.error(error))
|
|
|
|
})
|