index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!-- dall3 -->
  2. <template>
  3. <div class="prompt">
  4. <el-text tag="b">画面描述</el-text>
  5. <el-text tag="p">建议使用“形容词+动词+风格”的格式,使用“,”隔开.</el-text>
  6. <el-input
  7. v-model="prompt"
  8. maxlength="1024"
  9. rows="5"
  10. style="width: 100%; margin-top: 15px;"
  11. input-style="border-radius: 7px;"
  12. placeholder="例如:童话里的小屋应该是什么样子?"
  13. show-word-limit
  14. type="textarea"
  15. />
  16. </div>
  17. <div class="hot-words">
  18. <div>
  19. <el-text tag="b">随机热词</el-text>
  20. </div>
  21. <el-space wrap class="word-list">
  22. <el-button round
  23. class="btn"
  24. :type="(selectHotWord === hotWord ? 'primary' : 'default')"
  25. v-for="hotWord in hotWords"
  26. :key="hotWord"
  27. @click="handlerHotWordClick(hotWord)"
  28. >
  29. {{ hotWord }}
  30. </el-button>
  31. </el-space>
  32. </div>
  33. <div class="model">
  34. <div>
  35. <el-text tag="b">模型</el-text>
  36. </div>
  37. <el-space wrap class="model-list">
  38. <div
  39. :class="selectModel === model ? 'modal-item selectModel' : 'modal-item'"
  40. v-for="model in models"
  41. :key="model.key"
  42. >
  43. <el-image
  44. :src="model.image"
  45. fit="contain"
  46. @click="handlerModelClick(model)"
  47. />
  48. <div class="model-font">{{model.name}}</div>
  49. </div>
  50. </el-space>
  51. </div>
  52. <div class="image-size">
  53. <div>
  54. <el-text tag="b">尺寸</el-text>
  55. </div>
  56. <el-space wrap class="size-list">
  57. <div class="size-item"
  58. v-for="imageSize in imageSizeList"
  59. :key="imageSize.key"
  60. @click="handlerSizeClick(imageSize)">
  61. <div :class="selectImageSize === imageSize ? 'size-wrapper selectImageSize' : 'size-wrapper'">
  62. <div :style="imageSize.style"></div>
  63. </div>
  64. <div class="size-font">{{ imageSize.key }}</div>
  65. </div>
  66. </el-space>
  67. </div>
  68. <div class="btns">
  69. <!-- <el-button size="large" round>重置内容</el-button>-->
  70. <el-button type="primary" size="large" round @click="handlerGenerateImage">生成内容</el-button>
  71. </div>
  72. </template>
  73. <script setup lang="ts">
  74. // image 模型
  75. interface ImageModelVO {
  76. key: string
  77. name: string
  78. image: string
  79. }
  80. // image 大小
  81. interface ImageSizeVO {
  82. key: string
  83. style: string,
  84. }
  85. // 定义属性
  86. const prompt = ref<string>('') // 提示词
  87. const selectHotWord = ref<string>('') // 选中的热词
  88. const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) // 热词
  89. const selectModel = ref<any>() // 选中的热词
  90. const models = ref<ImageModelVO[]>([
  91. {
  92. key: 'qinxi',
  93. name: '清晰',
  94. image: 'https://h5.cxyhub.com/images/model_1.png',
  95. },
  96. {
  97. key: 'ziran',
  98. name: '清晰',
  99. image: 'https://h5.cxyhub.com/images/model_2.png',
  100. },
  101. ]) // 模型
  102. const selectImageSize = ref<ImageSizeVO>({} as ImageSizeVO) // 选中 size
  103. const imageSizeList = ref<ImageSizeVO[]>([
  104. {
  105. key: '1:1',
  106. style: 'width: 30px; height: 30px;background-color: #dcdcdc;',
  107. },
  108. {
  109. key: '3:5',
  110. style: 'width: 30px; height: 50px;background-color: #dcdcdc;',
  111. },
  112. {
  113. key: '5:3',
  114. style: 'width: 50px; height: 30px;background-color: #dcdcdc;',
  115. }
  116. ]) // size
  117. // 定义 Props
  118. const props = defineProps({})
  119. /**
  120. * 热词 - click
  121. */
  122. const handlerHotWordClick = async (hotWord: string) => {
  123. // 取消
  124. if (selectHotWord.value == hotWord) {
  125. selectHotWord.value = ''
  126. return
  127. }
  128. // 选中
  129. selectHotWord.value = hotWord
  130. }
  131. /**
  132. * 模型 - click
  133. */
  134. const handlerModelClick = async (model: ImageModelVO) => {
  135. if (selectModel.value === model) {
  136. selectModel.value = {} as ImageModelVO
  137. return
  138. }
  139. selectModel.value = model
  140. }
  141. /**
  142. * size - click
  143. */
  144. const handlerSizeClick = async (imageSize: ImageSizeVO) => {
  145. if (selectImageSize.value === imageSize) {
  146. selectImageSize.value = {} as ImageSizeVO
  147. return
  148. }
  149. selectImageSize.value = imageSize
  150. console.log(imageSize)
  151. }
  152. /**
  153. * 图片生产
  154. */
  155. const handlerGenerateImage = async () => {
  156. // todo @范 图片生产逻辑
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. // 提示词
  161. .prompt {
  162. }
  163. // 热词
  164. .hot-words {
  165. display: flex;
  166. flex-direction: column;
  167. margin-top: 30px;
  168. .word-list {
  169. display: flex;
  170. flex-direction: row;
  171. flex-wrap: wrap;
  172. justify-content: start;
  173. margin-top: 15px;
  174. .btn {
  175. margin: 0;
  176. }
  177. }
  178. }
  179. // 模型
  180. .model {
  181. margin-top: 30px;
  182. .model-list {
  183. margin-top: 15px;
  184. .modal-item {
  185. width: 110px;
  186. //outline: 1px solid blue;
  187. overflow: hidden;
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. border: 3px solid transparent;
  192. cursor: pointer;
  193. .model-font {
  194. font-size: 14px;
  195. color: #3e3e3e;
  196. font-weight: bold;
  197. }
  198. }
  199. .selectModel {
  200. border: 3px solid #1293ff;
  201. border-radius: 5px;
  202. }
  203. }
  204. }
  205. // 尺寸
  206. .image-size {
  207. width: 100%;
  208. margin-top: 30px;
  209. .size-list {
  210. display: flex;
  211. flex-direction: row;
  212. justify-content: space-between;
  213. width: 100%;
  214. margin-top: 20px;
  215. .size-item {
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. cursor: pointer;
  220. .size-wrapper {
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. justify-content: center;
  225. border-radius: 7px;
  226. padding: 4px;
  227. width: 50px;
  228. height: 50px;
  229. background-color: #fff;
  230. border: 1px solid #fff;
  231. }
  232. .size-font {
  233. font-size: 14px;
  234. color: #3e3e3e;
  235. font-weight: bold;
  236. }
  237. }
  238. }
  239. .selectImageSize {
  240. border: 1px solid #1293ff !important;
  241. }
  242. }
  243. .btns {
  244. display: flex;
  245. justify-content: center;
  246. margin-top: 50px;
  247. }
  248. </style>