MatchingPreview.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="matching-preview" :style="[getAreaStyle(), getComponentStyle()]">
  4. <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
  5. <div class="main">
  6. <ul ref="list" class="option-list">
  7. <li v-for="(item, i) in data.option_list" :key="i" class="list-item">
  8. <template v-for="({ content, mark, multilingual, paragraph_list, rich_text_list }, j) in item">
  9. <div
  10. v-if="content"
  11. :key="mark"
  12. :class="['item-wrapper', `item-${mark}`, computedAnswerClass(mark, i, j), { isMobile: isMobile }]"
  13. :style="{
  14. cursor: disabled ? 'default' : 'pointer',
  15. flex: isMobile ? '0 1 auto' : '',
  16. width: isMobile ? 'calc(50% - 8px)' : '',
  17. overflow: isMobile ? 'auto' : '',
  18. }"
  19. @mousedown="mousedown($event, i, j, mark)"
  20. @mouseup="mouseup($event, i, j, mark)"
  21. @click="handleClickConnection($event, i, j, mark)"
  22. >
  23. <PinyinText
  24. v-if="isEnable(data.property.view_pinyin)"
  25. class="content"
  26. :paragraph-list="paragraph_list"
  27. :rich-text-list="rich_text_list"
  28. :pinyin-position="data.property.pinyin_position"
  29. :is-preview="true"
  30. />
  31. <span v-else class="content rich-text" v-html="convertText(sanitizeHTML(content))"></span>
  32. <div v-if="showLang" class="lang">
  33. {{ multilingual.find((item) => item.type === getLang())?.translation }}
  34. </div>
  35. </div>
  36. <div v-else :key="mark" style="width: calc(50% - 36px); padding: 12px 24px"></div>
  37. </template>
  38. </li>
  39. </ul>
  40. </div>
  41. <PreviewOperation @showAnswerAnalysis="showAnswerAnalysis" @retry="retry" />
  42. <AnswerCorrect
  43. :answer-correct="data?.answer_correct"
  44. :visible.sync="visibleAnswerCorrect"
  45. @closeAnswerCorrect="closeAnswerCorrect"
  46. />
  47. <AnswerAnalysis
  48. :visible.sync="visibleAnswerAnalysis"
  49. :answer-list="data.answer_list"
  50. :analysis-list="data.analysis_list"
  51. @closeAnswerAnalysis="closeAnswerAnalysis"
  52. >
  53. <div slot="right-answer" class="right-answer">
  54. <ul ref="answerList" class="option-list">
  55. <li v-for="(item, i) in data.option_list" :key="i" class="list-item">
  56. <div v-for="{ content, mark } in item" :key="mark" :class="['item-wrapper', `answer-item-${mark}`]">
  57. <span class="content rich-text" v-html="convertText(sanitizeHTML(content))"></span>
  58. </div>
  59. </li>
  60. </ul>
  61. </div>
  62. </AnswerAnalysis>
  63. </div>
  64. </template>
  65. <script>
  66. import { getMatchingData, svgNS } from '@/views/book/courseware/data/matching';
  67. import { arraysIntersect } from '@/utils/validate';
  68. import PreviewMixin from '../common/PreviewMixin';
  69. export default {
  70. name: 'MatchingPreview',
  71. mixins: [PreviewMixin],
  72. data() {
  73. return {
  74. data: getMatchingData(),
  75. answerList: [], // 答案列表
  76. curConnectionPoint: { i: -1, j: -1, mark: '' }, // 当前连线点
  77. // 拖拽相关
  78. drag: false,
  79. mouseEvent: {
  80. clientX: 0,
  81. clientY: 0,
  82. },
  83. };
  84. },
  85. watch: {
  86. 'data.option_list': {
  87. handler(val) {
  88. this.clearLine();
  89. if (!val) return;
  90. let list = val.map((item) => {
  91. return item.map(({ mark }) => {
  92. return { mark, preMark: [], nextMark: [] };
  93. });
  94. });
  95. this.$set(this, 'answerList', list);
  96. },
  97. immediate: true,
  98. },
  99. answerList: {
  100. handler(list) {
  101. let arr = [];
  102. list.forEach((item) => {
  103. let markArr = [];
  104. item.forEach(({ mark, nextMark }, j) => {
  105. if (j === 0) {
  106. markArr.push(mark);
  107. markArr.push([...nextMark]);
  108. } else if (item.length === 3 && j === 1) {
  109. markArr.push([...nextMark]);
  110. }
  111. });
  112. arr.push(markArr);
  113. });
  114. // 答案数组为 第一个值为固定字符串,后面为连接的值数组,如:['A', ['B', 'C'], ['1', '2']],根据此结构来判断对错、绘制连线
  115. this.answer.answer_list = arr;
  116. },
  117. deep: true,
  118. },
  119. isShowRightAnswer(cur) {
  120. if (cur) {
  121. this.$nextTick(() => {
  122. this.circulateAnswerList();
  123. });
  124. }
  125. },
  126. },
  127. created() {
  128. document.addEventListener('click', this.handleEventConnection);
  129. document.addEventListener('mousemove', this.documentMousemouse);
  130. document.addEventListener('mouseup', this.documentMouseup);
  131. },
  132. beforeDestroy() {
  133. document.removeEventListener('click', this.handleEventConnection);
  134. document.removeEventListener('mousemove', this.documentMousemouse);
  135. document.removeEventListener('mouseup', this.documentMouseup);
  136. },
  137. methods: {
  138. /* 用 mouse 事件模拟拖拽 开始*/
  139. documentMousemouse(e) {
  140. if (!this.drag) return;
  141. // 使用 svg 绘制跟随鼠标移动的连接线
  142. let svg = document.querySelector('.move-connection');
  143. let list = this.$refs.list.getBoundingClientRect(); // 列表的位置
  144. let { clientX, clientY } = e;
  145. let isLeft = clientX < this.mouseEvent.clientX; // 鼠标是否向左移动
  146. // 计算 svg 的宽度,宽度不能超过列表的宽度
  147. let width = Math.min(list.width, isLeft ? list.width - clientX + list.left - 1 : clientX - list.left - 1);
  148. if (svg) {
  149. svg.setAttribute(
  150. 'style',
  151. `position: absolute; ${isLeft ? 'right: 0;' : 'left: 0;'} width: ${width}px; height: 100%;`,
  152. );
  153. } else {
  154. svg = document.createElementNS(svgNS, 'svg');
  155. svg.classList.add('move-connection');
  156. svg.setAttribute('style', `position: absolute; width: ${width}px; height: 100%;`);
  157. let path = document.createElementNS(svgNS, 'path');
  158. this.setPathAttr(path);
  159. svg.appendChild(path);
  160. this.$refs.list.appendChild(svg);
  161. }
  162. let top = this.mouseEvent.clientY - list.top;
  163. let left = isLeft
  164. ? this.mouseEvent.clientX - list.left - Math.abs(width - list.width)
  165. : this.mouseEvent.clientX - list.left;
  166. let mouseX = isLeft ? clientX - list.left - Math.abs(width - list.width) : clientX - list.left;
  167. let mouseY = clientY - list.top;
  168. let path = svg.querySelector('path');
  169. path.setAttribute('d', `M ${left} ${top} L ${mouseX} ${mouseY}`);
  170. },
  171. documentMouseup() {
  172. if (!this.drag) return;
  173. this.drag = false;
  174. document.querySelector('.move-connection')?.remove();
  175. document.body.style.userSelect = 'auto'; // 允许选中文本
  176. this.mousePointer = { i: -1, j: -1, mark: '' };
  177. this.mouseEvent = { clientX: 0, clientY: 0 };
  178. },
  179. /**
  180. * 鼠标按下事件,设置当前连线点
  181. * @param {PointerEvent} e 事件对象
  182. * @param {number} i 选项列表索引
  183. * @param {number} j 选项索引
  184. * @param {string} mark 选项标识
  185. */
  186. mousedown(e, i, j, mark) {
  187. if (this.disabled) return;
  188. this.drag = true;
  189. document.body.style.userSelect = 'none'; // 禁止选中文本
  190. this.mouseEvent = { clientX: e.clientX, clientY: e.clientY };
  191. this.mousePointer = { i, j, mark };
  192. },
  193. /**
  194. * 鼠标抬起事件,如果是一个合适的连接点,则创建连接线
  195. * @param {PointerEvent} e 事件对象
  196. * @param {Number} i 选项列表索引
  197. * @param {Number} j 选项索引
  198. * @param {String} mark 选项标识
  199. */
  200. mouseup(e, i, j, mark) {
  201. if (this.disabled || !this.drag) return;
  202. let { i: curI, j: curJ, mark: curMark } = this.mousePointer;
  203. if (curI === -1 && curJ === -1) return;
  204. if (Math.abs(curJ - j) > 1 || mark === curMark) return;
  205. this.changeConnectionList(mark, j, true);
  206. this.createLine(mark, true);
  207. },
  208. /* 用 mouse 事件模拟拖拽 结束 */
  209. // 重置当前连线点
  210. resetCurConnectionPoint() {
  211. this.curConnectionPoint = { i: -1, j: -1, mark: '' };
  212. },
  213. /**
  214. * 当点击的不是连线点时,清除所有连线点的选中状态
  215. * @param {PointerEvent} e
  216. */
  217. handleEventConnection(e) {
  218. let currentNode = e.target;
  219. while (currentNode !== null) {
  220. if (currentNode.classList && currentNode.classList.contains('item-wrapper')) {
  221. break;
  222. }
  223. currentNode = currentNode.parentNode;
  224. }
  225. if (currentNode) return;
  226. Array.from(document.getElementsByClassName('item-wrapper')).forEach((item) => {
  227. item.classList.remove('focus');
  228. });
  229. this.resetCurConnectionPoint();
  230. },
  231. /**
  232. * 处理点击连线
  233. * @param {PointerEvent} e 事件对象
  234. * @param {Number} i 选项列表索引
  235. * @param {Number} j 选项索引
  236. * @param {String} mark 选项标识
  237. */
  238. handleClickConnection(e, i, j, mark) {
  239. if (this.disabled) return;
  240. let { i: curI, j: curJ, mark: curMark } = this.curConnectionPoint;
  241. // 获取 item-wrapper 元素
  242. let currentNode = e.target;
  243. while (currentNode !== null) {
  244. if (currentNode.classList && currentNode.classList.contains('item-wrapper')) {
  245. break;
  246. }
  247. currentNode = currentNode.parentNode;
  248. }
  249. // 如果当前连线点不存在或就是当前连线点,则设置当前连线点
  250. if ((curI === -1 && curJ === -1) || mark === curMark) {
  251. this.curConnectionPoint = { i, j, mark };
  252. currentNode.classList.add('focus');
  253. return;
  254. }
  255. // 如果当前连线点存在,清除所有连线点的选中状态
  256. Array.from(this.$refs.list.getElementsByClassName('item-wrapper')).forEach((item) => {
  257. item.classList.remove('focus');
  258. });
  259. // 如果当前连线点与上一个连线点不在相邻的位置,则设置点击的连接点为当前连线点
  260. if (Math.abs(curJ - j) > 1 || mark === curMark || (curJ === j && curI !== i)) {
  261. this.curConnectionPoint = { i, j, mark };
  262. currentNode.classList.add('focus');
  263. return;
  264. }
  265. this.changeConnectionList(mark, j);
  266. // 如果当前连线点与上一个连线点在相邻的位置,则创建连接线
  267. this.createLine(mark);
  268. },
  269. /**
  270. * @description 循环答案列表
  271. */
  272. circulateAnswerList() {
  273. this.data.answer.answer_list.forEach((item, index) => {
  274. let preMark = ''; // 上一个连线点标识
  275. item.forEach(({ mark }, j) => {
  276. if (j === 0) {
  277. preMark = mark;
  278. return;
  279. }
  280. if (mark.length <= 0) return;
  281. if (j === 2) {
  282. preMark = this.data.option_list[index][j - 1].mark;
  283. }
  284. let cur = { i: -1, j: -1, mark: '' }; // 当前连线点
  285. // 根据 preMark 查找当前连线点的位置
  286. this.data.option_list.find((list, i) => {
  287. return list.find((li, idx) => {
  288. if (li.mark === preMark) {
  289. cur = { i, j: idx };
  290. return true;
  291. }
  292. });
  293. });
  294. // 循环 mark 数组,创建连接线
  295. mark.forEach((m) => {
  296. this.curConnectionPoint = { i: cur.i, j: cur.j, mark: preMark };
  297. this.createLine(m, false, true);
  298. });
  299. });
  300. });
  301. },
  302. /**
  303. * 创建连接线
  304. * @param {String} mark 选项标识
  305. * @param {Boolean} isDrag 是否是拖拽
  306. * @param {Boolean} isShowRightAnswer 是否是显示正确答案
  307. */
  308. createLine(mark, isDrag = false, isShowRightAnswer = false) {
  309. const { offsetWidth, offsetLeft, offsetTop, offsetHeight } = document.getElementsByClassName(
  310. `${isShowRightAnswer ? 'answer-' : ''}item-${mark}`,
  311. )[0];
  312. const { curOffsetWidth, curOffsetLeft, curOffsetTop, curOffsetHeight, curMark } = this.computedCurConnectionPoint(
  313. isDrag,
  314. isShowRightAnswer,
  315. );
  316. let top = Math.min(offsetTop + offsetHeight / 2, curOffsetTop + curOffsetHeight / 2);
  317. // 判断是否是同一行
  318. const isSameRow = Math.abs(offsetTop + offsetHeight / 2 - (curOffsetTop + curOffsetHeight / 2)) <= 2;
  319. let left = Math.min(offsetLeft + offsetWidth, curOffsetLeft + curOffsetWidth);
  320. let width = Math.abs(
  321. offsetLeft > curOffsetLeft
  322. ? curOffsetLeft - offsetLeft + offsetWidth
  323. : offsetLeft - curOffsetLeft + curOffsetWidth,
  324. );
  325. let height = 0;
  326. if (!isSameRow) {
  327. height =
  328. curOffsetTop > offsetTop
  329. ? Math.abs(offsetTop + offsetHeight / 2 - (curOffsetTop + curOffsetHeight / 2))
  330. : Math.abs(offsetTop - curOffsetTop + offsetHeight / 2 - curOffsetHeight / 2);
  331. }
  332. let size = offsetLeft > curOffsetLeft ? offsetTop > curOffsetTop : offsetTop < curOffsetTop; // 判断是左上还是右下
  333. // 创建一个空的SVG元素
  334. let svg = document.createElementNS(svgNS, 'svg');
  335. svg.setAttribute(
  336. 'style',
  337. `position:absolute; width: 122px; height: ${Math.max(8, height)}px; top: ${top}px; left: ${left}px;overflow: visible;`,
  338. );
  339. svg.classList.add('connection-line', `svg-${mark}-${curMark}`); // 添加类名
  340. // 向SVG元素添加 path 元素
  341. let path = document.createElementNS(svgNS, 'path');
  342. path.setAttribute('d', `M ${size ? 0 : width} 0 L ${size ? width : 0} ${height}`); // 设置路径数据
  343. this.setPathAttr(path);
  344. svg.appendChild(path);
  345. // 在 svg 元素中的 path 元素上两端添加圆形标记
  346. let circleStart = document.createElementNS(svgNS, 'circle');
  347. circleStart.setAttribute('cx', size ? '0' : width); // 设置圆心的 x 坐标
  348. circleStart.setAttribute('cy', '0'); // 设置圆心的 y 坐标
  349. circleStart.setAttribute('r', '4'); // 设置半径
  350. const assistColor = this.data?.unified_attrib?.topic_color || '#306eff';
  351. circleStart.setAttribute('fill', assistColor); // 设置填充颜色
  352. svg.appendChild(circleStart);
  353. let circleEnd = document.createElementNS(svgNS, 'circle');
  354. circleEnd.setAttribute('cx', size ? width : '0'); // 设置圆心的 x 坐标
  355. circleEnd.setAttribute('cy', height); // 设置圆心的 y 坐标
  356. circleEnd.setAttribute('r', '4'); // 设置半径
  357. circleEnd.setAttribute('fill', assistColor); // 设置填充颜色
  358. svg.appendChild(circleEnd);
  359. this.$refs[isShowRightAnswer ? 'answerList' : 'list'].appendChild(svg); // 将SVG元素插入到文档中
  360. // 清除当前连线点
  361. this.resetCurConnectionPoint();
  362. },
  363. // 设置 path 公用属性
  364. setPathAttr(path) {
  365. path.setAttribute('stroke-width', '2'); // 设置线条宽度
  366. path.setAttribute('stroke-linecap', 'round'); // 设置线段的两端样式
  367. const assistColor = this.data?.unified_attrib?.topic_color || '#306eff';
  368. path.setAttribute('stroke', assistColor); // 设置填充颜色
  369. },
  370. /**
  371. * 计算当前连线点的位置
  372. * @param {Boolean} isDrag 是否是拖拽
  373. * @param {Boolean} isShowRightAnswer 是否是显示正确答案
  374. */
  375. computedCurConnectionPoint(isDrag = false, isShowRightAnswer = false) {
  376. let { mark } = isDrag ? this.mousePointer : this.curConnectionPoint;
  377. let type = Object.prototype.toString.call(mark);
  378. if (type === '[object String]') {
  379. type = 'string';
  380. } else if (type === '[object Object]') {
  381. type = 'object';
  382. }
  383. if (type === 'object') {
  384. mark = mark.mark;
  385. }
  386. const dom = document.getElementsByClassName(`${isShowRightAnswer ? 'answer-' : ''}item-${mark}`)[0];
  387. return {
  388. curOffsetWidth: dom.offsetWidth,
  389. curOffsetLeft: dom.offsetLeft,
  390. curOffsetTop: dom.offsetTop,
  391. curOffsetHeight: dom.offsetHeight,
  392. curMark: mark,
  393. };
  394. },
  395. // 清除所有连接线
  396. clearLine() {
  397. document.querySelectorAll('svg.connection-line').forEach((item) => {
  398. item.remove();
  399. });
  400. },
  401. /**
  402. * 修改连接列表
  403. * @param {String} mark 选项标识
  404. * @param {Number} j 当前选项索引
  405. * @param {Boolean} isDrag 是否是拖拽
  406. */
  407. changeConnectionList(mark, j, isDrag = false) {
  408. const { mark: curMark, j: curJ } = isDrag ? this.mousePointer : this.curConnectionPoint;
  409. this.changeAnswerList(curMark, mark, curJ < j);
  410. this.changeAnswerList(mark, curMark, curJ > j);
  411. },
  412. /**
  413. * 改变答案列表
  414. * @param {String} curMark 当前选项标识
  415. * @param {String} mark 选项标识
  416. */
  417. changeAnswerList(curMark, mark, isPre) {
  418. this.answerList.find((item) =>
  419. item.find((li) => {
  420. if (li.mark === curMark) {
  421. if (isPre && !li.preMark.includes(mark)) {
  422. li.nextMark.push(mark);
  423. } else if (!isPre && !li.nextMark.includes(mark)) {
  424. li.preMark.push(mark);
  425. }
  426. return true;
  427. }
  428. }),
  429. );
  430. },
  431. /**
  432. * 根据 mark 查找 nextMark 或 preMark
  433. * @param {Array} list 答案列表
  434. * @param {String} mark 标记
  435. * @param {'pre'|'next'} type 类型
  436. * @returns {String} 返回 nextMark 或 preMark
  437. */
  438. findMark(list, mark, type) {
  439. let fMark = '';
  440. list.find((item) => {
  441. return item.find((li) => {
  442. if (mark === li.mark) {
  443. fMark = type === 'pre' ? li.preMark : li.nextMark;
  444. return true;
  445. }
  446. });
  447. });
  448. return fMark;
  449. },
  450. /**
  451. * 计算答题对错选项class
  452. * @param {string} mark 选项标识
  453. * @param {number} i 选项列表索引
  454. * @param {number} j 选项索引
  455. * @returns {string} 返回 class 名称
  456. */
  457. computedAnswerClass(mark, i, j) {
  458. if (!this.isJudgingRightWrong) return '';
  459. if (j === 0) {
  460. return this.judgeFirstAnswerRightWrong(i);
  461. }
  462. let answer = this.data.answer.answer_list.find((item) => {
  463. return item.some((li) => Array.isArray(li.mark) && li.mark.includes(mark));
  464. }); // 正确答案列
  465. let userAnswer = this.answer.answer_list.find((item) => {
  466. return item.some((li) => Array.isArray(li) && li.includes(mark));
  467. }); // 选项对应的用户答案列
  468. if (answer === undefined || userAnswer === undefined) return 'wrong';
  469. if (answer.length === 0 && userAnswer.length === 0) return '';
  470. if (answer.length === 0 || userAnswer.length === 0) return 'wrong';
  471. let isRight = true;
  472. if (j === 1) {
  473. // 判断第二行答案对错,answer[0].mark 和 userAnswer[0] 是否相等
  474. isRight = answer[0].mark === userAnswer[0];
  475. } else if (j === 2) {
  476. // 判断第三行答案对错,answer[1].mark 和 userAnswer[1] 是否相交
  477. isRight = arraysIntersect(answer[1].mark, userAnswer[1]);
  478. }
  479. return isRight ? 'right' : 'wrong';
  480. },
  481. /**
  482. * 判断第一列答案对错,是否有个一个选项连接正确
  483. * @param {number} i 选项列表索引
  484. */
  485. judgeFirstAnswerRightWrong(i) {
  486. let answer = this.data.answer.answer_list[i]; // 正确答案列
  487. let userAnswer = this.answer.answer_list[i]; // 选项对应的用户答案列
  488. if (answer === undefined || userAnswer === undefined) return 'wrong';
  489. if (answer.length === 0 && userAnswer.length === 0) return '';
  490. if (answer.length === 0 || userAnswer.length === 0) return 'wrong';
  491. let isRight = true;
  492. // 判断 answer[1].mark 和 userAnswer[1] 是否相交
  493. const answerSet = new Set(answer[1].mark);
  494. isRight = userAnswer[1].some((x) => answerSet.has(x));
  495. return isRight ? 'right' : 'wrong';
  496. },
  497. retry() {
  498. this.clearLine();
  499. this.$set(
  500. this,
  501. 'answerList',
  502. this.answerList.map((item) => item.map(({ mark }) => ({ mark, preMark: [], nextMark: [] }))),
  503. );
  504. this.$set(this, 'answer', { answer_list: [], is_right: false });
  505. },
  506. /**
  507. * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
  508. */
  509. getNoTextContentData() {
  510. let noTextContentData = JSON.parse(JSON.stringify(this.data));
  511. const resetFieldMap = {
  512. analysis_list: [],
  513. answer_list: [],
  514. };
  515. Object.assign(noTextContentData, resetFieldMap);
  516. noTextContentData.option_list.forEach((list) => {
  517. list.forEach((item) => {
  518. item.content = '';
  519. item.multilingual = [];
  520. item.paragraph_list = [];
  521. item.paragraph_list_parameter = {
  522. text: '',
  523. pinyin_proofread_word_list: [],
  524. };
  525. });
  526. });
  527. if (noTextContentData.answer) {
  528. noTextContentData.answer.answer_list = [];
  529. noTextContentData.answer.reference_answer = '';
  530. }
  531. return noTextContentData;
  532. },
  533. },
  534. };
  535. </script>
  536. <style lang="scss" scoped>
  537. @use '@/styles/mixin.scss' as *;
  538. .matching-preview {
  539. @include preview-base;
  540. overflow: auto;
  541. .option-list {
  542. position: relative;
  543. display: flex;
  544. flex-direction: column;
  545. row-gap: 16px;
  546. .list-item {
  547. display: flex;
  548. column-gap: 120px;
  549. align-items: stretch;
  550. padding: 1px;
  551. .item-wrapper {
  552. position: relative;
  553. display: flex;
  554. flex-wrap: wrap;
  555. column-gap: 24px;
  556. align-items: center;
  557. width: calc(50% - 36px);
  558. min-height: 48px;
  559. padding: 12px 24px;
  560. background-color: $content-color;
  561. border-radius: 4px;
  562. &.focus {
  563. background-color: #dcdbdd;
  564. }
  565. &.right {
  566. background-color: $right-bc-color;
  567. }
  568. &.wrong {
  569. box-shadow: 0 0 0 1px $error-color;
  570. }
  571. .content {
  572. flex: 1;
  573. }
  574. .lang {
  575. width: 100%;
  576. }
  577. }
  578. }
  579. }
  580. .right-answer {
  581. .title {
  582. margin: 24px 0;
  583. }
  584. }
  585. }
  586. </style>