mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
perf: 预览
This commit is contained in:
parent
6e6d743899
commit
96dbb57862
@ -1,8 +1,8 @@
|
|||||||
import { http } from "@/utils/http";
|
import { http } from "@/utils/http";
|
||||||
import { type ApiAbstract, VersionEntity } from "@/utils/http/ApiAbstract";
|
import type { ApiAbstract } from "@/utils/http/ApiAbstract";
|
||||||
import { baseUrlApi } from "../utils";
|
import { baseUrlApi } from "../utils";
|
||||||
|
|
||||||
export class Generator extends VersionEntity {
|
export class Generator {
|
||||||
name: string;
|
name: string;
|
||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
@ -2,30 +2,35 @@
|
|||||||
import "@wangeditor/editor/dist/css/style.css";
|
import "@wangeditor/editor/dist/css/style.css";
|
||||||
import { IEditorConfig } from "@wangeditor/editor";
|
import { IEditorConfig } from "@wangeditor/editor";
|
||||||
import { Editor } from "@wangeditor/editor-for-vue";
|
import { Editor } from "@wangeditor/editor-for-vue";
|
||||||
import { onMounted, onBeforeUnmount, shallowRef, ref } from "vue";
|
import {
|
||||||
import { type Generator } from "@/api/generator/generator";
|
onMounted,
|
||||||
|
onBeforeUnmount,
|
||||||
|
shallowRef,
|
||||||
|
defineProps,
|
||||||
|
defineEmits,
|
||||||
|
ref
|
||||||
|
} from "vue";
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "BaseEditor"
|
name: "BaseEditor"
|
||||||
});
|
});
|
||||||
|
|
||||||
const content = defineModel<Generator>("content");
|
const content = defineProps({
|
||||||
|
content: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:content"]);
|
||||||
const mode = "default";
|
const mode = "default";
|
||||||
// 编辑器实例,必须用 shallowRef
|
// 编辑器实例,必须用 shallowRef
|
||||||
const editorRef = shallowRef();
|
const editorRef = shallowRef();
|
||||||
|
|
||||||
// 内容 HTML
|
// 内容 HTML
|
||||||
const valueHtml = ref("");
|
|
||||||
const editorConfig: Partial<IEditorConfig> = { MENU_CONF: {} };
|
const editorConfig: Partial<IEditorConfig> = { MENU_CONF: {} };
|
||||||
|
|
||||||
onMounted(() => {
|
console.log("content", content.content);
|
||||||
console.log("content", content.value.content);
|
const htmlText = ref(content.content);
|
||||||
valueHtml.value =
|
onMounted(() => {});
|
||||||
'<pre><code class="language-java">' +
|
|
||||||
content.value.content +
|
|
||||||
"</code></pre>";
|
|
||||||
const editorConfig: Partial<IEditorConfig> = { MENU_CONF: {} };
|
|
||||||
});
|
|
||||||
const handleCreated = editor => {
|
const handleCreated = editor => {
|
||||||
// 记录 editor 实例,重要!
|
// 记录 editor 实例,重要!
|
||||||
editorRef.value = editor;
|
editorRef.value = editor;
|
||||||
@ -40,12 +45,12 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="wangeditor">
|
<div>
|
||||||
<Editor
|
<Editor
|
||||||
v-model="valueHtml"
|
v-model="htmlText"
|
||||||
:defaultConfig="editorConfig"
|
:defaultConfig="editorConfig"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
style="height: 500px; overflow-y: hidden"
|
style="height: 100%; overflow-y: hidden"
|
||||||
@onCreated="handleCreated"
|
@onCreated="handleCreated"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDetail } from "./hook";
|
import { useDetail } from "./hook";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref, reactive } from "vue";
|
||||||
import { get } from "@/api/generator/generator";
|
import { get, type Generator } from "@/api/generator/generator";
|
||||||
import { Base } from "@/views/editor/components";
|
import { Base } from "@/views/editor/components";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@ -11,20 +11,32 @@ defineOptions({
|
|||||||
const { initToDetail, getParameter } = useDetail();
|
const { initToDetail, getParameter } = useDetail();
|
||||||
initToDetail("query");
|
initToDetail("query");
|
||||||
const datas = ref([]);
|
const datas = ref([]);
|
||||||
|
const content = ref("");
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
get(getParameter.id, 1).then(data => {
|
get(getParameter.id, 1).then(data => {
|
||||||
console.log("data", data);
|
console.log("data", data);
|
||||||
datas.value = data.data;
|
datas.value = data.data;
|
||||||
|
content.value =
|
||||||
|
'<pre><code class="language-java">' +
|
||||||
|
data.data[0].content +
|
||||||
|
"</code></pre>";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
const clickFn = (item: String) => {
|
||||||
|
content.value = '<pre><code class="language-java">' + item + "</code></pre>";
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<span v-for="(item, index) in datas" :key="index">
|
<span
|
||||||
|
v-for="(item, index) in datas"
|
||||||
|
:key="index"
|
||||||
|
@click="clickFn(item.content)"
|
||||||
|
>
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<Base v-model:content="datas[0]" />
|
<Base v-model:content="content" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user