mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-07 10:37:33 +08:00
feat: enable dark mode for diff2html
This commit is contained in:
@@ -45,6 +45,7 @@ import { useIsMobile } from '~/utils/screen'
|
|||||||
import 'diff2html/bundles/css/diff2html.min.css'
|
import 'diff2html/bundles/css/diff2html.min.css'
|
||||||
import BaseImage from '~/components/BaseImage.vue'
|
import BaseImage from '~/components/BaseImage.vue'
|
||||||
import { navigateTo } from 'nuxt/app'
|
import { navigateTo } from 'nuxt/app'
|
||||||
|
import { themeState } from '~/utils/theme'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
log: Object,
|
log: Object,
|
||||||
title: String,
|
title: String,
|
||||||
@@ -52,6 +53,11 @@ const props = defineProps({
|
|||||||
|
|
||||||
const diffHtml = computed(() => {
|
const diffHtml = computed(() => {
|
||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
|
// Track theme changes
|
||||||
|
const isDark = import.meta.client && document.documentElement.dataset.theme === 'dark'
|
||||||
|
themeState.mode
|
||||||
|
const colorScheme = isDark ? 'dark' : 'light'
|
||||||
|
|
||||||
if (props.log.type === 'CONTENT') {
|
if (props.log.type === 'CONTENT') {
|
||||||
const oldContent = props.log.oldContent ?? ''
|
const oldContent = props.log.oldContent ?? ''
|
||||||
const newContent = props.log.newContent ?? ''
|
const newContent = props.log.newContent ?? ''
|
||||||
@@ -62,6 +68,7 @@ const diffHtml = computed(() => {
|
|||||||
matching: 'lines',
|
matching: 'lines',
|
||||||
drawFileList: false,
|
drawFileList: false,
|
||||||
outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side',
|
outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side',
|
||||||
|
colorScheme,
|
||||||
})
|
})
|
||||||
} else if (props.log.type === 'TITLE') {
|
} else if (props.log.type === 'TITLE') {
|
||||||
const oldTitle = props.log.oldTitle ?? ''
|
const oldTitle = props.log.oldTitle ?? ''
|
||||||
@@ -73,6 +80,7 @@ const diffHtml = computed(() => {
|
|||||||
matching: 'lines',
|
matching: 'lines',
|
||||||
drawFileList: false,
|
drawFileList: false,
|
||||||
outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side',
|
outputFormat: isMobile.value ? 'line-by-line' : 'side-by-side',
|
||||||
|
colorScheme,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
Reference in New Issue
Block a user