mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 13:42:50 +00:00
优化
This commit is contained in:
parent
0c66ddc038
commit
30384e0b6a
@ -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(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user