提交 40ce20e7 编写于 作者: 张敬贤's avatar 张敬贤

修改

上级 37bf2789
...@@ -34,8 +34,8 @@ ia32: ...@@ -34,8 +34,8 @@ ia32:
- dist/electron/**/* - dist/electron/**/*
nsis: nsis:
script: |- script: |-
!include "/Users/evan/Desktop/pica/electron-vue-admin/node_modules/app-builder-lib/templates/nsis/include/StdUtils.nsh" !include "F:\yqy\electron-phy-exam\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
!addincludedir "/Users/evan/Desktop/pica/electron-vue-admin/node_modules/app-builder-lib/templates/nsis/include" !addincludedir "F:\yqy\electron-phy-exam\node_modules\app-builder-lib\templates\nsis\include"
!macro _isUpdated _a _b _t _f !macro _isUpdated _a _b _t _f
${StdUtils.TestParameter} $R9 "updated" ${StdUtils.TestParameter} $R9 "updated"
StrCmp "$R9" "true" `${_t}` `${_f}` StrCmp "$R9" "true" `${_t}` `${_f}`
...@@ -107,8 +107,8 @@ nsis: ...@@ -107,8 +107,8 @@ nsis:
!insertmacro MUI_LANGUAGE "Vietnamese" !insertmacro MUI_LANGUAGE "Vietnamese"
!macroend !macroend
!addplugindir /x86-unicode "/Users/evan/Library/Caches/electron-builder/nsis/nsis-resources-3.4.1/plugins/x86-unicode" !addplugindir /x86-unicode "C:\Users\Duncan\AppData\Local\electron-builder\Cache\nsis\nsis-resources-3.4.1\plugins\x86-unicode"
!include "/private/var/folders/86/qhpf7xn161z5hmq6dkmqfv5m0000gn/T/t-MTPfEX/0-messages.nsh" !include "C:\Users\Duncan\AppData\Local\Temp\t-0w43Sq\0-messages.nsh"
Var newStartMenuLink Var newStartMenuLink
Var oldStartMenuLink Var oldStartMenuLink
......
directories: directories:
output: build-test output: build-test
buildResources: build buildResources: build
productName: electron-vue-admin productName: PICA
appId: org.simulatedgreg.electron-vue appId: org.simulatedgreg.PICA
files: files:
- filter: - filter:
- dist/electron/**/* - dist/electron/**/*
......
version: 3.0.0
files:
- url: electron-vue-admin-Setup-3.0.0.exe
sha512: 1bowHWzNUUXiuKzDR3Fpcn8b6tIPehoYAkQxjqNxa6oNw4jy+JWoyRoHV9SteasEA2pbI/Un42lN2rNwxakbjw==
size: 73923607
path: electron-vue-admin-Setup-3.0.0.exe
sha512: 1bowHWzNUUXiuKzDR3Fpcn8b6tIPehoYAkQxjqNxa6oNw4jy+JWoyRoHV9SteasEA2pbI/Un42lN2rNwxakbjw==
releaseDate: '2022-10-08T09:30:47.135Z'
owner: PanJiaChen
repo: electron-vue-admin
provider: github
updaterCacheDirName: electron-vue-admin-updater
owner: PanJiaChen
repo: electron-vue-admin
provider: github
updaterCacheDirName: electron-vue-admin-updater
{ {
"name": "electron-vue-admin", "name": "PICA",
"version": "3.0.0", "version": "3.0.0",
"author": "Pan <panfree23@gmail.com>", "author": "DUNCAN",
"description": "An electron-vue project", "description": "An electron-vue project",
"license": "MIT", "license": "MIT",
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
"postinstall": "npm run lint:fix" "postinstall": "npm run lint:fix"
}, },
"build": { "build": {
"productName": "electron-vue-admin", "productName": "PICA",
"appId": "org.simulatedgreg.electron-vue", "appId": "org.simulatedgreg.PICA",
"directories": { "directories": {
"output": "build-test" "output": "build-test"
}, },
...@@ -63,14 +63,16 @@ ...@@ -63,14 +63,16 @@
}, },
"dependencies": { "dependencies": {
"axios": "0.17.1", "axios": "0.17.1",
"element-ui": "2.3.4", "element-ui": "^2.15.10",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"mssql": "^6.4.1", "mssql": "^6.4.1",
"normalize.css": "7.0.0", "normalize.css": "7.0.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"polyfill-object.fromentries": "^1.0.1", "polyfill-object.fromentries": "^1.0.1",
"regedit": "^5.1.1",
"vue": "2.5.10", "vue": "2.5.10",
"vue-electron": "^1.0.6", "vue-electron": "^1.0.6",
"vue-infinite-scroll": "^2.0.2",
"vue-router": "3.0.1", "vue-router": "3.0.1",
"vuex": "3.0.1" "vuex": "3.0.1"
}, },
......
import { app, BrowserWindow } from 'electron' import { app, BrowserWindow } from 'electron'
import path from 'path'
const appFolder = path.dirname(process.execPath)
const updateExe = path.resolve(appFolder, 'PICA.exe')
const exeName = path.basename(process.execPath)
// const regedit = require('regedit')
// console.log('global,', global)
// global.$eleSession = session
const isDevelopment = process.env.NODE_ENV !== 'production'
// localStorage.setItem('filePath', updateExe)
/** /**
* Set `__static` path to static files in production * Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/ */
// const ex = process.execPath
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
} }
// regedit.list('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', (err, data) => {
// console.log('errdata', err, data, data['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'].values['electron.app.PICA'])
// if (err) {
// console.log(err)
// }
// if (!data['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'].values['electron.app.PICA'] ||
// data['HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'].values['electron.app.PICA'] !==
// app.getPath('exe')) { // 未注册或注册地址与现地址不一致则 进行注册
// regedit.putValue({
// 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run': {
// 'electron.app.PICA': {
// value: app.getPath('exe'),
// type: 'REG_SZ'
// }
// }
// }, (error) => {
// if (error) console.log(error)
// })
// }
// })
let mainWindow let mainWindow
const winURL = process.env.NODE_ENV === 'development' const winURL = process.env.NODE_ENV === 'development'
...@@ -21,6 +51,9 @@ function createWindow() { ...@@ -21,6 +51,9 @@ function createWindow() {
height: 563, height: 563,
useContentSize: true, useContentSize: true,
width: 1000 width: 1000
// webPreferences: {
// nodeIntegration: true // web开启主进程中集成node
// }
}) })
mainWindow.loadURL(winURL) mainWindow.loadURL(winURL)
...@@ -30,7 +63,10 @@ function createWindow() { ...@@ -30,7 +63,10 @@ function createWindow() {
}) })
} }
app.on('ready', createWindow) app.on('ready', async() => {
createWindow()
if (!isDevelopment) launchAtStartup()
})
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
...@@ -43,7 +79,26 @@ app.on('activate', () => { ...@@ -43,7 +79,26 @@ app.on('activate', () => {
createWindow() createWindow()
} }
}) })
function launchAtStartup() {
if (process.platform === 'darwin') {
app.setLoginItemSettings({
openAtLogin: true,
openAsHidden: true
})
} else {
app.setLoginItemSettings({
openAtLogin: true,
openAsHidden: true,
path: updateExe,
args: [
'--processStart',
`"${exeName}"`,
'--process-start-args',
`"--hidden"`
]
})
}
}
/** /**
* Auto Updater * Auto Updater
* *
......
...@@ -12,10 +12,13 @@ import store from './store' ...@@ -12,10 +12,13 @@ import store from './store'
import '@/icons' // icon import '@/icons' // icon
import '@/permission' // permission control import '@/permission' // permission control
import infiniteScroll from 'vue-infinite-scroll'
if (!process.env.IS_WEB) Vue.use(require('vue-electron')) if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
// import VueElectron from './vue_electron'
// Vue.use(VueElectron)
Vue.use(ElementUI, { locale }) Vue.use(ElementUI, { locale })
Vue.use(infiniteScroll)
Vue.config.productionTip = false Vue.config.productionTip = false
......
...@@ -2,28 +2,37 @@ import router from './router' ...@@ -2,28 +2,37 @@ import router from './router'
import store from './store' import store from './store'
import NProgress from 'nprogress' // Progress 进度条 import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式 import 'nprogress/nprogress.css'// Progress 进度条样式
import { Message } from 'element-ui' import { setAutoLogin, getAutoLogin } from './utils/auth'
const whiteList = ['/login'] // 不重定向白名单 const whiteList = ['/login'] // 不重定向白名单
// import { ipcMain } from 'electron'
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
// 设置开机自启动 并记录状态在本地,
const isAutoLogin = getAutoLogin()
if (!(isAutoLogin && isAutoLogin === 'open')) {
setAutoLogin('open')
store.commit('SET_OPEN_ATLOGIN', 'open')
console.log('isAutoLogin', getAutoLogin())
}
if (store.getters.token) { if (store.getters.token) {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }) next({ path: '/' })
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
} else { } else {
if (store.getters.roles.length === 0) { // if (store.getters.roles.length === 0) {
store.dispatch('GetInfo').then(res => { // 拉取用户信息 // store.dispatch('GetInfo').then(res => { // 拉取用户信息
next() // next()
}).catch((err) => { // }).catch((err) => {
store.dispatch('FedLogOut').then(() => { // store.dispatch('FedLogOut').then(() => {
Message.error(err || 'Verification failed, please login again') // Message.error(err || 'Verification failed, please login again')
next({ path: '/' }) // next({ path: '/' })
}) // })
}) // })
} else { // } else {
next() // next()
} // }
next()
} }
} else { } else {
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
......
...@@ -4,6 +4,7 @@ const getters = { ...@@ -4,6 +4,7 @@ const getters = {
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
name: state => state.user.name, name: state => state.user.name,
roles: state => state.user.roles roles: state => state.user.roles,
openAtLogin: state => state.app.openAtLogin
} }
export default getters export default getters
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { getAutoLogin } from '../../utils/auth'
const app = { const app = {
state: { state: {
sidebar: { sidebar: {
opened: !+Cookies.get('sidebarStatus'), opened: !+Cookies.get('sidebarStatus'),
withoutAnimation: false withoutAnimation: false
}, },
device: 'desktop' device: 'desktop',
openAtLogin: getAutoLogin()
}, },
mutations: { mutations: {
TOGGLE_SIDEBAR: state => { TOGGLE_SIDEBAR: state => {
...@@ -24,6 +25,10 @@ const app = { ...@@ -24,6 +25,10 @@ const app = {
}, },
TOGGLE_DEVICE: (state, device) => { TOGGLE_DEVICE: (state, device) => {
state.device = device state.device = device
},
SET_OPEN_ATLOGIN: (state, status) => {
state.openAtLogin = status
console.log('status', state.openAtLogin)
} }
}, },
actions: { actions: {
...@@ -35,6 +40,9 @@ const app = { ...@@ -35,6 +40,9 @@ const app = {
}, },
ToggleDevice({ commit }, device) { ToggleDevice({ commit }, device) {
commit('TOGGLE_DEVICE', device) commit('TOGGLE_DEVICE', device)
},
setAutoLogin({ commit }, status) {
commit('SET_OPEN_ATLOGIN', status)
} }
} }
} }
......
...@@ -13,3 +13,11 @@ export function setToken(token) { ...@@ -13,3 +13,11 @@ export function setToken(token) {
export function removeToken() { export function removeToken() {
return Cookies.remove(TokenKey) return Cookies.remove(TokenKey)
} }
//
export function setAutoLogin() {
return localStorage.setItem('AutoLogin', 'open')
}
export function getAutoLogin() {
console.log('localStorage.getItem()', localStorage.getItem('AutoLogin'))
return localStorage.getItem('AutoLogin')
}
<template> <template>
<div class="dashboard-container"> <div class="dashboard-container">
<div class="dashboard-text">name:{{name}}</div> <div>{{file}}</div>
<div class="dashboard-text">roles:<span v-for='role in roles' :key='role'>{{role}}</span></div> <div class="dashboard-header">云鹊医体检对接客户端</div>
<el-descriptions title="" :column="2">
<el-descriptions-item label="当前机构">{{form.name}}</el-descriptions-item>
<el-descriptions-item label="程序版本">{{form.version}}</el-descriptions-item>
<el-descriptions-item label="开机自启">
<el-switch
v-model="form.isAuto"
@change="changeIsAuto"
:active-text="form.isAuto?'开启':'关闭'"
active-color="#13ce66"
inactive-color="#ccc">
</el-switch>
</el-descriptions-item>
<el-descriptions-item label="数据库链接状态">
<el-switch
v-model="form.status"
:active-text="form.status?'运行中':'已停止'"
active-color="#13ce66"
inactive-color="#ccc">
</el-switch>
</el-descriptions-item>
</el-descriptions>
<div class="dashboard-title">数据统计</div>
<div style="margin-bottom:20px">
<el-row :gutter="30">
<el-col :span="6" v-for=" i in cardList" :key="i.name">
<el-card class="box-card">
<div slot="header" class="box-card-header">
<span>{{i.name}}</span>
</div>
<div class="box-card-value">
{{i.value}}
</div>
</el-card>
</el-col>
</el-row>
</div>
<div class="dashboard-title">程序日志</div>
<div class="dashboard-log">
<ul class="infinite-list" v-infinite-scroll="load" style="overflow:auto">
<li v-for="(i,index) in count" :key="i" class="infinite-list-item">
<span>{{index + 1}}</span>
<span style="margin-left:10px">这是一条log{{i}}</span>
</li>
</ul>
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
// import { app, ipcMain } from 'electron'
// import { session } from 'electron'
// const ex = process.execPath
export default { export default {
name: 'dashboard', name: 'dashboard',
data() {
return {
form: {
name: '华程医院',
version: 'V2022100901',
isAuto: false,
status: true
},
count: 0,
file: '',
cardList: [
{
name: '昨日推送',
value: '111'
},
{
name: '今日推送',
value: '111'
},
{
name: '昨日报告',
value: '111'
},
{
name: '今日报告',
value: '111'
}
]
}
},
computed: { computed: {
...mapGetters([ ...mapGetters([
'name', 'name',
'roles' 'roles',
'openAtLogin'
]) ])
},
mounted() {
this.file = localStorage.getItem('filePath')
this.form.isAuto = this.openAtLogin === 'open'
},
methods: {
load() {
this.count += 200
},
changeIsAuto() {
console.log('this.form.isAuto', this.$electron.remote.session.defaultSession.cookies)
// const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
this.$electron.remote.session.defaultSession.cookies.get({ session: true }).then((cookies) => {
console.error(cookies)
}, (error) => {
console.error(error)
})
const text = !this.form.isAuto ? '关闭' : '开启'
this.$confirm(`此操作将${text}开机自动启动, 是否继续?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: `${text}成功!`
})
this.form.isAuto ? this.closeAutoOpen() : this.oepnAutoOpen()
}).catch(() => {
this.form.isAuto = !this.form.isAuto
})
},
oepnAutoOpen() {
// 开启 开机自启动
// ipcMain.on('openAutoStart', () => {
// console.log('updateExe', app.getLoginItemSettings().openAtLogin)
// localStorage.setItem('AutoLogin', 'open')
// app.setLoginItemSettings({
// openAtLogin: true,
// path: '',
// args: []
// })
// })
},
closeAutoOpen() {
// 关闭 开机自启动
// ipcMain.on('closeAutoStart', () => {
// app.setLoginItemSettings({
// openAtLogin: false,
// path: '',
// args: []
// })
// })
}
} }
} }
</script> </script>
...@@ -22,11 +158,38 @@ export default { ...@@ -22,11 +158,38 @@ export default {
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.dashboard { .dashboard {
&-container { &-container {
margin: 30px; padding: 0 40px 60px 40px;
.dashboard-title{
margin-bottom: 20px;
font-size: 20px;
line-height: 46px;
}
.box-card-header{
text-align: center;
}
.box-card-value{
text-align: center;
}
.infinite-list{
padding: 20px;
min-height: 100px;
max-height: 300px;
list-style: none;
overflow-y: scroll;
background: #000;
li{
color: #ccc;
line-height: 20px;
font-size: 14px;
}
}
} }
&-text { &-header {
margin: 20px auto;
text-align: center;
font-size: 30px; font-size: 30px;
line-height: 46px; line-height: 46px;
} }
} }
</style> </style>
<template> <template>
<div class="app-wrapper" :class="classObj"> <div class="app-wrapper" :class="classObj">
<sidebar class="sidebar-container"></sidebar> <!-- <sidebar class="sidebar-container"></sidebar> -->
<div class="main-container"> <div class="main">
<navbar></navbar> <!-- <navbar></navbar> -->
<app-main></app-main> <app-main></app-main>
</div> </div>
</div> </div>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
// import { isvalidUsername } from '@/utils/validate' // import { isvalidUsername } from '@/utils/validate'
var sql = require('mssql') var sql = require('mssql')
let that = null let that = null
import Cookies from 'js-cookie'
export default { export default {
name: 'login', name: 'login',
data() { data() {
...@@ -108,9 +109,12 @@ export default { ...@@ -108,9 +109,12 @@ export default {
return pool.request() return pool.request()
.query('select id,LAB09,LAB14,BCE03 from KangNing.dbo.TEMP') .query('select id,LAB09,LAB14,BCE03 from KangNing.dbo.TEMP')
}).then(result => { }).then(result => {
console.dir('---', result) console.log('---', that)
console.log('---', result)
that.sqlres = result that.sqlres = result
Cookies.set('Admin-Token', 'token')
that.$store.commit('SET_TOKEN', '1111')
that.loading = false
that.$router.push({ path: '/' })
}).catch(err => { }).catch(err => {
// ... error checks // ... error checks
console.dir(err) console.dir(err)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册