Skip to content

Commit

Permalink
fix: 代码解析错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
daidaibg committed Jul 29, 2024
1 parent 72c3cf3 commit 91a94fc
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions src/components/codes/code-highlights.vue
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
<script lang="ts" setup>
import { watch, computed, reactive, ref } from "vue";
import { MdPreview } from "md-editor-v3";
import { userThemeStore } from "@/store";
import "md-editor-v3/lib/preview.css";
<script lang="ts" setup>
import { watch, computed, reactive, ref } from "vue";
import { MdPreview } from "md-editor-v3";
import { userThemeStore } from "@/store";
import "md-editor-v3/lib/preview.css";
import type { PropType } from "vue";
import type { PropType } from "vue";
const themeStore = userThemeStore();
const themeStore = userThemeStore();
const props = defineProps({
text: {
type: String,
default: () => "",
},
wrapClass: {
type: String,
default: () => "",
},
codeType: {
type: String,
default: () => "",
},
asyncCodeText: {
type: Function as PropType<() => Promise<string>> | undefined,
default: void 0,
},
codeFoldable: {
type: Boolean,
default: false,
},
});
const str = ref("");
const props = defineProps({
text: {
type: String,
default: () => "",
},
wrapClass: {
type: String,
default: () => "",
},
codeType: {
type: String,
default: () => "",
},
asyncCodeText: {
type: Function as PropType<() => Promise<string>> | undefined,
default: void 0,
},
codeFoldable: {
type: Boolean,
default: false,
},
});
if (props.asyncCodeText) {
props.asyncCodeText().then((res) => {
str.value = res;
});
}
const str = ref("");
const codeText = computed(() => {
console.log({ codeType: props.codeType, asyncCodeText: props.asyncCodeText, str: str.value, text: props.text });
return `
\`\`\`${props.codeType}
${props.asyncCodeText ? str.value : props.text}
\`\`\`
`;
if (props.asyncCodeText) {
props.asyncCodeText().then((res) => {
str.value = res;
});
watch(
() => codeText.value,
(val) => {
console.log(val);
}
);
</script>
}
const codeText = computed(() => {
console.log({ codeType: props.codeType, asyncCodeText: props.asyncCodeText, str: str.value, text: props.text });
return `
\`\`\`${props.codeType}
${props.asyncCodeText ? str.value : props.text}
\`\`\`
`;
});
watch(
() => codeText.value,
(val) => {
console.log(val);
}
);
</script>

<template>
<MdPreview
:model-value="codeText"
:theme="themeStore.theme"
:previewTheme="themeStore.previewTheme"
:code-theme="themeStore.codeTheme"
showCodeRowNumber
:codeFoldable="codeFoldable"
id="yh-md"
/>
</template>
<template>
<MdPreview
:model-value="codeText"
:theme="themeStore.theme"
:previewTheme="themeStore.previewTheme"
:code-theme="themeStore.codeTheme"
showCodeRowNumber
:codeFoldable="codeFoldable"
id="yh-md"
/>
</template>

<style lang="scss" scoped></style>
<style lang="scss" scoped></style>

0 comments on commit 91a94fc

Please sign in to comment.