@@ -15,6 +15,7 @@ div#wrapper(v-if="loaded")
1515<script lang="ts">
1616import { useSettingsStore } from ' ~/stores/settings' ;
1717import { useServerStore } from ' ~/stores/server' ;
18+ import { detectPreferredTheme } from ' ~/util/theme' ;
1819// if vite is used, you can import css file as module
1920// import darkCssUrl from '../static/dark.css?url';
2021// import darkCssContent from '../static/dark.css?inline';
@@ -39,8 +40,10 @@ export default {
3940 const settingsStore = useSettingsStore ();
4041 await settingsStore .ensureLoaded ();
4142 const theme = settingsStore .theme ;
42- // Check Application Mode (Light | Dark)
43- if (theme !== null && theme === ' dark' ) {
43+ const detectedTheme = theme === ' auto' ? detectPreferredTheme () : theme ;
44+
45+ // Apply the dark theme if detected
46+ if (detectedTheme === ' dark' ) {
4447 const method: ' link' | ' style' = ' link' ;
4548
4649 if (method === ' link' ) {
@@ -49,8 +52,8 @@ export default {
4952 const themeLink = document .createElement (' link' );
5053 themeLink .href = ' /dark.css' ; // darkCssUrl
5154 themeLink .rel = ' stylesheet' ;
52- // Append Dark Theme Element If Selected Mode Is Dark
53- theme === ' dark ' ? document .querySelector (' head' ).appendChild (themeLink ) : ' ' ;
55+ // Append Dark Theme Element
56+ document .querySelector (' head' ).appendChild (themeLink );
5457 } else {
5558 // Not supported for Webpack due to not supporting ?inline import in a cross-compatible way (afaik)
5659 // Method 2: Create <style> Element
0 commit comments