Browse Source

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

panqiuyao 9 months ago
parent
commit
e3b26f95cb

+ 3 - 1
frontend/package.json

@@ -15,12 +15,14 @@
     "pinia": "3.0.1",
     "pinia-plugin-persistedstate": "4.2.0",
     "vue": "3.5.13",
-    "vue-router": "4.5.0"
+    "vue-router": "4.5.0",
+    "crypto-js": "^4.1.1"
   },
   "devDependencies": {
     "@types/node": "22.13.5",
     "@types/crypto-js": "4.1.1",
     "@vitejs/plugin-vue": "5.2.1",
+    "@types/crypto-js": "^4.1.1",
     "@vue/tsconfig": "0.7.0",
     "sass-embedded": "^1.85.1",
     "typescript": "5.7.2",

+ 1 - 2
frontend/src/utils/appfun.ts

@@ -1,7 +1,6 @@
-import { ossResize, ossImageInfo } from './oss'
+import { ossResize } from './oss'
 export  {
   // 格式化图片
   ossResize,
   // 获取图片信息
-  ossImageInfo,
 } 

+ 27 - 18
frontend/src/views/Photography/check.vue

@@ -17,12 +17,12 @@
         <div class="example-image flex-col"><span class="example-text">示范图片</span></div>
       </div>
       <div v-if="!imageUrl" class="action-button flex cente">
-        <div @click="toPhoto" class="check-button  button--primary1 flex-col"><span class="button-text">拍照检查</span>
+        <div @click="takePictures" class="check-button  button--primary1 flex-col"><span class="button-text">拍照检查</span>
         </div>
       </div>
 
       <div v-else class="action-button flex center">
-        <div @click="imageUrl = ''" class="check-button  button--white flex-col">
+        <div @click="takePictures" class="check-button  button--white flex-col">
           <span class="button-text">重新拍照检查</span>
         </div>
         <router-link class="mar-left-20 " :to="{
@@ -37,22 +37,30 @@
     </div>
   </div>
 </template>
-<script>
-const url = 'https://ossimg.valimart.net/uploads/vali_ai/20240312/171022217892595.png'
-export default {
-  data() {
-    return {
-      imageUrl: '',
-
-    };
-  },
-  methods: {
-    toPhoto() {
-      this.imageUrl = url
-    }
-
+<script setup lang="ts">
+import client from "@/stores/modules/client";
+import icpList from '@/utils/ipc'
+const clientStore = client();
+console.log(icpList);
+import { ref } from 'vue'
+const url = ref('https://ossimg.valimart.net/uploads/vali_ai/20240312/171022217892595.png')
+const imageUrl = ref('')
+const previewKey = ref(0)
+const preview = ref('http://localhost:5513/preview.jpg')
+
+
+function takePictures() {
+  if (clientStore.isClient) {
+    clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
+    clientStore.ipc.send(icpList.camera.takePictures);
+    clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
+      setTimeout(() => {
+        previewKey.value++;
+        preview.value = `http://localhost:5513/preview.jpg?key=${previewKey.value}`
+      }, 1000)
+    })
   }
-};
+}
 </script>
 <style scoped lang="scss">
 .check-page {
@@ -117,7 +125,8 @@ export default {
           width: 600px;
           margin: 4px 0 0 16px;
           position: relative;
-          .camera-description{
+
+          .camera-description {
             position: absolute;
             bottom: 20px;
             width: 60%;

+ 1 - 3
frontend/src/views/Photography/shot.vue

@@ -402,12 +402,10 @@ const test_image_url = ref('https://shadow.elemecdn.com/app/element/hamburger.9c
               margin: 7px 0 42px 83px;
 
               .input-item {
-                ::v-deep {
-                  .el-input__inner {
+                :deep(.el-input__inner){ 
                     height: 36px;
                     line-height: 36px;
                   }
-                }
               }
 
             }

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

@@ -180,19 +180,23 @@
                     </div>
                 </div>
           </div>
+    </div>
       <div class="text-center mt-8">
         <button class="bg-gradient-to-r from-primary" @click="saveSetting">
           保存
         </button>
       </div>
-    </div>
   </div>
 </template>
 
 <script setup>
 // 这里可以添加Vue组件的逻辑
 import { ref } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
+import { onMounted, watch } from 'vue';
 
+const route = useRoute();
+const router = useRouter();
 const folderPath = ref('');
 const activeIndex = ref(0);
 const formData = ref({
@@ -292,6 +296,37 @@ const downList = ref([
   { label: '左右移', value: '3' },
 ]);
 
+// Watch for changes in the route query parameter 'type'
+watch(() => route.query.type, (newType) => {
+  if (newType) {
+    // Convert the query parameter to a number and update activeIndex
+    const typeValue = parseInt(newType);
+    if (!isNaN(typeValue) && typeValue >= 0 && typeValue <= 3) {
+      activeIndex.value = typeValue;
+    }
+  }
+}, { immediate: true });
+
+// Update the URL when activeIndex changes
+watch(() => activeIndex.value, (newIndex) => {
+  router.push({
+    query: {
+      ...route.query,
+      type: newIndex.toString()
+    }
+  });
+});
+
+// Initialize activeIndex based on the route query on component mount
+onMounted(() => {
+  if (route.query.type) {
+    const typeValue = parseInt(route.query.type);
+    if (!isNaN(typeValue) && typeValue >= 0 && typeValue <= 3) {
+      activeIndex.value = typeValue;
+    }
+  }
+});
+
 const selectFolder = () => {
   // 这里可以添加选择文件夹的逻辑
   // 由于浏览器安全限制,网页应用无法直接访问本地文件系统
@@ -380,6 +415,7 @@ body {
   padding: 30px;
   width: 800px;
   margin: 0 auto;
+  height: 306px;
 }
 .form-item {
   margin-bottom: 24px;
@@ -407,7 +443,7 @@ body {
 .select-wrapper {
   position: relative;
   width: 200px;
-  ::v-deep(.el-input__inner){ 
+  :deep(.el-input__inner){ 
     border-radius: 6px;
   }
 }
@@ -418,7 +454,6 @@ body {
 }
 .from-primary{
     width: 150px;
-    margin-top: 30px;
     height: 40px;
     color: #FFFFFF;
     background: linear-gradient( 135deg, #2FB0FF 0%, #B863FB 100%);
@@ -452,4 +487,10 @@ body {
     height: 16px;
   }
 }
+.mt-8{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding-bottom: 30px;
+}
 </style>