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

修改

上级 37bf2789
......@@ -34,8 +34,8 @@ ia32:
- dist/electron/**/*
nsis:
script: |-
!include "/Users/evan/Desktop/pica/electron-vue-admin/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"
!include "F:\yqy\electron-phy-exam\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
!addincludedir "F:\yqy\electron-phy-exam\node_modules\app-builder-lib\templates\nsis\include"
!macro _isUpdated _a _b _t _f
${StdUtils.TestParameter} $R9 "updated"
StrCmp "$R9" "true" `${_t}` `${_f}`
......@@ -107,8 +107,8 @@ nsis:
!insertmacro MUI_LANGUAGE "Vietnamese"
!macroend
!addplugindir /x86-unicode "/Users/evan/Library/Caches/electron-builder/nsis/nsis-resources-3.4.1/plugins/x86-unicode"
!include "/private/var/folders/86/qhpf7xn161z5hmq6dkmqfv5m0000gn/T/t-MTPfEX/0-messages.nsh"
!addplugindir /x86-unicode "C:\Users\Duncan\AppData\Local\electron-builder\Cache\nsis\nsis-resources-3.4.1\plugins\x86-unicode"
!include "C:\Users\Duncan\AppData\Local\Temp\t-0w43Sq\0-messages.nsh"
Var newStartMenuLink
Var oldStartMenuLink
......
directories:
output: build-test
buildResources: build
productName: electron-vue-admin
appId: org.simulatedgreg.electron-vue
productName: PICA
appId: org.simulatedgreg.PICA
files:
- filter:
- 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",
"author": "Pan <panfree23@gmail.com>",
"author": "DUNCAN",
"description": "An electron-vue project",
"license": "MIT",
"main": "./dist/electron/main.js",
......@@ -19,8 +19,8 @@
"postinstall": "npm run lint:fix"
},
"build": {
"productName": "electron-vue-admin",
"appId": "org.simulatedgreg.electron-vue",
"productName": "PICA",
"appId": "org.simulatedgreg.PICA",
"directories": {
"output": "build-test"
},
......@@ -63,14 +63,16 @@
},
"dependencies": {
"axios": "0.17.1",
"element-ui": "2.3.4",
"element-ui": "^2.15.10",
"js-cookie": "^2.2.0",
"mssql": "^6.4.1",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"polyfill-object.fromentries": "^1.0.1",
"regedit": "^5.1.1",
"vue": "2.5.10",
"vue-electron": "^1.0.6",
"vue-infinite-scroll": "^2.0.2",
"vue-router": "3.0.1",
"vuex": "3.0.1"
},
......
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
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
// const ex = process.execPath
if (process.env.NODE_ENV !== 'development') {
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
const winURL = process.env.NODE_ENV === 'development'
......@@ -21,6 +51,9 @@ function createWindow() {
height: 563,
useContentSize: true,
width: 1000
// webPreferences: {
// nodeIntegration: true // web开启主进程中集成node
// }
})
mainWindow.loadURL(winURL)
......@@ -30,7 +63,10 @@ function createWindow() {
})
}
app.on('ready', createWindow)
app.on('ready', async() => {
createWindow()
if (!isDevelopment) launchAtStartup()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
......@@ -43,7 +79,26 @@ app.on('activate', () => {
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
*
......
......@@ -12,10 +12,13 @@ import store from './store'
import '@/icons' // icon
import '@/permission' // permission control
import infiniteScroll from 'vue-infinite-scroll'
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
// import VueElectron from './vue_electron'
// Vue.use(VueElectron)
Vue.use(ElementUI, { locale })
Vue.use(infiniteScroll)
Vue.config.productionTip = false
......
......@@ -2,28 +2,37 @@ import router from './router'
import store from './store'
import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式
import { Message } from 'element-ui'
import { setAutoLogin, getAutoLogin } from './utils/auth'
const whiteList = ['/login'] // 不重定向白名单
// import { ipcMain } from 'electron'
router.beforeEach((to, from, next) => {
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 (to.path === '/login') {
next({ path: '/' })
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
if (store.getters.roles.length === 0) {
store.dispatch('GetInfo').then(res => { // 拉取用户信息
next()
}).catch((err) => {
store.dispatch('FedLogOut').then(() => {
Message.error(err || 'Verification failed, please login again')
next({ path: '/' })
})
})
} else {
next()
}
// if (store.getters.roles.length === 0) {
// store.dispatch('GetInfo').then(res => { // 拉取用户信息
// next()
// }).catch((err) => {
// store.dispatch('FedLogOut').then(() => {
// Message.error(err || 'Verification failed, please login again')
// next({ path: '/' })
// })
// })
// } else {
// next()
// }
next()
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
......
......@@ -4,6 +4,7 @@ const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
roles: state => state.user.roles
roles: state => state.user.roles,
openAtLogin: state => state.app.openAtLogin
}
export default getters
import Cookies from 'js-cookie'
import { getAutoLogin } from '../../utils/auth'
const app = {
state: {
sidebar: {
opened: !+Cookies.get('sidebarStatus'),
withoutAnimation: false
},
device: 'desktop'
device: 'desktop',
openAtLogin: getAutoLogin()
},
mutations: {
TOGGLE_SIDEBAR: state => {
......@@ -24,6 +25,10 @@ const app = {
},
TOGGLE_DEVICE: (state, device) => {
state.device = device
},
SET_OPEN_ATLOGIN: (state, status) => {
state.openAtLogin = status
console.log('status', state.openAtLogin)
}
},
actions: {
......@@ -35,6 +40,9 @@ const app = {
},
ToggleDevice({ commit }, device) {
commit('TOGGLE_DEVICE', device)
},
setAutoLogin({ commit }, status) {
commit('SET_OPEN_ATLOGIN', status)
}
}
}
......
......@@ -13,3 +13,11 @@ export function setToken(token) {
export function removeToken() {
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>
<div class="dashboard-container">
<div class="dashboard-text">name:{{name}}</div>
<div class="dashboard-text">roles:<span v-for='role in roles' :key='role'>{{role}}</span></div>
<div>{{file}}</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>
</template>
<script>
import { mapGetters } from 'vuex'
// import { app, ipcMain } from 'electron'
// import { session } from 'electron'
// const ex = process.execPath
export default {
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: {
...mapGetters([
'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>
......@@ -22,11 +158,38 @@ export default {
<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
&-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;
line-height: 46px;
}
}
</style>
<template>
<div class="app-wrapper" :class="classObj">
<sidebar class="sidebar-container"></sidebar>
<div class="main-container">
<navbar></navbar>
<!-- <sidebar class="sidebar-container"></sidebar> -->
<div class="main">
<!-- <navbar></navbar> -->
<app-main></app-main>
</div>
</div>
......
......@@ -34,6 +34,7 @@
// import { isvalidUsername } from '@/utils/validate'
var sql = require('mssql')
let that = null
import Cookies from 'js-cookie'
export default {
name: 'login',
data() {
......@@ -108,9 +109,12 @@ export default {
return pool.request()
.query('select id,LAB09,LAB14,BCE03 from KangNing.dbo.TEMP')
}).then(result => {
console.dir('---', result)
console.log('---', result)
console.log('---', that)
that.sqlres = result
Cookies.set('Admin-Token', 'token')
that.$store.commit('SET_TOKEN', '1111')
that.loading = false
that.$router.push({ path: '/' })
}).catch(err => {
// ... error checks
console.dir(err)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册