liyongli 1 жил өмнө
parent
commit
1547d71002

+ 14 - 0
src/api/aleditor.js

@@ -137,3 +137,17 @@ export function getBase64(params) {
     method: 'POST',
   });
 }
+
+/**
+ * AI绘图
+ * @returns ajax
+ */
+export function getSID() {
+    return ajax({
+      api: '/sid',
+      noload: true,
+      base: 'xzMao',
+      noJY: true,
+      method: 'POST',
+    });
+  }

+ 53 - 12
src/view/allMedia/AIeditor/components/continuation.vue

@@ -3,12 +3,16 @@
     <br />
     <div class="head">
       <span> 根据上下文,为您推荐: </span>
-      <el-select v-model="select" style="float: right; margin-right: ">
-        <el-option label="通用" value="通用" />
-        <el-option label="新闻" value="新闻" />
-        <el-option label="论文" value="论文" />
-        <el-option label="公文" value="公文" />
-        <el-option label="小说" value="小说" />
+      <el-select
+        v-model="select"
+        style="float: right; margin-top: 15px"
+        @change="get"
+      >
+        <el-option label="通用" value="common" />
+        <el-option label="新闻" value="news" />
+        <el-option label="论文" value="paper" />
+        <el-option label="公文" value="official" />
+        <el-option label="小说" value="novel" />
       </el-select>
     </div>
 
@@ -17,21 +21,57 @@
       @click="() => seva(item)"
       v-for="(item, i) in list"
       :key="i"
-      v-text="item"
+      v-text="item.text"
     ></div>
   </div>
 </template>
 
 <script setup>
-import { ref, defineEmits } from 'vue';
+import { ref, defineEmits, defineProps } from 'vue';
+import { checkContent } from '@/api/aleditor.js';
 const emits = defineEmits(['closeType', 'setHtml', 'getImage']);
-const select = ref('通用');
-const list = ref([
-  '他们走上了岸,慢慢地向岛上走去,但奇怪的是,他们并没有看到任何人影。',
-]);
+const select = ref('common');
+const list = ref([]);
 const seva = text => {
   emits('setHtml', text);
 };
+const load = ref(false);
+const props = defineProps({
+  headTitle: String,
+  html: Function,
+  text: Function,
+});
+
+const get = () => {
+  load.value = true;
+  checkContent({
+    data: {
+      content: props.html(),
+      contentText: props.text(),
+      docId: localStorage.getItem('fileId') || undefined,
+      generationInfo: {
+        sid: Date.now(),
+        domain: select.value,
+        data: [{ prefix: props.text(), title: props.headTitle }],
+      },
+      shouldGenerate: true,
+    },
+  })
+    .then(r => {
+      load.value = false;
+      let li = r.data.result || [];
+      let l = [];
+      for (let i = 0; i < li.length; i++) {
+        const v = li[i];
+        if (v.candidate && v.candidate.length) l.push(...v.candidate);
+      }
+      list.value = l;
+    })
+    .catch(() => {
+      load.value = false;
+    });
+};
+get();
 </script>
 
 <style scoped>
