Upload.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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 { useDisplay } from "vuetify";
  7. import type { VideoCreate } from "@/interfaces";
  8. import router from "@/router";
  9. const { t } = useI18n();
  10. const { name } = useDisplay();
  11. const width = computed(() => {
  12. switch (name.value) {
  13. case "xs":
  14. return 6;
  15. case "sm":
  16. return 4;
  17. case "md":
  18. return 3;
  19. case "lg":
  20. return 2;
  21. }
  22. return "auto";
  23. });
  24. const valid = ref(true);
  25. const dialog = ref(false);
  26. const title = ref("");
  27. const zipFiles = ref();
  28. const Form = ref();
  29. let anchor = ref(0);
  30. let templateId = ref(0);
  31. const anchorList = reactive([
  32. {
  33. anchor_id: 0,
  34. language_id: 1,
  35. name: "Peggy",
  36. },
  37. {
  38. anchor_id: 1,
  39. language_id: 1,
  40. name: "Jocelyn",
  41. },
  42. {
  43. anchor_id: 2,
  44. language_id: 1,
  45. name: "Summer",
  46. },
  47. {
  48. anchor_id: 3,
  49. language_id: 1,
  50. name: "Angela",
  51. },
  52. {
  53. anchor_id: 4,
  54. language_id: 1,
  55. name: "主播-01",
  56. },
  57. {
  58. anchor_id: 5,
  59. language_id: 1,
  60. name: "主播-02",
  61. },
  62. {
  63. anchor_id: 6,
  64. language_id: 1,
  65. name: "主播-03",
  66. },
  67. {
  68. anchor_id: 7,
  69. language_id: 1,
  70. name: "主播-04",
  71. },
  72. {
  73. anchor_id: 8,
  74. language_id: 1,
  75. name: "主播-05",
  76. },
  77. {
  78. anchor_id: 9,
  79. language_id: 1,
  80. name: "主播-06",
  81. },
  82. {
  83. anchor_id: 10,
  84. language_id: 1,
  85. name: "主播-07",
  86. },
  87. ]);
  88. const templateList = reactive([
  89. {
  90. template_id: 0,
  91. img: "../src/assets/img/template/鏡面-01.webp",
  92. },
  93. {
  94. template_id: 1,
  95. img: "../src/assets/img/template/鏡面-02.webp",
  96. },
  97. {
  98. template_id: 2,
  99. img: "../src/assets/img/template/鏡面-03.webp",
  100. },
  101. {
  102. template_id: 3,
  103. img: "../src/assets/img/template/鏡面-04.webp",
  104. },
  105. {
  106. template_id: 4,
  107. img: "../src/assets/img/template/鏡面-05.webp",
  108. },
  109. {
  110. template_id: 5,
  111. img: "../src/assets/img/template/鏡面-06.webp",
  112. },
  113. ]);
  114. let anchorLang = ref("中文");
  115. let items = reactive([
  116. { lang: "中文", id: 0 },
  117. { lang: "英文", id: 1 },
  118. ]);
  119. // 取得圖片路徑
  120. const getImageUrl = (imgFolder: string, name: string) => {
  121. return new URL(`../../assets/img/${imgFolder}/${name}.webp`, import.meta.url)
  122. .href;
  123. };
  124. const mainStore = useMainStore();
  125. watch(dialog, (newVal, oldVal) => {
  126. if (!newVal) {
  127. router.push("/main/progress");
  128. }
  129. });
  130. async function Submit() {
  131. setTimeout(() => {
  132. dialog.value = true;
  133. }, 2000);
  134. await (Form as any).value.validate();
  135. if (valid.value) {
  136. valid.value = false;
  137. const video_data: VideoCreate = {
  138. title: title.value,
  139. anchor_id: anchor.value,
  140. lang_id: 0,
  141. };
  142. await mainStore.uploadPlot(video_data, zipFiles.value[0]);
  143. // (Form as any).value.reset();
  144. }
  145. }
  146. </script>
  147. <template>
  148. <v-container fluid>
  149. <v-card class="ma-3 pa-3">
  150. <v-card-title primary-title>
  151. <h3 class="card-title mb-3">{{ t("makeVideo") }}</h3>
  152. </v-card-title>
  153. <v-card-text>
  154. <v-form v-model="valid" ref="Form">
  155. <v-text-field
  156. :label="$t('videoTitle')"
  157. v-model="title"
  158. :rules="required"
  159. prepend-icon="title"
  160. >
  161. </v-text-field>
  162. <v-file-input
  163. v-model="zipFiles"
  164. :rules="[(v) => v.length || 'select zip file.']"
  165. accept=".zip"
  166. :label="$t('fileInput')"
  167. prepend-icon="folder_zip"
  168. ></v-file-input>
  169. <!-- <v-select
  170. v-model="anchorLang"
  171. :items="items"
  172. item-title="lang"
  173. item-value="id"
  174. prepend-icon="language"
  175. label="選擇語言"
  176. ></v-select> -->
  177. </v-form>
  178. <v-expansion-panels class="anchor-list">
  179. <v-expansion-panel title="選擇主播">
  180. <v-expansion-panel-text class="p-0">
  181. <v-item-group mandatory v-model="anchor">
  182. <v-container fluid>
  183. <ul>
  184. <li v-for="n in anchorList" :key="n.anchor_id">
  185. <v-item v-slot="{ isSelected, toggle }">
  186. <v-card
  187. :color="isSelected ? 'primary' : ''"
  188. class="d-flex flex-column align-center"
  189. dark
  190. @click="toggle"
  191. :title="n.name"
  192. >
  193. <v-scroll-y-transition>
  194. <img :src="getImageUrl('anchor', n.name)" alt="" />
  195. </v-scroll-y-transition>
  196. </v-card>
  197. </v-item>
  198. </li>
  199. </ul>
  200. </v-container>
  201. </v-item-group>
  202. </v-expansion-panel-text>
  203. </v-expansion-panel>
  204. </v-expansion-panels>
  205. <v-expansion-panels class="template-list mt-6">
  206. <v-expansion-panel title="選擇模板">
  207. <v-expansion-panel-text class="p-0">
  208. <v-sheet class="mx-auto">
  209. <v-slide-group
  210. v-model="anchor"
  211. selected-class="bg-primary"
  212. show-arrows
  213. >
  214. <v-slide-group-item
  215. v-for="n in templateList"
  216. :key="n.template_id"
  217. v-slot="{ isSelected, toggle, selectedClass }"
  218. >
  219. <v-card
  220. color="grey-lighten-1"
  221. :class="['ma-4', selectedClass]"
  222. @click="toggle"
  223. >
  224. <span
  225. class="choose-btn"
  226. :class="{ 'active-color': isSelected }"
  227. >
  228. <v-icon icon="done" color="white" />
  229. </span>
  230. <img :src="n.img" alt="" />
  231. </v-card>
  232. </v-slide-group-item>
  233. </v-slide-group>
  234. </v-sheet>
  235. </v-expansion-panel-text>
  236. </v-expansion-panel>
  237. </v-expansion-panels>
  238. </v-card-text>
  239. <v-card-actions>
  240. <v-spacer></v-spacer>
  241. <v-btn @click="Submit" :disabled="!valid">
  242. {{ t("send") }}
  243. </v-btn>
  244. </v-card-actions>
  245. </v-card>
  246. <v-card class="ma-3 pa-3 mt-8">
  247. <v-card-title primary-title>
  248. <h3 class="text-center">使用教學</h3>
  249. </v-card-title>
  250. <v-card-text>
  251. <ul class="mt-5 step-list">
  252. <li>
  253. <h4>1. 取得快速製作模板</h4>
  254. <p class="excerpt">請點擊下方按鈕取得模板範例</p>
  255. <div class="mb-5">
  256. <a :href="'/example/影片範例.zip'" class="link-btn" download
  257. >點我下載</a
  258. >
  259. </div>
  260. </li>
  261. <li>
  262. <h4>2. 準備影片內容</h4>
  263. <p class="excerpt text-center">
  264. 範例的資料夾內,有 "素材資料夾" 跟 "EXCEL 檔" <br />
  265. (您也可以自行創建資料夾)
  266. </p>
  267. <img src="@/assets/img/step/step-01.png" alt="" class="mb-4" />
  268. <p class="excerpt">素材資料夾裡面放照片或影片</p>
  269. <img src="@/assets/img/step/step-02.png" alt="" />
  270. <small class="d-block ms-4"
  271. >包含內容:圖片/影片(.jpg/.mp4)</small
  272. >
  273. <p class="mt-5 excerpt">
  274. EXCEL 檔整理成這個格式-大標、字幕、素材、發音
  275. </p>
  276. <img src="@/assets/img/step/step-03.png" alt="" />
  277. <ul class="point-list">
  278. <li>
  279. 1. 字幕之間的斷句請使用符號【\】進行換行
  280. <br />
  281. (建議 10 個字內,若超過請使用換行符號)
  282. </li>
  283. <li>2. 字幕段落勿超過中文 25 字、英文 50 字</li>
  284. <li>3. 大標字數勿超過中文 15 字、英文 30 字</li>
  285. <li>4. 音檔請留空白</li>
  286. </ul>
  287. <p class="mt-5 excerpt">以下為顯示效果:</p>
  288. <img src="@/assets/img/step/step-04.png" alt="" />
  289. <p class="mt-5 excerpt">
  290. 接下來同時選素材資料夾跟 EXCEL 檔,壓縮成 ZIP 檔
  291. </p>
  292. <img src="@/assets/img/step/step-05.png" alt="" class="my-5" />
  293. </li>
  294. <li>
  295. <h4>3. 上傳 ZIP 資料夾至 AI Spokesgirl 平台</h4>
  296. <p class="excerpt">影片檔名請寫上影片名稱</p>
  297. <img src="@/assets/img/step/step-06.png" alt="" />
  298. <h4 class="my-5 caption">
  299. 點選“送出”之後需等待一段影片製作的時間 <br />
  300. 請您耐心等候,待製作完畢可於影片清單查看
  301. </h4>
  302. </li>
  303. </ul>
  304. </v-card-text>
  305. </v-card>
  306. <template>
  307. <div class="text-center">
  308. <v-dialog v-model="dialog" width="auto">
  309. <v-card>
  310. <v-card-text>
  311. <section class="d-flex flex-column align-center">
  312. <v-icon
  313. style="font-size: 70px"
  314. icon="info"
  315. color="orange-darken-3"
  316. />
  317. <p class="mt-3">影片處理需要約 5-10 分鐘,敬請耐心等候</p>
  318. </section>
  319. </v-card-text>
  320. <v-card-actions>
  321. <v-btn color="primary" block @click="dialog = false">{{
  322. t("close")
  323. }}</v-btn>
  324. </v-card-actions>
  325. </v-card>
  326. </v-dialog>
  327. </div>
  328. </template>
  329. </v-container>
  330. </template>
  331. <style lang="scss">
  332. .anchor-list {
  333. ul {
  334. display: grid;
  335. grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
  336. grid-gap: 20px;
  337. justify-content: center;
  338. padding: initial;
  339. li {
  340. list-style-type: none;
  341. }
  342. }
  343. img {
  344. width: 100%;
  345. height: 140px;
  346. object-fit: cover;
  347. }
  348. .v-card--variant-elevated {
  349. box-shadow: 0px 2px 5px 1px
  350. var(--v-shadow-key-umbra-opacity, rgba(0, 0, 0, 0.2)),
  351. 0px 1px 1px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.14)),
  352. 0px 1px 3px 0px var(--v-shadow-key-penumbra-opacity, rgba(0, 0, 0, 0.12));
  353. }
  354. .v-card-item {
  355. padding: 0;
  356. text-align: center;
  357. .v-card-title {
  358. font-size: 18px;
  359. }
  360. }
  361. .bg-success {
  362. background: linear-gradient(
  363. -225deg,
  364. rgb(234, 84, 19) 35%,
  365. rgb(178, 69, 146) 100%
  366. ) !important;
  367. }
  368. .v-expansion-panel-text__wrapper {
  369. padding: 0 !important;
  370. }
  371. }
  372. .anchor-list,
  373. .template-list {
  374. padding-left: 40px;
  375. .v-expansion-panel-title {
  376. height: 55px;
  377. min-height: 0;
  378. }
  379. }
  380. .template-list {
  381. img {
  382. width: 100%;
  383. height: 180px;
  384. }
  385. .choose-btn {
  386. padding: 5px;
  387. position: absolute;
  388. right: 8px;
  389. bottom: 13px;
  390. background: #ccc;
  391. border-radius: 100px;
  392. }
  393. .active-color {
  394. background: #ea5413;
  395. }
  396. }
  397. .step-list {
  398. list-style: none;
  399. img {
  400. width: 100%;
  401. max-width: 800px;
  402. }
  403. li {
  404. display: flex;
  405. flex-direction: column;
  406. align-items: center;
  407. font-size: 16px;
  408. p {
  409. line-height: 32px;
  410. }
  411. h4 {
  412. margin: 20px auto;
  413. color: #ea5413;
  414. font-weight: bold;
  415. text-align: center;
  416. line-height: 34px;
  417. font-size: 20px;
  418. }
  419. }
  420. .link-btn {
  421. display: inline-block;
  422. padding: 12px 20px;
  423. margin-top: 25px;
  424. border-radius: 100px;
  425. text-decoration: none;
  426. color: #fff;
  427. background: #ea5413;
  428. transition: all 0.3s;
  429. &:hover {
  430. opacity: 0.8;
  431. }
  432. }
  433. .point-list {
  434. display: flex;
  435. flex-direction: column;
  436. align-items: baseline;
  437. margin-left: 40px;
  438. }
  439. .excerpt::before {
  440. content: "";
  441. font-weight: bold;
  442. display: inline-block;
  443. border: 5px solid #ea5413;
  444. border-radius: 20px;
  445. margin-right: 10px;
  446. margin-bottom: 2px;
  447. }
  448. }
  449. </style>