|
|
@@ -1,19 +1,5 @@
|
|
|
<template>
|
|
|
- <div
|
|
|
- ref="courserware"
|
|
|
- class="courserware"
|
|
|
- :style="[
|
|
|
- {
|
|
|
- backgroundImage: background.background_image_url ? `url(${background.background_image_url})` : '',
|
|
|
- backgroundSize: background.background_image_url
|
|
|
- ? `${background.background_position.width}% ${background.background_position.height}%`
|
|
|
- : '',
|
|
|
- backgroundPosition: background.background_image_url
|
|
|
- ? `${background.background_position.left}% ${background.background_position.top}%`
|
|
|
- : '',
|
|
|
- },
|
|
|
- ]"
|
|
|
- >
|
|
|
+ <div ref="courserware" class="courserware" :style="computedCourserwareStyle()">
|
|
|
<template v-for="(row, i) in data.row_list">
|
|
|
<div v-show="computedRowVisibility(row.row_id)" :key="i" class="row" :style="getMultipleColStyle(i)">
|
|
|
<el-checkbox
|
|
|
@@ -132,6 +118,10 @@ export default {
|
|
|
type: Boolean,
|
|
|
default: true,
|
|
|
},
|
|
|
+ project: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -320,6 +310,35 @@ export default {
|
|
|
gridTemplateRows,
|
|
|
};
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算课件背景样式
|
|
|
+ * @returns {Object} 课件背景样式对象
|
|
|
+ */
|
|
|
+ computedCourserwareStyle() {
|
|
|
+ const { background_image_url: bcImgUrl = '', background_position: pos = {} } = this.background || {};
|
|
|
+ const hasNoRows = !Array.isArray(this.data?.row_list) || this.data.row_list.length === 0;
|
|
|
+ const projectCover = this.project?.cover_image_file_url || '';
|
|
|
+
|
|
|
+ // 优先在空行时使用背景图或项目封面
|
|
|
+ const backgroundImage = hasNoRows ? bcImgUrl || projectCover : '';
|
|
|
+
|
|
|
+ // 保护性读取位置/大小值,避免 undefined 导致字符串 "undefined%"
|
|
|
+ const widthPct = typeof pos.width === 'undefined' ? '' : pos.width;
|
|
|
+ const heightPct = typeof pos.height === 'undefined' ? '' : pos.height;
|
|
|
+ const leftPct = typeof pos.left === 'undefined' ? '' : pos.left;
|
|
|
+ const topPct = typeof pos.top === 'undefined' ? '' : pos.top;
|
|
|
+
|
|
|
+ const hasBcImg = Boolean(bcImgUrl);
|
|
|
+ const backgroundSize = hasBcImg ? `${widthPct}% ${heightPct}%` : hasNoRows ? 'contain' : '';
|
|
|
+ const backgroundPosition = hasBcImg ? `${leftPct}% ${topPct}%` : hasNoRows ? 'center' : '';
|
|
|
+
|
|
|
+ return {
|
|
|
+ backgroundImage: backgroundImage ? `url(${backgroundImage})` : '',
|
|
|
+ backgroundSize,
|
|
|
+ backgroundPosition,
|
|
|
+ };
|
|
|
+ },
|
|
|
handleContextMenu(event, id) {
|
|
|
if (this.canRemark) {
|
|
|
event.preventDefault(); // 阻止默认的上下文菜单显示
|