Upload.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <script setup lang="ts">
  2. import { ref, reactive, watch, computed } from "vue";
  3. import { useMainStore } from "@/stores/main";
  4. import { required } from "@/utils";
  5. import { useI18n } from "vue-i18n";
  6. import { wsUrl } from "@/env";
  7. import type { VideoCreate } from "@/interfaces";
  8. import type { VideoUploaded } from "@/interfaces";
  9. import router from "@/router";
  10. import Dialog from "@/components/Dialog.vue";
  11. const { t } = useI18n();
  12. const mainStore = useMainStore();
  13. const WS = mainStore.videosWebSocket;
  14. const valid = ref(true);
  15. const title = ref("");
  16. const zipFiles = ref();
  17. const Form = ref();
  18. let anchor = ref(0);
  19. let templateId = ref(0);
  20. let selectAnchor = ref("angela");
  21. let selectTemplate = ref("style1");
  22. // props
  23. let dialog = reactive({
  24. msg: "",
  25. state: "info",
  26. show: false,
  27. });
  28. const anchorList = reactive([
  29. {
  30. anchor_id: "hannah1",
  31. name: "Hannah-1",
  32. },
  33. {
  34. anchor_id: "hannah2",
  35. name: "Hannah-2",
  36. },
  37. {
  38. anchor_id: "nelly",
  39. name: "Nelly",
  40. },
  41. {
  42. anchor_id: "teresa2",
  43. name: "Teresa-2",
  44. },
  45. {
  46. anchor_id: "zoya1",
  47. name: "Zoya-1",
  48. },
  49. {
  50. anchor_id: "zoya2",
  51. name: "Zoya-2",
  52. },
  53. {
  54. anchor_id: "aima",
  55. name: "Aima",
  56. },
  57. {
  58. anchor_id: "alitia",
  59. name: "Alitia",
  60. },
  61. {
  62. anchor_id: "cora",
  63. name: "Cora",
  64. },
  65. {
  66. anchor_id: "elara",
  67. name: "Elara",
  68. },
  69. {
  70. anchor_id: "sporty",
  71. name: "Sporty",
  72. },
  73. {
  74. anchor_id: "angela",
  75. name: "Angela",
  76. },
  77. {
  78. anchor_id: "jocelyn",
  79. name: "Jocelyn",
  80. },
  81. {
  82. anchor_id: "summer",
  83. name: "Summer",
  84. },
  85. {
  86. anchor_id: "peggy",
  87. name: "Peggy",
  88. },
  89. {
  90. anchor_id: "itri-1",
  91. name: "ITRI-1",
  92. },
  93. {
  94. anchor_id: "itri-2",
  95. name: "ITRI-2",
  96. },
  97. {
  98. anchor_id: "itri-3",
  99. name: "ITRI-3",
  100. },
  101. {
  102. anchor_id: "syscom",
  103. name: "James Liu",
  104. },
  105. ]);
  106. const templateList = reactive([
  107. {
  108. template_id: "style1",
  109. img: "鏡面-01",
  110. },
  111. {
  112. template_id: "style2",
  113. img: "鏡面-02",
  114. },
  115. {
  116. template_id: "style3",
  117. img: "鏡面-03",
  118. },
  119. {
  120. template_id: "style4",
  121. img: "鏡面-04",
  122. },
  123. {
  124. template_id: "style5",
  125. img: "鏡面-05",
  126. },
  127. {
  128. template_id: "ITRI_1",
  129. img: "ITRI背景-1",
  130. },
  131. {
  132. template_id: "ITRI_2",
  133. img: "ITRI背景-2",
  134. },
  135. {
  136. template_id: "ITRI_3",
  137. img: "ITRI背景-3",
  138. },
  139. {
  140. template_id: "ITRI_4",
  141. img: "ITRI背景-4",
  142. },
  143. {
  144. template_id: "ITRI_5",
  145. img: "ITRI背景-5",
  146. },
  147. {
  148. template_id: "ITRI_6",
  149. img: "ITRI背景-6",
  150. },
  151. {
  152. template_id: "ITRI_7",
  153. img: "ITRI背景-7",
  154. },
  155. {
  156. template_id: "ITRI_8",
  157. img: "ITRI背景-8",
  158. },
  159. {
  160. template_id: "ITRI_9",
  161. img: "ITRI背景-9",
  162. },
  163. {
  164. template_id: "ITRI_10",
  165. img: "ITRI背景-10",
  166. },
  167. {
  168. template_id: "syscom",
  169. img: "syscom",
  170. },
  171. {
  172. template_id: "凌群2",
  173. img: "syscom-2",
  174. },
  175. ]);
  176. let anchorLang = ref("中文");
  177. let items = reactive([
  178. { lang: "中文", id: 0 },
  179. { lang: "英文", id: 1 },
  180. ]);
  181. // 取得圖片路徑
  182. const getImageUrl = (imgFolder: string, name: string) => {
  183. return new URL(`../../assets/img/${imgFolder}/${name}.webp`, import.meta.url)
  184. .href;
  185. };
  186. watch(dialog, (newVal) => {
  187. if (!newVal.show && newVal.state === "error") {
  188. return;
  189. } else if (!newVal.show && newVal.state === "success") {
  190. router.push("/main/progress");
  191. }
  192. });
  193. watch(anchor, (newVal) => {
  194. selectAnchor.value = anchorList[newVal].anchor_id;
  195. console.log("selectAnchor", selectAnchor.value);
  196. });
  197. watch(templateId, (newVal) => {
  198. selectTemplate.value = templateList[newVal].template_id;
  199. });
  200. async function Submit() {
  201. WS.send("subscribe");
  202. await (Form as any).value.validate();
  203. if (valid.value) {
  204. valid.value = false;
  205. const video_data: VideoCreate = {
  206. title: title.value,
  207. anchor: selectAnchor.value,
  208. style: selectTemplate.value,
  209. lang: "zh",
  210. };
  211. const ret: VideoUploaded = await mainStore.uploadPlot(
  212. video_data,
  213. zipFiles.value[0]
  214. );
  215. if (ret.accepted) {
  216. dialog.msg = t("acceptZipMessage");
  217. dialog.state = "success";
  218. dialog.show = true;
  219. } else {
  220. dialog.msg = ret.error_message!;
  221. dialog.state = "error";
  222. dialog.show = true;
  223. }
  224. valid.value = true;
  225. // (Form as any).value.reset();
  226. }
  227. }
  228. </script>
  229. <template>
  230. <v-container fluid>
  231. <v-card class="ma-3 pa-3">
  232. <v-card-title primary-title>
  233. <h3 class="card-title mb-3">{{ t("makeVideo") }}</h3>
  234. </v-card-title>
  235. <v-card-text>
  236. <v-form v-model="valid" ref="Form">
  237. <v-text-field
  238. :label="$t('videoTitle')"
  239. v-model="title"
  240. :rules="required()"
  241. prepend-icon="title"
  242. >
  243. </v-text-field>
  244. <v-file-input
  245. v-model="zipFiles"
  246. :rules="[(v) => v.length || 'select zip file.']"
  247. accept=".zip"
  248. :label="$t('fileInput')"
  249. prepend-icon="folder_zip"
  250. ></v-file-input>
  251. <!-- <v-select
  252. v-model="anchorLang"
  253. :items="items"
  254. item-title="lang"
  255. item-value="id"
  256. prepend-icon="language"
  257. label="選擇語言"
  258. ></v-select> -->
  259. </v-form>
  260. <v-expansion-panels class="anchor-list">
  261. <v-expansion-panel title="選擇主播">
  262. <v-expansion-panel-text class="p-0">
  263. <v-item-group mandatory v-model="anchor">
  264. <v-container fluid>
  265. <ul>
  266. <li v-for="n in anchorList" :key="n.anchor_id">
  267. <v-item v-slot="{ isSelected, toggle }">
  268. <v-card
  269. :color="isSelected ? 'primary' : ''"
  270. class="d-flex flex-column align-center"
  271. dark
  272. @click="toggle"
  273. :title="n.name"
  274. >
  275. <v-scroll-y-transition>
  276. <!-- <div v-if="n.anchor_id !== 0" class="img-disabled">
  277. <img
  278. :src="getImageUrl('anchor', n.name)"
  279. alt=""
  280. />
  281. <p>Coming Soon</p>
  282. </div> -->
  283. <img :src="getImageUrl('anchor', n.name)" alt="" />
  284. </v-scroll-y-transition>
  285. </v-card>
  286. </v-item>
  287. </li>
  288. </ul>
  289. </v-container>
  290. </v-item-group>
  291. </v-expansion-panel-text>
  292. </v-expansion-panel>
  293. </v-expansion-panels>
  294. <v-expansion-panels class="template-list mt-6">
  295. <v-expansion-panel title="選擇模板">
  296. <v-expansion-panel-text class="p-0">
  297. <v-sheet class="mx-auto">
  298. <v-slide-group
  299. v-model="templateId"
  300. selected-class="bg-primary"
  301. show-arrows
  302. >
  303. <v-slide-group-item
  304. v-for="n in templateList"
  305. :key="n.template_id"
  306. v-slot="{ isSelected, toggle, selectedClass }"
  307. >
  308. <v-card
  309. color="grey-lighten-1"
  310. :class="['ma-4', selectedClass]"
  311. @click="toggle"
  312. >
  313. <span
  314. class="choose-btn"
  315. :class="{ 'active-color': isSelected }"
  316. >
  317. <v-icon icon="done" color="white" />
  318. </span>
  319. <img :src="getImageUrl('template', n.img)" alt="" />
  320. <!-- <div :class="{ 'img-disabled': n.template_id !== 0 }">
  321. <img :src="getImageUrl('template', n.img)" alt="" />
  322. <p v-if="n.template_id !== 0">Coming Soon</p>
  323. </div> -->
  324. </v-card>
  325. </v-slide-group-item>
  326. </v-slide-group>
  327. </v-sheet>
  328. </v-expansion-panel-text>
  329. </v-expansion-panel>
  330. </v-expansion-panels>
  331. </v-card-text>
  332. <v-card-actions>
  333. <v-spacer></v-spacer>
  334. <v-btn @click="Submit" :disabled="!valid" variant="outlined">
  335. {{ t("send") }}
  336. </v-btn>
  337. </v-card-actions>
  338. </v-card>
  339. <v-card class="ma-3 pa-3 mt-8">
  340. <v-card-title primary-title>
  341. <h3 class="text-center">使用教學</h3>
  342. </v-card-title>
  343. <v-card-text>
  344. <ul class="mt-5 step-list">
  345. <li>
  346. <h4>1. 取得快速製作模板</h4>
  347. <p class="excerpt">請點擊下方按鈕取得模板範例</p>
  348. <div class="mb-5">
  349. <a :href="'/example/影片範例.zip'" class="link-btn" download
  350. >點我下載</a
  351. >
  352. </div>
  353. </li>
  354. <li>
  355. <h4>2. 準備影片內容</h4>
  356. <p class="excerpt text-center">
  357. 範例的資料夾內,有 "素材資料夾" 跟 "EXCEL 檔" <br />
  358. (您也可以自行創建資料夾)
  359. </p>
  360. <img src="@/assets/img/step/step-01.png" alt="" class="mb-4" />
  361. <p class="excerpt">素材資料夾裡面放照片或影片</p>
  362. <img src="@/assets/img/step/step-02.png" alt="" />
  363. <small class="d-block ms-4"
  364. >包含內容:圖片/影片(.jpg/.mp4)</small
  365. >
  366. <p class="mt-5 excerpt">
  367. EXCEL 檔整理成這個格式-大標、字幕、素材、發音
  368. </p>
  369. <img src="@/assets/img/step/step-03.png" alt="" />
  370. <ul class="point-list">
  371. <li>
  372. 1. 字幕之間的斷句請使用符號【\】進行換行
  373. <br />
  374. (建議 10 個字內,若超過請使用換行符號)
  375. </li>
  376. <li>2. 大標字數勿超過中文 15 字、英文 30 字</li>
  377. <li>3. 音檔請留空白</li>
  378. </ul>
  379. <p class="mt-5 excerpt">以下為顯示效果:</p>
  380. <img src="@/assets/img/step/step-04.png" alt="" />
  381. <p class="mt-5 excerpt">
  382. 接下來同時選素材資料夾跟 EXCEL 檔,壓縮成 ZIP 檔
  383. </p>
  384. <img src="@/assets/img/step/step-05.png" alt="" class="my-5" />
  385. </li>
  386. <li>
  387. <h4>3. 上傳 ZIP 資料夾至 AI Spokesgirl 平台</h4>
  388. <p class="excerpt">影片檔名請寫上影片名稱</p>
  389. <img src="@/assets/img/step/step-06.png" alt="" />
  390. <h4 class="my-5 caption">
  391. 點選“送出”之後需等待一段影片製作的時間 <br />
  392. 請您耐心等候,待製作完畢可於影片清單查看
  393. </h4>
  394. </li>
  395. </ul>
  396. </v-card-text>
  397. </v-card>
  398. <template>
  399. <div class="text-center">
  400. <Dialog
  401. :msg="dialog.msg"
  402. :state="dialog.state"
  403. :dialog="dialog.show"
  404. @close="dialog.show = false"
  405. ></Dialog>
  406. </div>
  407. </template>
  408. </v-container>
  409. </template>
  410. <style lang="scss">
  411. .anchor-list {
  412. ul {
  413. display: grid;
  414. grid-template-columns: repeat(auto-fit, minmax(185px, max-content));
  415. grid-gap: 20px;
  416. justify-content: center;
  417. padding: initial;
  418. li {
  419. list-style-type: none;
  420. }
  421. }
  422. img {
  423. width: 190px;
  424. height: 155px;
  425. object-fit: cover;
  426. }
  427. .v-card--variant-elevated {
  428. box-shadow: 0px 2px 5px 1px
  429. var(--v-shadow-key-umbra-opacity, rgba(0, 0, 0, 0.2)),
  430. 0px 1px 1px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.14)),
  431. 0px 1px 3px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.12));
  432. }
  433. .v-card-item {
  434. padding: 0;
  435. text-align: center;
  436. .v-card-title {
  437. font-size: 18px;
  438. }
  439. }
  440. .bg-success {
  441. background: linear-gradient(
  442. -225deg,
  443. rgb(234, 84, 19) 35%,
  444. rgb(178, 69, 146) 100%
  445. ) !important;
  446. }
  447. .v-expansion-panel-text__wrapper {
  448. padding: 0 !important;
  449. }
  450. }
  451. .anchor-list,
  452. .template-list {
  453. padding-left: 40px;
  454. .v-expansion-panel-title {
  455. height: 55px;
  456. min-height: 0;
  457. }
  458. }
  459. .template-list {
  460. img {
  461. width: 100%;
  462. height: 180px;
  463. }
  464. .choose-btn {
  465. padding: 5px;
  466. position: absolute;
  467. right: 8px;
  468. bottom: 13px;
  469. background: #ccc;
  470. border-radius: 100px;
  471. }
  472. .active-color {
  473. background: #ea5413;
  474. }
  475. }
  476. .step-list {
  477. list-style: none;
  478. img {
  479. width: 100%;
  480. max-width: 800px;
  481. }
  482. li {
  483. display: flex;
  484. flex-direction: column;
  485. align-items: center;
  486. font-size: 16px;
  487. p {
  488. line-height: 32px;
  489. }
  490. h4 {
  491. margin: 20px auto;
  492. color: #ea5413;
  493. font-weight: bold;
  494. text-align: center;
  495. line-height: 34px;
  496. font-size: 20px;
  497. }
  498. }
  499. .link-btn {
  500. display: inline-block;
  501. padding: 12px 20px;
  502. margin-top: 25px;
  503. border-radius: 100px;
  504. text-decoration: none;
  505. color: #fff;
  506. background: #ea5413;
  507. transition: all 0.3s;
  508. &:hover {
  509. opacity: 0.8;
  510. }
  511. }
  512. .point-list {
  513. display: flex;
  514. flex-direction: column;
  515. align-items: baseline;
  516. margin-left: 40px;
  517. }
  518. .excerpt::before {
  519. content: "";
  520. font-weight: bold;
  521. display: inline-block;
  522. border: 5px solid #ea5413;
  523. border-radius: 20px;
  524. margin-right: 10px;
  525. margin-bottom: 2px;
  526. }
  527. }
  528. .img-disabled {
  529. position: relative;
  530. z-index: 999;
  531. background-color: #ccc;
  532. margin-bottom: -5px;
  533. img {
  534. opacity: 0.7;
  535. }
  536. p {
  537. position: absolute;
  538. top: 50%;
  539. left: 50%;
  540. color: #fff;
  541. transform: translate(-50%, -50%);
  542. font-size: 16px;
  543. text-align: center;
  544. letter-spacing: 1px;
  545. text-shadow: 2px 2px 6px #000;
  546. }
  547. }
  548. .v-card--disabled > :not(.v-card__loader) {
  549. opacity: 1 !important;
  550. }
  551. </style>