Przeglądaj źródła

Merge remote-tracking branch 'origin/dev-frontend' into dev-frontend

panqiuyao 8 miesięcy temu
rodzic
commit
a2d4dd6141

+ 14 - 1
frontend/src/components/check/index.vue

@@ -54,7 +54,7 @@
             <div class="check-btn cu-p" @click="reCheck">重新监测</div>
         </div>
         <div class="flex" v-else>
-            <div class="check-btn cu-p" style="width: 180px" @click="confirm()">正常,开始下一步</div>
+            <div class="check-btn cu-p" style="width: 180px" @click="confirm()"> {{ checkInfoStore.isFirstCheck ? '正常,开始下一步' : '检测成功,继续操作'}}</div>
         </div>
     </template>
   </el-dialog>
@@ -148,6 +148,18 @@ watchEffect(async ()=>{
   }
 })
 
+
+
+watchEffect(async ()=>{
+  if( checkCount.value >= 1 && checkInfoStore.getProgress !== 100 && !checkInfoStore.isFirstCheck.value){
+    visible.value = true
+    checkLoading.value = false;
+    checkSuccess.value = false;
+  }
+})
+
+
+
 watchEffect(async ()=>{
   if(checkInfoStore.getProgress === 100 ){
     checkLoading.value = false;
@@ -175,6 +187,7 @@ watchEffect(async ()=>{
 
 function confirm(){
   visible.value = false;
+  checkInfoStore.set_isFirstCheck(false);
   emit('confirm')
 }
 

+ 29 - 7
frontend/src/components/header-bar/index.vue

@@ -9,13 +9,21 @@
     <div class="header-bar__title">
       <span class="header-bar__text">{{ title }}</span>
     </div>
-    <div class="header-bar__buttons">
-<!--      <div class="header-bar__button" @click="minimizeWindow">
-        <img :src="iconMinimize" class="header-bar__button-icon" />
+    <div class="header-bar__buttons" >
+      <div class="header-bar__button header-bar__button__user" v-if="showUser">
+
+
+        <el-dropdown>
+          <span class="el-dropdown-link">
+           {{useUserInfoStore.userInfo.account_name || useUserInfoStore.userInfo.real_name || useUserInfoStore.userInfo.login_name}}
+          </span>
+          <template #dropdown>
+            <el-dropdown-menu>
+              <el-dropdown-item @click="loginOut">退出登录</el-dropdown-item>
+            </el-dropdown-menu>
+          </template>
+        </el-dropdown>
       </div>
-      <div class="header-bar__button" @click="closeWindow">
-        <img :src="iconClose" class="header-bar__button-icon" />
-      </div>-->
     </div>
   </div>
   <div class="header-bar_blank"></div>
@@ -23,6 +31,7 @@
 
 <script setup lang="ts">
 import { defineProps, reactive } from 'vue';
+import useUserInfo from "@/stores/modules/user";
 import { useRouter} from "vue-router";
 import iconsz from './assets/shezhi@2x.png'
 import iconykq from './assets/yaokong@2x.png'
@@ -32,6 +41,7 @@ import icpList from '@/utils/ipc'
 import { getRouterUrl } from '@/utils/appfun'
 import client from "@/stores/modules/client";
 const clientStore = client();
+const useUserInfoStore = useUserInfo();
 
 // 定义 menu 项的类型
 interface MenuItem {
@@ -50,6 +60,10 @@ const props = defineProps({
   menu: {
     type: Array as () => MenuItem[],
     default: () => []
+  },
+  showUser:{
+    type: Boolean,
+    default: false
   }
 });
 const Router = useRouter()
@@ -104,6 +118,11 @@ function openSetting() {
   clientStore.ipc.send(icpList.utils.openMain, params);
 }
 
+function loginOut(){
+  useUserInfoStore.loginOut();
+  useUserInfoStore.updateLoginShow(true)
+}
+
 // 新增
 function minimizeWindow() {
   clientStore.ipc.send(icpList.utils.minimizeWindow);
@@ -196,7 +215,7 @@ function closeWindow() {
 }
 
 .header-bar__button {
-  width: 30px;
+  min-width: 30px;
   height: 30px;
   border: none;
   cursor: pointer;
@@ -205,6 +224,9 @@ function closeWindow() {
   justify-content: center;
 }
 
+.header-bar__button__user {
+  padding: 0 10px;
+}
 .header-bar__button:hover {
   background-color: #e0e0e0;
 }

+ 25 - 0
frontend/src/composables/userCheck.ts

@@ -0,0 +1,25 @@
+import { watchEffect } from 'vue';
+import { ElMessageBox  } from 'element-plus';
+import checkInfo from "../stores/modules/check";
+import {fa} from "element-plus/es/locale";
+
+const checkInfoStore = checkInfo()
+export function useCheckInfo() {
+
+    watchEffect(async ()=>{
+        if( checkInfoStore.getProgress !== 100 && !checkInfoStore.isFirstCheck.value){
+            ElMessageBox({
+                title:"链接出错!",
+                message:'设备连接出错,请在主窗口中重新连接设备后,在重新打开此窗口后进行操作',
+                showCancelButton:false,
+                showConfirmButton:false,
+                closeOnClickModal:false,
+                closeOnPressEscape:false,
+                closeOnHashChange:false,
+                showClose:false
+            })
+            return
+        }
+    })
+
+}

+ 1 - 1
frontend/src/router/index.ts

@@ -5,7 +5,7 @@ import { authGuard } from './plugins/authGuard'
 const routes: RouteRecordRaw[] = [
     {
         path: "/",
-        redirect: "/photography/check"
+        redirect: "/home"
     },
     {
         path: "/home",

+ 14 - 2
frontend/src/stores/modules/check.ts

@@ -36,7 +36,15 @@ export const checkInfo = defineStore('checkInfo', () => {
     const blue_tooth_scan_NO = ref('')
     const checkTime = ref(0)
     let CKTimerInterval:any = null
-
+    let CKCamControlInterval:any = null
+    const isFirstCheck = ref(true)
+    const set_isFirstCheck = ()=>{
+        isFirstCheck.value = false
+        //开始监听相机软件连接状态
+        CKCamControlInterval =   setInterval(()=>{
+            checkcamControl()
+        },3000)
+    }
     //mcu 初始化
     const mcu = reactive({
         isInitSend:false,
@@ -49,7 +57,8 @@ export const checkInfo = defineStore('checkInfo', () => {
         for (const device of Object.values(devices)) {
             if (device.status === 2) completed++;
         }
-        return parseFloat((completed / total * 100).toFixed(2));
+        let value = parseFloat((completed / total * 100).toFixed(2));
+        return value
     });
 
     // 获取错误信息
@@ -164,6 +173,7 @@ export const checkInfo = defineStore('checkInfo', () => {
         for (const deviceName of Object.keys(devices)) {
             switch (deviceName){
                 case 'cam_control':
+                    if(CKCamControlInterval) clearInterval(CKCamControlInterval)
                     await checkcamControl();
                     break;
                 case 'camera':
@@ -215,6 +225,8 @@ export const checkInfo = defineStore('checkInfo', () => {
         blueTooth: devices.blueTooth,
         camControl: devices.camControl,
         camera: devices.camera,
+        isFirstCheck,
+        set_isFirstCheck,
         blue_tooth_scan_NO,
         set_blue_tooth_scan_NO,
         checkAction,

+ 21 - 1
frontend/src/stores/modules/user.ts

@@ -52,7 +52,7 @@ export const useUserInfo = defineStore('userInfo', () => {
     try {
       const res = await login(data); // 调用登录接口
       await updateToken(res.data.token); // 更新登录令牌
-   //   await getInfo(); // 获取用户信息
+      //   await getInfo(); // 获取用户信息
       return res;
     } catch (error) {
       console.error('登录失败:', error);
@@ -60,6 +60,25 @@ export const useUserInfo = defineStore('userInfo', () => {
     }
   };
 
+
+
+  /**
+   * 执行用户登录操作。
+   *
+   * @param {any} data - 登录所需的用户凭据。
+   * @returns {Promise<any>} 登录接口返回的结果。
+   * @throws {Error} 如果登录失败,抛出错误。
+   */
+  const loginOut = async (data: any) => {
+    try {
+      await updateToken(''); // 更新登录令牌
+      await updateUserInfo({})
+    } catch (error) {
+      console.error('登录失败:', error);
+      throw error;
+    }
+  };
+
   /**
    * 获取用户信息并更新状态。
    *
@@ -88,6 +107,7 @@ export const useUserInfo = defineStore('userInfo', () => {
     updateUserInfo,
     updateLoginShow,
     loginAction,
+    loginOut,
     getInfo,
   };
 });

+ 1 - 0
frontend/src/views/Photography/check.vue

@@ -3,6 +3,7 @@
   <headerBar
       title="拍摄物体镜头矫正"
       :menu="menu"
+      showUser
   />
   <div class="check-wrap flex">
 

+ 9 - 8
frontend/src/views/Photography/detail.vue

@@ -1,14 +1,11 @@
 <template>
 
-  <headerBar title="拍摄商品" :menu="[
+  <headerBar title="主图与详情生成" :menu="[
     {
       type: 'setting'
-    },
-    {
-      name: '详情高级配置',
-      click: openPhotographySeniorDetail
     }
   ]" />
+
   <div class="detail-container">
     <div>
       <!-- 主图LOGO部分 -->
@@ -211,6 +208,10 @@ import { getRouterUrl } from '@/utils/appfun'
 import { Close, Warning } from '@element-plus/icons-vue'
 import LoadingDialog from '@/views/Photography/components/LoadingDialog.vue'
 
+
+import { useCheckInfo } from '@/composables/useCheckInfo';
+useCheckInfo();
+
 const showTips = ref(true)
 
 const folderPath = ref('') //货号文件夹
@@ -252,7 +253,7 @@ const queryParams = reactive({ // 分页查询参数
   current: 1,
 })
 const form = reactive({
-  selectTemplate: {}, //选中的模板 
+  selectTemplate: {}, //选中的模板
   dataType: '1', // 1: 选择excel文件 2: 系统对接
   logo_path: '', // 主图LOGO
   excelFilePath: 'D:\\MyDocuments\\PythonCode\\MyPython\\red_dragonfly\\deal_pics\\auto_capture_V2\\auto_photo', // 商品基础资料EXCEL文件选择
@@ -386,10 +387,10 @@ const generate = async function () {
       message.value = loadingMsg
     }
   });
-} 
+}
 const openLoadingDialog = (timer: number) => {
   loadingDialogVisible.value = true
- 
+
   showButton.value = true
   // 根据传入的秒数计算每次增加的进度值
   const step = 100 / timer

+ 5 - 0
frontend/src/views/Photography/shot.vue

@@ -2,12 +2,16 @@
 
   <headerBar
       title="拍摄商品"
+      showUser
       :menu="[
         {
           type:'setting'
         }
     ]"
   />
+
+  <hardware-check/>
+
   <div class="photography-page flex-col">
     <div class="main-container">
       <div class="content-wrapper flex-row">
@@ -162,6 +166,7 @@ import socket from "@/stores/modules/socket";
 import { ElMessage ,ElMessageBox } from 'element-plus'
 import { getFilePath,getRouterUrl } from '@/utils/appfun'
 import {useRouter} from "vue-router";
+import HardwareCheck from '@/components/check/index.vue'
 import checkInfo from "@/stores/modules/check";
 
 

+ 3 - 0
frontend/src/views/Setting/index.vue

@@ -340,6 +340,8 @@ import icpList from '@/utils/ipc';
 const clientStore = client();
 import { ElMessage, ElMessageBox } from 'element-plus';
 
+import { useCheckInfo } from '@/composables/useCheckInfo';
+useCheckInfo();
 // 路由和状态管理初始化
 const route = useRoute();
 const router = useRouter();
@@ -807,6 +809,7 @@ async function changeNum(type, min, max) {
     });
   }
 }
+
 </script>