|
@@ -1,86 +1,87 @@
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ *
|
|
* 当前应用queen5接受的消息处理。
|
|
* 当前应用queen5接受的消息处理。
|
|
* 目前文件依赖 设计为 当前文件 依赖于modules/ediotor/controllers下的文件,这样避免share页面打包
|
|
* 目前文件依赖 设计为 当前文件 依赖于modules/ediotor/controllers下的文件,这样避免share页面打包
|
|
* 当前模块,导致nats.ws文件被引用,引发 部分手机 share页面打不开的bug
|
|
* 当前模块,导致nats.ws文件被引用,引发 部分手机 share页面打不开的bug
|
|
*/
|
|
*/
|
|
|
|
|
|
-
|
|
|
|
|
|
+import { CompImageObj } from "@/modules/editor/components/CompUI/basicUI/Image2";
|
|
import { EditorModule } from "@/modules/editor/module";
|
|
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 { 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();
|
|
|
|
+ }
|
|
}
|
|
}
|