index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!-- video -->
  2. <template>
  3. <div class="ai-video">
  4. <div class="left">
  5. <div class="segmented">
  6. <el-segmented v-model="selectPlatform" :options="platformOptions" />
  7. </div>
  8. <div class="modal-switch-container">
  9. <Common
  10. v-if="selectPlatform === 'common'"
  11. ref="commonRef"
  12. :models="models"
  13. @on-draw-complete="handleDrawComplete"
  14. />
  15. <VideoImage
  16. v-if="selectPlatform === 'videoImage'"
  17. ref="VideoImageRef"
  18. :models="models"
  19. @on-draw-complete="handleDrawComplete"
  20. />
  21. <VideoImages
  22. v-if="selectPlatform === 'videoImages'"
  23. ref="VideoImagesRef"
  24. :models="models"
  25. @on-draw-complete="handleDrawComplete"
  26. />
  27. </div>
  28. </div>
  29. <div class="main">
  30. <VideoList ref="videoListRef" @on-regeneration="handleRegeneration" />
  31. </div>
  32. </div>
  33. </template>
  34. <script setup lang="ts">
  35. import VideoList from './components/VideoList.vue'
  36. import { VideoVO } from '@/api/ai/video'
  37. import Common from './components/common/index.vue'
  38. import VideoImage from './components/videoImage/index.vue'
  39. import VideoImages from './components/videoImages/index.vue'
  40. import { ModelApi, ModelVO } from '@/api/ai/model/model'
  41. import { AiModelTypeEnum } from '@/views/ai/utils/constants'
  42. const videoListRef = ref<any>() // video 列表 ref
  43. const commonRef = ref<any>() // stable diffusion ref
  44. // 定义属性
  45. const selectPlatform = ref('common') // 选中的平台
  46. const platformOptions = [
  47. {
  48. label: '通用',
  49. value: 'common'
  50. },
  51. {
  52. label: '图生视频',
  53. value: "videoImage"
  54. },
  55. {
  56. label: '图生集视频',
  57. value: "videoImages"
  58. },
  59. ]
  60. const models = ref<ModelVO[]>([]) // 模型列表
  61. /** 视频 start */
  62. const handleDrawStart = async (platform: string) => {}
  63. /** 视频 complete */
  64. const handleDrawComplete = async (platform: string) => {
  65. await videoListRef.value.getVideoList()
  66. }
  67. /** 重新生成:将画图详情填充到对应平台 */
  68. const handleRegeneration = async (video: VideoVO) => {
  69. // 切换平台
  70. selectPlatform.value = video.platform
  71. // 根据不同平台填充 video
  72. await nextTick()
  73. // if (video.platform === AiPlatformEnum.DOU_BAO) {
  74. // // // 新增:通用平台(包括豆包)使用 commonRef 填充数据
  75. // commonRef.value.settingValues(video)
  76. // }
  77. }
  78. /** 组件挂载的时候 */
  79. onMounted(async () => {
  80. // 获取模型列表
  81. models.value = await ModelApi.getModelSimpleList(AiModelTypeEnum.VIDEO)
  82. })
  83. </script>
  84. <style scoped lang="scss">
  85. .ai-video {
  86. position: absolute;
  87. left: 0;
  88. right: 0;
  89. bottom: 0;
  90. top: 0;
  91. display: flex;
  92. flex-direction: row;
  93. height: 100%;
  94. width: 100%;
  95. .left {
  96. display: flex;
  97. flex-direction: column;
  98. padding: 20px;
  99. width: 390px;
  100. .segmented .el-segmented {
  101. --el-border-radius-base: 16px;
  102. --el-segmented-item-selected-color: #fff;
  103. background-color: #ececec;
  104. width: 350px;
  105. }
  106. .modal-switch-container {
  107. height: 100%;
  108. overflow-y: auto;
  109. margin-top: 30px;
  110. }
  111. }
  112. .main {
  113. flex: 1;
  114. background-color: #fff;
  115. }
  116. .right {
  117. width: 350px;
  118. background-color: #f7f8fa;
  119. }
  120. }
  121. </style>