浏览代码

Merge branch 'dev-frontend_0702' into dev-frontend

panqiuyao 5 月之前
父节点
当前提交
b4cd161844

+ 3 - 1
electron/config/config.prod.js

@@ -1,5 +1,7 @@
 'use strict';
 
+const { readConfigFile } = require('../utils/config');
+const configDeault = readConfigFile();
 /**
  * 生产环境配置,覆盖 config.default.js
  */
@@ -9,7 +11,7 @@ module.exports = (appInfo) => {
   /**
    * 开发者工具
    */
-  config.openDevTools = true;
+  config.openDevTools = configDeault.openDevTools;
 
   /**
    * 应用程序顶部菜单

+ 40 - 0
electron/controller/takephoto.js

@@ -1,4 +1,5 @@
 'use strict';
+const fs = require('fs');
 const { Controller } = require('ee-core');
 const  { getPhotoRecords,delectGoodsArts,createMainImage,getLastPhotoRecord } =  require('../api/takephoto');
 const errData = {
@@ -65,6 +66,45 @@ class takePhotoController extends Controller {
       const result = await createMainImage(params);
       console.log('result')
       console.log(result)
+      if(result.code === 0 && result.data?.main_out_path){
+        const filePath =  result.data?.main_out_path
+        const fileBuffer = fs.readFileSync(filePath);
+        const base64Image = fileBuffer.toString('base64');
+
+
+        // 获取文件扩展名
+        const extension = path.extname(filePath).toLowerCase().replace('.', '');
+
+        // 根据扩展名确定 MIME 类型
+        let mimeType = '';
+        switch (extension) {
+          case 'jpg':
+          case 'jpeg':
+            mimeType = 'image/jpeg';
+            break;
+          case 'png':
+            mimeType = 'image/png';
+            break;
+          case 'gif':
+            mimeType = 'image/gif';
+            break;
+          case 'webp':
+            mimeType = 'image/webp';
+            break;
+          case 'avif':
+            mimeType = 'image/avif';
+            break;
+          default:
+            mimeType = 'application/octet-stream'; // 默认 MIME 类型
+            break;
+        }
+
+        // 构建 data URL
+        const dataUrl = `data:${mimeType};base64,${base64Image}`;
+
+        result.data.main_out_path = dataUrl
+
+      }
       if(result.data)  return result.data
       return errData;
     } catch (error) {

+ 4 - 1
electron/controller/utils.js

@@ -8,6 +8,9 @@ const fs = require('fs');
 const path = require('path');
 const CoreWindow = require('ee-core/electron/window');
 const { BrowserWindow, Menu } = require('electron');
+
+const { readConfigFile } = require('../utils/config');
+const configDeault = readConfigFile();
 const errData = {
   msg :'请求失败,请联系管理员',
   code:999
@@ -69,7 +72,7 @@ class UtilsController extends Controller {
     });
     await win.loadURL(config.url); // 设置窗口的 URL
     // 监听窗口关闭事件
-    if(this.app?.env === 'development')  win.webContents.openDevTools(config.openDevTools)
+    if(configDeault.openDevTools)  win.webContents.openDevTools(config.openDevTools)
    //
     win.on('close', () => {
       delete this.app.electron[config.id]; // 删除窗口引用

+ 66 - 0
electron/utils/config.js

@@ -0,0 +1,66 @@
+// electron/utils/readConfig.js
+
+const fs = require('fs');
+const path = require('path');
+const { app } = require('electron');
+
+const configPath = path.join(app.getPath("userData"),'config.default.json');
+
+
+/**
+ * 读取配置文件
+ */
+function readConfigFile() {
+
+  try {
+    if (fs.existsSync(configPath)) {
+      const data = fs.readFileSync(configPath, 'utf8');
+      return JSON.parse(data);
+    } else {
+      console.log('配置文件不存在');
+      // 创建空白JSON文件
+      fs.writeFileSync(configPath, '{}', 'utf8');
+      return {};
+    }
+  } catch (error) {
+    console.error('读取配置文件出错:', error);
+    return null;
+  }
+}
+
+/**
+ * 写入配置文件
+ * @param {string} key - 要写入的配置项键名
+ * @param {*} value - 要写入的配置项值
+ */
+function writeConfigFile(key, value) {
+
+  try {
+    let config = {};
+
+    // 如果配置文件存在,则读取现有内容
+    if (fs.existsSync(configPath)) {
+      const data = fs.readFileSync(configPath, 'utf8');
+      config = JSON.parse(data);
+    }else {
+      console.log('配置文件不存在');
+      // 创建空白JSON文件
+      fs.writeFileSync(configPath, '{}', 'utf8');
+      config = {}
+    }
+
+    // 更新配置项
+    config[key] = value;
+
+    // 将更新后的配置写回文件
+    fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf8');
+    console.log(`成功写入配置项: ${key}`);
+  } catch (error) {
+    console.error('写入配置文件出错:', error);
+  }
+}
+
+module.exports = {
+  readConfigFile,
+  writeConfigFile
+};

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

@@ -230,6 +230,8 @@ clientStore.ipc.on(icpList.socket.message+'_run_mcu_single', async (event, resul
         step.value = 2
         loading.value = false;
       }else if(result.msg){
+        loading.value = false;
+        showVideo()
         if(result.code !== 0) ElMessage.error(result.msg)
       }
       clientStore.ipc.removeAllListeners(icpList.takePhoto.createMainImage);

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
   "name": "ZhiHuiYin",
-  "version": "1.1.0",
-  "description": "1:新增OTA升级系统 2:新增场景图,模特图,生成视频模块 3:新增金币体系,",
+  "version": "1.1.1",
+  "description": "1、优化了抠图速度;2、升级了详情图生成速度",
   "main": "main.js",
   "scripts": {
     "dev": "ee-bin dev",

+ 2 - 2
public/dist/index.html

@@ -5,8 +5,8 @@
     <link rel="icon" type="image/svg+xml" href="./vite.svg" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>智惠映AI自动拍照机</title>
-    <script type="module" crossorigin src="./assets/index-CnxFcUMX.js"></script>
-    <link rel="stylesheet" crossorigin href="./assets/index-BAP24IE0.css">
+    <script type="module" crossorigin src="./assets/index-CBoEZzqz.js"></script>
+    <link rel="stylesheet" crossorigin href="./assets/index-CWbjMgyJ.css">
   </head>
   <body>
     <div id="app"></div>