|
|
@@ -158,6 +158,13 @@ const mixin = {
|
|
|
},
|
|
|
},
|
|
|
created() {
|
|
|
+ // 生词、气泡等子面板复用了组件混入,但它们不是课件组件(没有组件 ID),
|
|
|
+ // 不能请求组件内容/背景接口,否则会带着空 component_id 请求并被服务端拒绝
|
|
|
+ if (!this.id) {
|
|
|
+ this.property.isGetContent = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
const movedContent = this.getMovedComponentContent?.(this.id);
|
|
|
if (movedContent) {
|
|
|
this.background = movedContent.background || '';
|
|
|
@@ -184,7 +191,7 @@ const mixin = {
|
|
|
},
|
|
|
methods: {
|
|
|
GetCoursewareComponentContent() {
|
|
|
- if (this.courseware_id === '' || this.id === '') return;
|
|
|
+ if (!this.courseware_id || !this.id) return;
|
|
|
this.$emit('contentLoading', true);
|
|
|
this.property.isSilentPropertyWatch = true;
|
|
|
const coursewareID = this.sourceCoursewareId || this.courseware_id;
|
|
|
@@ -327,7 +334,7 @@ const mixin = {
|
|
|
if (this.backgroundPromise) return this.backgroundPromise;
|
|
|
// 新建组件尚未保存,没有已保存的背景,直接用当前(默认)背景
|
|
|
if (this.isNew) return '';
|
|
|
- if (this.courseware_id === '' || this.id === '') return '';
|
|
|
+ if (!this.courseware_id || !this.id) return '';
|
|
|
|
|
|
// 与组件内容保持一致:从模板课件取内容时,背景也按模板组件的 id 取
|
|
|
const courseware_id = this.sourceCoursewareId || this.courseware_id;
|
|
|
@@ -458,7 +465,7 @@ const mixin = {
|
|
|
* @returns {Promise} 返回 Promise,便于父组件 await
|
|
|
*/
|
|
|
saveCoursewareComponentBackground(background = this.background) {
|
|
|
- if (!background || this.courseware_id === '' || this.id === '') return Promise.resolve();
|
|
|
+ if (!background || !this.courseware_id || !this.id) return Promise.resolve();
|
|
|
return SaveCoursewareComponentBackground({
|
|
|
courseware_id: this.courseware_id,
|
|
|
component_id: this.id,
|