| | |
| | | <a-button @click="toggleTheme" class="mb-2" type="primary"> 黑暗主题 </a-button> |
| | | <a-button @click="clearValue" class="mb-2" type="default"> 清空内容 </a-button> |
| | | <MarkDown |
| | | v-model:value="value" |
| | | v-model:value="valueRef" |
| | | @change="handleChange" |
| | | ref="markDownRef" |
| | | placeholder="这是占位文本" |
| | | /> |
| | | </div> |
| | | <div class="mt-2"> |
| | | <a-card title="Markdown Viewer 组件演示"> |
| | | <MarkdownViewer :value="value" /> |
| | | </a-card> |
| | | <Card title="Markdown Viewer 组件演示"> |
| | | <MarkdownViewer :value="valueRef" /> |
| | | </Card> |
| | | </div> |
| | | </PageWrapper> |
| | | </template> |
| | | <script lang="ts"> |
| | | import { defineComponent, ref, unref } from 'vue'; |
| | | import { MarkDown, MarkDownActionType, MarkdownViewer } from '/@/components/Markdown'; |
| | | import { PageWrapper } from '/@/components/Page'; |
| | | <script lang="ts" setup> |
| | | import { ref, unref } from 'vue'; |
| | | import { MarkDown, MarkDownActionType, MarkdownViewer } from '@/components/Markdown'; |
| | | import { PageWrapper } from '@/components/Page'; |
| | | import { Card } from 'ant-design-vue'; |
| | | import { type Nullable } from '@vben/types'; |
| | | |
| | | export default defineComponent({ |
| | | components: { MarkDown, PageWrapper, MarkdownViewer, ACard: Card }, |
| | | setup() { |
| | | const markDownRef = ref<Nullable<MarkDownActionType>>(null); |
| | | const valueRef = ref(` |
| | | const markDownRef = ref<Nullable<MarkDownActionType>>(null); |
| | | const valueRef = ref(` |
| | | # 标题h1 |
| | | |
| | | ##### 标题h5 |
| | |
| | | | 4 | 5 | 6 | |
| | | `); |
| | | |
| | | function toggleTheme() { |
| | | const markDown = unref(markDownRef); |
| | | if (!markDown) return; |
| | | const vditor = markDown.getVditor(); |
| | | vditor.setTheme('dark', 'dark', 'dracula'); |
| | | } |
| | | function toggleTheme() { |
| | | const markDown = unref(markDownRef); |
| | | if (!markDown) return; |
| | | const vditor = markDown.getVditor(); |
| | | vditor.setTheme('dark', 'dark', 'dracula'); |
| | | } |
| | | |
| | | function handleChange(v: string) { |
| | | valueRef.value = v; |
| | | } |
| | | function handleChange(v: string) { |
| | | valueRef.value = v; |
| | | } |
| | | |
| | | function clearValue() { |
| | | valueRef.value = ''; |
| | | } |
| | | |
| | | return { |
| | | value: valueRef, |
| | | toggleTheme, |
| | | markDownRef, |
| | | handleChange, |
| | | clearValue, |
| | | }; |
| | | }, |
| | | }); |
| | | function clearValue() { |
| | | valueRef.value = ''; |
| | | } |
| | | </script> |