lianghongjie 1 year ago
parent
commit
53188a05e4

+ 13 - 0
src/assets/icons/components/IconQueen.tsx

@@ -0,0 +1,13 @@
+
+import { createIcon } from '@queenjs/icons';
+export const IconQueen = createIcon(<svg viewBox="0 0 33 33">
+  
+  <g transform="translate(3 2)">
+    <path fill="currentColor"
+      d="M59.576,345.96h-.73c-.038,0-.076-.011-.115-.013-.318-.021-.637-.026-.953-.065-.432-.053-.864-.12-1.292-.2a12.65,12.65,0,0,1-2.631-.808A13.673,13.673,0,0,1,48.4,340.7a13.508,13.508,0,0,1-2.351-4.538,12.879,12.879,0,0,1-.5-2.532c-.032-.356-.068-.713-.069-1.069-.007-1.638,0-3.277,0-4.915,0-.112.006-.224.015-.335a.634.634,0,0,1,.545-.553c.16-.014.32-.017.481-.017H71.9c.119,0,.239,0,.358,0a.72.72,0,0,1,.367.1.683.683,0,0,1,.315.626c0,1.553,0,3.106,0,4.66a14.366,14.366,0,0,1-.13,1.992,13.314,13.314,0,0,1-.3,1.531,13.718,13.718,0,0,1-11.56,10.2c-.428.054-.861.071-1.292.105C59.633,345.95,59.6,345.956,59.576,345.96Zm-.359-14.652H50.5a.451.451,0,0,0-.45.42,9.764,9.764,0,0,0,.062,1.573,11.238,11.238,0,0,0,.217,1.162A9.033,9.033,0,0,0,53.4,339.3a8.913,8.913,0,0,0,2.774,1.566,9.228,9.228,0,0,0,4.072.461,8.7,8.7,0,0,0,1.242-.229,9.089,9.089,0,0,0,4.8-3.057,8.894,8.894,0,0,0,1.484-2.548,8.7,8.7,0,0,0,.57-2.571c.024-.391.021-.783.03-1.174a.338.338,0,0,0-.007-.065.474.474,0,0,0-.47-.376Q63.555,331.311,59.216,331.308Z"
+      transform="translate(-45.479 -318.03)" />
+    <path fill="currentColor"
+      d="M76.332,303.413c-.876,0-1.753.006-2.629,0a5.694,5.694,0,0,1-1.39-.129,3,3,0,0,1-2.124-1.855,3.2,3.2,0,0,1-.208-.91c-.055-.568-.048-1.137-.055-1.706a.3.3,0,0,0-.163-.284.656.656,0,0,1-.361-.563.685.685,0,1,1,1.029.551c-.068.04-.14.08-.149.166a.406.406,0,0,0,.02.17,2.975,2.975,0,0,0,5.743-.33,3.094,3.094,0,0,0,.041-.935.333.333,0,0,0-.141-.244.679.679,0,0,1-.081-1.058.683.683,0,0,1,1.144.393.643.643,0,0,1-.257.641.419.419,0,0,0-.171.319,2.977,2.977,0,0,0,5.785,1.233c.064-.187.037-.26-.133-.362a.685.685,0,0,1,.218-1.258.687.687,0,0,1,.82.67.647.647,0,0,1-.339.59.331.331,0,0,0-.187.323c0,.341,0,.682-.013,1.022a5.007,5.007,0,0,1-.159,1.3,3.012,3.012,0,0,1-1.829,2,3.254,3.254,0,0,1-.947.208c-.831.072-1.664.037-2.5.045-.324,0-.647,0-.971,0Z"
+      transform="translate(-62.605 -296.094)" />
+  </g>
+</svg>)

+ 1 - 0
src/assets/icons/index.ts

@@ -10,6 +10,7 @@ export * from "./components/IconFloatOn";
 export * from "./components/IconLayerDown";
 export * from "./components/IconLayerUp";
 export * from "./components/IconMove";
+export * from "./components/IconQueen";
 export * from "./components/IconResizeY";
 export * from "./components/IconRotate";
 export * from "./components/IconWechat";

+ 10 - 0
src/assets/icons/svg/queen.svg

