index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!-- image -->
  2. <template>
  3. <div class="ai-image">
  4. <div class="left">
  5. <div class="segmented">
  6. <el-segmented v-model="selectModel" :options="modelOptions" />
  7. </div>
  8. <div class="modal-switch-container">
  9. <!-- TODO @fan:1)建议 Dall3 改成 OpenAI 绘图。因为 dall3 其实本质是模型;2)涉及到中英文的地方,中文和英文之间,有个空格哈 -->
  10. <Dall3 v-if="selectModel === 'DALL3绘画'"
  11. @on-draw-start="handlerDrawStart"
  12. @on-draw-complete="handlerDrawComplete" />
  13. <Midjourney v-if="selectModel === 'MJ绘画'" />
  14. <StableDiffusion v-if="selectModel === 'Stable Diffusion'" @on-draw-complete="handlerDrawComplete" />
  15. </div>
  16. </div>
  17. <div class="main">
  18. <ImageTask ref="imageTaskRef" />
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. // TODO @fan:在整个挪到 /views/ai/image/index 目录。因为我想在 /views/ai/image/manager 做管理的功能,进行下区分!
  24. import Dall3 from './dall3/index.vue'
  25. import Midjourney from './midjourney/index.vue'
  26. import StableDiffusion from './stable-diffusion/index.vue'
  27. import ImageTask from './ImageTask.vue'
  28. // ref
  29. const imageTaskRef = ref<any>() // image task ref
  30. // 定义属性
  31. const selectModel = ref('Stable Diffusion')
  32. const modelOptions = ['DALL3绘画', 'MJ绘画', 'Stable Diffusion']
  33. const drawIn = ref<boolean>(false) // 生成中
  34. /** 绘画 - start */
  35. const handlerDrawStart = async (type) => {
  36. // todo
  37. drawIn.value = true
  38. }
  39. /** 绘画 - complete */
  40. const handlerDrawComplete = async (type) => {
  41. drawIn.value = false
  42. // todo
  43. await imageTaskRef.value.getImageList()
  44. }
  45. //
  46. onMounted( async () => {
  47. })
  48. </script>
  49. <style scoped lang="scss">
  50. .ai-image {
  51. position: absolute;
  52. left: 0;
  53. right: 0;
  54. bottom: 0;
  55. top: 0;
  56. display: flex;
  57. flex-direction: row;
  58. height: 100%;
  59. width: 100%;
  60. .left {
  61. display: flex;
  62. flex-direction: column;
  63. padding: 20px;
  64. width: 350px;
  65. .segmented {
  66. }
  67. .segmented .el-segmented {
  68. --el-border-radius-base: 16px;
  69. --el-segmented-item-selected-color: #fff;
  70. background-color: #ececec;
  71. width: 350px;
  72. }
  73. .modal-switch-container {
  74. height: 100%;
  75. overflow-y: auto;
  76. margin-top: 30px;
  77. }
  78. }
  79. .main {
  80. flex: 1;
  81. background-color: #fff;
  82. }
  83. .right {
  84. width: 350px;
  85. background-color: #f7f8fa;
  86. }
  87. }
  88. </style>