File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -744,7 +744,7 @@ section.cover blockquote>p>a:hover {
744744
745745.sidebar ,
746746body {
747- background-color : var (--background );
747+ background-color : var (--background , # 091a28 );
748748 transition : background-image .15s ease-in-out .15s
749749}
750750
Original file line number Diff line number Diff line change 125125 < div id ="app "> 加载中...</ div >
126126
127127 < script >
128- ( function checkHash ( ) {
128+ function checkHash ( ) {
129129 const hash = window . location . hash
130130
131131 // 判断是否以 #/en/ 或 #/zh/ 开头
144144 const newUrl = window . location . origin + window . location . pathname + window . location . search + newHash
145145 window . location . replace ( newUrl )
146146 }
147- } ) ( )
147+ }
148+
149+ function checkTheme ( ) {
150+ // 默认黑色主题
151+ let theme = window . localStorage . getItem ( 'DARK_LIGHT_THEME' )
152+ if ( ! theme ) {
153+ window . localStorage . setItem ( 'DARK_LIGHT_THEME' , 'dark' )
154+ }
155+ }
156+
157+ checkHash ( )
158+ checkTheme ( )
148159
149160 window . $docsify = {
150161 name : 'Listen-文档中心' ,
181192 // 解析完文档后
182193 hook . afterEach ( function ( html , next ) {
183194 const styles = window . getComputedStyle ( document . documentElement )
184- const isDark = styles . getPropertyValue ( 'color-scheme' ) === 'dark'
195+ const isDark = styles . getPropertyValue ( 'color-scheme' ) === 'dark' || window . localStorage . getItem ( 'DARK_LIGHT_THEME' ) === 'dark'
185196 if ( isDark ) {
186197 html = html . replaceAll ( '/img/light/' , '/img/dark/' )
187198 } else {
You can’t perform that action at this time.
0 commit comments