bianjiang 1 жил өмнө
parent
commit
ea18492d31

+ 3 - 3
src/comm/controllers/appScreenMsgCtrl.tsx

@@ -45,14 +45,14 @@ export class AppScreenMsgController extends AppMsgRecvController {
 
       let thumbnail = source.products[0].thumbnail;
       if (thumbnail?.url) {
-        const thumb = this.loadfile(`/assets/${id}`, thumbnail.url);
+        const thumb = this.loadfile(`/assets/${id}/`, thumbnail.url);
         await thumb?.promise;
         source.products[0].thumbnail.url = thumb?.file;
       }
 
       const configFile = JSON.stringify(source);
       await deviceCtrl.WriteFileText(
-        `${deviceCtrl.appDataDir}/screen/assets/${id}.json`,
+        `${deviceCtrl.appDataDir}/screen/assets/${id}/${id}.json`,
         configFile
       );
       const currentCategory = config.category;
@@ -66,7 +66,7 @@ export class AppScreenMsgController extends AppMsgRecvController {
           name: config.name,
           thumbnail: thumbnail.url,
           type: "3D",
-          meshId: `/assets/${id}.json`,
+          source: `/assets/${id}/${id}.json`,
         };
         assets.push(assetItem);
         await deviceCtrl.WriteFileText(

+ 11 - 2
src/comm/controllers/components/SaveForm.tsx

@@ -66,7 +66,7 @@ export default defineComponent({
             <Form {...layout} name="basic">
               <Form.Item {...validateInfos.name}>
                 <Input
-                  prefix="填写名称"
+                  prefix="名称"
                   v-model={[formState.name, "value"]}
                   maxlength={20}
                 />
@@ -90,7 +90,16 @@ export default defineComponent({
   },
 });
 
-const EditFormStyle = css``;
+const EditFormStyle = css`
+  .thumbnail {
+    text-align: center;
+    img {
+      width: 180px;
+      height: 180px;
+      object-fit: cover;
+    }
+  }
+`;
 
 const btsStyle = css`
   display: flex;

+ 2 - 0
src/comm/controllers/index.ts

@@ -1,11 +1,13 @@
 import { DeviceController } from "./deviceCtrl";
 import { NatsController } from "./natsCtrl";
 import { AppScreenMsgController } from "./appScreenMsgCtrl";
+import { AppMsgSendController } from "@queenjs/assets";
 import { StoreController } from "./storeCtrl";
 
 export {
   DeviceController,
   NatsController,
   AppScreenMsgController,
+  AppMsgSendController,
   StoreController,
 };

+ 1 - 0
src/comm/ctx/config.ts

@@ -4,6 +4,7 @@ const ctx = {
   natsCtrl: new Controls.NatsController(),
   msgCtrl: new Controls.AppScreenMsgController(),
   storeCtrl: new Controls.StoreController(),
+  msgSendCtrl: new Controls.AppMsgSendController(),
 };
 
 export { ctx };

+ 1 - 1
src/comm/ctx/index.ts

@@ -1,6 +1,6 @@
 import { ctx } from "./config";
 
-let initOrder = ["deviceCtrl", "natsCtrl", "msgCtrl"];
+let initOrder = ["deviceCtrl", "natsCtrl", "msgCtrl","storeCtrl"];
 export async function SetInitOrder<K extends keyof typeof ctx>(ctrls: K[]) {
   initOrder = ctrls;
 }

+ 1 - 0
src/modules/list/actions/list.ts

@@ -49,5 +49,6 @@ export default ListModule.action({
       `${appDataDir}/screen/assets_${currentCategory}.json`,
       JSON.stringify(list)
     );
+    await deviceCtrl.RemoveFile(`${appDataDir}/screen/assets/${record._id}`)
   },
 });

+ 3 - 3
src/modules/list/actions/load.ts

@@ -79,10 +79,10 @@ export default ListModule.action({
 
   async loadPack3d(item: ItemObject) {
     const { deviceCtrl } = useCtx();
-    const meshId = item.meshId;
-    if (!meshId) return;
+    const source = item.source;
+    if (!source) return;
 
-    const ret: any = await this.https.loadLocal(deviceCtrl.httpServer + meshId);
+    const ret: any = await this.https.loadLocal(deviceCtrl.httpServer + source);
     console.log("loadPack3d", ret);
 
     return ret;

+ 1 - 1
src/modules/list/objects/item.ts

@@ -11,7 +11,7 @@ export class ItemObject {
   type: "img" | "video" | "3D" = "img";
   images?: string[];
   videoUrl?: string;
-  meshId = "";
+  source = "";
 }
 export class ColDataType {
   offset = 0;

+ 24 - 39
src/pages/frame3d/routes/frame3d/index.tsx

@@ -38,16 +38,13 @@ const Canvas3d = defineComponent({
     const { actions, components, controls, store } = useQueditor();
     store.showLoading = false;
     const getLocalSource = (asset: any) => {
-      let pack = cloneDeep(asset);
-      let source = pack.source;
+      let source = cloneDeep(asset);
 
       const { deviceCtrl } = useCtx();
       const httpServer = deviceCtrl.httpServer;
-      let scope = this;
 
       //模型处理
       let geom = source.geoms[0];
-      let osgbinUrl = geom.osgjs.url;
 
       geom.osgjs.url = httpServer + geom.osgjs.url;
       source.geoms = [geom];
@@ -81,28 +78,27 @@ const Canvas3d = defineComponent({
           m.opacity.texture.url = httpServer + m.opacity.texture.url;
         }
       });
-
-      //环境球
-      source.env3ds.forEach((item: any) => {
-        if (item.background?.image?.url) {
-          item.background.image.url = httpServer + item.background.image.url;
-        }
-        item.config.textures.forEach((t: any) => {
-          t.images.forEach((im: any) => {
-            im.file = httpServer + im.file;
-          });
-        });
-      });
-
-      source.scenes.forEach((c: any) => {
-        //@ts-ignore
-        const url = c.background?.image?.url;
-        if (url) {
-          //@ts-ignore
-          c.background.image.url = httpServer + c.background.image.url;
-        }
-      });
-
+      const scene = {
+        background: {
+          color: [0.749, 0.749, 0.749],
+          type: 2,
+        },
+        id: "001",
+        products: [
+          {
+            id: "1",
+            prodId: source.products[0].id,
+            transform: {
+              pos: [0, 0, 0],
+              rotation: [0, 0, 0],
+              scale: [1, 1, 1],
+            },
+            visible: true,
+          },
+        ],
+      };
+
+      source.scenes = [scene];
       return source;
     };
     const initQueen = () => {
@@ -110,18 +106,7 @@ const Canvas3d = defineComponent({
       actions.initPack(source);
       actions.on("initQueen3dScene:success", () => {
         const queen3d = controls.queen3dCtrl.queen3d;
-        const app = controls.queen3dCtrl.queen3d.getAppInstance();
-
-        app.setNoPan(true);
-
         queen3d.setTransparntBg();
-
-        queen3d.setControllerZoom(0.5, 6);
-
-        if (queen3d.picker) {
-          queen3d.picker.enable = false;
-        }
-
         queen3d.redraw();
         state.loaded = true;
         emit("init", true);
@@ -141,7 +126,7 @@ export default defineComponent({
   setup(props) {
     const query = getQuery();
     const dialogId = query.dialogid;
-    const meshId = query.id;
+    const source = query.source;
     const packRef = ref();
     const state = reactive({ loaded: false, loading: true });
     // window.addEventListener("message", (e: any) => {
@@ -157,7 +142,7 @@ export default defineComponent({
     // });
     const { actions } = useList();
     onMounted(async () => {
-      const res = await actions.loadPack3d({ meshId: meshId } as any);
+      const res = await actions.loadPack3d({ source: source } as any);
       packRef.value = res?.data;
       state.loaded = true;
       document.addEventListener("mousedown", () => {

+ 3 - 0
src/pages/website/routes/list/dialog.tsx

@@ -91,6 +91,9 @@ export default defineComponent({
     const initEvent = () => {
       window.addEventListener("message", (e) => {
         try {
+          if (!e.data || typeof e.data != "string") {
+            return;
+          }
           const data = JSON.parse(e.data);
           if (data.type == "start") {
             messageCloseEnd(data.dialogId);

+ 5 - 2
src/pages/website/routes/list/item.tsx

@@ -36,6 +36,9 @@ export default defineComponent({
       });
       window.addEventListener("message", (e) => {
         try {
+          if (!e.data || typeof e.data != "string") {
+            return;
+          }
           const data = JSON.parse(e.data);
           if (data.type == "ready") {
             ifRef.value?.contentWindow?.postMessage(
@@ -104,8 +107,8 @@ export default defineComponent({
             <iframe
               ref={ifRef}
               src={
-                "./frame3d.html#/?id=" +
-                props.data?.meshId +
+                "./frame3d.html#/?source=" +
+                props.data?.source +
                 "&dialogid=" +
                 props.dialogId
               }