Skip to content

Commit

Permalink
fix: 版本更新弹框日夜间样式问题 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhuili12138 authored Oct 10, 2022
1 parent e35d713 commit d725822
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/HappyBoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import HbAdminDevTool from '@/components/dev/HbAdminDevTool.vue'
import { useMessage, useThemeVars,useNotification,NButton ,NModal,NCard,NTimeline,NTimelineItem,NTag} from 'naive-ui'
import HbAdminLoading from '@/components/HbAdminLoading.vue'
import 'github-markdown-css'
import {isDark} from "./global/config";
window.$message = useMessage()
const vars = useThemeVars()
// 生产环境可以删除以下JS代码
import moment from 'moment'
import MarkdownIt from 'markdown-it'
import {onMounted,h,ref} from "vue"
import {onMounted, h, ref, computed, watch, nextTick} from "vue"
import API from '@/global/api'
const notification = useNotification()
const showModal = ref(false)
Expand All @@ -34,6 +35,41 @@ onMounted(()=>{
})
})
function themeVars () {
if (isDark.value) {
return {
textColor: '#c9d1d9',
accentColor: '#58a6ff'
}
} else {
return {
textColor: '#24292f',
accentColor: '#0969da'
}
}
}
function changeTheme() {
if (showModal.value) {
nextTick(() => {
const versionDom = document.getElementById('versions-body')
versionDom.style.color = themeVars().textColor
const aDoms = versionDom.querySelectorAll('a')
aDoms.forEach(e => {
e.style.color = themeVars().accentColor
})
})
}
}
watch(showModal, () => {
changeTheme()
})
watch(isDark, () => {
changeTheme()
})
function dateFormat(date){
return moment(date).startOf('month').format("YYYY-MM-DD")
}
Expand Down Expand Up @@ -73,7 +109,7 @@ function dateFormat(date){
<n-tag v-else type="info">{{e.name}}</n-tag>
</div>
</template>
<div class="markdown-body" style="background-color: transparent" v-html="md.render(e.body)"></div>
<div id="versions-body" class="markdown-body" style="background-color: transparent" v-html="md.render(e.body)"></div>
</n-timeline-item>
</n-timeline>
</n-card>
Expand Down

1 comment on commit d725822

@vercel
Copy link

@vercel vercel bot commented on d725822 Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.