@@ -0,0 +1,10 @@
+<svg viewBox="0 0 33 33">
+  <g transform="translate(3 2)">
+    <path fill="currentColor"
+      d="M59.576,345.96h-.73c-.038,0-.076-.011-.115-.013-.318-.021-.637-.026-.953-.065-.432-.053-.864-.12-1.292-.2a12.65,12.65,0,0,1-2.631-.808A13.673,13.673,0,0,1,48.4,340.7a13.508,13.508,0,0,1-2.351-4.538,12.879,12.879,0,0,1-.5-2.532c-.032-.356-.068-.713-.069-1.069-.007-1.638,0-3.277,0-4.915,0-.112.006-.224.015-.335a.634.634,0,0,1,.545-.553c.16-.014.32-.017.481-.017H71.9c.119,0,.239,0,.358,0a.72.72,0,0,1,.367.1.683.683,0,0,1,.315.626c0,1.553,0,3.106,0,4.66a14.366,14.366,0,0,1-.13,1.992,13.314,13.314,0,0,1-.3,1.531,13.718,13.718,0,0,1-11.56,10.2c-.428.054-.861.071-1.292.105C59.633,345.95,59.6,345.956,59.576,345.96Zm-.359-14.652H50.5a.451.451,0,0,0-.45.42,9.764,9.764,0,0,0,.062,1.573,11.238,11.238,0,0,0,.217,1.162A9.033,9.033,0,0,0,53.4,339.3a8.913,8.913,0,0,0,2.774,1.566,9.228,9.228,0,0,0,4.072.461,8.7,8.7,0,0,0,1.242-.229,9.089,9.089,0,0,0,4.8-3.057,8.894,8.894,0,0,0,1.484-2.548,8.7,8.7,0,0,0,.57-2.571c.024-.391.021-.783.03-1.174a.338.338,0,0,0-.007-.065.474.474,0,0,0-.47-.376Q63.555,331.311,59.216,331.308Z"
+      transform="translate(-45.479 -318.03)" />
+    <path fill="currentColor"
+      d="M76.332,303.413c-.876,0-1.753.006-2.629,0a5.694,5.694,0,0,1-1.39-.129,3,3,0,0,1-2.124-1.855,3.2,3.2,0,0,1-.208-.91c-.055-.568-.048-1.137-.055-1.706a.3.3,0,0,0-.163-.284.656.656,0,0,1-.361-.563.685.685,0,1,1,1.029.551c-.068.04-.14.08-.149.166a.406.406,0,0,0,.02.17,2.975,2.975,0,0,0,5.743-.33,3.094,3.094,0,0,0,.041-.935.333.333,0,0,0-.141-.244.679.679,0,0,1-.081-1.058.683.683,0,0,1,1.144.393.643.643,0,0,1-.257.641.419.419,0,0,0-.171.319,2.977,2.977,0,0,0,5.785,1.233c.064-.187.037-.26-.133-.362a.685.685,0,0,1,.218-1.258.687.687,0,0,1,.82.67.647.647,0,0,1-.339.59.331.331,0,0,0-.187.323c0,.341,0,.682-.013,1.022a5.007,5.007,0,0,1-.159,1.3,3.012,3.012,0,0,1-1.829,2,3.254,3.254,0,0,1-.947.208c-.831.072-1.664.037-2.5.045-.324,0-.647,0-.971,0Z"
+      transform="translate(-62.605 -296.094)" />
+  </g>
+</svg>

+ 5 - 0
src/modules/editor/components/TipIcons/index.ts

