GenVideo.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <script setup lang="ts">
  2. import { ref, reactive, watch } from "vue";
  3. import { useMainStore } from "@/stores/main";
  4. import { required, emailRules } from "@/utils";
  5. import { useI18n } from "vue-i18n";
  6. import { wsUrl } from "@/env";
  7. import router from "@/router";
  8. import Navbar from "@/components/Navbar.vue";
  9. const { t } = useI18n();
  10. const mainStore = useMainStore();
  11. const WS = mainStore.videosWebSocket;
  12. const valid = ref(true);
  13. const Form = ref();
  14. let dialog = ref(false);
  15. let paragraphList = reactive([""]);
  16. // 新增段落
  17. function addParagraph() {
  18. paragraphList.push("");
  19. }
  20. let data = reactive({
  21. model: "sd3",
  22. email: "",
  23. lang: "zh",
  24. });
  25. // let model = ref("sd3");
  26. let loading = ref(false);
  27. const zipFile = ref(); // 儲存 ZIP 檔案
  28. async function generateVideo() {
  29. console.log("data", data);
  30. loading.value = true;
  31. const response: any = await mainStore.generateVideo(data, paragraphList);
  32. if (response[0].status === 200) {
  33. loading.value = false;
  34. alert("影片已開始製作,請留意來自我們的信件,謝謝!");
  35. dialog.value = false;
  36. }
  37. console.log("response", response);
  38. }
  39. </script>
  40. <template>
  41. <Navbar />
  42. <v-container fluid class="mt-16">
  43. <v-row class="justify-center">
  44. <v-col cols="10">
  45. <v-card class="ma-3 py-8 px-16">
  46. <v-card-title class="text-center" primary-title>
  47. <h3 class="card-title mb-3">
  48. 自動製作影片(試用版)<br />
  49. <small>Gen Video</small>
  50. </h3>
  51. </v-card-title>
  52. <v-card-text>
  53. <v-form v-model="valid" ref="Form">
  54. <!-- <div class="d-flex justify-center mb-10">
  55. <div class="pe-10 border-e-sm">
  56. <p>Model</p>
  57. <v-radio-group
  58. v-model="data.model"
  59. color="primary"
  60. class="mt-2"
  61. hide-details
  62. inline
  63. style="margin-left: -10px"
  64. >
  65. <v-radio label="flux" value="flux"></v-radio>
  66. <v-radio label="sd3" value="sd3" class="ms-2"></v-radio>
  67. </v-radio-group>
  68. </div>
  69. <div class="ms-10">
  70. <p>使用語言</p>
  71. <v-radio-group
  72. v-model="data.lang"
  73. color="primary"
  74. class="mt-2"
  75. hide-details
  76. inline
  77. style="margin-left: -10px"
  78. >
  79. <v-radio label="中文" value="zh"></v-radio>
  80. <v-radio label="en" value="en" class="ms-2"></v-radio>
  81. </v-radio-group>
  82. </div>
  83. </div> -->
  84. <div class="mb-7">
  85. <p>使用語言</p>
  86. <v-radio-group
  87. v-model="data.lang"
  88. color="primary"
  89. class="mt-2"
  90. hide-details
  91. inline
  92. style="margin-left: -10px"
  93. >
  94. <v-radio label="中文" value="zh"></v-radio>
  95. <v-radio label="en" value="en" class="ms-2"></v-radio>
  96. </v-radio-group>
  97. </div>
  98. <v-text-field
  99. v-for="(item, index) in paragraphList"
  100. :label="`${t('paragraph')} ${index + 1}`"
  101. v-model="paragraphList[index]"
  102. :rules="required()"
  103. prepend-icon="title"
  104. >
  105. </v-text-field>
  106. <v-btn
  107. @click="addParagraph()"
  108. size="large"
  109. color="primary"
  110. variant="tonal"
  111. class="w-100 text-white mt-5 mb-2"
  112. >
  113. {{ t("addParagraph") }}
  114. </v-btn>
  115. </v-form>
  116. </v-card-text>
  117. </v-card>
  118. </v-col>
  119. </v-row>
  120. <div class="ma-3 mt-10 d-flex justify-center">
  121. <v-btn
  122. @click="dialog = true"
  123. size="large"
  124. color="primary"
  125. variant="flat"
  126. class="h-auto"
  127. >
  128. <span class="d-flex flex-column py-2">
  129. <p class="mb-1">生成影片</p>
  130. <small>Generate Video</small>
  131. </span>
  132. </v-btn>
  133. </div>
  134. <v-dialog v-model="dialog" width="700">
  135. <v-card class="pa-5">
  136. <v-card-title class="font-weight-bold text-center">
  137. 請輸入您的信箱
  138. </v-card-title>
  139. <v-card-text>
  140. <v-text-field
  141. v-model="data.email"
  142. :rules="emailRules()"
  143. label="電子郵件"
  144. required
  145. variant="solo"
  146. ></v-text-field>
  147. <p class="py-3">影片完成後我們會將影片寄送至您的信箱。</p>
  148. </v-card-text>
  149. <v-card-actions>
  150. <v-btn
  151. @click="generateVideo()"
  152. class="mx-auto"
  153. color="primary"
  154. variant="flat"
  155. size="large"
  156. :loading="loading"
  157. >
  158. {{ t("send") }}
  159. </v-btn>
  160. </v-card-actions>
  161. </v-card>
  162. </v-dialog>
  163. </v-container>
  164. </template>
  165. <style lang="scss">
  166. .anchor-list {
  167. ul {
  168. display: grid;
  169. grid-template-columns: repeat(auto-fit, minmax(185px, max-content));
  170. grid-gap: 20px;
  171. justify-content: center;
  172. padding: initial;
  173. li {
  174. list-style-type: none;
  175. }
  176. }
  177. img {
  178. width: 190px;
  179. height: 155px;
  180. object-fit: cover;
  181. }
  182. .v-card--variant-elevated {
  183. box-shadow: 0px 2px 5px 1px
  184. var(--v-shadow-key-umbra-opacity, rgba(0, 0, 0, 0.2)),
  185. 0px 1px 1px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.14)),
  186. 0px 1px 3px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.12));
  187. }
  188. .v-card-item {
  189. padding: 0;
  190. text-align: center;
  191. .v-card-title {
  192. font-size: 18px;
  193. }
  194. }
  195. .bg-success {
  196. background: linear-gradient(
  197. -225deg,
  198. rgb(234, 84, 19) 35%,
  199. rgb(178, 69, 146) 100%
  200. ) !important;
  201. }
  202. .v-expansion-panel-text__wrapper {
  203. padding: 0 !important;
  204. }
  205. }
  206. .anchor-list,
  207. .template-list {
  208. padding-left: 40px;
  209. .v-expansion-panel-title {
  210. height: 55px;
  211. min-height: 0;
  212. }
  213. }
  214. .template-list {
  215. img {
  216. width: 100%;
  217. height: 180px;
  218. }
  219. .choose-btn {
  220. padding: 5px;
  221. position: absolute;
  222. right: 8px;
  223. bottom: 13px;
  224. background: #ccc;
  225. border-radius: 100px;
  226. }
  227. .active-color {
  228. background: #ea5413;
  229. }
  230. }
  231. .step-list {
  232. list-style: none;
  233. img {
  234. width: 100%;
  235. max-width: 1000px;
  236. }
  237. li {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. font-size: 16px;
  242. p {
  243. line-height: 32px;
  244. }
  245. h4 {
  246. margin: 20px auto;
  247. color: #ea5413;
  248. font-weight: bold;
  249. text-align: center;
  250. line-height: 34px;
  251. font-size: 20px;
  252. }
  253. }
  254. .link-btn {
  255. display: inline-block;
  256. padding: 12px 20px;
  257. margin-top: 25px;
  258. border-radius: 100px;
  259. text-decoration: none;
  260. color: #fff;
  261. background: #ea5413;
  262. transition: all 0.3s;
  263. &:hover {
  264. opacity: 0.8;
  265. }
  266. }
  267. .point-list {
  268. display: flex;
  269. flex-direction: column;
  270. align-items: baseline;
  271. margin-left: 40px;
  272. }
  273. .point-content {
  274. .base,
  275. .advanced {
  276. padding: 40px;
  277. margin-top: 50px;
  278. max-width: 1000px;
  279. letter-spacing: 1px;
  280. border-radius: 5px;
  281. }
  282. .base {
  283. border: 4px solid #ea5413;
  284. }
  285. .advanced {
  286. border: 4px dashed #ea5413;
  287. }
  288. ul {
  289. display: flex;
  290. flex-direction: column;
  291. align-items: flex-start;
  292. li {
  293. margin: 5px 0;
  294. }
  295. }
  296. h5 {
  297. margin-bottom: 20px;
  298. text-align: center;
  299. font-size: 1.25rem;
  300. }
  301. hr {
  302. margin: 30px;
  303. border-color: #f2f2f2;
  304. opacity: 0.3;
  305. }
  306. }
  307. .excerpt::before {
  308. content: "";
  309. font-weight: bold;
  310. display: inline-block;
  311. border: 5px solid #ea5413;
  312. border-radius: 20px;
  313. margin-right: 10px;
  314. margin-bottom: 2px;
  315. }
  316. }
  317. .img-disabled {
  318. position: relative;
  319. z-index: 999;
  320. background-color: #ccc;
  321. margin-bottom: -5px;
  322. img {
  323. opacity: 0.7;
  324. }
  325. p {
  326. position: absolute;
  327. top: 50%;
  328. left: 50%;
  329. color: #fff;
  330. transform: translate(-50%, -50%);
  331. font-size: 16px;
  332. text-align: center;
  333. letter-spacing: 1px;
  334. text-shadow: 2px 2px 6px #000;
  335. }
  336. }
  337. .v-card--disabled > :not(.v-card__loader) {
  338. opacity: 1 !important;
  339. }
  340. </style>