chore: prepare open source archive
This commit is contained in:
@@ -3,6 +3,14 @@ import { siteConfig } from '~/config/site'
|
||||
|
||||
const colorMode = useColorMode()
|
||||
const container = ref<HTMLElement>()
|
||||
const isEnabled = computed(() =>
|
||||
Boolean(
|
||||
siteConfig.giscus.repo
|
||||
&& siteConfig.giscus.repoId
|
||||
&& siteConfig.giscus.category
|
||||
&& siteConfig.giscus.categoryId
|
||||
)
|
||||
)
|
||||
|
||||
function loadGiscus() {
|
||||
if (!container.value) return
|
||||
@@ -29,10 +37,12 @@ function loadGiscus() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadGiscus()
|
||||
if (isEnabled.value) loadGiscus()
|
||||
})
|
||||
|
||||
watch(() => colorMode.value, () => {
|
||||
if (!isEnabled.value) return
|
||||
|
||||
const frame = document.querySelector<HTMLIFrameElement>('iframe.giscus-frame')
|
||||
if (frame?.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
@@ -44,7 +54,7 @@ watch(() => colorMode.value, () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="isEnabled">
|
||||
<h2 class="text-xl font-semibold mb-4">评论</h2>
|
||||
<div ref="container" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user