@@ -7,6 +7,7 @@ import {
   IconFloatOn,
   IconLayerDown,
   IconLayerUp,
+  IconQueen,
 } from "@/assets/icons";
 import {
   IconCamera,
@@ -24,6 +25,10 @@ import {
 import { createTipIcon } from "./create";
 
 export const TipIcons = {
+  QueenService: createTipIcon({
+    icons: [IconQueen],
+    tips: ["3dqueen服务"],
+  }),
   Screenshot: createTipIcon({
     icons: [IconCamera],
     tips: ["截屏并保存封面"],

+ 12 - 0
src/modules/editor/components/Viewport/Toolbar/index.tsx

@@ -2,10 +2,12 @@ import { useEditor } from "@/modules/editor";
 import { defineUI } from "queenjs";
 import { TipIcons } from "../../TipIcons";
 import { css } from "@linaria/core";
+import { useLauncher } from "@/modules/launcher";
 
 export default defineUI({
   setup() {
     const { actions, controls } = useEditor();
+    const launcher = useLauncher();
     const { history } = controls.historyCtrl;
     return () => (
       <>
@@ -27,6 +29,16 @@ export default defineUI({
             onClick={() => actions.updateThumbnailByScreenshot(true)}
           />
         </div>
+        <div class="absolute bottom-20px right-20px z-999">
+          <TipIcons.QueenService
+            class={btnCls}
+            onClick={() => {
+              launcher.showModal(<launcher.components.Viewport />, {
+                width: "400px",
+              });
+            }}
+          />
+        </div>
       </>
     );
   },

+ 14 - 1
src/modules/launcher/actions/index.ts

@@ -1,7 +1,20 @@
+import { queenApi } from "queenjs";
 import { LauncherModule } from "..";
+import { Application } from "../objects/Application";
 
 export const actions = LauncherModule.action({
   init() {
-    this.store.setApps([])
+    this.store.setApps([
+      new Application("queengine", { visible: true, disable: true }),
+      new Application("queentree", { visible: true }),
+      new Application("queenter", { visible: true }),
+    ]);
+  },
+  async updateHost() {
+    const host = await queenApi.showInput({
+      title: "设置Host",
+      defaultValue: this.store.host,
+    });
+    this.store.setHost(host);
   },
 });

+ 18 - 0
src/modules/launcher/apis/queentree.ts

@@ -0,0 +1,18 @@
+import { LauncherModule } from "..";
+
+export const queentreeApi = LauncherModule.define({
+  async selectOneAsset(assetType: string) {
+    
+    const { waitChanell } = await this.controls.natsCtrl.requestApi(
+      "tree.selector.iframe.packcomp"
+    );
+    this.controls.natsCtrl.subscribe(waitChanell, (asset: any) => {
+      console.log(asset);
+    });
+
+    const url = await this.controls.natsCtrl.requestApi("xxx.url");
+
+    //openIframe
+    //wait iframe result
+  },
+});

+ 24 - 3
src/modules/launcher/components/Viewport/index.tsx

@@ -1,9 +1,30 @@
 import { defineComponent } from "vue";
+import { useLauncher } from "../..";
+import { ApplicationTypes } from "../../objects/Application/types";
 
 export const Viewport = defineComponent({
   setup() {
-    return () => <div>
-      
-    </div>;
+    const { store, actions } = useLauncher();
+    return () => (
+      <div>
+        <div>
+          <span class="mr-10px">当前Host: </span>
+          <a onClick={() => actions.updateHost()}>{store.host}</a>
+        </div>
+        <div class="border-bottom my-10px"></div>
+        <div class="space-y-6px">
+          {store.apps
+            .filter((d) => d.visible)
+            .map((d) => {
+              return (
+                <div class="flex justify-between" key={d.appKey}>
+                  <span>{ApplicationTypes[d.appKey].name}</span>
+                  <button>{d.disable ? "不可用" : "打开"}</button>
+                </div>
+              );
+            })}
+        </div>
+      </div>
+    );
   },
 });

+ 9 - 0
src/modules/launcher/index.ts

@@ -4,6 +4,7 @@ import { components } from "./components";
 import { stores } from "./stores";
 import { BusController } from "@/controllers/natsController";
 import { IAppKeys } from "./objects/Application/types";
+import { queentreeApi } from "./apis/queentree";
 
 export class LauncherModule extends ModuleRoot {
   config = this.setConfig({
@@ -14,7 +15,15 @@ export class LauncherModule extends ModuleRoot {
   store = this.createStore(stores);
   actions = this.createActions(actions);
 
+  queentreeApi = this.use(queentreeApi);
+
   controls = {
     natsCtrl: new BusController(),
   };
+
+  onReady() {
+    this.actions.init();
+  }
 }
+
+export const { initLauncher, useLauncher } = LauncherModule.hook("Launcher");

+ 1 - 1
src/modules/launcher/objects/Application/index.ts

@@ -5,7 +5,7 @@ export class Application {
   disable = false;
   constructor(
     public appKey: IAppKeys,
-    options: Partial<Application>
+    options?: Partial<Application>
   ) {
     Object.assign(this, options);
   }

+ 4 - 1
src/modules/launcher/stores/index.ts

@@ -3,12 +3,15 @@ import { Application } from "../objects/Application";
 
 export const stores = LauncherModule.store({
   state: () => ({
-    readyState: false,
+    host: "https://www.ccc.com/",
     apps: [] as Application[],
   }),
   actions: {
     setApps(apps: Application[]) {
       this.store.apps = apps;
     },
+    setHost(host: string) {
+      this.store.host = host;
+    },
   },
 });

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

@@ -1,11 +1,12 @@
 import { startApp } from "@/App";
 import { initAuthDef } from "@/hooks/initAuthDef";
+import { initLauncher } from "@/modules/launcher";
+import { initResource } from "@/modules/resource";
 import CKEditor from "@ckeditor/ckeditor5-vue";
 import router from "./router";
-import { initResource } from "@/modules/resource";
 
 document.title = "推广编辑器";
 
-startApp(router, [initAuthDef, initResource], (app) => {
+startApp(router, [initAuthDef, initResource, initLauncher], (app) => {
   app.use(CKEditor);
 });