@@ -48,6 +88,7 @@ const seva = text => {
   border: 1px solid #e1e1e1;
   width: 95%;
   cursor: pointer;
+  margin-bottom: 20px;
 }
 .c_main:hover {
   border-color: #93c8ff;

+ 2 - 2
src/view/allMedia/AIeditor/components/draw.vue

@@ -84,7 +84,7 @@ const load = ref(false);
 const create = () => {
   const p = {
     cnt: 1,
-    docId: '8347104926682292224',
+    docId: localStorage.getItem('fileId') || undefined,
     text: `${form.value.fengge} ${form.value.bili} | ${form.value.title}`,
   };
   load.value = true;
@@ -124,7 +124,7 @@ const getBase64Func = id => {
   getBase64({
     data: {
       id,
-      docId: '8347104926682292224',
+      docId: localStorage.getItem('fileId') || undefined,
     },
   })
     .then(r => {

+ 8 - 4
src/view/allMedia/AIeditor/components/review.vue

@@ -43,18 +43,22 @@
 
 <script setup>
 // 校阅
-import { ref, inject } from 'vue';
+import { ref, defineProps } from 'vue';
 import { checkContent } from '@/api/aleditor.js';
 import { image_base64 } from './data';
 import jy from '@/assets/img/jy.png';
 const is_status = ref('show');
-
+const props = defineProps({
+    headTitle: String,
+    body: String,
+    bodyText: String
+})
 const jiaoyue = () => {
   //   is_status.value = 'load';
   checkContent({
     data: {
-      content: inject('getHtml')(),
-      contentText: inject('getText')(),
+      content: props.body,
+      contentText: props.bodyText,
       // cursorPosition: 42,
       // docId: '8344800447857377280',
       // generationInfo: null,

+ 1 - 1
src/view/allMedia/AIeditor/components/short_video.vue

@@ -174,7 +174,7 @@ const create = () => {
       long.value === 'short' ? 400 : long.value === 'default' ? 600 : 1000,
     noblock: true,
     query_type: 'koubo_multi',
-    docId: '8347104926682292224',
+    docId: localStorage.getItem('fileId') || undefined,
   };
   advertisement({
     data: p,

+ 30 - 11
src/view/allMedia/AIeditor/index.vue

@@ -8,18 +8,26 @@
     />
     <div class="main">
       <div class="bgeditor">
-        <div class="editor" style="padding-top: 100px;">
+        <div class="editor" style="padding-top: 100px">
           <input
             contenteditable
             v-model="titleh1"
-            style="display: block; width: calc(100% - 200px);font-size: 24px; margin: 0 auto; border: none; outline: none"
+            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)"
             mode="default"
             @onCreated="handleCreated"
+            @onChange="contentChange"
           />
           <Transition name="toolCol">
             <div class="tool" v-if="toolShow">
@@ -177,6 +185,9 @@
               @setHtml="setHtml"
               @setTitle="setTitle"
               @setImage="setImage"
+              :headTitle="titleh1"
+              :html="() => editorRef.getHtml()"
+              :text="() => editorRef.getText()"
               :is="component_2_list[select_right_2_btn_type]"
             ></component>
           </div>
@@ -188,9 +199,9 @@
 
 <script setup>
 import '@wangeditor/editor/dist/css/style.css'; // 引入 css
-import { onBeforeUnmount, ref, shallowRef, onMounted, provide } from 'vue';
+import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue';
 import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
-import { advertisement, generate_pc_get } from '@/api/aleditor.js';
+import { advertisement, generate_pc_get, getSID } from '@/api/aleditor.js';
 // 右侧一级组件
 import pen_ink from './components/pen_ink.vue';
 import review from './components/review.vue';
@@ -284,9 +295,6 @@ const select_right_btn_list = ref([
   },
 ]);
 
-provide('getHtml', () => editorRef.value.getHtml());
-provide('getText', () => editorRef.value.getText());
-
 onMounted(() => {});
 
 const statusPage = ref([false, true]); // 0 --> 目录  1 --> operate
@@ -294,6 +302,16 @@ const load = ref(false);
 const toolShow = ref(true);
 const btnType = ref('short');
 
+const getSidFun = () => {
+  getSID().then(r => {
+    console.log(r);
+    localStorage.setItem('fileId', r.fileId);
+    localStorage.setItem('sid', r.sid);
+  });
+};
+
+!localStorage.getItem('fileId') && getSidFun();
+
 const toolbarConfig = {
   toolbarKeys: [
     'redo',
@@ -336,9 +354,10 @@ const editorConfig = {
   },
 };
 
-// const seaveTitle = e => {
-//   title.value = e.target.innerHTML;
-// };
+const contentChange = e =>{
+    console.log(e.getHtml());
+    // 编辑器修改
+}
 
 // 组件销毁时,也及时销毁编辑器
 onBeforeUnmount(() => {