1
0
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 Message Date
FrankLo
ec3afcc232 🐛 fix package bug 2018-08-25 11:51:04 +08:00
Pan
64dfb93d7e add cookie 2018-05-03 17:12:22 +08:00
Pan
abe94410c2 add Download 2018-05-03 16:05:25 +08:00
7 changed files with 35 additions and 13391 deletions

View File

@ -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',

View File

@ -30,3 +30,7 @@ npm run pack
![](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/electron-login.png) ![](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/electron-login.png)
![](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/electron-admin.gif) ![](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/electron-admin.gif)
## Download
Mac: [app release](https://github.com/PanJiaChen/electron-vue-admin/releases/tag/v3.0.0)

13388
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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",

View File

@ -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
}, },

View File

@ -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()
}) })

View 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)
}