升级:VitePress 版本升级为 v1.0.0-alpha.8
This commit is contained in:
@@ -3,9 +3,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, toRefs, onBeforeUnmount, watch } from 'vue'
|
||||
import { reactive, toRefs, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { WordCloud, G2 } from '@antv/g2plot'
|
||||
import { debounce, useDark } from '@pureadmin/utils'
|
||||
|
||||
// 定义属性
|
||||
const props = defineProps({
|
||||
@@ -16,16 +15,9 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
// 渲染WordCloud
|
||||
const theme = G2.getTheme('dark')
|
||||
G2.registerTheme('customize-dark', {
|
||||
...theme,
|
||||
background: 'transparent',
|
||||
})
|
||||
|
||||
const { isDark } = useDark()
|
||||
let wordCloud
|
||||
debounce(() => {
|
||||
wordCloud = new WordCloud("wordcloud-container", {
|
||||
onMounted(() => {
|
||||
wordCloud = new WordCloud("wordcloud-container", {
|
||||
data: props.dataList,
|
||||
wordField: 'name',
|
||||
weightField: 'value',
|
||||
@@ -35,18 +27,11 @@ debounce(() => {
|
||||
fontSize: [14, 35],
|
||||
rotation: 0,
|
||||
},
|
||||
theme: isDark.value ? 'customize-dark' : 'light',
|
||||
// 返回值设置成一个 [0, 1) 区间内的值,
|
||||
// 可以让每次渲染的位置相同(前提是每次的宽高一致)。
|
||||
random: () => 0.5,
|
||||
random: () => 0.5
|
||||
})
|
||||
wordCloud.render()
|
||||
}, 5)()
|
||||
|
||||
watch(isDark, (value) => {
|
||||
value
|
||||
? wordCloud?.update({ theme: 'customize-dark' })
|
||||
: wordCloud?.update({ theme: 'light' })
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
Reference in New Issue
Block a user