mirror of
https://github.com/PanJiaChen/electron-vue-admin.git
synced 2025-04-06 03:57:57 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ec3afcc232 | ||
|
64dfb93d7e | ||
|
abe94410c2 |
@ -121,7 +121,7 @@ let rendererConfig = {
|
|||||||
plugins: [
|
plugins: [
|
||||||
new ExtractTextPlugin('styles.css'),
|
new ExtractTextPlugin('styles.css'),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': config.dev.env
|
'process.env': process.env.NODE_ENV === 'production' ? config.build.env : config.dev.env
|
||||||
}),
|
}),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
|
@ -30,3 +30,7 @@ npm run pack
|
|||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
## Download
|
||||||
|
Mac: [app release](https://github.com/PanJiaChen/electron-vue-admin/releases/tag/v3.0.0)
|
||||||
|
13388
package-lock.json
generated
13388
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -55,6 +55,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "0.17.1",
|
"axios": "0.17.1",
|
||||||
"element-ui": "2.3.4",
|
"element-ui": "2.3.4",
|
||||||
|
"js-cookie": "^2.2.0",
|
||||||
"normalize.css": "7.0.0",
|
"normalize.css": "7.0.0",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"vue": "2.5.10",
|
"vue": "2.5.10",
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
const app = {
|
const app = {
|
||||||
state: {
|
state: {
|
||||||
sidebar: {
|
sidebar: {
|
||||||
opened: true,
|
opened: !+Cookies.get('sidebarStatus'),
|
||||||
withoutAnimation: false
|
withoutAnimation: false
|
||||||
},
|
},
|
||||||
device: 'desktop'
|
device: 'desktop'
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
TOGGLE_SIDEBAR: state => {
|
TOGGLE_SIDEBAR: state => {
|
||||||
|
if (state.sidebar.opened) {
|
||||||
|
Cookies.set('sidebarStatus', 1)
|
||||||
|
} else {
|
||||||
|
Cookies.set('sidebarStatus', 0)
|
||||||
|
}
|
||||||
state.sidebar.opened = !state.sidebar.opened
|
state.sidebar.opened = !state.sidebar.opened
|
||||||
},
|
},
|
||||||
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
||||||
|
Cookies.set('sidebarStatus', 1)
|
||||||
state.sidebar.opened = false
|
state.sidebar.opened = false
|
||||||
state.sidebar.withoutAnimation = withoutAnimation
|
state.sidebar.withoutAnimation = withoutAnimation
|
||||||
},
|
},
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { login, logout, getInfo } from '@/api/login'
|
import { login, logout, getInfo } from '@/api/login'
|
||||||
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
token: '',
|
token: getToken(),
|
||||||
name: '',
|
name: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
roles: []
|
roles: []
|
||||||
@ -30,6 +31,7 @@ const user = {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(username, userInfo.password).then(response => {
|
login(username, userInfo.password).then(response => {
|
||||||
const data = response.data
|
const data = response.data
|
||||||
|
setToken(data.token)
|
||||||
commit('SET_TOKEN', data.token)
|
commit('SET_TOKEN', data.token)
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -63,6 +65,7 @@ const user = {
|
|||||||
logout(state.token).then(() => {
|
logout(state.token).then(() => {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
|
removeToken()
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
@ -73,6 +76,7 @@ const user = {
|
|||||||
// 前端 登出
|
// 前端 登出
|
||||||
FedLogOut({ commit }) {
|
FedLogOut({ commit }) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
removeToken()
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
15
src/renderer/utils/auth.js
Normal file
15
src/renderer/utils/auth.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
|
const TokenKey = 'Admin-Token'
|
||||||
|
|
||||||
|
export function getToken() {
|
||||||
|
return Cookies.get(TokenKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setToken(token) {
|
||||||
|
return Cookies.set(TokenKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeToken() {
|
||||||
|
return Cookies.remove(TokenKey)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user