chenyc
2022-09-26 21698c91c9011fbce6fd8b8d6487f9e00ec9bb94
upkoa
9个文件已修改
3个文件已删除
372 ■■■■■ 已修改文件
electron/main/index.ts 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/App.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/httpServer.ts 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/node-api.ts 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/timerServer.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/sockteInfo.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/test/index.vue 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vite.config.ts 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
electron/main/index.ts
@@ -3,6 +3,38 @@
import { join } from 'path'
import fs from 'fs'
import iconv from 'iconv-lite'
//koa----
import  Koa from 'koa';
import  Router from 'koa-router';
const koaBody = require('koa-body');
const creatorKoa=(win)=>{
  const app = new Koa();
  const router = new Router();
  app.use(koaBody({
  multipart: true
  }));
  router.get('/', async (ctx) => {
      ctx.body = 'Hello World!';
  });
  router.post('/postResult', async (ctx)=>{
  const body=ctx.request.body
  win?.webContents.send('message-koa',body)
  ctx.body={
      "code": 200,
      "data": body,
      "message": "接收成功"
  }
  //   writeResult(body)
  })
  app.use(router.routes());
  app.listen(3131,()=>{
      console.log('koa Service start, port:3131')
  });
}
// 配制文件的读写实例
const Store = require('electron-store');
@@ -53,7 +85,8 @@
  // Test active push message to Renderer-process
  // 测试推送消息到Renderer进程
  win.webContents.on('did-finish-load', () => {
    // win?.webContents.send('main-process-message', new Date().toLocaleString())
    creatorKoa(win)
    win?.webContents.send('message-koa','nihao0-----')
    win?.webContents.send('getScreenTimeout',store.get('screenTimeout'))
    win?.webContents.send('getPcName',store.get('machineName'))
    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('devices'),store.path)
@@ -75,7 +108,7 @@
app.on('second-instance', () => {
  if (win) {
    // Focus on the main window if the user tried to open another
    // 如果用户试图打开另一个窗口,则将焦点放在主窗口上
    if (win.isMinimized()) win.restore()
    win.focus()
  }
@@ -90,7 +123,7 @@
  }
})
// new window example arg: new windows url
// 新窗口示例arg:新的Windows url
ipcMain.handle("open-win", (event, arg) => {
  const childWindow = new BrowserWindow({
    webPreferences: {
package.json
@@ -1,6 +1,6 @@
{
  "name": "sign-tool",
  "version": "2.1.0",
  "version": "2.2.0",
  "icon": "public/favicon.ico",
  "main": "dist/electron/main/index.js",
  "author": "",
@@ -8,7 +8,7 @@
  "private": true,
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build && electron-builder"
    "build": "vite build && electron-builder"
  },
  "engines": {
    "node": ">=14.17.0"
src/App.vue
@@ -11,12 +11,4 @@
</template>
<style>
#app {
  /* font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px; */
}
</style>
src/main.ts
@@ -5,7 +5,6 @@
import { createPinia } from 'pinia'
import App from './App.vue'
import './samples/node-api'
import './samples/httpServer'
createApp(App)
  .use(createPinia())
src/router/index.ts
@@ -6,7 +6,6 @@
const routes: Array<RouteRecordRaw> = [
    // { path: '/', name: 'Home', component: () => import('@/views/home/index.vue')},
    { path: '/', name: 'test', component: () => import('@/views/home/index.vue')},
    { path: '/test', name: 'Home', component: () => import('@/views/test/index.vue')},
]
const router = createRouter({
src/samples/httpServer.ts
File was deleted
src/samples/node-api.ts
@@ -10,9 +10,26 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import { on } from 'events'
interface ResultInfo{
  clientCode:string;
  commCode :string;
  deviceType:string;
  deviceName :string;
  result :string;
  resultTime :string
}
let deviceList=[]
let clientCode=''
// 主进程发送消息到渲染进程
ipcRenderer.on('message-koa', (_event, ...args) => {
  console.log('koa返回http请求消息', ...args)
  const Result:ResultInfo=args[0]
  writeResult(Result)
})
ipcRenderer.on('main-process-message', (_event, ...args) => {
  console.log('[Receive Main-process message]:', ...args)
})
ipcRenderer.on('main-process-message', (_event, ...args) => {
  console.log('[Receive Main-process message]:', ...args)
})
@@ -68,4 +85,48 @@
    console.log("网路链接失败")
  })
},10000)
const writeResult=(res: ResultInfo)=>{
  console.log(res)
  console.log(`写入结果类型${res.deviceType},写入结果=${res.result}`)
  switch(res.deviceType){
      case '读卡器':
          console.log('读卡器收到消息')
          if(res.clientCode!==null){
              sockteStore().setdkqSockte(
                  {
                      deviceName:res.deviceName,
                      type:"读卡器",
                      result:res.result,
                      resultTime:res.resultTime,
                      state:2
                  }
              )
          }
          break
      case "体重秤":
          sockteStore().setweightSockte(
              {
                  deviceName:res.deviceName,
                  type:"体重秤",
                  result:Number(res.result).toString(),
                  resultTime:res.resultTime,
                  state:2
              }
          )
          break
      case "血压计":
          sockteStore().setxyjSockte(
              {
                  deviceName:res.deviceName,
                  type:"血压计",
                  result:res.result,
                  resultTime:res.resultTime,
                  state:2
              }
          )
          break
      default:
          console.log('有配置类型没有匹配')
  }
}
src/samples/timerServer.ts
File was deleted
src/stores/sockteInfo.ts
@@ -50,12 +50,13 @@
     * 更新体重秤结果
     * @param info 体重结果
     */
    function setweightSockte(info:info){
    function setweightSockte(info:weightInfo){
        console.log(info,'入参')
        weightSockte.value.deviceName=info.deviceName
        weightSockte.value.result=info.result
        weightSockte.value.resultTime=info.resultTime
        weightSockte.value.state=info.state
        console.debug('体重秤更新')
        console.log('体重秤更新')
    }
     /**
     * 更新体重秤工作状态
src/views/home/index.vue
@@ -128,10 +128,6 @@
            () => patientInfo.value.datetime,
            () => {
              console.log('患者信息变化',patientInfo.value)
                if(patientInfo.value.isScheduled===0){
                      AudioRef5.value.play();
                      return
                }
                if (patientInfo.value.id !== 0) {
                    AudioRef.value.play();
                    sockteStore().setweightSockte({
@@ -150,23 +146,26 @@
                    })
                    settime()
                }else{
                  if(patientInfo.value.name===''){
                }
                else if(patientInfo.value.name===''){
                    AudioRef4.value.play();
                    return
                  }
                else if(patientInfo.value.isScheduled===0){
                      AudioRef5.value.play();
                      return
                }
            }
        )
        );
        watch(
            () => weightInfo.value.result,
            () => weightInfo.value.resultTime,
            () => {
                settime()
                console.log("体重变化了",weightInfo.value)
                // AudioRef2.value.play()
                if (patientInfo.value.id === 0) {
                    AudioRef0.value.play()
                    inputRef.value.focus();
                }
                else {
                    AudioRef2.value.play()
@@ -185,7 +184,7 @@
                    }
                }
            }
        )
        );
        watch(
            () => xyjInfo.value.resultTime,
            () => {
@@ -218,7 +217,7 @@
                    state.mai_bu = ""
                }
            }
        )
        );
        watch(
            () => dkqInfo.value.resultTime,
            () => {
@@ -229,12 +228,12 @@
                  sendPationCode(code)
                }
            }
        )
        );
        watch(() => viewNumber,
            () => {
                state.clockNum = viewNumber.value
            }
        )
        );
        const inputChabge = () => {
            sendPationCode(state.inputCode)
            setTimeout(function () {
@@ -253,13 +252,10 @@
            state.haodu=(document.documentElement.clientHeight-180)/2+'px'
            state.clockNum = patientInfoStore().viewNumber
            setTimeout(function () {
                console.log('7秒后操作')
                inputRef.value.focus();
            }, 7000)
            setInterval(function () {
                state.Newdate = formatDate(new Date(), "YYYY-mm-dd HH:MM:SS")
                inputRef.value.focus();
            }, 1000)
        })
        return {
            ...toRefs(state), guyanbi,isLink, netLink, weightInfo, patientInfo, xyjInfo, inputRef, AudioRef0, AudioRef, AudioRef4,AudioRef5, AudioRef2, AudioRef3, inputChabge
@@ -270,15 +266,15 @@
<template>
    <div class="pagehome">
         <!-- 提醒刷卡 -->
        <audio src="https://dhcdn.leon056.com/hemo/autoselfsign/step1.mp3" ref="AudioRef0" id="eventAudio2"></audio>
        <audio :src="step1" ref="AudioRef0" id="eventAudio1"></audio>
        <!-- 患者信息读取成功 -->
        <audio src="https://dhcdn.leon056.com/hemo/autoselfsign/step2.mp3" ref="AudioRef" id="eventAudio2"></audio>
        <audio :src="step2" ref="AudioRef" id="eventAudio2"></audio>
        <!-- 体重结果回传成功 -->
        <audio src="https://dhcdn.leon056.com/hemo/autoselfsign/step3.mp3" ref="AudioRef2" id="eventAudio3"></audio>
        <audio :src="step3" ref="AudioRef2" id="eventAudio3"></audio>
        <!-- 血压结果回传成功 -->
        <audio src="https://dhcdn.leon056.com/hemo/autoselfsign/step4.mp3" ref="AudioRef3" id="eventAudio4"></audio>
        <audio :src="step4" ref="AudioRef3" id="eventAudio4"></audio>
        <!-- 没有找到患者 -->
        <audio src="https://dhcdn.leon056.com/hemo/autoselfsign/step5.mp3" ref="AudioRef4" id="eventAudio5"></audio>
        <audio :src="step5" ref="AudioRef4" id="eventAudio5"></audio>
         <!-- 没有找到排班 -->
         <audio :src="step6" ref="AudioRef5" id="eventAudio6"></audio>
        <!-- <el-dialog title="提示" v-model="netLink" width="30%">
src/views/test/index.vue
File was deleted
vite.config.ts
@@ -41,6 +41,24 @@
    renderer(),
  ],
  base:'./',
  server: {
    host: '127.0.0.1',
    port: 8991,
    // 是否开启 https
    https: false,
  },
  proxy: {
    '/api1': {
      // 后台地址
      target: 'http://127.0.0.1:3131/',
      changeOrigin: true,
    },
    '/api2': {
      // 后台地址
      target: 'http://127.0.0.1:3132/',
      changeOrigin: true,
    }
  },
  resolve:{
    alias: {
        '@': pathResolve('./src'),  // 设置 `@` 指向 `src` 目录