-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbdd44a
commit 0dd6665
Showing
15 changed files
with
231 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ const include = [ | |
"dayjs", | ||
"axios", | ||
"pinia", | ||
"vditor", | ||
"typeit", | ||
"swiper", | ||
"qrcode", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { $t } from "@/plugins/i18n"; | ||
import { markdown } from "@/router/enums"; | ||
|
||
export default { | ||
path: "/markdown", | ||
redirect: "/markdown/index", | ||
meta: { | ||
icon: "ri:markdown-line", | ||
title: $t("menus.pureMarkdown"), | ||
rank: markdown | ||
}, | ||
children: [ | ||
{ | ||
path: "/markdown/index", | ||
name: "Markdown", | ||
component: () => import("@/views/markdown/index.vue"), | ||
meta: { | ||
title: $t("menus.pureMarkdown"), | ||
extraIcon: "IF-pure-iconfont-new svg" | ||
} | ||
} | ||
] | ||
} satisfies RouteConfigsTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<script setup lang="ts"> | ||
import "vditor/dist/index.css"; | ||
import Vditor from "vditor"; | ||
import { useDark } from "@pureadmin/utils"; | ||
import { useIntervalFn } from "@vueuse/core"; | ||
import { onMounted, ref, watch, toRaw, onUnmounted } from "vue"; | ||
const emit = defineEmits([ | ||
"update:modelValue", | ||
"after", | ||
"focus", | ||
"blur", | ||
"esc", | ||
"ctrlEnter", | ||
"select" | ||
]); | ||
const props = defineProps({ | ||
options: { | ||
type: Object, | ||
default() { | ||
return {}; | ||
} | ||
}, | ||
modelValue: { | ||
type: String, | ||
default: "" | ||
} | ||
}); | ||
const { isDark } = useDark(); | ||
const editor = ref<Vditor | null>(null); | ||
const markdownRef = ref<HTMLElement | null>(null); | ||
onMounted(() => { | ||
editor.value = new Vditor(markdownRef.value as HTMLElement, { | ||
...props.options, | ||
value: props.modelValue, | ||
cache: { | ||
enable: false | ||
}, | ||
fullscreen: { | ||
index: 10000 | ||
}, | ||
after() { | ||
emit("after", toRaw(editor.value)); | ||
}, | ||
input(value: string) { | ||
emit("update:modelValue", value); | ||
}, | ||
focus(value: string) { | ||
emit("focus", value); | ||
}, | ||
blur(value: string) { | ||
emit("blur", value); | ||
}, | ||
esc(value: string) { | ||
emit("esc", value); | ||
}, | ||
ctrlEnter(value: string) { | ||
emit("ctrlEnter", value); | ||
}, | ||
select(value: string) { | ||
emit("select", value); | ||
} | ||
}); | ||
}); | ||
watch( | ||
() => props.modelValue, | ||
newVal => { | ||
if (newVal !== editor.value?.getValue()) { | ||
editor.value?.setValue(newVal); | ||
} | ||
} | ||
); | ||
watch( | ||
() => isDark.value, | ||
newVal => { | ||
const { pause } = useIntervalFn(() => { | ||
if (editor.value.vditor) { | ||
newVal | ||
? editor.value.setTheme("dark", "dark", "rose-pine") | ||
: editor.value.setTheme("classic", "light", "github"); | ||
pause(); | ||
} | ||
}, 20); | ||
} | ||
); | ||
onUnmounted(() => { | ||
const editorInstance = editor.value; | ||
if (!editorInstance) return; | ||
try { | ||
editorInstance?.destroy?.(); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div ref="markdownRef" /> | ||
</template> |
Oops, something went wrong.