novel.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="model-item-container">
  3. <br />
  4. <el-form label-position="top">
  5. <el-form-item label="请输入小说标题 *">
  6. <el-input v-model="form.title" />
  7. </el-form-item>
  8. <el-form-item label="请输入小说开头">
  9. <el-input
  10. v-model="form.desc"
  11. type="textarea"
  12. :rows="5"
  13. :maxlength="1000"
  14. show-word-limit
  15. />
  16. </el-form-item>
  17. </el-form>
  18. <el-form label-width="100px" :model="form" label-position="left">
  19. <el-form-item label="文章长度">
  20. <div style="text-align: right; width: 100%">
  21. <el-button
  22. @click="form.long = 'short'"
  23. plain
  24. :class="{ act: form.long === 'short' }"
  25. >
  26. </el-button>
  27. <el-button
  28. @click="form.long = 'default'"
  29. plain
  30. :class="{ act: form.long === 'default' }"
  31. >
  32. </el-button>
  33. <el-button
  34. @click="form.long = 'long'"
  35. plain
  36. :class="{ act: form.long === 'long' }"
  37. >
  38. </el-button>
  39. </div>
  40. </el-form-item>
  41. </el-form>
  42. <div class="btn_group">
  43. <el-button
  44. type="primary"
  45. style="width: 100%"
  46. :loading="load"
  47. @click="create"
  48. >生成内容</el-button
  49. >
  50. <div class="bottom-content-safe-tip">
  51. <img :src="image_base64.tanhao" class="content-safe-tip-icon" />
  52. <div class="content-safe-tip-text">
  53. 声明:内容为概率模型生成,可能会产生不正确的信息,不代表我司的观点和立场
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script setup>
  60. import { ref,defineEmits } from 'vue';
  61. import { image_base64 } from './data.js';
  62. import { advertisement, generate_pc_get } from '@/api/aleditor.js';
  63. const emits = defineEmits(['closeType', 'setHtml', 'getImage']);
  64. const form = ref({
  65. title: '',
  66. desc: '',
  67. long: 'small',
  68. });
  69. const load = ref(false);
  70. const create = () => {
  71. load.value = true;
  72. const p = {
  73. count: form.value.num,
  74. data: {
  75. title: form.value.title,
  76. prev: form.value.desc,
  77. next: ""
  78. },
  79. generateType: 2,
  80. domain: "novel",
  81. length: form.value.long,
  82. noblock: true,
  83. query_type: 'comment',
  84. };
  85. advertisement({
  86. data: p,
  87. noload: true,
  88. }).then(r => {
  89. if (r.errCode !== 0) return (load.value = false);
  90. p.req = { doc_id: r.data.doc_id };
  91. get(p);
  92. });
  93. };
  94. const get = p => {
  95. generate_pc_get({
  96. data: p,
  97. noload: true,
  98. })
  99. .then(res => {
  100. load.value = false;
  101. if (res.errCode !== 0 && res.data.status === 'RUNNING') {
  102. let t = setTimeout(() => {
  103. get(p);
  104. clearTimeout(t);
  105. }, 200);
  106. return;
  107. }
  108. emits('setHtml', '<h3>' + form.value.title + '</h3><p>' + form.value.desc + res.data.result.content + '</p>');
  109. })
  110. .catch(() => {
  111. load.value = false;
  112. });
  113. };
  114. </script>
  115. <style scoped>
  116. .model-item-container {
  117. text-align: center;
  118. -webkit-box-flex: 1;
  119. -ms-flex: 1;
  120. flex: 1;
  121. display: -webkit-box;
  122. display: -ms-flexbox;
  123. display: flex;
  124. -webkit-box-orient: vertical;
  125. -webkit-box-direction: normal;
  126. -ms-flex-direction: column;
  127. flex-direction: column;
  128. min-height: 0;
  129. width: 95%;
  130. height: 100%;
  131. }
  132. .model-item-part {
  133. -webkit-box-flex: 0;
  134. -ms-flex: none;
  135. flex: none;
  136. font-size: 14px;
  137. }
  138. .act {
  139. color: var(--el-button-hover-text-color);
  140. border-color: var(--el-button-hover-border-color);
  141. background-color: var(--el-button-hover-bg-color);
  142. outline: 0;
  143. }
  144. .btn_group {
  145. width: 100%;
  146. }
  147. .bottom-content-safe-tip {
  148. display: -webkit-box;
  149. display: -ms-flexbox;
  150. display: flex;
  151. padding: 15px 0;
  152. -webkit-box-pack: center;
  153. -ms-flex-pack: center;
  154. justify-content: center;
  155. width: 100%;
  156. zoom: 0.83;
  157. }
  158. .bottom-content-safe-tip .content-safe-tip-icon {
  159. width: 15px;
  160. height: 15px;
  161. margin-right: 10px;
  162. }
  163. .bottom-content-safe-tip .content-safe-tip-text {
  164. font-size: 12px;
  165. line-height: 15px;
  166. color: #cacaca;
  167. }
  168. </style>