Browse Source

load asset

bianjiang 1 year ago
parent
commit
c4ee3ae3ff

+ 1 - 1
main.js

@@ -29,7 +29,7 @@ const createWindow = () => {
         },
 
         {
-          label: "文物管理",
+          label: "管理",
           click: async () => {
             win.loadFile("./dist/index.html", {
               hash: "/backend",

+ 3 - 2
package.json

@@ -18,7 +18,8 @@
     "@linaria/core": "^4.1.1",
     "@queenjs-modules/auth": "^0.0.18",
     "@queenjs-modules/queditor": "^0.0.9",
-    "@queenjs-modules/queentree": "^0.0.7",
+    "@queenjs-modules/queentree": "^0.0.8",
+    "@queenjs-modules/queentree-explorer": "^0.0.2",
     "@queenjs/components": "^0.0.5",
     "@queenjs/controllers": "^0.0.6",
     "@queenjs/icons": "^0.0.20",
@@ -47,7 +48,7 @@
     "proto.gl": "^1.0.0",
     "qrcode": "^1.5.1",
     "queen3d": "^0.0.80",
-    "queenjs": "^1.0.0-beta.68",
+    "queenjs": "^1.0.0-beta.69",
     "queentree": "^0.1.86-nocheck",
     "rimraf": "^3.0.2",
     "scp2": "^0.5.0",

+ 4 - 0
src/modules/list/actions/canvas.ts

@@ -9,6 +9,9 @@ export default ListModule.action({
     const totalLines = this.store.animate.totalLines;
     const scrollType = this.store.animate.scrollType;
     const items = await this.actions.loadData();
+    if (!items) {
+      return;
+    }
     const scale = Math.max(devicePixelRatio, 2);
 
     const canvas = {
@@ -27,6 +30,7 @@ export default ListModule.action({
     if (scrollType == "horizontal") {
       await this.actions.initHorizontalList(items);
     }
+    return true;
   },
   async initVerticalList(items) {
     const totalLines = this.store.animate.totalLines;

+ 2 - 1
src/modules/list/actions/index.ts

@@ -4,5 +4,6 @@ import list from "./list";
 
 import canvas from "./canvas";
 import animate from "./animate";
+import storage from "./storage";
 
-export default [load, dialog, canvas, animate,list];
+export default [load, dialog, canvas, animate, list, storage];

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

@@ -1,9 +1,17 @@
 import ListModule from "..";
 
 export default ListModule.action({
-  getListData() {
-    this.controls.bus.requestApi("queentree.local.profile").then((list) => {
-      console.log(list);
+  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 getAssetList(dbId: string, defineId: string) {
+    const res = await this.https.loadAsset(dbId, defineId);
+    console.log(res);
+    // this.store.list = res;
+  },
 });

+ 6 - 1
src/modules/list/actions/load.ts

@@ -54,7 +54,12 @@ export default ListModule.action({
     return arr;
   },
   async loadData() {
-    const list = await this.https.loadLocal(artifacts);
+    const dbId = localStorage.getItem("dbId");
+    const defineId = localStorage.getItem("defineId");
+    if (!dbId || !defineId) {
+      return;
+    }
+    const list = await this.https.loadAsset(dbId, defineId);
     this.store.list = list.data;
     const ps = this.store.list.map((item: ItemObject, index) =>
       loadImg(item.thumbnail, item._id, item.name)

+ 47 - 0
src/modules/list/actions/storage.ts

@@ -0,0 +1,47 @@
+import { Exp_Storage } from "@queenjs-modules/queentree-explorer/dicts/storage";
+import {
+  HostRootItem,
+  NodeRootItem,
+} from "@queenjs-modules/queentree-explorer/typings";
+
+import ListModule from "..";
+
+export default ListModule.action({
+  initExpStorage(baseURL: string) {
+    Exp_Storage.setVersion("1.0.5").setDefaultValue(() => {
+      const expHosts: { [name: string]: HostRootItem } = {};
+
+      const localNodeRoot: NodeRootItem = {
+        names: ["本地"],
+        ids: [Math.random().toString()],
+        nodeType: "host",
+        tabPerms: ["rename"],
+        nodePerms: ["editable", "saveAs"],
+      };
+
+      expHosts[localNodeRoot.ids[0]] = {
+        baseURL: baseURL,
+        authURL: "",
+        authKey: "queentreesku3d",
+      };
+
+      const expNodeRoots = [localNodeRoot];
+
+      return {
+        expHosts,
+        expWindows: [
+          {
+            groupName: "我的资源",
+            rootNodeIds: expNodeRoots.map(
+              (rootNode) => rootNode.ids.at(-1) || ""
+            ),
+          },
+        ],
+        expNodeRoots,
+        expActiveState: {
+          currWindowName: "我的资源",
+        },
+      };
+    });
+  },
+});

+ 5 - 0
src/modules/list/http.ts

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

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

@@ -4,6 +4,7 @@ import actions from "./actions";
 import { https } from "./http";
 import { stores } from "./stores";
 import { BusController } from "@/controllers/natsController";
+
 export default class ListModule extends ModuleRoot {
   config = this.setConfig({
     httpConfig: {
@@ -19,7 +20,7 @@ export default class ListModule extends ModuleRoot {
   };
 
   onReady() {
-    this.actions.getListData();
+    this.actions.getProfileData();
     this.actions.initAnimateAttr();
   }
 }

+ 1 - 0
src/pages/App.tsx

@@ -3,6 +3,7 @@ import { Provider } from "queenjs/adapter/vue";
 import { Router } from "vue-router";
 import { createApp } from "vue";
 import { queenApi } from "queenjs";
+import "windi.css";
 import "@/styles/global.less";
 let setModuleHooks: any[] = [];
 

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

@@ -1,14 +1,16 @@
+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 { defineComponent } from "vue";
 
-import { Image } from "@queenjs/ui";
-
-import { useList } from "@/modules/list";
-
 export default defineComponent({
   setup() {
-    const { store, showModal } = useList();
+    const { store, showModal, actions } = useList();
+    setQueentreeExplorer({});
     const columns = [
       {
         title: "封面图",
@@ -25,6 +27,40 @@ export default defineComponent({
       },
     ];
 
+    const showFiles = () => {
+      showModal(
+        <PickNodeSteps
+          onSubmit={(branch: BranchFolder) => {
+            const dbId = branch.parent?.state.id;
+            const defineId = branch.state.id;
+            localStorage.setItem("dbId", dbId);
+            localStorage.setItem("defineId", defineId);
+            console.log(dbId, defineId);
+            actions.getAssetList(dbId, defineId);
+          }}
+          lastStepText="选择"
+          steps={[
+            {
+              title: "选择模型库",
+              content: () => {
+                return (
+                  <PickNodeSteps.PickNodeStep
+                    options={{
+                      nodeType: "branch",
+                      childNodeType: "pack",
+                    }}
+                  />
+                );
+              },
+            },
+          ]}
+          expConfig={{ showNodeToolbar: false, nodeListColumns: 6 }}
+        />,
+        {
+          width: "600px",
+        }
+      );
+    };
     return () => (
       <div class={ViewStyle}>
         <div class="table_header">
@@ -35,7 +71,7 @@ export default defineComponent({
                 type="primary"
                 ghost
                 onClick={() => {
-                  console.log(1);
+                  showFiles();
                 }}
               >
                 导入模型

+ 4 - 1
src/pages/website/routes/home/index.tsx

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

+ 7 - 0
src/styles/global.less

@@ -1,4 +1,5 @@
 @import "./theme";
+
 html {
   font-size: calc(1920px / 19.2);
 }
@@ -7,3 +8,9 @@ html {
   width: 100%;
   height: 100%;
 }
+@direction: top, bottom, left, right;
+each(@direction, {
+  .border-@{value} {
+    border-@{value}: 1px solid @inf-border-color;
+  }
+});

+ 7 - 17
tsconfig.json

@@ -13,28 +13,18 @@
     "keyofStringsOnly": true,
     "sourceMap": true,
     "baseUrl": ".",
-    "types": [
-      "webpack-env",
-    ],
+    "types": ["webpack-env"],
     "paths": {
-      "@/*": [
-        "src/*"
-      ]
+      "@/*": ["src/*"]
     },
-    "lib": [
-      "esnext",
-      "dom",
-      "dom.iterable",
-      "scripthost"
-    ]
+    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
   },
   "include": [
     "src/**/*.ts",
     "src/**/*.tsx",
     "src/**/*.vue",
-    "node_modules/queenjs/**/*.ts"
+    "node_modules/queenjs/**/*.ts",
+    "node_modules/@queenjs-modules/**/*.ts"
   ],
-  "exclude": [
-    "node_modules"
-  ]
-}
+  "exclude": ["node_modules"]
+}

+ 24 - 0
vue.config.js

@@ -56,5 +56,29 @@ module.exports = defineConfig({
             },
         },
     },
+    pluginOptions: {
+        windicss: {
+            scan: {
+                dirs: ["node_modules/@queenjs-modules"],
+                fileExtensions: ["tsx"]
+            },
+            preflight: false,
+            onOptionsResolved: (options) => {
+                options.scanOptions.extraTransformTargets = {
+                    css: [(f) => {
+                        if (/node_modules\\@queenjs-modules\\.+\.(css|less)/.test(f)) {
+                            return true;
+                        }
+                        return false;
+                    }],
+                    detect: [],
+                }
+                return options
+            },
+
+
+            // see https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts
+        },
+    },
 
 });

+ 13 - 8
yarn.lock

@@ -1229,10 +1229,15 @@
   resolved "http://124.70.149.18:4873/@queenjs-modules%2fqueditor/-/queditor-0.0.9.tgz#2c4c0b8d68da48e3e30dc92b0acb5f1f8d8761ce"
   integrity sha512-iK9PykYQO0gZOcz851e4NNBUAg/DlmhuQrQgRkmlK287oD7u6r8pD/ONOD7Anyy04FP6BTe9DOhGMW55imdlVw==
 
-"@queenjs-modules/queentree@^0.0.7":
-  version "0.0.7"
-  resolved "http://124.70.149.18:4873/@queenjs-modules%2fqueentree/-/queentree-0.0.7.tgz#11cb29201d8bc0e27ec10af46f2ff56a99daafc0"
-  integrity sha512-aKAfet022zGSmN8mmGMaVBdX4OG9rzf/vi90uxY2F6boa6EkE8SD8zgoeFimgEWgR8IgqFQ2Zn8h0Rb3D2bcMQ==
+"@queenjs-modules/queentree-explorer@^0.0.2":
+  version "0.0.2"
+  resolved "http://124.70.149.18:4873/@queenjs-modules%2fqueentree-explorer/-/queentree-explorer-0.0.2.tgz#fbbee041ed4d6de19edc7401f1c2734a2b971952"
+  integrity sha512-gV3Uba0LJxcpgDltktvtQ6F2ndj3w7T57PV1iD0xpezLCDYgNGnOVWBGrpKekr2QAnbxlX2z2jRv6XotHicRww==
+
+"@queenjs-modules/queentree@^0.0.8":
+  version "0.0.8"
+  resolved "http://124.70.149.18:4873/@queenjs-modules%2fqueentree/-/queentree-0.0.8.tgz#2a471100a1d09e72dcbc54daa453fc4c275a71b7"
+  integrity sha512-+B9WbIUgm656hR9bougNDLAq2p7foaEhybfyjLHu2DIqmyNooKkzNth8e/R/R4QjbCI6Who6Pg6q0H9txnjLcA==
 
 "@queenjs/components@^0.0.5":
   version "0.0.5"
@@ -6365,10 +6370,10 @@ queen3d@^0.0.80:
   resolved "http://124.70.149.18:4873/queen3d/-/queen3d-0.0.80.tgz"
   integrity sha512-GaBzki+vcjC4JDN4olh/UI3oW6BRc1qbk1+pwUlbBN0oC+ilKNn9C64tLSEio0zWZikEtGb6A9jrUXntX1no4A==
 
-queenjs@^1.0.0-beta.68:
-  version "1.0.0-beta.68"
-  resolved "http://124.70.149.18:4873/queenjs/-/queenjs-1.0.0-beta.68.tgz"
-  integrity sha512-ToUBPQfxa6aHtomXjNUuBFVkZG1FDXe+AGuaBTK+cUbjyHo6KD1X3h1xArdN3bepnrgUGe2nWKhY6Ep8N+towA==
+queenjs@^1.0.0-beta.69:
+  version "1.0.0-beta.69"
+  resolved "http://124.70.149.18:4873/queenjs/-/queenjs-1.0.0-beta.69.tgz#ee348103035562ab0943564a30c66c7314c26789"
+  integrity sha512-PrEzn48RiuI7gbAhMhWL0zVF9Yp1w9fgHCahEPTDW2LUozyhL7rMA4Q6g7IuGy3H4ydxj3SHVl1KhqmYMI1IeQ==
   dependencies:
     axios "^0.27.2"
     eventemitter3 "^4.0.7"