|
@@ -8,13 +8,13 @@
|
|
|
/>
|
|
|
<div class="main">
|
|
|
<div class="bgeditor">
|
|
|
- <div class="editor">
|
|
|
- <h1
|
|
|
- v-html="title"
|
|
|
- @input="e => seaveTitle(e)"
|
|
|
+ <div class="editor" style="padding-top: 100px;">
|
|
|
+ <input
|
|
|
contenteditable
|
|
|
- style="padding: 100px 100px 0; outline: none"
|
|
|
- ></h1>
|
|
|
+ v-model="titleh1"
|
|
|
+ style="display: block; width: calc(100% - 200px);font-size: 24px; margin: 0 auto; border: none; outline: none"
|
|
|
+ placeholder="无标题"
|
|
|
+ />
|
|
|
<Editor
|
|
|
:defaultConfig="editorConfig"
|
|
|
style="padding: 0 90px; height: calc(100% - 150px)"
|
|
@@ -32,16 +32,18 @@
|
|
|
border-top-right-radius: 0;
|
|
|
border-bottom-right-radius: 0;
|
|
|
"
|
|
|
+ @click="() => saveDagang(18)"
|
|
|
>
|
|
|
写内容
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
style="
|
|
|
- border-top-left-radius: 0;
|
|
|
+ border-top-left-radius;
|
|
|
border-bottom-left-radius: 0;
|
|
|
margin-left: 0;
|
|
|
"
|
|
|
+ @click="() => saveDagang(17)"
|
|
|
>
|
|
|
写大纲
|
|
|
</el-button>
|
|
@@ -65,22 +67,22 @@
|
|
|
</div>
|
|
|
<div
|
|
|
class="btnType"
|
|
|
- :class="{ btnTypeAct: btnType === 0 }"
|
|
|
- @click="btnType = 0"
|
|
|
+ :class="{ btnTypeAct: btnType === 'short' }"
|
|
|
+ @click="btnType = 'short'"
|
|
|
>
|
|
|
短
|
|
|
</div>
|
|
|
<div
|
|
|
class="btnType"
|
|
|
- :class="{ btnTypeAct: btnType === 1 }"
|
|
|
- @click="btnType = 1"
|
|
|
+ :class="{ btnTypeAct: btnType === 'default' }"
|
|
|
+ @click="btnType = 'default'"
|
|
|
>
|
|
|
中
|
|
|
</div>
|
|
|
<div
|
|
|
class="btnType"
|
|
|
- :class="{ btnTypeAct: btnType === 2 }"
|
|
|
- @click="btnType = 2"
|
|
|
+ :class="{ btnTypeAct: btnType === 'long' }"
|
|
|
+ @click="btnType = 'long'"
|
|
|
>
|
|
|
长
|
|
|
</div>
|
|
@@ -188,7 +190,7 @@
|
|
|
import '@wangeditor/editor/dist/css/style.css'; // 引入 css
|
|
|
import { onBeforeUnmount, ref, shallowRef, onMounted, provide } from 'vue';
|
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
|
|
|
-
|
|
|
+import { advertisement, generate_pc_get } from '@/api/aleditor.js';
|
|
|
// 右侧一级组件
|
|
|
import pen_ink from './components/pen_ink.vue';
|
|
|
import review from './components/review.vue';
|
|
@@ -197,7 +199,7 @@ import dictionary from './components/dictionary.vue';
|
|
|
import comment from './components/comment.vue';
|
|
|
// 右侧二级组件
|
|
|
import full_text from './components/full_text.vue';
|
|
|
-import advertisement from './components/advertisement.vue';
|
|
|
+import advertisementEle from './components/advertisement.vue';
|
|
|
import inspiration from './components/inspiration.vue';
|
|
|
import inspiration_fangan from './components/inspiration_fangan.vue';
|
|
|
import literature from './components/literature.vue';
|
|
@@ -217,13 +219,13 @@ import continuation from './components/continuation.vue';
|
|
|
// 右侧头部数据
|
|
|
const right_head = ref({});
|
|
|
|
|
|
-const title = ref('无标题');
|
|
|
+const titleh1 = ref('');
|
|
|
|
|
|
const componment_list = [pen_ink, review, image, dictionary, comment];
|
|
|
// index对应ai里的功能
|
|
|
const component_2_list = [
|
|
|
full_text,
|
|
|
- advertisement,
|
|
|
+ advertisementEle,
|
|
|
inspiration,
|
|
|
literature,
|
|
|
little_red_book,
|
|
@@ -238,7 +240,7 @@ const component_2_list = [
|
|
|
poetry,
|
|
|
novel,
|
|
|
composition,
|
|
|
- continuation
|
|
|
+ continuation,
|
|
|
];
|
|
|
|
|
|
const noOpenSon = ref(true);
|
|
@@ -288,9 +290,9 @@ provide('getText', () => editorRef.value.getText());
|
|
|
onMounted(() => {});
|
|
|
|
|
|
const statusPage = ref([false, true]); // 0 --> 目录 1 --> operate
|
|
|
-const load = ref(true);
|
|
|
+const load = ref(false);
|
|
|
const toolShow = ref(true);
|
|
|
-const btnType = ref(0);
|
|
|
+const btnType = ref('short');
|
|
|
|
|
|
const toolbarConfig = {
|
|
|
toolbarKeys: [
|
|
@@ -334,9 +336,9 @@ const editorConfig = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-const seaveTitle = e => {
|
|
|
- title.value = e.target.innerHTML;
|
|
|
-};
|
|
|
+// const seaveTitle = e => {
|
|
|
+// title.value = e.target.innerHTML;
|
|
|
+// };
|
|
|
|
|
|
// 组件销毁时,也及时销毁编辑器
|
|
|
onBeforeUnmount(() => {
|
|
@@ -389,6 +391,8 @@ const saveData = item => {
|
|
|
right_head.value = item;
|
|
|
};
|
|
|
|
|
|
+let doc_id = '';
|
|
|
+
|
|
|
// 右侧生成编辑器内容
|
|
|
const setHtml = html => {
|
|
|
const ot = editorRef.value.getHtml();
|
|
@@ -399,7 +403,67 @@ const setImage = imgs => {
|
|
|
console.log(imgs);
|
|
|
};
|
|
|
const setTitle = text => {
|
|
|
- title.value = text;
|
|
|
+ titleh1.value = text;
|
|
|
+};
|
|
|
+
|
|
|
+// 写大纲
|
|
|
+const saveDagang = generateType => {
|
|
|
+ if (!titleh1.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ load.value = true;
|
|
|
+ const p = {
|
|
|
+ data: {
|
|
|
+ title: titleh1.value,
|
|
|
+ prev: '一、第一章\n', // 获取大纲内容
|
|
|
+ next: '',
|
|
|
+ },
|
|
|
+ generateType,
|
|
|
+ length: btnType.value,
|
|
|
+ noblock: true,
|
|
|
+ query_type: generateType === 17 ? 'title' : 'content',
|
|
|
+ };
|
|
|
+ if (doc_id) {
|
|
|
+ p.req = { doc_id };
|
|
|
+ }
|
|
|
+ advertisement({
|
|
|
+ data: p,
|
|
|
+ noload: true,
|
|
|
+ }).then(r => {
|
|
|
+ if (r.errCode !== 0) return (load.value = false);
|
|
|
+ doc_id = r.data.doc_id;
|
|
|
+ p.req = { doc_id };
|
|
|
+ get(p, generateType);
|
|
|
+ });
|
|
|
+};
|
|
|
+const get = (p, generateType) => {
|
|
|
+ generate_pc_get({
|
|
|
+ data: p,
|
|
|
+ noload: true,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ load.value = false;
|
|
|
+ if (res.errCode !== 0 && res.data.status === 'RUNNING') {
|
|
|
+ let t = setTimeout(() => {
|
|
|
+ get(p);
|
|
|
+ clearTimeout(t);
|
|
|
+ }, 200);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (generateType == 17) {
|
|
|
+ let t = '';
|
|
|
+ for (let i = 0; i < res.data.result.subtitles.length; i++) {
|
|
|
+ const v = res.data.result.subtitles[i];
|
|
|
+ t += `<h4>${v.title}</h4>`;
|
|
|
+ }
|
|
|
+ setHtml(t);
|
|
|
+ } else {
|
|
|
+ setHtml(res.data.result.content);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ load.value = false;
|
|
|
+ });
|
|
|
};
|
|
|
</script>
|
|
|
|