|
|
@@ -386,28 +386,89 @@ export default {
|
|
|
* @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 {
|
|
|
+ background_image_url: bcImgUrl = '',
|
|
|
+ background_position: pos = {},
|
|
|
+ background: back,
|
|
|
+ } = 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 : bcImgUrl;
|
|
|
+ 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;
|
|
|
+ // 保护性读取位置/大小值,避免 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' : '';
|
|
|
+ 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,
|
|
|
+ return {
|
|
|
+ backgroundImage: backgroundImage ? `url(${backgroundImage})` : '',
|
|
|
+ backgroundSize,
|
|
|
+ backgroundPosition,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ let canvasStyle = {
|
|
|
+ backgroundSize: bcImgUrl ? `${pos.width}% ${pos.height}%` : '',
|
|
|
+ backgroundPosition: bcImgUrl ? `${pos.left}% ${pos.top}%` : '',
|
|
|
+ backgroundImage: bcImgUrl ? `url(${bcImgUrl})` : '',
|
|
|
+ backgroundColor: bcImgUrl ? `rgba(255, 255, 255, ${1 - back.image_opacity / 100})` : '',
|
|
|
};
|
|
|
+
|
|
|
+ if (back) {
|
|
|
+ if (back.mode === 'image') {
|
|
|
+ canvasStyle['backgroundBlendMode'] = 'lighten';
|
|
|
+ } else {
|
|
|
+ canvasStyle['backgroundBlendMode'] = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.imageMode === 'fill') {
|
|
|
+ canvasStyle['backgroundRepeat'] = 'repeat';
|
|
|
+ } else {
|
|
|
+ canvasStyle['backgroundRepeat'] = 'no-repeat';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.imageMode === 'stretch') {
|
|
|
+ canvasStyle['backgroundSize'] = '100% 100%';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.imageMode === 'adapt') {
|
|
|
+ canvasStyle['backgroundSize'] = 'contain';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.mode === 'color') {
|
|
|
+ canvasStyle['backgroundColor'] = back.color;
|
|
|
+ canvasStyle['backgroundImage'] = '';
|
|
|
+ canvasStyle['backgroundRepeat'] = '';
|
|
|
+ canvasStyle['backgroundPosition'] = '';
|
|
|
+ canvasStyle['backgroundSize'] = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.enable_border) {
|
|
|
+ canvasStyle['border'] = `${back.border_width}px ${back.border_style} ${back.border_color}`;
|
|
|
+ } else {
|
|
|
+ canvasStyle['border'] = 'none';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (back.enable_radius) {
|
|
|
+ canvasStyle['border-top-left-radius'] = `${back.top_left_radius}px`;
|
|
|
+ canvasStyle['border-top-right-radius'] = `${back.top_right_radius}px`;
|
|
|
+ canvasStyle['border-bottom-left-radius'] = `${back.bottom_left_radius}px`;
|
|
|
+ canvasStyle['border-bottom-right-radius'] = `${back.bottom_right_radius}px`;
|
|
|
+ } else {
|
|
|
+ canvasStyle['border-radius'] = '0';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return canvasStyle;
|
|
|
},
|
|
|
handleContextMenu(event, id) {
|
|
|
if (this.canRemark) {
|