VoiceMatrix.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. <template>
  2. <div v-if="curQue" class="voice-matrix">
  3. <div class="voice-matrix-audio">
  4. <div v-if="curQue.voiceMatrix.isAudioNumber" class="audio-number">
  5. <span
  6. :class="[
  7. themeColor.length === 0 || themeColor === 'red'
  8. ? 'serial-number'
  9. : `serial-number-${themeColor}`
  10. ]"
  11. >
  12. {{ curQue.voiceMatrix.audioSerialNumber }}
  13. </span>
  14. </div>
  15. <div v-show="hasSelectedCell" class="audio-simple">
  16. <img :src="playing ? voicePlaySrc : voicePauseSrc" @click="playAudio">
  17. <span
  18. :class="['Repeat-16', isRepeat ? '' : 'disabled']"
  19. @click="isRepeat = !isRepeat"
  20. />
  21. </div>
  22. <audio-line
  23. v-show="!hasSelectedCell"
  24. ref="audioLine"
  25. audio-id="voiceMatrixAudio"
  26. :mp3="mp3Url"
  27. :get-cur-time="getCurTime"
  28. :stop-audio="stopAudio"
  29. :mp3-source="mp3Source"
  30. @handleChangeStopAudio="handleChangeStopAudio"
  31. @playChange="playChange"
  32. />
  33. </div>
  34. <!-- 语音矩阵 -->
  35. <div class="voice-matrix-container">
  36. <div
  37. v-if="curQue.voiceMatrix.matrix.length > 0"
  38. class="matrix"
  39. :style="{
  40. 'grid-template': `36px repeat(${curQue.voiceMatrix.matrix.length}, auto) minmax(36px, 1fr) / 36px repeat(${curQue.voiceMatrix.matrix[0].length}, auto) minmax(36px, 1fr)`
  41. }"
  42. @mouseleave="clearSelectCell"
  43. >
  44. <!-- 顶部单元格 -->
  45. <div class="matrix-top" @mouseenter="clearSelectCell" />
  46. <template v-for="(row, i) in curQue.voiceMatrix.matrix[0]">
  47. <div
  48. :key="`top-${i}`"
  49. :class="[
  50. 'matrix-top',
  51. curQue.voiceMatrix.columnSelection &&
  52. (selectColumn === i ||
  53. (selectedLine.type === 'column' && selectedLine.index === i))
  54. ? 'read'
  55. : ''
  56. ]"
  57. @mouseenter="checkboxMouseenter(selectColumn === i, 'column')"
  58. >
  59. <span
  60. v-if="
  61. row.type !== 'connection' && curQue.voiceMatrix.columnSelection
  62. "
  63. v-show="
  64. selectColumn === i ||
  65. (selectedLine.type === 'column' && selectedLine.index === i)
  66. "
  67. :class="[
  68. `matrix-checkbox-row-${themeColor}`,
  69. selectedLine.type === 'column' && selectedLine.index === i
  70. ? 'active'
  71. : ''
  72. ]"
  73. @click="selectRowOrColumn(i, 'column')"
  74. />
  75. </div>
  76. </template>
  77. <div class="matrix-top" @mouseenter="clearSelectCell" />
  78. <!-- 主矩阵 -->
  79. <template v-for="(row, i) in curQue.voiceMatrix.matrix">
  80. <div
  81. :key="`start-${i}`"
  82. :class="[
  83. 'column-wrapper',
  84. curQue.voiceMatrix.rowSelection &&
  85. (selectRow === i ||
  86. (selectedLine.type === 'row' && selectedLine.index === i))
  87. ? 'read'
  88. : ''
  89. ]"
  90. @mouseenter="checkboxMouseenter(selectRow === i, 'row')"
  91. >
  92. <span
  93. v-if="curQue.voiceMatrix.rowSelection"
  94. v-show="
  95. selectRow === i ||
  96. (selectedLine.type === 'row' && selectedLine.index === i)
  97. "
  98. :class="[
  99. `matrix-checkbox-column-${themeColor}`,
  100. selectedLine.type === 'row' && selectedLine.index === i
  101. ? 'active'
  102. : ''
  103. ]"
  104. @click="selectRowOrColumn(i, 'row')"
  105. />
  106. </div>
  107. <!-- 单元格 -->
  108. <template v-for="(column, j) in row">
  109. <div
  110. :key="`wrapper-${i}-${j}`"
  111. :class="[
  112. 'column-wrapper',
  113. (curQue.voiceMatrix.rowSelection && selectRow === i) ||
  114. (curQue.voiceMatrix.columnSelection && selectColumn === j) ||
  115. (curQue.voiceMatrix.columnSelection &&
  116. selectedLine.type === 'column' &&
  117. selectedLine.index === j) ||
  118. (curQue.voiceMatrix.rowSelection &&
  119. selectedLine.type === 'row' &&
  120. selectedLine.index === i)
  121. ? 'read'
  122. : '',
  123. (i === 0 && curQue.voiceMatrix.firstLineHighlight) ||
  124. (j === row.length - 1 && curQue.voiceMatrix.lastColumnHighlight)
  125. ? `highlight-${themeColor}`
  126. : ''
  127. ]"
  128. @mouseenter="matrixCellMouseenter(i, j, column.type)"
  129. >
  130. <!-- 文本 -->
  131. <div
  132. v-if="column.type === 'text'"
  133. :key="`column-${i}-${j}`"
  134. :class="[
  135. column.text.length === 0 ? 'space' : `column-${themeColor}`,
  136. (selectCell.row === i && selectCell.column === j) ||
  137. (selectedLine.type === 'column' &&
  138. selectedLine.index === j) ||
  139. (selectedLine.type === 'row' && selectedLine.index === i)
  140. ? 'selected'
  141. : '',
  142. playing &&
  143. column.lrc_data.begin_time / 1000 <= curTime &&
  144. (curTime < column.lrc_data.end_time / 1000 ||
  145. column.lrc_data.end_time === -1)
  146. ? 'playing'
  147. : '',
  148. column.isTitle ? 'title' : ''
  149. ]"
  150. @click="matrixCellClick(i, j)"
  151. >
  152. <span>{{ column.text }}</span>
  153. </div>
  154. <!-- 连接线 -->
  155. <div
  156. v-else-if="column.type === 'connection'"
  157. :key="`column-${i}-${j}`"
  158. :class="[
  159. 'connection',
  160. i === 0 && curQue.voiceMatrix.firstLineHighlight
  161. ? `highlight-bc-${themeColor}`
  162. : ''
  163. ]"
  164. />
  165. <!-- 分词 -->
  166. <div
  167. v-else-if="column.type === 'SentenceSegwordChs'"
  168. :key="`column-${i}-${j}`"
  169. :class="[
  170. `sentence-${themeColor}`,
  171. (selectCell.row === i && selectCell.column === j) ||
  172. (selectedLine.type === 'column' &&
  173. selectedLine.index === j) ||
  174. (selectedLine.type === 'row' && selectedLine.index === i)
  175. ? 'selected'
  176. : '',
  177. playing &&
  178. column.lrc_data.begin_time / 1000 <= curTime &&
  179. (curTime < column.lrc_data.end_time / 1000 ||
  180. column.lrc_data.end_time === -1)
  181. ? 'playing'
  182. : '',
  183. column.isTitle ? 'title' : ''
  184. ]"
  185. :style="{
  186. 'grid-template-columns': `repeat(${column.sentence_data.wordsList.length}, auto)`
  187. }"
  188. @click="matrixCellClick(i, j)"
  189. >
  190. <template v-for="(word, w) in column.sentence_data.wordsList">
  191. <span
  192. v-if="column.sentence_data.pyPosition === 'top'"
  193. :key="`pinyin-${w}`"
  194. class="pinyin"
  195. >
  196. {{ word.pinyin }}
  197. </span>
  198. <span v-else :key="`chs-${w}`" class="chs">
  199. {{ word.chs }}
  200. </span>
  201. </template>
  202. <template v-for="(word, w) in column.sentence_data.wordsList">
  203. <span
  204. v-if="column.sentence_data.pyPosition === 'top'"
  205. :key="`chs-${w}`"
  206. class="chs"
  207. >
  208. {{ word.chs }}
  209. </span>
  210. <span v-else :key="`pinyin-${w}`" class="pinyin">
  211. {{ word.pinyin }}
  212. </span>
  213. </template>
  214. </div>
  215. <!-- 拼音 + 英文 -->
  216. <div
  217. v-else-if="column.type === 'PinyinEnglish'"
  218. :key="`column-${i}-${j}`"
  219. :class="[
  220. `pinyinEnglish-${themeColor}`,
  221. (selectCell.row === i && selectCell.column === j) ||
  222. (selectedLine.type === 'column' &&
  223. selectedLine.index === j) ||
  224. (selectedLine.type === 'row' && selectedLine.index === i)
  225. ? 'selected'
  226. : '',
  227. playing &&
  228. column.lrc_data.begin_time / 1000 <= curTime &&
  229. (curTime < column.lrc_data.end_time / 1000 ||
  230. column.lrc_data.end_time === -1)
  231. ? 'playing'
  232. : '',
  233. column.isTitle ? 'title' : ''
  234. ]"
  235. @click="matrixCellClick(i, j)"
  236. >
  237. <div class="inside-wrapper">
  238. <div class="pinyin">
  239. {{ column.pinyin_english_data.pinyin }}
  240. </div>
  241. <div class="english">
  242. {{ column.pinyin_english_data.english }}
  243. </div>
  244. </div>
  245. </div>
  246. <!-- 文本中有括号 -->
  247. <div
  248. v-else-if="column.type === 'textBrackets'"
  249. :key="`column-${i}-${j}`"
  250. :class="[
  251. `textBrackets-${themeColor}`,
  252. (selectCell.row === i && selectCell.column === j) ||
  253. (selectedLine.type === 'column' &&
  254. selectedLine.index === j) ||
  255. (selectedLine.type === 'row' && selectedLine.index === i)
  256. ? 'selected'
  257. : '',
  258. playing &&
  259. column.lrc_data.begin_time / 1000 <= curTime &&
  260. (curTime < column.lrc_data.end_time / 1000 ||
  261. column.lrc_data.end_time === -1)
  262. ? 'playing'
  263. : '',
  264. column.isTitle ? 'title' : ''
  265. ]"
  266. @click="matrixCellClick(i, j)"
  267. >
  268. <span>
  269. <span class="brackets-text">{{
  270. column.text_brackets.brackets_outer
  271. }}</span>
  272. <span class="brackets">&nbsp;[&nbsp;</span>
  273. <span class="brackets-text">{{
  274. column.text_brackets.brackets_inner
  275. }}</span>
  276. <span class="brackets">&nbsp;]</span>
  277. </span>
  278. </div>
  279. </div>
  280. </template>
  281. <div
  282. :key="`end-${i}`"
  283. :class="[
  284. curQue.voiceMatrix.rowSelection &&
  285. (selectRow === i ||
  286. (selectedLine.type === 'row' && selectedLine.index === i))
  287. ? 'read'
  288. : ''
  289. ]"
  290. @mouseenter="clearSelectCell"
  291. />
  292. </template>
  293. <!-- 底部格子 -->
  294. <div class="matrix-bottom" @mouseenter="clearSelectCell" />
  295. <template v-for="(row, i) in curQue.voiceMatrix.matrix[0]">
  296. <div
  297. :key="`bottom-${i}`"
  298. :class="[
  299. 'matrix-bottom',
  300. curQue.voiceMatrix.columnSelection &&
  301. (selectColumn === i ||
  302. (selectedLine.type === 'column' && selectedLine.index === i))
  303. ? 'read'
  304. : ''
  305. ]"
  306. @mouseenter="clearSelectCell"
  307. />
  308. </template>
  309. <div class="matrix-bottom" @mouseenter="clearSelectCell" />
  310. </div>
  311. </div>
  312. <div class="voice-luyin">
  313. <soundrecord
  314. type="promax"
  315. class="luyin-box"
  316. :file-name="fileName"
  317. :select-data="selectData"
  318. @getWavblob="getWavblob"
  319. @getSelectData="getSelectData"
  320. @handleParentPlay="handleParentPlay"
  321. @sentPause="sentPause"
  322. />
  323. <audio-compare
  324. :theme-color="themeColor"
  325. :wavblob="wavblob"
  326. :url="mp3Url"
  327. :is-record="isRecord"
  328. :sent-pause="sentPause"
  329. :matrix-select-lrc="matrixSelectLrc"
  330. :get-cur-time="getCurTime"
  331. :cur-time="curTime"
  332. :handle-change-stop-audio="handleChangeStopAudio"
  333. @playing="playChange"
  334. />
  335. </div>
  336. </div>
  337. </template>
  338. <script>
  339. import Bus from "./components/Bus.js";
  340. import AudioLine from "./AudioLine.vue";
  341. import Soundrecord from "./Soundrecord.vue";
  342. import AudioCompare from "./AudioCompareMatrix.vue";
  343. export default {
  344. components: {
  345. AudioLine,
  346. Soundrecord,
  347. AudioCompare
  348. },
  349. props: ["curQue", "themeColor"],
  350. data() {
  351. return {
  352. curTime: 0,
  353. playing: false,
  354. stopAudio: true,
  355. unWatch: null,
  356. lrcArray: [],
  357. cellTimer: null,
  358. fileName: "",
  359. // 底色行、列
  360. selectRow: -1,
  361. selectColumn: -1,
  362. // 行、列选中
  363. selectedLine: {
  364. type: "",
  365. index: 0
  366. },
  367. // 点击选中
  368. selectCell: {
  369. row: -1,
  370. column: -1
  371. },
  372. isRepeat: false,
  373. // 跟读所需属性
  374. wavblob: null,
  375. isRecord: false,
  376. matrixSelectLrc: null
  377. };
  378. },
  379. computed: {
  380. mp3Url() {
  381. let mp3_list = this.curQue.mp3_list[0];
  382. if (mp3_list === undefined) return "";
  383. return mp3_list.url.match(/^\[FID##/)
  384. ? mp3_list.temporary_url
  385. : mp3_list.url;
  386. },
  387. mp3Source() {
  388. let mp3_list = this.curQue.mp3_list[0];
  389. if (mp3_list === undefined) return "";
  390. return "source" in mp3_list ? mp3_list.source : "";
  391. },
  392. mp3Duration() {
  393. let mp3_list = this.curQue.mp3_list[0];
  394. if (mp3_list === undefined) return 0;
  395. return mp3_list.media_duration * 1000;
  396. },
  397. hasSelectedCell() {
  398. let { type, index } = this.selectedLine;
  399. let { row, column } = this.selectCell;
  400. return (type.length > 0 && index >= 0) || (row >= 0 && column >= 0);
  401. },
  402. selectData() {
  403. let { type, index } = this.selectedLine;
  404. let { row, column } = this.selectCell;
  405. return {
  406. type: type.length > 0 && index >= 0 ? type : "cell",
  407. index,
  408. row,
  409. column
  410. };
  411. },
  412. voicePauseSrc() {
  413. let themeColor = this.themeColor;
  414. if (themeColor.length === 0 || themeColor === "red") {
  415. return require("../../../assets/NPC/play-red.png");
  416. }
  417. return require(`../../../assets/NPC/play-${themeColor}.png`);
  418. },
  419. voicePlaySrc() {
  420. let themeColor = this.themeColor;
  421. if (themeColor.length === 0 || themeColor === "red") {
  422. return require("../../../assets/NPC/icon-voice-play-red.png");
  423. }
  424. return require(`../../../assets/NPC/icon-voice-play-${themeColor}.png`);
  425. }
  426. },
  427. watch: {
  428. hasSelectedCell() {
  429. this.handleParentPlay();
  430. }
  431. },
  432. created() {
  433. Bus.$on("audioPause", () => {
  434. this.handleParentPlay();
  435. });
  436. },
  437. methods: {
  438. // 鼠标移入移出
  439. matrixCellMouseenter(i, j, type) {
  440. if (type === "connection") {
  441. this.selectRow = -1;
  442. this.selectColumn = -1;
  443. } else {
  444. this.selectRow = i;
  445. this.selectColumn = j;
  446. }
  447. },
  448. clearSelectCell() {
  449. this.selectRow = -1;
  450. this.selectColumn = -1;
  451. },
  452. // 单击单元格
  453. matrixCellClick(row, column) {
  454. if (this.playing) this.handleParentPlay();
  455. if (this.unWatch) this.unWatch();
  456. this.lrcArray = [];
  457. if (row === this.selectCell.row && column === this.selectCell.column) {
  458. this.selectCell = { row: -1, column: -1 };
  459. return;
  460. }
  461. this.selectedLine = { type: "", index: -1 };
  462. this.selectCell = { row, column };
  463. this.handleChangeTime(
  464. this.curQue.voiceMatrix.matrix[row][column].lrc_data
  465. );
  466. // 设置录音文件名
  467. this.setRecordingFileName(row, column);
  468. },
  469. setRecordingFileName(row, column) {
  470. let {
  471. type,
  472. text,
  473. sentence_data,
  474. pinyin_english_data,
  475. text_brackets
  476. } = this.curQue.voiceMatrix.matrix[row][column];
  477. if (type === "text") this.fileName = text;
  478. if (type === "SentenceSegwordChs") this.fileName = sentence_data.sentence;
  479. if (type === "PinyinEnglish") this.fileName = pinyin_english_data.pinyin;
  480. if (type === "textBrackets") {
  481. this.fileName = `${text_brackets.brackets_outer}[${text_brackets.brackets_inner}]`;
  482. }
  483. },
  484. checkboxMouseenter(isSelected, type) {
  485. if (!isSelected) return this.clearSelectCell();
  486. if (type === "row") this.selectColumn = -1;
  487. if (type === "column") this.selectRow = -1;
  488. },
  489. // 选中行、列
  490. selectRowOrColumn(index, type) {
  491. this.handleParentPlay();
  492. this.lrcArray = [];
  493. this.selectCell = { row: -1, column: -1 };
  494. if (this.unWatch) this.unWatch();
  495. if (
  496. this.selectedLine.type === type &&
  497. this.selectedLine.index === index
  498. ) {
  499. this.selectedLine = { type: "", index: -1 };
  500. return;
  501. }
  502. this.selectedLine = { type, index };
  503. let number = index;
  504. if (type === "column") {
  505. this.curQue.voiceMatrix.matrix[index].forEach(({ type }, i) => {
  506. if (i >= index) return;
  507. if (type === "connection") number -= 1;
  508. });
  509. }
  510. this.fileName = `第 ${number + 1} ${type === "row" ? "行" : "列"}`;
  511. },
  512. playAudio() {
  513. if (!this.hasSelectedCell) return;
  514. if (this.playing) return this.handleParentPlay();
  515. if (this.lrcArray.length > 0) return this.$refs.audioLine.PlayAudio();
  516. if (this.unWatch) this.unWatch();
  517. this.lrcArray = [];
  518. let { type, index } = this.selectedLine;
  519. if (type.length > 0 && index >= 0 && type === "row") {
  520. this.curQue.voiceMatrix.matrix[index].forEach(
  521. item => {
  522. let data = this.getLrcData(item);
  523. if (data) this.lrcArray.push(data);
  524. }
  525. );
  526. if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);
  527. return;
  528. }
  529. if (type.length > 0 && index >= 0 && type === "column") {
  530. this.curQue.voiceMatrix.matrix.forEach(item => {
  531. let data = this.getLrcData(item[index]);
  532. if (data) this.lrcArray.push(data);
  533. });
  534. if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);
  535. return;
  536. }
  537. let { row, column } = this.selectCell;
  538. if (row >= 0 && column >= 0) {
  539. this.handleChangeTime(
  540. this.curQue.voiceMatrix.matrix[row][column].lrc_data
  541. );
  542. }
  543. },
  544. lrcPlay({ begin_time, end_time }, index) {
  545. this.handleParentPlay();
  546. this.$nextTick(() => {
  547. this.$refs.audioLine.onTimeupdateTime(begin_time / 1000);
  548. this.$refs.audioLine.PlayAudio();
  549. if (end_time === -1) return;
  550. let end = end_time / 1000 - 0.01;
  551. this.unWatch = this.$watch("curTime", val => {
  552. if (val >= end) {
  553. if (!this.hasSelectedCell) return this.unWatch();
  554. this.handleParentPlay();
  555. this.$refs.audioLine.onTimeupdateTime(end);
  556. this.unWatch();
  557. let i = index + 1;
  558. if (i < this.lrcArray.length) {
  559. return this.lrcPlay(this.lrcArray[i], i);
  560. }
  561. if (this.isRepeat) {
  562. return this.lrcPlay(this.lrcArray[0], 0);
  563. }
  564. this.lrcArray = [];
  565. }
  566. });
  567. });
  568. },
  569. playChange(playing) {
  570. this.playing = playing;
  571. // 子组件通信,同时只能播放一个音频
  572. if (playing) Bus.$emit("audioPause");
  573. },
  574. // 暂停音频播放
  575. handleParentPlay() {
  576. this.stopAudio = true;
  577. },
  578. // 音频播放时改变布尔值
  579. handleChangeStopAudio() {
  580. this.stopAudio = false;
  581. },
  582. getCurTime(curTime) {
  583. this.curTime = curTime;
  584. },
  585. getWavblob(wavblob) {
  586. this.wavblob = wavblob;
  587. },
  588. getSelectData({ type, index, row, column }) {
  589. if (type === "") return;
  590. let arr = [];
  591. if (type.length > 0 && index >= 0 && type === "row") {
  592. this.curQue.voiceMatrix.matrix[index].forEach(
  593. item => {
  594. let data = this.getLrcData(item);
  595. if (data) arr.push(data);
  596. }
  597. );
  598. this.matrixSelectLrc = arr;
  599. return;
  600. }
  601. if (type.length > 0 && index >= 0 && type === "column") {
  602. this.curQue.voiceMatrix.matrix.forEach(item => {
  603. let data = this.getLrcData(item[index]);
  604. if (data) arr.push(data);
  605. });
  606. this.matrixSelectLrc = arr;
  607. return;
  608. }
  609. if (type === "cell" && row >= 0 && column >= 0) {
  610. let lrcData = this.curQue.voiceMatrix.matrix[row][column].lrc_data;
  611. if (lrcData.end_time === -1) lrcData.end_time = this.mp3Duration;
  612. this.matrixSelectLrc = [lrcData];
  613. }
  614. },
  615. getLrcData({ type, text, lrc_data }) {
  616. if (
  617. type === "SentenceSegwordChs" ||
  618. type === "PinyinEnglish" ||
  619. type === "textBrackets" ||
  620. (type === "text" && text.length > 0)
  621. ) {
  622. if (lrc_data.end_time === -1) {
  623. return {
  624. begin_time: lrc_data.begin_time,
  625. end_time: this.mp3Duration,
  626. text: lrc_data.text
  627. };
  628. }
  629. return lrc_data;
  630. }
  631. return false;
  632. },
  633. sentPause(isRecord) {
  634. this.isRecord = isRecord;
  635. },
  636. handleChangeTime({ begin_time, end_time }) {
  637. if (this.unWatch) this.unWatch();
  638. this.handleParentPlay();
  639. this.$nextTick(() => {
  640. this.$refs.audioLine.onTimeupdateTime(begin_time / 1000);
  641. this.$refs.audioLine.PlayAudio();
  642. // 监听是否已到结束时间,为了选中效果 - 0.01
  643. if (end_time === -1) return;
  644. let end = end_time / 1000 - 0.01;
  645. this.unWatch = this.$watch("curTime", val => {
  646. if (val >= end) {
  647. this.handleParentPlay();
  648. this.$refs.audioLine.onTimeupdateTime(end);
  649. this.unWatch();
  650. this.unWatch = null;
  651. }
  652. });
  653. });
  654. }
  655. }
  656. };
  657. </script>
  658. <style lang="scss" scoped>
  659. $select-color: #de4444;
  660. $border-color: #e6e6e6;
  661. $select-color-green: #24b99e;
  662. $select-color-green-bc: rgba(36, 185, 158, 0.25);
  663. $select-color-green-hover: #3dd4b8;
  664. $select-color-green-active: #1fa189;
  665. $select-color-brown: #bd8865;
  666. $select-color-brown-bc: rgba(189, 136, 101, 0.25);
  667. $select-color-brown-hover: #d6a687;
  668. $select-color-brown-active: #a37557;
  669. .voice-matrix {
  670. height: 100%;
  671. width: 100%;
  672. padding-bottom: 24px;
  673. color: #262626;
  674. &-audio {
  675. display: flex;
  676. height: 42px;
  677. border: 1px solid $border-color;
  678. border-radius: 8px 8px 0 0;
  679. .audio-number {
  680. padding: 11px 0 0 12px;
  681. %serial-number,
  682. .serial-number {
  683. display: inline-block;
  684. width: 16px;
  685. height: 16px;
  686. text-align: center;
  687. line-height: 16px;
  688. font-size: 12px;
  689. background-color: $select-color;
  690. font-family: "robot";
  691. color: #fff;
  692. border-radius: 50%;
  693. }
  694. .serial-number-green {
  695. @extend %serial-number;
  696. background-color: $select-color-green;
  697. }
  698. .serial-number-brown {
  699. @extend %serial-number;
  700. background-color: $select-color-brown;
  701. }
  702. }
  703. .audio-simple {
  704. flex-grow: 1;
  705. line-height: 46px;
  706. height: 100%;
  707. display: flex;
  708. align-items: center;
  709. justify-content: space-between;
  710. img {
  711. cursor: pointer;
  712. width: 16px;
  713. height: 16px;
  714. margin-left: 12px;
  715. }
  716. .Repeat-16 {
  717. display: inline-block;
  718. width: 16px;
  719. height: 16px;
  720. margin-right: 12px;
  721. cursor: pointer;
  722. }
  723. }
  724. }
  725. // 语音矩阵
  726. &-container {
  727. height: calc(100% - 80px);
  728. background-color: #f5f5f5;
  729. border-left: 1px solid $border-color;
  730. border-right: 1px solid $border-color;
  731. word-break: break-word;
  732. .matrix {
  733. display: inline-grid;
  734. width: 100%;
  735. height: 100%;
  736. %matrix-checkbox {
  737. position: relative;
  738. top: calc(50% - 5px);
  739. display: block;
  740. width: 14px;
  741. height: 14px;
  742. border: 1.5px solid #b0b0b0;
  743. border-radius: 4px;
  744. margin: 0 auto;
  745. cursor: pointer;
  746. &.active {
  747. border-color: $select-color;
  748. &::after {
  749. box-sizing: content-box;
  750. content: "";
  751. border: 1px solid $select-color;
  752. border-left: 0;
  753. border-top: 0;
  754. height: 7px;
  755. left: 4px;
  756. position: absolute;
  757. width: 3px;
  758. transform: rotate(45deg) scaleY(1);
  759. transition: transform 0.15s ease-in 0.05s;
  760. transform-origin: center;
  761. }
  762. }
  763. }
  764. .matrix-checkbox-row-,
  765. .matrix-checkbox-row-red {
  766. @extend %matrix-checkbox;
  767. }
  768. .matrix-checkbox-row-green {
  769. @extend %matrix-checkbox;
  770. &.active {
  771. border-color: $select-color-green-active;
  772. &::after {
  773. border-color: $select-color-green-active;
  774. }
  775. }
  776. }
  777. .matrix-checkbox-row-brown {
  778. @extend %matrix-checkbox;
  779. &.active {
  780. border-color: $select-color-brown-active;
  781. &::after {
  782. border-color: $select-color-brown-active;
  783. }
  784. }
  785. }
  786. %matrix-checkbox-column,
  787. .matrix-checkbox-column-,
  788. .matrix-checkbox-column-red {
  789. @extend %matrix-checkbox;
  790. top: calc(50% - 7px);
  791. right: -2px;
  792. }
  793. .matrix-checkbox-column-green {
  794. @extend %matrix-checkbox-column;
  795. &.active {
  796. border-color: $select-color-green-active;
  797. &::after {
  798. border-color: $select-color-green-active;
  799. }
  800. }
  801. }
  802. .matrix-checkbox-column-brown {
  803. @extend %matrix-checkbox-column;
  804. &.active {
  805. border-color: $select-color-brown-active;
  806. &::after {
  807. border-color: $select-color-brown-active;
  808. }
  809. }
  810. }
  811. .read {
  812. background-color: #eaeaea;
  813. }
  814. .highlight-,
  815. .highlight-red {
  816. color: $select-color;
  817. }
  818. .highlight-green {
  819. color: $select-color-green;
  820. }
  821. .highlight-brown {
  822. color: $select-color-brown;
  823. }
  824. .column-wrapper {
  825. padding: 4px;
  826. %column {
  827. width: 100%;
  828. height: 100%;
  829. min-height: 32px;
  830. background-color: #fff;
  831. border: 1px solid $border-color;
  832. border-radius: 8px;
  833. transition: 0.2s;
  834. cursor: pointer;
  835. user-select: none;
  836. &:hover {
  837. border-color: #8c8c8c;
  838. }
  839. &.selected {
  840. color: $select-color;
  841. border-color: $select-color;
  842. }
  843. &.playing {
  844. background-color: #fee;
  845. }
  846. &.title {
  847. background-color: transparent;
  848. border-color: transparent;
  849. }
  850. > span {
  851. display: inline-block;
  852. padding: 4px 12px;
  853. line-height: 24px;
  854. }
  855. }
  856. %column-red,
  857. .column-,
  858. .column-red {
  859. @extend %column;
  860. position: relative;
  861. font-family: "GB-PINYINOK-B", "FZJCGFKTK";
  862. &::before {
  863. display: inline-block;
  864. content: "";
  865. vertical-align: middle;
  866. }
  867. }
  868. .column-green {
  869. @extend %column-red;
  870. &.selected {
  871. color: $select-color-green;
  872. border-color: $select-color-green;
  873. }
  874. &.playing {
  875. background-color: $select-color-green-bc;
  876. }
  877. }
  878. .column-brown {
  879. @extend %column-red;
  880. &.selected {
  881. color: $select-color-brown;
  882. border-color: $select-color-brown;
  883. }
  884. &.playing {
  885. background-color: $select-color-brown-bc;
  886. }
  887. }
  888. %sentence,
  889. .sentence-,
  890. .sentence-red {
  891. @extend %column;
  892. display: inline-grid;
  893. padding: 4px 12px;
  894. line-height: 24px;
  895. column-gap: 8px;
  896. justify-items: center;
  897. justify-content: start;
  898. > span {
  899. padding: 0;
  900. }
  901. .pinyin {
  902. font-family: "GB-PINYINOK-B";
  903. opacity: 0.45;
  904. font-size: 12px;
  905. line-height: 20px;
  906. }
  907. .chs {
  908. font-family: "FZJCGFKTK";
  909. font-size: 16px;
  910. line-height: 24px;
  911. }
  912. }
  913. .sentence-green {
  914. @extend %sentence;
  915. &.selected {
  916. color: $select-color-green;
  917. border-color: $select-color-green;
  918. }
  919. &.playing {
  920. background-color: $select-color-green-bc;
  921. }
  922. }
  923. .sentence-brown {
  924. @extend %sentence;
  925. &.selected {
  926. color: $select-color-brown;
  927. border-color: $select-color-brown;
  928. }
  929. &.playing {
  930. background-color: $select-color-brown-bc;
  931. }
  932. }
  933. .connection {
  934. position: relative;
  935. top: calc(50% - 1px);
  936. height: 2px;
  937. width: 16px;
  938. margin: 0 -4px;
  939. border-radius: 4px;
  940. background-color: #252525;
  941. &.highlight-bc-,
  942. &.highlight-bc-red {
  943. background-color: $select-color;
  944. }
  945. &.highlight-bc-green {
  946. background-color: $select-color-green;
  947. }
  948. &.highlight-bc-brown {
  949. background-color: $select-color-brown;
  950. }
  951. }
  952. // 拼音 + 文字
  953. %pinyinEnglish,
  954. .pinyinEnglish-,
  955. .pinyinEnglish-red {
  956. @extend %column;
  957. .inside-wrapper {
  958. padding: 4px 12px;
  959. .pinyin {
  960. font-family: "GB-PINYINOK-B";
  961. font-size: 16px;
  962. line-height: 24px;
  963. }
  964. .english {
  965. font-family: "robot";
  966. opacity: 0.45;
  967. font-size: 12px;
  968. line-height: 20px;
  969. }
  970. }
  971. }
  972. .pinyinEnglish-green {
  973. @extend %pinyinEnglish;
  974. &.selected {
  975. color: $select-color-green;
  976. border-color: $select-color-green;
  977. }
  978. &.playing {
  979. background-color: $select-color-green-bc;
  980. }
  981. }
  982. .pinyinEnglish-brown {
  983. @extend %pinyinEnglish;
  984. &.selected {
  985. color: $select-color-brown;
  986. border-color: $select-color-brown;
  987. }
  988. &.playing {
  989. background-color: $select-color-brown-bc;
  990. }
  991. }
  992. %textBrackets,
  993. .textBrackets-,
  994. .textBrackets-red {
  995. @extend %column;
  996. .brackets-text {
  997. font-family: "GB-PINYINOK-B";
  998. }
  999. .brackets {
  1000. font-size: 16px;
  1001. font-family: "FZJCGFKTK";
  1002. }
  1003. }
  1004. .textBrackets-green {
  1005. @extend %textBrackets;
  1006. &.selected {
  1007. color: $select-color-green;
  1008. border-color: $select-color-green;
  1009. }
  1010. &.playing {
  1011. background-color: $select-color-green-bc;
  1012. }
  1013. }
  1014. .textBrackets-brown {
  1015. @extend %textBrackets;
  1016. &.selected {
  1017. color: $select-color-brown;
  1018. border-color: $select-color-brown;
  1019. }
  1020. &.playing {
  1021. background-color: $select-color-brown-bc;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. .matrix-audio {
  1027. width: 228px;
  1028. height: 40px;
  1029. padding: 4px 4px 4px 16px;
  1030. margin: 24px 24px 0 0;
  1031. background-color: #fff;
  1032. border: 1px solid $border-color;
  1033. border-radius: 8px;
  1034. }
  1035. }
  1036. .voice-luyin {
  1037. display: flex;
  1038. border: 1px solid $border-color;
  1039. border-radius: 0 0 8px 8px;
  1040. align-items: center;
  1041. padding: 3px 16px;
  1042. height: 40px;
  1043. }
  1044. }
  1045. </style>
  1046. <style lang="scss" scoped>
  1047. .NNPE-tableList-tr-last {
  1048. .voice-matrix {
  1049. padding-bottom: 0;
  1050. }
  1051. }
  1052. </style>
  1053. <style lang="scss">
  1054. .voice-matrix {
  1055. &-audio {
  1056. .audioLine {
  1057. border-radius: 8px 8px 0 0 !important;
  1058. }
  1059. .el-slider {
  1060. width: 100% !important;
  1061. }
  1062. }
  1063. .luyin-box {
  1064. .el-select .el-input {
  1065. width: 136px;
  1066. }
  1067. }
  1068. }
  1069. </style>