qinyan 1 년 전
부모
커밋
6d68ba2983

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "@queenjs-modules/queentree": "^0.0.10",
     "@queenjs-modules/queentree-explorer": "^0.0.6",
     "@queenjs-modules/queentree-explorer-viewer": "^0.0.3",
+    "@queenjs/assets": "^0.0.20",
     "@queenjs/components": "^0.0.23",
     "@queenjs/controllers": "^0.0.8",
     "@queenjs/icons": "^0.0.20",

+ 4 - 1
src/App.tsx

@@ -1,9 +1,11 @@
+import { Provider as AssetsProvider } from "@queenjs/assets/queenjs/adapter/vue";
+import zh_cn from "ant-design-vue/es/locale/zh_CN";
 import { queenApi } from "queenjs";
 import { Provider } from "queenjs/adapter/vue";
 import { createApp, defineComponent } from "vue";
 import { Router } from "vue-router";
 import "./styles";
-import zh_cn from "ant-design-vue/es/locale/zh_CN";
+
 let setModuleHooks: any[] = [];
 
 const App = defineComponent(() => {
@@ -11,6 +13,7 @@ const App = defineComponent(() => {
   setModuleHooks = [];
   return () => (
     <Provider locale={zh_cn}>
+      <AssetsProvider />
       <router-view></router-view>
     </Provider>
   );

+ 65 - 64
src/comm/controllers/appMsgQueen5Ctrl.ts

@@ -1,86 +1,87 @@
 /**
- * 
+ *
  * 当前应用queen5接受的消息处理。
  *   目前文件依赖 设计为 当前文件 依赖于modules/ediotor/controllers下的文件,这样避免share页面打包
  *   当前模块,导致nats.ws文件被引用,引发 部分手机 share页面打不开的bug
  */
 
-
+import { CompImageObj } from "@/modules/editor/components/CompUI/basicUI/Image2";
 import { EditorModule } from "@/modules/editor/module";
-import { Controller } from "../core/controller";
-import { useCtx } from "../ctx";
+import { AppMsgRecvController, AssetTypes } from "@queenjs/assets";
 import { queenApi } from "queenjs";
-import { CompImageObj } from "@/modules/editor/components/CompUI/basicUI/Image2";
-export class AppMsgQueen5Controller extends Controller {
 
-    editorModule?:EditorModule;
+export class AppMsgQueen5Controller extends AppMsgRecvController {
+  editorModule?: EditorModule;
 
-    get editor() {
-        //使用的时候确定当前模块内容已经被设定
-        return this.editorModule as EditorModule;
-    }
+  get editor() {
+    //使用的时候确定当前模块内容已经被设定
+    return this.editorModule as EditorModule;
+  }
 
-    async onReady() {
-        this.ResetEditor();
-    }
+  Clear() {
+    this.clearListeners();
+    this.emitChange();
+  }
 
-    Clear() {
-        const { recvCtrl } = useCtx();
-        recvCtrl.clearListeners()
-        recvCtrl.emitChange();
-    }
+  async uploadImage(url: string) {
+    const response = await fetch(url);
+    const blob = await response.blob();
+    const file = await this.editor.controls.uploader.uploadFile(
+      blob,
+      "queenshow"
+    );
+    return file.url;
+  }
 
-    async uploadImage(url:string) {
+  //重置状态
+  initAssetsListeners() {
+    this.clearListeners();
+    this.addImageListener("添加图片", async (data: any) => {
+      const { uri } = data.payload;
+      console.log("添加图片=>", uri);
 
-        const response = await fetch(url)
-        const blob = await response.blob();
-        const file = await this.editor.controls.uploader.uploadFile(blob, "queenshow");
-        return file.url;
-    }
+      queenApi.showLoading("添加图片中");
+      const url = await this.uploadImage(uri);
+      await this.editor.actions.addImageToDesign(url);
+      queenApi.hideLoading();
 
-    //重置状态    
-    ResetEditor() {
-        const { recvCtrl } = useCtx();
-        recvCtrl.clearListeners()
-        recvCtrl.addImageListener("添加图片", async (uri:string)=>{
-            console.log("添加图片=>", uri);
+      return true;
+    });
 
-            queenApi.showLoading("添加图片中")
-            const url = await this.uploadImage(uri)
-            await this.editor.actions.addImageToDesign(url);
-            queenApi.hideLoading();
+    this.addImageListener("替换当前图片", async (data: any) => {
+      const { uri } = data.payload;
+      console.log("替换当前图片=>", uri);
 
-            return true;
-        })
-        recvCtrl.addImageListener("替换当前图片", async (uri:string)=>{
-            console.log("替换当前图片=>", uri);
+      if (this.editor.controls.selectCtrl.gizmo.selectedIds.length != 1) {
+        queenApi.messageError("当前没有选中的图片");
+        return true;
+      }
 
-            if (this.editor.controls.selectCtrl.gizmo.selectedIds.length != 1) {
-                queenApi.messageError("当前没有选中的图片");
-                return true;
-            }
+      queenApi.showLoading("图片替换中");
+      const url = (await this.uploadImage(uri)) as string;
 
-            queenApi.showLoading("图片替换中")
-            const url = await this.uploadImage(uri) as string;
+      const comp = this.editor.controls.pageCtrl.currComp as CompImageObj;
+      comp.value.url = url;
+      comp.value.x = 0;
+      comp.value.y = 0;
+      comp.value.s = 1;
+      comp.value.matrix = "";
+      queenApi.hideLoading();
+      return true;
+    });
 
-            const comp = this.editor.controls.pageCtrl.currComp  as CompImageObj;
-            comp.value.url = url;
-            comp.value.x = 0;
-            comp.value.y = 0;
-            comp.value.s = 1;
-            comp.value.matrix = "";
-            queenApi.hideLoading();
-            return true;
-        })
-        recvCtrl.addWebpackuriListener("添加3D组件", async (url:string, name:string, thumbnail:string)=>{
-            console.log("url", url, name, thumbnail);
+    // this.addWebpackuriListener(
+    //   "添加3D组件",
+    //   async (url: string, name: string, thumbnail: string) => {
+    //     console.log("url", url, name, thumbnail);
 
-            await this.editor.actions.clickCompToDesign("Web3D", (comp) => {
-                comp.value.url = url;
-                comp.value.poster = thumbnail;
-            });
-            return true;
-        })
-        recvCtrl.emitChange();
-    }
+    //     await this.editor.actions.clickCompToDesign("Web3D", (comp) => {
+    //       comp.value.url = url;
+    //       comp.value.poster = thumbnail;
+    //     });
+    //     return true;
+    //   }
+    // );
+    this.emitChange();
+  }
 }

+ 0 - 9
src/comm/controllers/appMsgSendCtrl.ts

@@ -1,9 +0,0 @@
-/**
- * 应用间消息发送模块
- */
-
-import { Controller } from "../core/controller";
-
-export class AppMsgSendController extends Controller {
-
-}

+ 4 - 4
src/comm/controllers/index.ts

@@ -1,13 +1,13 @@
+import { CmdSvcController } from "./cmdsvcCtrl";
 import { DeviceController } from "./deviceCtrl";
 import { NatsController } from "./natsCtrl";
-import { CmdSvcController } from "./cmdsvcCtrl";
-import { AppMsgRecvController } from "./appMsgRecvCtrl";
+import { AppMsgSendController } from "@queenjs/assets";
 import { AppMsgQueen5Controller } from "./appMsgQueen5Ctrl";
 
 export {
+  AppMsgSendController,
   DeviceController,
   NatsController,
   CmdSvcController,
-  AppMsgRecvController,
-  AppMsgQueen5Controller
+  AppMsgQueen5Controller,
 };

+ 5 - 4
src/comm/ctx/config.ts

@@ -1,9 +1,10 @@
 import * as Controls from "../controllers";
+
 const ctx = {
   deviceCtrl: new Controls.DeviceController(),
   natsCtrl: new Controls.NatsController(),
-  recvCtrl: new Controls.AppMsgRecvController(),
-  queen5MsgCtrl:new Controls.AppMsgQueen5Controller(),
-}
+  queen5MsgCtrl: new Controls.AppMsgQueen5Controller(),
+  msgSendCtrl: new Controls.AppMsgSendController(),
+};
 
-export {ctx};
+export { ctx };

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

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

+ 5 - 4
src/pages/editor/EditPage/index.tsx

@@ -51,9 +51,10 @@ export default defineComponent(() => {
     return resource.treeController.selectOnePackScene();
   };
 
-  InitControllers().then(()=>{
-     useCtx().queen5MsgCtrl.editorModule = editor;
-  })
-  
+  InitControllers().then(() => {
+    useCtx().queen5MsgCtrl.initAssetsListeners();
+    useCtx().queen5MsgCtrl.editorModule = editor;
+  });
+
   return () => <Viewport class="!h-100vh" />;
 });

+ 2 - 1
src/pages/editor/index.ts

@@ -3,10 +3,11 @@ import { initAuthDef } from "@/hooks/initAuthDef";
 import { initLauncher } from "@/modules/launcher";
 import { initResource } from "@/modules/resource";
 // import CKEditor from "@ckeditor/ckeditor5-vue";
+import { initRouter } from "@queenjs/assets/queenjs/adapter/vue";
 import router from "./router";
 
 document.title = "Queen5.鲲舞";
-
+initRouter(router);
 startApp(router, [initAuthDef, initResource, initLauncher], (app) => {
   // app.use(CKEditor);
 });

+ 5 - 0
yarn.lock

@@ -1796,6 +1796,11 @@
   resolved "http://124.70.149.18:4873/@queenjs-modules%2fqueentree/-/queentree-0.0.10.tgz"
   integrity sha512-P4cIjXKgcvd8h3vVs4f1rGLNf3/Kd5G+qGiZN+idkLjiu22HU6SNmOVLUwV6PuKg+9sTPRn7FKamSHuFxXWX5g==
 
+"@queenjs/assets@^0.0.20":
+  version "0.0.20"
+  resolved "http://124.70.149.18:4873/@queenjs%2fassets/-/assets-0.0.20.tgz#5319c4077d8bced42af0cd679c515ddca9f11d07"
+  integrity sha512-ddZIsTSCUBerC0xDeYsb0j0REu0Y4Bw8zc/IMz1MBCHVQF4y+gnwPhXWo3+S8Y0PnLr0yNCi8F47Mit8sBj4KQ==
+
 "@queenjs/components@^0.0.23":
   version "0.0.23"
   resolved "http://124.70.149.18:4873/@queenjs%2fcomponents/-/components-0.0.23.tgz#2451ddc94a99d19d37baf2d1a6d371131aa07485"