index.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { useResource } from "@/modules/resource";
  2. import { initQueditor } from "@queenjs-modules/queditor";
  3. import { switchSceneProdComp } from "@queenjs-modules/queditor/module/controls/Queen3dCtrl/actions/geom";
  4. import { initExpViewer } from "@queenjs-modules/queentree-explorer-viewer";
  5. import { defineComponent, onBeforeUnmount, onMounted } from "vue";
  6. import { useRoute } from "vue-router";
  7. import AttrPanel from "./components/AttrPanel";
  8. import Header from "./components/Header";
  9. import LeftPanel from "./components/LeftPanel";
  10. export default defineComponent({
  11. setup() {
  12. const route = useRoute();
  13. const expViewer = initExpViewer({
  14. modules: {
  15. queditor: initQueditor({
  16. config: {
  17. dragEnable: true,
  18. },
  19. }),
  20. },
  21. });
  22. const resource = useResource();
  23. const { queditor } = expViewer.modules;
  24. expViewer.initComponents({
  25. Viewport: {
  26. Header: {
  27. default: Header,
  28. },
  29. EditPanel: {
  30. default: AttrPanel,
  31. },
  32. },
  33. });
  34. queditor.initComponents({
  35. Viewport: {
  36. SiderLeft: {
  37. default: LeftPanel,
  38. },
  39. Toolbar: {
  40. default: () => null,
  41. },
  42. },
  43. });
  44. const { id } = route.params;
  45. const init = async () => {
  46. await resource.actions.queryTplsDetail(id as string);
  47. queditor.actions.initPack(resource.store.sourceDetail?.webEditor?.pack);
  48. queditor.store.setCurrScene(0);
  49. expViewer.store.setEditNodeUid(resource.store.sourceDetail._id);
  50. queditor.actions.on("initQueen3dScene:success", () => {
  51. switchSceneProdComp.call(
  52. queditor.controls.queen3dCtrl,
  53. queditor.store.pack.scenes[0].products[0].id,
  54. resource.store.currentMesh.meshName
  55. );
  56. });
  57. };
  58. onMounted(() => init());
  59. onBeforeUnmount(() => resource.store.setSourceDetail({}));
  60. return () => {
  61. return (
  62. <div class="h-100vh">
  63. <expViewer.components.Viewport />
  64. </div>
  65. );
  66. };
  67. },
  68. });