fix(assets): apply correct json-viewer theme after content decryption

This commit is contained in:
Cell
2026-07-26 02:08:02 +08:00
parent a5a7b98c95
commit 610fa1d561
2 changed files with 17 additions and 2 deletions
@@ -26,6 +26,17 @@ $$ \ce{CO2 + C -> 2 CO} $$
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
## JSON
```json
{
"name": "fixit",
"version": "1.0.0",
"description": "A Hugo theme for creating encrypted content.",
"author": "Lruihao"
}
```
## style
{{< style "text-align:right; strong{color:#00b1ff;}" >}}
+6 -2
View File
@@ -8,8 +8,8 @@
import { eventBus } from '../core/event-bus'
import { isDarkMode } from '../utils'
function applyJsonViewerTheme(isDark: boolean) {
document.querySelectorAll('json-viewer').forEach(($el: Element) => {
function applyJsonViewerTheme(isDark: boolean, scope: Element | Document = document) {
scope.querySelectorAll('json-viewer').forEach(($el: Element) => {
$el.setAttribute('theme', isDark ? 'dark' : 'light')
})
}
@@ -25,4 +25,8 @@ document.addEventListener('DOMContentLoaded', () => {
return
applyJsonViewerTheme(detail.isDark)
})
eventBus.on('fixit:content-decrypted', ({ detail }) => {
applyJsonViewerTheme(isDarkMode(), detail.target)
})
}, false)