Parcourir la source

fix: 链接创建项目与项目创建弹窗

Mickey Mike il y a 3 semaines
Parent
commit
03ae5adbef

+ 13 - 1
src/renderer/src/views/designer/index.vue

@@ -24,7 +24,7 @@
       </div>
     </div>
   </div>
-  <ProjectModal />
+  <ProjectModal ref="projectModel" />
 </template>
 
 <script setup lang="ts">
@@ -35,6 +35,18 @@ import Workspace from './workspace/index.vue'
 import Config from './config/index.vue'
 import Info from './info/index.vue'
 import ProjectModal from './modals/projectModal/index.vue'
+import { ref, provide } from 'vue'
+
+const projectModel = ref()
+
+const handleMenuClick = (item: { label: string; img: string }) => {
+  switch (item.label) {
+    case '新建项目':
+      projectModel.value.open()
+  }
+}
+
+provide('onMenuClick', handleMenuClick)
 </script>
 
 <style lang="less" scoped></style>

+ 7 - 1
src/renderer/src/views/designer/tools/project.vue

@@ -3,6 +3,7 @@
     v-for="item in projectMenu"
     :key="item.label"
     class="flex flex-col justify-center items-center h-full w-60px cursor-pointer mr-10px"
+    @click="handleClick(item)"
   >
     <img :src="item.img" class="w-35px h-35px" :alt="item.label" />
     <div class="text-12px">{{ item.label }}</div>
@@ -10,7 +11,8 @@
 </template>
 
 <script setup lang="ts">
-import { reactive } from 'vue'
+import { reactive, inject } from 'vue'
+const onMenuClick = inject<(item: { label: string; img: string }) => void>('onMenuClick', () => {})
 const projectMenu = reactive([
   {
     label: '新建项目',
@@ -49,6 +51,10 @@ const projectMenu = reactive([
     img: new URL('@/assets/down.svg', import.meta.url).href
   }
 ])
+
+const handleClick = (item: { label: string; img: string }) => {
+  onMenuClick?.(item)
+}
 </script>
 
 <style lang="less" scoped></style>