正在显示
11 个修改的文件
包含
44 行增加
和
194 行删除
package-lock.json
deleted
100644 → 0
此文件的差异太大,无法显示。
| ... | @@ -78,7 +78,6 @@ | ... | @@ -78,7 +78,6 @@ |
| 78 | "express": "^4.17.1", | 78 | "express": "^4.17.1", |
| 79 | "fs-extra": "^9.0.1", | 79 | "fs-extra": "^9.0.1", |
| 80 | "js-cookie": "^2.2.1", | 80 | "js-cookie": "^2.2.1", |
| 81 | - "nedb": "^1.8.0", | ||
| 82 | "nprogress": "^0.2.0", | 81 | "nprogress": "^0.2.0", |
| 83 | "vue": "^2.6.11", | 82 | "vue": "^2.6.11", |
| 84 | "vue-electron": "^1.0.6", | 83 | "vue-electron": "^1.0.6", | ... | ... |
| ... | @@ -4,61 +4,61 @@ import { winURL } from '../config/StaticPath' | ... | @@ -4,61 +4,61 @@ import { winURL } from '../config/StaticPath' |
| 4 | 4 | ||
| 5 | export default { | 5 | export default { |
| 6 | Mainfunc (mainWindow, IsUseSysTitle) { | 6 | Mainfunc (mainWindow, IsUseSysTitle) { |
| 7 | - ipcMain.on('IsUseSysTitle', (event) => { | 7 | + ipcMain.handle('IsUseSysTitle', () => { |
| 8 | - const data = IsUseSysTitle | 8 | + return IsUseSysTitle |
| 9 | - event.reply('CisUseSysTitle', data) | ||
| 10 | }) | 9 | }) |
| 11 | - ipcMain.on('windows-mini', () => { | 10 | + ipcMain.handle('windows-mini', () => { |
| 12 | mainWindow.minimize() | 11 | mainWindow.minimize() |
| 13 | }) | 12 | }) |
| 14 | - ipcMain.on('window-max', (event) => { | 13 | + ipcMain.handle('window-max', () => { |
| 15 | if (mainWindow.isMaximized()) { | 14 | if (mainWindow.isMaximized()) { |
| 16 | - event.reply('window-confirm', false) | ||
| 17 | mainWindow.restore() | 15 | mainWindow.restore() |
| 16 | + return { status: false } | ||
| 18 | } else { | 17 | } else { |
| 19 | - event.reply('window-confirm', true) | ||
| 20 | mainWindow.maximize() | 18 | mainWindow.maximize() |
| 19 | + return { status: true } | ||
| 21 | } | 20 | } |
| 22 | }) | 21 | }) |
| 23 | - ipcMain.on('window-close', () => { | 22 | + ipcMain.handle('window-close', () => { |
| 24 | mainWindow.close() | 23 | mainWindow.close() |
| 25 | }) | 24 | }) |
| 26 | - ipcMain.on('open-messagebox', (event, arg) => { | 25 | + ipcMain.handle('open-messagebox', async (event, arg) => { |
| 27 | - dialog.showMessageBox(mainWindow, { | 26 | + const res = await dialog.showMessageBox(mainWindow, { |
| 28 | type: arg.type || 'info', | 27 | type: arg.type || 'info', |
| 29 | title: arg.title || '', | 28 | title: arg.title || '', |
| 30 | buttons: arg.buttons || [], | 29 | buttons: arg.buttons || [], |
| 31 | message: arg.message || '', | 30 | message: arg.message || '', |
| 32 | noLink: arg.noLink || true | 31 | noLink: arg.noLink || true |
| 33 | - }).then(res => { | ||
| 34 | - event.reply('confirm-message', res) | ||
| 35 | }) | 32 | }) |
| 33 | + return res | ||
| 36 | }) | 34 | }) |
| 37 | - ipcMain.on('open-errorbox', (event, arg) => { | 35 | + ipcMain.handle('open-errorbox', (event, arg) => { |
| 38 | dialog.showErrorBox( | 36 | dialog.showErrorBox( |
| 39 | arg.title, | 37 | arg.title, |
| 40 | arg.message | 38 | arg.message |
| 41 | ) | 39 | ) |
| 42 | }) | 40 | }) |
| 43 | - ipcMain.on('statr-server', (event, arg) => { | 41 | + ipcMain.handle('statr-server', async () => { |
| 44 | - Server.StatrServer().then(res => { | 42 | + try { |
| 45 | - event.reply('confirm-start', res) | 43 | + const serveStatus = await Server.StatrServer() |
| 46 | - }).catch(err => { | 44 | + return serveStatus |
| 45 | + } catch (error) { | ||
| 47 | dialog.showErrorBox( | 46 | dialog.showErrorBox( |
| 48 | '错误', | 47 | '错误', |
| 49 | - err | 48 | + error |
| 50 | ) | 49 | ) |
| 51 | - }) | 50 | + } |
| 52 | }) | 51 | }) |
| 53 | - ipcMain.on('stop-server', (event, arg) => { | 52 | + ipcMain.handle('stop-server', async (event, arg) => { |
| 54 | - Server.StopServer().then(res => { | 53 | + try { |
| 55 | - event.reply('confirm-stop', res) | 54 | + const serveStatus = await Server.StopServer() |
| 56 | - }).catch(err => { | 55 | + return serveStatus |
| 56 | + } catch (error) { | ||
| 57 | dialog.showErrorBox( | 57 | dialog.showErrorBox( |
| 58 | '错误', | 58 | '错误', |
| 59 | - err | 59 | + error |
| 60 | ) | 60 | ) |
| 61 | - }) | 61 | + } |
| 62 | }) | 62 | }) |
| 63 | ipcMain.on('open-win', (event, arg) => { | 63 | ipcMain.on('open-win', (event, arg) => { |
| 64 | const ChildWin = new BrowserWindow({ | 64 | const ChildWin = new BrowserWindow({ | ... | ... |
| ... | @@ -58,14 +58,14 @@ function createMainWindow () { | ... | @@ -58,14 +58,14 @@ function createMainWindow () { |
| 58 | electronDevtoolsInstaller(VUEJS_DEVTOOLS) | 58 | electronDevtoolsInstaller(VUEJS_DEVTOOLS) |
| 59 | .then((name) => console.log(`installed: ${name}`)) | 59 | .then((name) => console.log(`installed: ${name}`)) |
| 60 | .catch(err => console.log('Unable to install `vue-devtools`: \n', err)) | 60 | .catch(err => console.log('Unable to install `vue-devtools`: \n', err)) |
| 61 | - loadWindow.destroy() | ||
| 62 | }) | 61 | }) |
| 62 | + if (config.UseStartupChart) loadWindow.destroy() | ||
| 63 | + | ||
| 63 | mainWindow.webContents.openDevTools(true) | 64 | mainWindow.webContents.openDevTools(true) |
| 64 | } else { | 65 | } else { |
| 65 | mainWindow.webContents.once('dom-ready', () => { | 66 | mainWindow.webContents.once('dom-ready', () => { |
| 66 | mainWindow.show() | 67 | mainWindow.show() |
| 67 | - loadWindow.destroy() | 68 | + if (config.UseStartupChart) loadWindow.destroy() |
| 68 | - // mainWindow.webContents.openDevTools(true) | ||
| 69 | }) | 69 | }) |
| 70 | } | 70 | } |
| 71 | 71 | ... | ... |
| 1 | -import request from '@/utils/request' | 1 | +// 仅示例 |
| 2 | +// import request from '@/utils/request' | ||
| 2 | 3 | ||
| 3 | -export function login (data) { | 4 | +// export function login (data) { |
| 4 | - return request({ | 5 | +// return request({ |
| 5 | - url: '/user/login', | 6 | +// url: '/user/login', |
| 6 | - method: 'post', | 7 | +// method: 'post', |
| 7 | - data | 8 | +// data |
| 8 | - }) | 9 | +// }) |
| 9 | -} | 10 | +// } |
| 10 | 11 | ||
| 11 | -export function getInfo (token) { | 12 | +// export function getInfo (token) { |
| 12 | - return request({ | 13 | +// return request({ |
| 13 | - url: '/user/info', | 14 | +// url: '/user/info', |
| 14 | - method: 'get', | 15 | +// method: 'get', |
| 15 | - params: { token } | 16 | +// params: { token } |
| 16 | - }) | 17 | +// }) |
| 17 | -} | 18 | +// } |
| 18 | - | ||
| 19 | -export function logout () { | ||
| 20 | - return request({ | ||
| 21 | - url: '/user/logout', | ||
| 22 | - method: 'post' | ||
| 23 | - }) | ||
| 24 | -} | ||
| 25 | - | ||
| 26 | -export function message () { | ||
| 27 | - return request({ | ||
| 28 | - url: '/message', | ||
| 29 | - method: 'get' | ||
| 30 | - }) | ||
| 31 | -} | ... | ... |
src/renderer/api/operationalData.js
deleted
100644 → 0
| 1 | -import db from '@/utils/db' | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - adddata (data) { | ||
| 5 | - return new Promise((resolve, reject) => { | ||
| 6 | - db.insert(data, (err, newdoc) => { | ||
| 7 | - if (err) { | ||
| 8 | - reject(err) | ||
| 9 | - return false | ||
| 10 | - } | ||
| 11 | - resolve(newdoc) | ||
| 12 | - }) | ||
| 13 | - }) | ||
| 14 | - }, | ||
| 15 | - finddata (query) { | ||
| 16 | - return new Promise((resolve, reject) => { | ||
| 17 | - db.find(query, (err, res) => { | ||
| 18 | - if (err) { | ||
| 19 | - reject(err) | ||
| 20 | - return false | ||
| 21 | - } | ||
| 22 | - resolve(res) | ||
| 23 | - }) | ||
| 24 | - }) | ||
| 25 | - }, | ||
| 26 | - findone (query) { | ||
| 27 | - return new Promise((resolve, reject) => { | ||
| 28 | - db.findOne(query, (err, res) => { | ||
| 29 | - if (err) { | ||
| 30 | - reject(err) | ||
| 31 | - return false | ||
| 32 | - } | ||
| 33 | - resolve(res) | ||
| 34 | - }) | ||
| 35 | - }) | ||
| 36 | - }, | ||
| 37 | - deleone (query) { | ||
| 38 | - return new Promise((resolve, reject) => { | ||
| 39 | - db.remove(query, (err, number) => { | ||
| 40 | - if (err) { | ||
| 41 | - reject(err) | ||
| 42 | - return false | ||
| 43 | - } | ||
| 44 | - resolve(number) | ||
| 45 | - }) | ||
| 46 | - }) | ||
| 47 | - }, | ||
| 48 | - deleall (query) { | ||
| 49 | - return new Promise((resolve, reject) => { | ||
| 50 | - db.remove(query, { | ||
| 51 | - multi: true | ||
| 52 | - }, (err, number) => { | ||
| 53 | - if (err) { | ||
| 54 | - reject(err) | ||
| 55 | - return false | ||
| 56 | - } | ||
| 57 | - resolve(number) | ||
| 58 | - }) | ||
| 59 | - }) | ||
| 60 | - } | ||
| 61 | -} |
| ... | @@ -19,9 +19,6 @@ | ... | @@ -19,9 +19,6 @@ |
| 19 | <div class="doc"> | 19 | <div class="doc"> |
| 20 | <div class="title alt">您可以点击的按钮测试功能</div> | 20 | <div class="title alt">您可以点击的按钮测试功能</div> |
| 21 | <el-button type="primary" round @click="open()">控制台打印</el-button> | 21 | <el-button type="primary" round @click="open()">控制台打印</el-button> |
| 22 | - <el-button type="primary" round @click="setdata">写入数据</el-button> | ||
| 23 | - <el-button type="primary" round @click="getdata">读取数据</el-button> | ||
| 24 | - <el-button type="primary" round @click="deledata">清除所有数据</el-button> | ||
| 25 | <el-button type="primary" round @click="CheckUpdate('one')">检查更新</el-button> | 22 | <el-button type="primary" round @click="CheckUpdate('one')">检查更新</el-button> |
| 26 | </div> | 23 | </div> |
| 27 | <div class="doc"> | 24 | <div class="doc"> |
| ... | @@ -121,56 +118,6 @@ export default { | ... | @@ -121,56 +118,6 @@ export default { |
| 121 | open() { | 118 | open() { |
| 122 | console.log(this.$electron); | 119 | console.log(this.$electron); |
| 123 | }, | 120 | }, |
| 124 | - // 设置数据库的数据 | ||
| 125 | - setdata() { | ||
| 126 | - this.$db | ||
| 127 | - .adddata(this.newdata) | ||
| 128 | - .then(res => this.getdata()) | ||
| 129 | - .catch(err => console.log(err)); | ||
| 130 | - }, | ||
| 131 | - // 获取数据库的数据 | ||
| 132 | - getdata() { | ||
| 133 | - this.$db | ||
| 134 | - .finddata() | ||
| 135 | - .then(res => { | ||
| 136 | - console.log(res); | ||
| 137 | - this.textarray = res; | ||
| 138 | - console.log(this.textarray); | ||
| 139 | - }) | ||
| 140 | - .catch(err => console.log(err)); | ||
| 141 | - }, | ||
| 142 | - // 清空数据库的数据 | ||
| 143 | - deledata() { | ||
| 144 | - // data则是显示需要的参数 | ||
| 145 | - const data = { | ||
| 146 | - title: "清除数据", | ||
| 147 | - buttons: ["确定了!", "才不要,我手滑了"], | ||
| 148 | - noLink: true, | ||
| 149 | - message: "此操作会清空本地数据库中的所有数据,是否继续?" | ||
| 150 | - }; | ||
| 151 | - this.$ipcApi.send("open-messagebox", data); | ||
| 152 | - this.$ipcApi.on("confirm-message", (event, arg) => { | ||
| 153 | - console.log(arg); | ||
| 154 | - if (arg.response === 0) { | ||
| 155 | - this.$db.deleall({ name: "yyy" }).then(res => { | ||
| 156 | - console.log(res); | ||
| 157 | - if (res !== 0) { | ||
| 158 | - this.getdata(); | ||
| 159 | - this.$message({ | ||
| 160 | - message: "成功删除" + res + "条", | ||
| 161 | - type: "success" | ||
| 162 | - }); | ||
| 163 | - } else { | ||
| 164 | - let errormsg = { | ||
| 165 | - title: "错误", | ||
| 166 | - message: "已经没有数据可以被删除!" | ||
| 167 | - }; | ||
| 168 | - this.$ipcApi.send("open-errorbox", errormsg); | ||
| 169 | - } | ||
| 170 | - }); | ||
| 171 | - } | ||
| 172 | - }); | ||
| 173 | - }, | ||
| 174 | CheckUpdate(data) { | 121 | CheckUpdate(data) { |
| 175 | switch (data) { | 122 | switch (data) { |
| 176 | case "one": | 123 | case "one": | ... | ... |
| ... | @@ -18,7 +18,6 @@ if (!process.env.IS_WEB) { | ... | @@ -18,7 +18,6 @@ if (!process.env.IS_WEB) { |
| 18 | require('@/styles/custom-title.scss') | 18 | require('@/styles/custom-title.scss') |
| 19 | } | 19 | } |
| 20 | // 当处于electron状态下才引用db | 20 | // 当处于electron状态下才引用db |
| 21 | - Vue.prototype.$db = require('./api/operationalData').default | ||
| 22 | Vue.prototype.$ipcApi = require('./utils/ipcRenderer').default | 21 | Vue.prototype.$ipcApi = require('./utils/ipcRenderer').default |
| 23 | } | 22 | } |
| 24 | 23 | ... | ... |
src/renderer/utils/db.js
deleted
100644 → 0
src/renderer/utils/ipcRenderer.js
deleted
100644 → 0
| 1 | -import $electron from 'electron' | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - send (data, arg, cb) { | ||
| 5 | - $electron.ipcRenderer.send(data, arg, (event, arg) => cb(event, arg)) | ||
| 6 | - }, | ||
| 7 | - on (data, arg, cb) { | ||
| 8 | - $electron.ipcRenderer.on(data, arg, (event, arg) => cb(event, arg)) | ||
| 9 | - }, | ||
| 10 | - remove (data) { | ||
| 11 | - $electron.ipcRenderer.removeAllListeners(data) | ||
| 12 | - } | ||
| 13 | -} |
yarn.lock
0 → 100644
此文件的差异太大,无法显示。
-
请 注册 或 登录 后发表评论