This commit is contained in:
神仙都没用 2023-10-18 14:41:14 +08:00
parent 0c66ddc038
commit 30384e0b6a

View File

@ -19,7 +19,7 @@ import { useFormat } from "./format";
import { parsePx } from "/@/cool/utils"; import { parsePx } from "/@/cool/utils";
import { useTypes } from "./types"; import { useTypes } from "./types";
import { useCool } from "/@/cool"; import { useCool } from "/@/cool";
import { merge } from "lodash-es"; import { isObject, merge } from "lodash-es";
const props = defineProps({ const props = defineProps({
modelValue: String, modelValue: String,
@ -61,10 +61,14 @@ function getContent() {
} }
// //
function setContent(value?: string) { function setContent(value: string = "") {
if (value != getContent()) { if (isObject(value)) {
editor?.setValue(value || ""); value = JSON.stringify(value);
} else {
value = value.toString();
} }
editor?.setValue(value);
} }
// //
@ -74,7 +78,7 @@ async function formatCode() {
} }
// //
function init() { function create() {
const options = merge( const options = merge(
{ {
theme: "default", theme: "default",
@ -148,7 +152,7 @@ watch(
); );
onMounted(() => { onMounted(() => {
init(); create();
}); });
onUnmounted(() => { onUnmounted(() => {