فهرست منبع

feat(frontend): 添加高级生成功能并优化相关功能

- 新增高级生成功能,包括模特图、场景图和生成视频
- 添加 getWebUrlrUrl 函数用于获取 TKK 地址
- 优化 header-bar 组件,添加点击外部区域关闭菜单的功能
- 更新 shot.vue,集成高级生成功能
- 新增 generate.ts 文件用于定义高级生成相关的菜单和功能
panqiuyao 5 ماه پیش
والد
کامیت
fa44914db0

+ 24 - 2
frontend/src/components/header-bar/index.vue

@@ -87,7 +87,7 @@
 </template>
 
 <script setup lang="ts">
-import { defineProps, reactive } from 'vue'
+import { defineProps, reactive, onMounted, onUnmounted } from 'vue'
 import useUserInfo from '@/stores/modules/user'
 import { useRouter } from 'vue-router'
 import iconsz from './assets/shezhi@2x.png'
@@ -157,7 +157,6 @@ const menuType = reactive({
   },
   ota: {
     name: '版本更新',
-    icon: gengxin,
     click: openOTA
   }
 })
@@ -254,6 +253,28 @@ function loginOut() {
   useUserInfoStore.loginOut()
   useUserInfoStore.updateLoginShow(true)
 }
+
+onMounted(() => {
+  document.addEventListener('click', handleOutsideClick)
+})
+
+onUnmounted(() => {
+  document.removeEventListener('click', handleOutsideClick)
+})
+
+function handleOutsideClick(event: MouseEvent) {
+  const menuElement = document.querySelector('.header-bar__menu')
+  if (menuElement && !menuElement.contains(event.target as Node)) {
+    // 关闭所有一级菜单
+    for (const key in submenuOpen) {
+      submenuOpen[key] = false
+    }
+    // 关闭所有三级菜单
+    for (const key in thirdLevelOpen) {
+      thirdLevelOpen[key] = false
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -384,6 +405,7 @@ function loginOut() {
   border-radius: 4px;
   overflow: hidden;
   display: none;
+  margin-top: 5px;
 
   &.submenu-open {
     display: block;

+ 23 - 0
frontend/src/utils/appfun.ts

@@ -1,4 +1,8 @@
 
+import { configs } from '@/utils/appconfig';
+import tokenInfo from '@/stores/modules/token';
+const tokenInfoStore = tokenInfo();
+
 //获取文件路径
 export  function getFilePath (file_path){
     if(file_path) return file_path;
@@ -10,3 +14,22 @@ export  function getFilePath (file_path){
 export  function getRouterUrl (href){
     return window.location.origin+window.location.pathname+href
 }
+
+
+
+//获取TKK地址
+export  function getWebUrlrUrl (config:{
+    url:string,
+    query:Object
+}){
+
+    console.log(config);
+    let params = '?source=camera&token=' + tokenInfoStore.getToken
+    if(config.query){
+        params += Object.keys(config.query).map(key => {
+            return encodeURIComponent(key) + '=' + encodeURIComponent(config.query[key])
+        }).join('&')
+    }
+    let url  = configs.tkkWebUrl + config.url + params
+    return url
+}

+ 70 - 0
frontend/src/utils/menus/generate.ts

@@ -0,0 +1,70 @@
+
+import icpList from '@/utils/ipc'
+import { getRouterUrl } from '@/utils/appfun'
+import client from '@/stores/modules/client'
+import {useRouter} from "vue-router";
+import { getWebUrlrUrl } from '@/utils/appfun'
+const Router = useRouter()
+
+const clientStore = client()
+const generate =
+        {
+            name:'高级生成',
+            children:[
+                {
+                    name:'模特图',
+                    click(){
+                        openGaenrate('onFeetImage')
+                    },
+                },
+                {
+                    name:'场景图',
+                    click(){
+                        openGaenrate('attachScenarios')
+                    },
+                },
+                {
+                    name:'生成视频',
+                    click(){
+                        openGaenrate('生成视频')
+                    },
+                },
+            ]
+        }
+
+
+
+
+
+export function openGaenrate(type) {
+
+    const config= {
+        "onFeetImage":{
+            url:"/onFeetImage",
+        },
+        "attachScenarios":{
+            url:"/attachScenarios"
+        },
+        "video":{
+            url:"/attachScenarios"
+        }
+    }
+
+
+    console.log(getWebUrlrUrl(config[type]));
+
+    clientStore.ipc.removeAllListeners(icpList.utils.openMain)
+    let params = {
+        title: '高级生成',
+        width: 1200,
+        height: 700,
+        frame: true,
+        id: 'generate',
+        url: getWebUrlrUrl(config[type])
+    }
+    clientStore.ipc.send(icpList.utils.openMain, params)
+}
+
+
+
+export default generate;

+ 6 - 2
frontend/src/views/Photography/shot.vue

@@ -185,6 +185,7 @@ import {useRouter} from "vue-router";
 import HardwareCheck from '@/components/check/index.vue'
 import checkInfo from "@/stores/modules/check";
 import RemoteControl from '@/views/RemoteControl/index'
+import  generate  from '@/utils/menus/generate'
 
 
 const loading = ref(false)
@@ -207,7 +208,6 @@ const menu = computed(()=>{
       },
       {
         name:'切换模式',
-        icon:qiehuan,
         click(){
           configInfoStore.updateAppModel(1)
           Router.push({
@@ -218,6 +218,9 @@ const menu = computed(()=>{
       {
         type:'ota'
       },
+      {
+        ...generate
+      }
     ]
   }
   if(useUserInfoStore.userInfo.brand_company_code === '1300'){
@@ -230,7 +233,8 @@ const menu = computed(()=>{
       },
       {
         type:'ota'
-      }
+      },
+      ...generate,
     ]
   }