123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <div class="short_video">
- <div style="padding: 25px 25px 0 25px">
- <el-table
- border
- header-row-class-name="head"
- :data="tableData"
- style="width: 100%"
- >
- <el-table-column prop="title" label="主题/产品" width="280">
- <template #default="scope">
- <div
- contenteditable
- class="input"
- v-text="scope.row.title"
- @input="e => setText(scope, 'title', e)"
- ></div>
- </template>
- </el-table-column>
- <el-table-column prop="desc" label="描述">
- <template #default="scope">
- <div
- contenteditable
- class="input"
- v-text="scope.row.desc"
- @input="e => setText(scope, 'desc', e)"
- ></div>
- </template>
- </el-table-column>
- <el-table-column prop="" label="">
- <template #default="scope">
- <el-button
- :icon="CircleClose"
- type="primary"
- link
- @click="() => deltable(scope)"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <br />
- <el-button :icon="CirclePlus" type="primary" link @click="addtable">
- 添加
- </el-button>
- <br />
- <el-form>
- <el-form-item label="文章长度">
- <div style="text-align: right; width: 100%">
- <el-button
- @click="long = 'short'"
- plain
- :class="{ act: long === 'short' }"
- >
- 短
- </el-button>
- <el-button
- @click="long = 'default'"
- plain
- :class="{ act: long === 'default' }"
- >
- 中
- </el-button>
- <el-button
- @click="long = 'long'"
- plain
- :class="{ act: long === 'long' }"
- >
- 长
- </el-button>
- </div>
- </el-form-item>
- </el-form>
- <div class="btn_group">
- <el-button type="primary" style="width: 100%" @click="create"
- >生成内容</el-button
- >
- <div class="bottom-content-safe-tip">
- <img :src="image_base64.tanhao" class="content-safe-tip-icon" />
- <div class="content-safe-tip-text">
- 声明:内容为概率模型生成,可能会产生不正确的信息,不代表我司的观点和立场
- </div>
- </div>
- </div>
- <template v-if="list.length">
- <div class="item" v-for="(item, i) in list" :key="i">
- <div class="content" v-text="item.text"></div>
- <div class="btn_div">
- <el-tooltip effect="dark" content="左侧导入" placement="top">
- <el-icon
- @click="() => inputText(item.text)"
- style="
- left: 50;
- top: 50%;
- transform: translate(-50%, -50%);
- cursor: pointer;
- "
- color="#cacaca"
- >
- <DArrowLeft />
- </el-icon>
- </el-tooltip>
- </div>
- <div class="btn_div">
- <el-tooltip effect="dark" content="复制" placement="top">
- <el-icon
- style="
- left: 50;
- top: 50%;
- transform: translate(-50%, -50%);
- cursor: pointer;
- "
- @click="() => copyurl(item.text)"
- color="#cacaca"
- >
- <CopyDocument />
- </el-icon>
- </el-tooltip>
- </div>
- </div>
- </template>
- </div>
- </div>
- </template>
- <script setup>
- import { copyurl } from '@/utils/tool.js';
- import { image_base64 } from './data.js';
- import { CircleClose, CirclePlus } from '@element-plus/icons-vue';
- import { ref, defineEmits } from 'vue';
- import { ElMessage } from 'element-plus';
- import { advertisement, generate_pc_get } from '@/api/aleditor.js';
- const emits = defineEmits(['closeType', 'setHtml', 'getImage']);
- const long = ref('short');
- const load = ref(false);
- const tableData = ref([
- {
- title: ' ',
- desc: ' ',
- },
- ]);
- const list = ref([]);
- const inputText = text => {
- emits('setHtml', text);
- };
- const addtable = () => {
- tableData.value.push({
- title: ' ',
- desc: ' ',
- });
- };
- const deltable = scope => {
- if (tableData.value.length <= 1)
- return ElMessage.error('至少需要一个或以上内容');
- tableData.value.splice(scope.$index, 1);
- };
- const setText = (scope, key, e) => {
- tableData.value[scope.$index][key] = e.target.innerText;
- };
- const create = () => {
- load.value = true;
- const p = {
- count: 5,
- data: {
- others: tableData.value.map(v => {
- return {
- name: v.title,
- desc: v.desc,
- };
- }),
- },
- generateType: 33,
- length:
- long.value === 'short' ? 400 : long.value === 'default' ? 600 : 1000,
- noblock: true,
- query_type: 'koubo_multi',
- docId: localStorage.getItem('fileId') || undefined,
- };
- advertisement({
- data: p,
- noload: true,
- }).then(r => {
- if (r.errCode !== 0) return (load.value = false);
- p.req = { doc_id: r.data.doc_id };
- get(p);
- });
- };
- const get = p => {
- 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;
- }
- const list = res.data.result.content;
- const l = [];
- for (let i = 0; i < list.length; i++) {
- const v = list[i];
- l.push({
- text: v,
- });
- }
- list.value.push(...l);
- })
- .catch(() => {
- load.value = false;
- });
- };
- </script>
- <style>
- .short_video .head,
- .short_video .el-table th.el-table__cell {
- background-color: #fafafa;
- color: #111;
- font-weight: 400;
- }
- .short_video .el-table .el-table__cell {
- padding: 0;
- }
- .short_video .input,
- .short_video .el-table .cell {
- height: 45px;
- line-height: 45px;
- outline: none;
- }
- </style>
- <style scoped>
- .act {
- color: var(--el-button-hover-text-color);
- border-color: var(--el-button-hover-border-color);
- background-color: var(--el-button-hover-bg-color);
- outline: 0;
- }
- .btn_group {
- padding-right: 1em;
- }
- .bottom-content-safe-tip {
- display: -webkit-box;
- display: -ms-flexbox;
- display: flex;
- padding: 15px 0;
- -webkit-box-pack: center;
- -ms-flex-pack: center;
- justify-content: center;
- width: 100%;
- zoom: 0.83;
- }
- .bottom-content-safe-tip .content-safe-tip-icon {
- width: 15px;
- height: 15px;
- margin-right: 10px;
- }
- .bottom-content-safe-tip .content-safe-tip-text {
- font-size: 12px;
- line-height: 15px;
- color: #cacaca;
- }
- .item {
- width: 100%;
- min-height: 45px;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- margin-bottom: 20px;
- text-align: left;
- position: relative;
- padding: 10px 10px 10px 0;
- display: flex;
- -webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
- border-bottom: 1px solid #eee;
- }
- .content {
- -webkit-box-flex: 1;
- -ms-flex: 1;
- flex: 1;
- outline: none;
- line-height: 28px;
- text-align: justify;
- overflow-y: auto;
- }
- .hover_class,
- .item:hover {
- background-color: #f5f5f5;
- border-bottom: 1px solid #f8f8f8;
- }
- .btn_div {
- height: 30px;
- width: 30px;
- position: relative;
- }
- </style>
|