Kaynağa Gözat

编辑器-基础:用户不设置封面的话自动进行设置

任一存 3 yıl önce
ebeveyn
işleme
8dd155328e
1 değiştirilmiş dosya ile 7 ekleme ve 54 silme
  1. 7 54
      packages/code/src/framework/EditorHead.vue

+ 7 - 54
packages/code/src/framework/EditorHead.vue

@@ -60,6 +60,7 @@ export default {
     ...mapGetters({
       info: "info",
       isShow: "isShow",
+      catalogTopology: 'catalogTopology',
     }),
   },
   methods: {
@@ -120,65 +121,17 @@ export default {
     },
 
     fixData() {
-    //   let tmp = [];
-    //   this.info.scenes.forEach((item) => {
-    //     this.info.catalogs.forEach((sub) => {
-    //       if (item.category == sub.id) {
-    //         tmp.push(sub);
-    //       }
-    //     });
-    //   });
-    //   tmp = this.$unique(tmp)
-    //   this.info.catalogs = tmp;
-    //   let rootmp = [];
-    //   tmp.forEach((item) => {
-    //     this.info.catalogRoot.forEach((sub) => {
-    //       sub.children = this.$unique(sub.children)
-    //       if (sub.children.indexOf(item.id) > -1) {
-    //         rootmp.push(sub);
-    //       }
-    //     });
-    //   });
-    //   rootmp = this.$unique(rootmp)
-
-    //   this.info.catalogRoot = rootmp.map((item) => {
-    //     let temp = [];
-    //     item.children = this.$unique(item.children)
-    //     item.children.forEach((sub) => {
-    //       tmp.forEach((jj) => {
-    //         if (jj.id == sub) {
-    //           temp.push(sub);
-    //         }
-    //       });
-    //     });
-    //     return {
-    //       ...item,
-    //       children: temp,
-    //     };
-    //   });
-    //   this.info.catalogs = tmp
-
-    //   let cid = 'c_'+this.$randomWord(true,8,8)
-
-    //   if (this.info.catalogRoot.length <= 0) {
-    //     this.info.catalogRoot.push({
-    //       id: 'r_'+this.$randomWord(true,8,8),
-    //       name: "全部场景",
-    //       children:[cid]
-    //     });
-    //   }
-
-    //   if (this.info.catalogs.length <= 0) {
-    //     this.info.catalogs.push({
-    //       id: cid,
-    //       name: "默认二级分组",
-    //     });
-    //   }
+      // 如果没有设置作品封面,拿第一个一级分组内第一个二级分组内第一个场景作为作品封面。
+      if (!this.info.icon) {
+        this.info.icon = this.catalogTopology[0].children[0].children[0].icon
+      }
 
+      // todo: 干啥呢?
       if (this.info.firstScene) {
         this.info.firstScene = this.info.scenes.find(item=>item.sceneCode==this.info.firstScene.sceneCode)
       }
 
+      // todo: 干啥呢?
       this.$store.commit("SetInfo", this.info);
     },