|
@@ -1,5 +1,10 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div ref="courserware" class="courserware" :style="computedCourserwareStyle()" @mouseup="handleTextSelection">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref="courserware"
|
|
|
|
|
+ class="courserware"
|
|
|
|
|
+ :style="computedCourserwareStyle('courseware')"
|
|
|
|
|
+ @mouseup="handleTextSelection"
|
|
|
|
|
+ >
|
|
|
<template v-for="(row, i) in data.row_list">
|
|
<template v-for="(row, i) in data.row_list">
|
|
|
<div v-show="computedRowVisibility(row.row_id)" :key="i" class="row" :style="getMultipleColStyle(i)">
|
|
<div v-show="computedRowVisibility(row.row_id)" :key="i" class="row" :style="getMultipleColStyle(i)">
|
|
|
<el-checkbox
|
|
<el-checkbox
|
|
@@ -397,37 +402,22 @@ export default {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 计算课件背景样式
|
|
* 计算课件背景样式
|
|
|
- * @returns {Object} 课件背景样式对象
|
|
|
|
|
|
|
+ * @param {'courseware' | 'commonPreview'} type 从哪个组件调用 'courseware' 或 'commonPreview'
|
|
|
|
|
+ * @returns {object} 课件背景样式对象
|
|
|
*/
|
|
*/
|
|
|
- computedCourserwareStyle() {
|
|
|
|
|
|
|
+ computedCourserwareStyle(type) {
|
|
|
const {
|
|
const {
|
|
|
background_image_url: bcImgUrl = '',
|
|
background_image_url: bcImgUrl = '',
|
|
|
background_position: pos = {},
|
|
background_position: pos = {},
|
|
|
background: back,
|
|
background: back,
|
|
|
} = this.background || {};
|
|
} = this.background || {};
|
|
|
|
|
|
|
|
- const hasNoRows = !Array.isArray(this.data?.row_list) || this.data.row_list.length === 0; // 判断是否没有行
|
|
|
|
|
- const projectCover = this.project?.cover_image_file_url || '';
|
|
|
|
|
-
|
|
|
|
|
- // 优先在空行时使用背景图或项目封面
|
|
|
|
|
- if (hasNoRows) {
|
|
|
|
|
- const backgroundImage = hasNoRows ? bcImgUrl || projectCover : bcImgUrl;
|
|
|
|
|
-
|
|
|
|
|
- // 保护性读取位置/大小值,避免 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,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ // 如果是 commonPreview 但背景不是全域的,或者是 courseware 但背景是全域的,都不应用背景样式
|
|
|
|
|
+ if (type === 'commonPreview' && !back?.is_global) {
|
|
|
|
|
+ return {};
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type === 'courseware' && back?.is_global) {
|
|
|
|
|
+ return {};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let canvasStyle = {
|
|
let canvasStyle = {
|
|
@@ -438,10 +428,12 @@ export default {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if (back) {
|
|
if (back) {
|
|
|
- if (back.mode === 'image') {
|
|
|
|
|
- canvasStyle['backgroundBlendMode'] = 'lighten';
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if (!back.has_image) {
|
|
|
canvasStyle['backgroundBlendMode'] = '';
|
|
canvasStyle['backgroundBlendMode'] = '';
|
|
|
|
|
+ canvasStyle['backgroundImage'] = '';
|
|
|
|
|
+ canvasStyle['backgroundRepeat'] = '';
|
|
|
|
|
+ canvasStyle['backgroundPosition'] = '';
|
|
|
|
|
+ canvasStyle['backgroundSize'] = '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (back.imageMode === 'fill') {
|
|
if (back.imageMode === 'fill') {
|
|
@@ -464,12 +456,8 @@ export default {
|
|
|
canvasStyle['backgroundPosition'] = `${pos.imgX}% ${pos.imgY}%`;
|
|
canvasStyle['backgroundPosition'] = `${pos.imgX}% ${pos.imgY}%`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (back.mode === 'color') {
|
|
|
|
|
|
|
+ if (back.has_color) {
|
|
|
canvasStyle['backgroundColor'] = back.color;
|
|
canvasStyle['backgroundColor'] = back.color;
|
|
|
- canvasStyle['backgroundImage'] = '';
|
|
|
|
|
- canvasStyle['backgroundRepeat'] = '';
|
|
|
|
|
- canvasStyle['backgroundPosition'] = '';
|
|
|
|
|
- canvasStyle['backgroundSize'] = '';
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (back.enable_border) {
|
|
if (back.enable_border) {
|
|
@@ -490,6 +478,7 @@ export default {
|
|
|
|
|
|
|
|
return canvasStyle;
|
|
return canvasStyle;
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
handleContextMenu(event, id) {
|
|
handleContextMenu(event, id) {
|
|
|
if (this.canRemark) {
|
|
if (this.canRemark) {
|
|
|
event.preventDefault(); // 阻止默认的上下文菜单显示
|
|
event.preventDefault(); // 阻止默认的上下文菜单显示
|