bianjiang 1 سال پیش
والد
کامیت
def00e36f9

+ 8 - 10
src/modules/list/actions/list.ts

@@ -1,17 +1,15 @@
 import ListModule from "..";
 
 export default ListModule.action({
-  getProfileData() {
-    this.controls.bus.requestApi("queentree.local.profile").then((data) => {
-      console.log(data);
-      localStorage.setItem("token", JSON.stringify(data.Token));
-      this.config.httpConfig.baseURL = data.BaseUrl;
-      this.actions.initExpStorage(data.BaseUrl);
-    });
+  async getProfileData() {
+    const data = await this.controls.bus.requestApi("queentree.local.profile");
+    console.log(data);
+    localStorage.setItem("token", JSON.stringify(data.Token));
+    this.store.baseURL = data.BaseUrl;
+    this.actions.initExpStorage(data.BaseUrl);
   },
   async getAssetList(dbId: string, defineId: string) {
-    const res = await this.https.loadAsset(dbId, defineId);
-    console.log(res);
-    // this.store.list = res;
+    const res = await this.https.loadAsset(dbId, defineId, this.store.baseURL);
+    this.store.list = res.result.list;
   },
 });

+ 12 - 9
src/modules/list/actions/load.ts

@@ -2,11 +2,15 @@ import ListModule from "..";
 import { ItemObject } from "../objects/item";
 import { DialogItem, ShowItem } from "../objects/item";
 const artifacts = "./Artifacts.json";
-
+const defaultImage = require("@/assets/default.png");
 function loadImg(url: string, id: string, name: string): Promise<ShowItem> {
   return new Promise((resolve, reject) => {
     const m = new Image();
-    m.src = url;
+    if (url) {
+      m.src = url;
+    } else {
+      m.src = defaultImage;
+    }
     m.onload = () => {
       resolve({
         id: id,
@@ -26,18 +30,17 @@ function loadImg(url: string, id: string, name: string): Promise<ShowItem> {
         offsetZ: 0,
         timer: 0,
         name,
-
         img: m,
       });
     };
   });
 }
 export default ListModule.action({
-  async initListData(wWidth: number, wHeight: number) {
-    const items = await this.actions.loadData();
+  // async initListData(wWidth: number, wHeight: number) {
+  //   const items = await this.actions.loadData();
 
-    this.actions.initLoadShowItems(items);
-  },
+  //   this.actions.initLoadShowItems(items);
+  // },
   async shuffleSelf(arr, size) {
     let index = -1;
     const length = arr.length;
@@ -59,8 +62,8 @@ export default ListModule.action({
     if (!dbId || !defineId) {
       return;
     }
-    const list = await this.https.loadAsset(dbId, defineId);
-    this.store.list = list.data;
+    await this.actions.getAssetList(dbId, defineId);
+
     const ps = this.store.list.map((item: ItemObject, index) =>
       loadImg(item.thumbnail, item._id, item.name)
     );

+ 2 - 1
src/modules/list/http.ts

@@ -7,9 +7,10 @@ export const https = ListModule.http({
       method: "GET",
     });
   },
-  loadAsset(dbId: string, defineId: string) {
+  loadAsset(dbId: string, defineId: string, baseURL: string) {
     return this.request(`/list/${dbId}/${defineId}`, {
       method: "GET",
+      baseURL,
     });
   },
   createArtifact(data: any) {

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

@@ -4,6 +4,7 @@ import { ColDataType, DialogItem } from "./objects/item";
 
 export const stores = ListModule.store({
   state: () => ({
+    baseURL: "",
     list: [],
     // items: [] as any,
     dialogs: [] as DialogItem[],

+ 1 - 2
src/pages/frame3d/main.ts

@@ -1,6 +1,5 @@
 import { startApp } from "../App";
-import { initList } from "@/modules/list";
 import { initQueditor } from "@queenjs-modules/queditor";
 import router from "./routes";
 import "./style.less";
-startApp(router, [initList, initQueditor]);
+startApp(router, [initQueditor]);

+ 11 - 5
src/pages/frame3d/routes/frame3d/index.tsx

@@ -68,15 +68,14 @@ const Canvas3d = defineComponent({
 export default defineComponent({
   setup(props) {
     const query = getQuery();
-    const meshId = query.id;
     const dialogId = query.dialogid;
     const packRef = ref();
     const state = reactive({ loaded: false, loading: true });
-    const { actions } = useList();
+
     onMounted(async () => {
-      const res = await actions.loadPack3d({ meshId: meshId } as any);
-      packRef.value = res?.data;
-      state.loaded = true;
+      // const res = await actions.loadPack3d({ meshId: meshId } as any);
+      // packRef.value = res?.data;
+
       document.addEventListener("mousedown", () => {
         window.parent.postMessage(JSON.stringify({ type: "start", dialogId }));
       });
@@ -89,6 +88,13 @@ export default defineComponent({
       document.addEventListener("touchend", () => {
         window.parent.postMessage(JSON.stringify({ type: "end", dialogId }));
       });
+      window.addEventListener("message", (e) => {
+        debugger;
+        console.log(e);
+        const data = JSON.parse(e.data);
+        packRef.value = data;
+        state.loaded = true;
+      });
     });
 
     return () => {

+ 6 - 4
src/pages/website/routes/backend/List.tsx

@@ -2,9 +2,9 @@ import { useList } from "@/modules/list";
 import { css } from "@linaria/core";
 import { setQueentreeExplorer } from "@queenjs-modules/queentree-explorer";
 import PickNodeSteps from "@queenjs-modules/queentree-explorer/components/PickNodeSteps";
-import { BranchFolder } from "@queenjs-modules/queentree-explorer/objects/fileSystem/branchFolder";
 import { Image } from "@queenjs/ui";
 import { Button, Space, Table } from "ant-design-vue";
+import Modal from "queenjs/adapter/vue/components/modal";
 import { defineComponent } from "vue";
 
 export default defineComponent({
@@ -27,16 +27,18 @@ export default defineComponent({
       },
     ];
 
-    const showFiles = () => {
+    const showFiles = async () => {
       showModal(
         <PickNodeSteps
-          onSubmit={(branch: BranchFolder) => {
+          onSubmit={(branchArr: any) => {
+            const branch = branchArr[0][0];
             const dbId = branch.parent?.state.id;
             const defineId = branch.state.id;
             localStorage.setItem("dbId", dbId);
             localStorage.setItem("defineId", defineId);
-            console.log(dbId, defineId);
+            console.log("xxxxxxxxxxxxxxxxx", dbId, defineId);
             actions.getAssetList(dbId, defineId);
+            Modal.clear();
           }}
           lastStepText="选择"
           steps={[

+ 11 - 9
src/pages/website/routes/home/index.tsx

@@ -13,15 +13,17 @@ export default defineComponent({
 
     const rootRef = ref<HTMLElement>();
 
-    onMounted(async () => {
-      const res = await actions.initListCanvasData(
-        rootRef.value?.clientWidth as number,
-        rootRef.value?.clientHeight as number
-      );
-      if (!res) {
-        return;
-      }
-      actions.startListRunning(canvasRef.value);
+    onMounted(() => {
+      actions.on("getProfileData:success", async () => {
+        const res = await actions.initListCanvasData(
+          rootRef.value?.clientWidth as number,
+          rootRef.value?.clientHeight as number
+        );
+        if (!res) {
+          return;
+        }
+        actions.startListRunning(canvasRef.value);
+      });
     });
 
     return () => (

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

@@ -13,6 +13,7 @@ export default defineComponent({
   },
   emits: ["close", "move", "touch"],
   setup(props, { emit }) {
+    console.log(props.data);
     // const ctx = useCtx();
     // const state = reactive({
     //   descShow: false,
@@ -33,6 +34,7 @@ export default defineComponent({
       moveRef.value?.addEventListener("mousedown", (e) => {
         emit("move", true);
       });
+      // window.opener.postMessage(JSON.stringify(props.data));
     });
     // const descTigger = () => {
     //   state.descShow = !state.descShow;