Skip to content

Commit 18b4181

Browse files
committed
electron
1 parent 586cac4 commit 18b4181

17 files changed

Lines changed: 19 additions & 1307 deletions

File tree

public/print.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<script>
2929
const { ipcRenderer } = require('electron')
3030
ipcRenderer.on('webview-print-render', (event, info) => {
31-
console.log(info)
3231
// 执行渲染
3332
document.getElementById('bd').innerHTML = info.html
3433
ipcRenderer.sendToHost('webview-print-do')

public/update.html

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/App.vue

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<template>
22
<div id="app">
3-
<el-button @click="autoUpdate">更新</el-button>
43
<el-button type="primary" @click="showPrint">设置打印机</el-button>
54
<printDialog :dialog-visible="dialogVisible" @cancel="handlePrintDialogCancel" />
65
<pinter ref="print" :html-data="HtmlData"></pinter>
7-
<el-table ref="filterTable" :data="tableData" style="width: 100%">
6+
<el-table :data="tableData" style="width: 100%">
87
<el-table-column prop="date" label="日期" width="180" column-key="date">
98
</el-table-column>
109
<el-table-column prop="name" label="姓名" width="180">
@@ -15,7 +14,6 @@
1514
<template slot-scope="scope">
1615
<el-button type="primary" @click="doPrint(scope.row)">打印</el-button>
1716
</template>
18-
1917
</el-table-column>
2018
</el-table>
2119
</div>
@@ -37,44 +35,30 @@ export default {
3735
printList: [],
3836
tableData: [{
3937
date: '2016-05-02',
40-
name: '王小虎1',
41-
address: '上海市普陀区金沙江路 1518 弄',
38+
name: '我是小仙女',
39+
address: '上海市浦东新区',
4240
tag: ''
4341
}, {
4442
date: '2016-05-04',
45-
name: '王小虎2',
46-
address: '上海市普陀区金沙江路 1517 弄',
43+
name: '我是小仙女1',
44+
address: '上海市浦东新区',
4745
tag: '公司'
4846
}, {
4947
date: '2016-05-01',
50-
name: '王小虎3',
51-
address: '上海市普陀区金沙江路 1519 弄',
48+
name: '我是小仙女2',
49+
address: '上海市浦东新区',
5250
tag: ''
5351
}, {
5452
date: '2016-05-03',
55-
name: '王小虎4',
56-
address: '上海市普陀区金沙江路 1516 弄',
53+
name: '我是小仙女3',
54+
address: '上海市浦东新区',
5755
tag: '公司'
5856
}]
5957
}
6058
},
6159
mounted() {
62-
ipcRenderer.send('checkVersion')
63-
this.getPrintListHandle()
6460
},
6561
methods: {
66-
autoUpdate() {
67-
ipcRenderer.send('autoUpdate');
68-
},
69-
getPrintListHandle() {
70-
console.log('mounted')
71-
// 改用ipc异步方式获取列表,解决打印列数量多的时候导致卡死的问题
72-
ipcRenderer.send('getPrinterList')
73-
ipcRenderer.once('getPrinterList', (event, data) => {
74-
// 过滤可用打印机
75-
this.printList = data.filter(element => element.status === 0)
76-
})
77-
},
7862
showPrint() {
7963
this.dialogVisible = true
8064
},

src/background.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,21 @@ import * as path from 'path'
22
import { app, protocol, BrowserWindow, ipcMain } from 'electron'
33
import { createProtocol, installVueDevtools } from 'vue-cli-plugin-electron-builder/lib'
44
import ElectronStore from 'electron-store'
5-
import electronLog from 'electron-log'
6-
import dayjs from 'dayjs'
5+
// ElectronStore 默认数据
76
import electronDefaultData from './config/electron-default-data'
7+
// 设置菜单
88
import { setMenu } from './main-process/menu'
9-
import { onCrash } from './main-process/crash'
9+
// 设置托盘
1010
import { setTray } from './main-process/tray'
11+
// 获取所有 ipcMain事件
1112
import ipcMainEvent from './main-process/event'
1213
const isDevelopment = process.env.NODE_ENV !== 'production'
1314
let tray = null
1415
// Keep a global reference of the window object, if you don't, the window will
1516
// be closed automatically when the JavaScript object is garbage collected.
16-
17-
// 日志配置
18-
electronLog.transports.console.level = false
19-
electronLog.transports.file.level = 'error'
20-
electronLog.transports.file.format = '{h}:{i}:{s}:{ms} {level} {text}'
21-
electronLog.transports.file.maxSize = 5 * 1024 * 1024
22-
electronLog.transports.file.file = path.join(app.getPath('logs'), `${dayjs().format('YYYY-MM-DD')}.log`)
2317
// 窗口映射对象
2418
global.$winodws = {
25-
main: null,
26-
login: null,
27-
check: null,
28-
service: null
19+
main: null
2920
}
3021

3122
const winodws = global.$winodws
@@ -99,7 +90,6 @@ app.on('ready', async() => {
9990
cwd: app.getPath('userData')
10091
})
10192
global.electronStore = electronStore
102-
global.electronLog = electronLog
10393
createWindow()
10494
})
10595

src/components/HelloWorld.vue

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/components/PrintDialog copy.vue

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)