chenyc
2023-06-20 68c9c462845e3bde04f34e88187b0b559ceffda5
完善配置信息使用
8个文件已修改
3个文件已添加
135 ■■■■ 已修改文件
dev-app-update.yml 补丁 | 查看 | 原始文档 | blame | 历史
electron/main/index.ts 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
electron/preload/autoUpdate.js 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
electron/preload/splash.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
imgs/1687242156020.png 补丁 | 查看 | 原始文档 | blame | 历史
package.json 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/node-api.ts 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/sockteStomp.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/StoresConfing.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/axios.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dev-app-update.yml
electron/main/index.ts
@@ -1,7 +1,7 @@
import { app, BrowserWindow, shell, ipcMain,Menu } from 'electron'
import { release } from 'os'
import { join } from 'path'
// import updater from "../preload/autoUpdate.js"
import logger from '../preload/logger.js'
import fs from 'fs'
import iconv from 'iconv-lite'
@@ -61,16 +61,18 @@
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`
async function createWindow() {
  win = new BrowserWindow({
    title: 'Main window',
    fullscreen: true,// 开启默认全屏
    // autoHideMenuBar:true, //关闭菜单栏
    autoHideMenuBar:store.get('debug'), //关闭菜单栏
    webPreferences: {
      preload: splash,
      nodeIntegration: true,
      contextIsolation: false,
    },
  })
  if (app.isPackaged) {
    win.loadFile(join(__dirname, '../../index.html'))
  } else {
@@ -100,6 +102,7 @@
  if (process.platform !== 'darwin') app.quit()
})
app.on('second-instance', () => {
  if (win) {
    // 如果用户试图打开另一个窗口,则将焦点放在主窗口上
@@ -116,6 +119,10 @@
    createWindow()
  }
})
// 自动更新
// app.on('ready', async () => {
//   updater()
// })
// 新窗口示例arg:新的Windows url
ipcMain.handle("open-win", (event, arg) => {
electron/preload/autoUpdate.js
New file
@@ -0,0 +1,73 @@
import { autoUpdater } from "electron-updater"
import {dialog, BrowserWindow} from 'electron'
import log from 'electron-log'
autoUpdater.logger = log
autoUpdater.logger.transports.file.level = "info"
const path = require('path')
const isDevelopment = process.env.NODE_ENV === 'development'
// 防止报错no such file or directory dev-app-update.yml
if (isDevelopment) {
    autoUpdater.updateConfigPath = path.join(__dirname, '../dev-app-update.yml')
}
export default () => {
    let win = null
    //设置自动下载
    autoUpdater.autoDownload = false
    // 检测是否有新版本
    autoUpdater.checkForUpdates()
    autoUpdater.on('checking-for-update', res => {
        log.info("获取版本信息:" + res)
    })
    autoUpdater.on('update-not-available', res => {
        log.info("没有可更新版本:" + res)
    })
    autoUpdater.on('update-available', res => {
        dialog.showMessageBox({
            type: 'info',
            title: '软件更新',
            message: '发现新版本, 确定更新?',
            buttons: ['确定', '取消']
        }).then(resp => {
            if (resp.response == 0) {
                createWindow()
                autoUpdater.downloadUpdate()
            }
        })
    })
    async function createWindow() {
        win = new BrowserWindow({
            width: 300,
            height: 300,
            title: "七鹊",
            frame: false,
            transparent: true,
            maximizable: false,
            webPreferences: {
                nodeIntegration: true,
                contextIsolation: false,
                enableRemoteModule: true
            },
        })
        if (process.env.WEBPACK_DEV_SERVER_URL) {
            await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL + '#/update')
        } else {
            win.loadURL('app://./index.html#/update')
        }
    }
    autoUpdater.on('download-progress', res => {
        log.info("下载监听:" + res)
        win.webContents.send('downloadProgress', res)
    })
    autoUpdater.on('update-downloaded', () => {
        dialog.showMessageBox({
            title: '下载完成',
            message: '最新版本已下载完成, 退出程序进行安装'
        }).then(() => {
            autoUpdater.quitAndInstall()
        })
    })
}
electron/preload/splash.ts
@@ -90,5 +90,5 @@
window.onmessage = ev => {
  ev.data.payload === 'removeLoading' && removeLoading()
}
setTimeout(removeLoading, 4999)
setTimeout(removeLoading, 6999)
imgs/1687242156020.png
package.json
@@ -1,6 +1,6 @@
{
  "name": "sign-tool",
  "version": "2.6.3",
  "version": "2.6.5",
  "icon": "public/favicon.ico",
  "main": "dist/electron/main/index.js",
  "author": "",
@@ -10,6 +10,12 @@
    "dev": "vite",
    "build": "vite build && electron-builder"
  },
  "publish": [
    {
      "provider": "generic",
      "url": "http://dhcdn.leon056.com/upgrade/icoldchain"
    }
  ],
  "engines": {
    "node": ">=14.17.0"
  },
@@ -50,6 +56,7 @@
    "axios": "^0.27.2",
    "electron-log": "^4.4.8",
    "electron-store": "^8.0.2",
    "electron-updater": "^6.1.1",
    "element-plus": "^2.2.6",
    "iconv-lite": "^0.6.3",
    "internet-available": "^1.0.0",
src/samples/node-api.ts
@@ -36,6 +36,7 @@
})
// 主进程获取配置项完成sockte注册和httpshu
ipcRenderer.on('getConfigData',(_event,...args)=>{
  console.log('----------------')
  console.log("config.json",...args)
  if(args!==null){
    if(args[0]===undefined){  
@@ -44,13 +45,8 @@
    else if(args.length>0&&args[0].clientCode.length>0){
      console.log('配置文件读取')
      clientCode=args[0].clientCode
      // 建立sockte 通讯
      deviceList=args[0].deviceList
      // 存放conging到仓库
      confingInfoStore().setconfingInfo(args[0])
      // connect()
      // creatorClient(args[0])
    }
  }
  
src/samples/sockteStomp.ts
@@ -1,6 +1,5 @@
import Stomp from 'stompjs'
import os from 'os'
import { ipcRenderer } from 'electron'
let stompClient: Stomp.Client | null=null
import { confingInfoStore } from '@/stores/StoresConfing'
@@ -170,7 +169,7 @@
// 创建客户端链接
const creatorClient=(configObj:any)=>{
    config=configObj
    devices=configObj.deviceList
    // devices=configObj.deviceList
    clientCode=configObj.clientCode
    console.log(devices,'设备列表','chong')
    const socket = new WebSocket('ws://hemobs.icoldchain.cn/broadcast')
src/stores/StoresConfing.ts
@@ -9,6 +9,7 @@
        face_score:0.55,
        timeJg:10000,
        base_api:"",
        face_push:3,
        
    })
    /**
src/utils/axios.ts
@@ -1,14 +1,16 @@
import axios, {AxiosError, AxiosResponse} from 'axios'
import { Session } from '@/utils/storage'
import { ElMessage } from 'element-plus'
import { confingInfoStore } from '@/stores/StoresConfing'
// const BASE_URL = 'https://hemobs.icoldchain.cn'
const BASE_URL = confingInfoStore().confingInfo.base_api
let BASE_URL = 'https://hemobs.icoldchain.cn'
const TIME_OUT = 10 * 1000
setTimeout(()=>{
    console.log('重新赋值api',confingInfoStore().confingInfo)
    BASE_URL=confingInfoStore().confingInfo.base_api
},10000)
/**
 * 创建axios实例
 */
src/views/home/index.vue
@@ -141,7 +141,7 @@
              </div>
              <div style="height: 75%;">
                <div style="background: rgba(243, 247, 243, 0.3); height: 100%; width: 100%; font-size: 1.3rem; font-weight: 800; color: #FFFFFF;">
                  <div class="textjuzhong" style="height: 25%;  width: 100%;">干体重  {{patientInfo.preWeight}}  kg</div>
                  <div class="textjuzhong" style="height: 25%;  width: 100%;">干体重  {{patientInfo.pureWeight}}  kg</div>
                  <div class="textjuzhong" style="height: 25%;  width: 100%;">透析器  {{patientInfo.txq}}</div>
                  <div class="textjuzhong" style="height: 25%;  width: 100%;">治疗模式  {{patientInfo.medMethod}}</div>
                  <div class="textjuzhong" style="height: 25%;  width: 100%;">灌流器  {{patientInfo.glq}}</div>
@@ -183,7 +183,6 @@
        <div class="footer" style="text-align: right;">
          <div class="fanhuikey" v-if="!dialogVisible" @click="fuxuan">
           返回
            <!-- <el-button type="primary" :icon="RefreshRight" circle /> -->
          </div>
        </div>
    </div>
@@ -201,12 +200,11 @@
import os from "os"
import Speech from 'speak-tts'
import { reactive,computed, toRefs, onMounted, watch, ref } from "vue"
import { RefreshRight } from '@element-plus/icons-vue'
import { sendPationCodeApi } from '../../samples/httpApi'
import { formatDate } from '@/utils/formatTime'
import { confingInfoStore } from '@/stores/StoresConfing'
import {base64toFile} from '@/samples/faceApi'
import { ElMessage } from 'element-plus'
import { ElLoading, ElMessage } from 'element-plus'
let trackerTask: any = null;
// 标识用的画布
const myCanvas = ref<HTMLCanvasElement | null>(null);
@@ -239,9 +237,9 @@
      base64toFile(imgSrc)
    }
    setTimeout(() => {
      console.log('监测到人脸后3s')
      console.log(configData.value.face_push+'秒跑一次人脸识别')
      trackerTask.run();
    }, 3000);
    }, configData.value.face_push*1000);
    // @ts-ignore
    if (typeof window.stream === "object") {
      myVideo.srcObject = null;
@@ -335,6 +333,7 @@
    }
    else {
      clearInterval(timer)
      clockNum.value = patientInfoStore().viewNumber
      patientInfoStore().setpatientInfo({
        id: 0,
        code: '',
@@ -354,6 +353,13 @@
      })
      sockteStore().setxyjSockte({
        type: '血压计',
        deviceName: '',
        result: '',
        resultTime: '',
        state: 2
      })
      sockteStore().setfaceSockte({
        type: '人脸识别',
        deviceName: '',
        result: '',
        resultTime: '',
@@ -672,7 +678,7 @@
onMounted(() => {
  console.log('页面初始化', os.hostname())
  setTimeout(()=>{
    console.log('3秒后执行')
    console.log('5秒后执行')
    console.log('打印设置文件')
    console.log(configData.value)
      // 是否开启脸识别
@@ -703,7 +709,7 @@
    speech.value?.init().then(() => {
      console.log('语音初始化成功')
    })
  },3000)
  },8000)
})