Skip to content

Commit

Permalink
格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Apr 22, 2019
1 parent ac80b2e commit d04e213
Show file tree
Hide file tree
Showing 16 changed files with 345 additions and 271 deletions.
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
</template>

<script>
export default {
name: 'App'
}
export default {
name: 'App'
}
</script>
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import '@/permission' // permission control
*/

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
Vue.use(ElementUI, {
locale
})

Vue.config.productionTip = false

Expand Down
18 changes: 13 additions & 5 deletions src/permission.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import router from './router'
import store from './store'
import { Message } from 'element-ui'
import {
Message
} from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getToken } from '@/utils/auth' // get token from cookie
import {
getToken
} from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'

NProgress.configure({ showSpinner: false }) // NProgress Configuration
NProgress.configure({
showSpinner: false
}) // NProgress Configuration

const whiteList = ['/login'] // no redirect whitelist

router.beforeEach(async(to, from, next) => {
router.beforeEach(async (to, from, next) => {
// start progress bar
NProgress.start()

Expand All @@ -23,7 +29,9 @@ router.beforeEach(async(to, from, next) => {
if (hasToken) {
if (to.path === '/login') {
// if is logged in, redirect to the home page
next({ path: '/' })
next({
path: '/'
})
NProgress.done()
} else {
const hasGetUserInfo = store.getters.name
Expand Down
14 changes: 11 additions & 3 deletions src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ const mutations = {
}

const actions = {
toggleSideBar({ commit }) {
toggleSideBar({
commit
}) {
commit('TOGGLE_SIDEBAR')
},
closeSideBar({ commit }, { withoutAnimation }) {
closeSideBar({
commit
}, {
withoutAnimation
}) {
commit('CLOSE_SIDEBAR', withoutAnimation)
},
toggleDevice({ commit }, device) {
toggleDevice({
commit
}, device) {
commit('TOGGLE_DEVICE', device)
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/store/modules/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import defaultSettings from '@/settings'

const { showSettings, fixedHeader, sidebarLogo } = defaultSettings
const {
showSettings,
fixedHeader,
sidebarLogo
} = defaultSettings

const state = {
showSettings: showSettings,
Expand All @@ -9,15 +13,20 @@ const state = {
}

const mutations = {
CHANGE_SETTING: (state, { key, value }) => {
CHANGE_SETTING: (state, {
key,
value
}) => {
if (state.hasOwnProperty(key)) {
state[key] = value
}
}
}

const actions = {
changeSetting({ commit }, data) {
changeSetting({
commit
}, data) {
commit('CHANGE_SETTING', data)
}
}
Expand All @@ -28,4 +37,3 @@ export default {
mutations,
actions
}

58 changes: 45 additions & 13 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { login, logout, getInfo } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth'
import { resetRouter } from '@/router'
import {
login,
logout,
getInfo
} from '@/api/user'
import {
getToken,
setToken,
removeToken
} from '@/utils/auth'
import {
resetRouter
} from '@/router'

const state = {
token: getToken(),
Expand All @@ -22,11 +32,21 @@ const mutations = {

const actions = {
// user login
login({ commit }, userInfo) {
const { username, password } = userInfo
login({
commit
}, userInfo) {
const {
username,
password
} = userInfo
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => {
const { data } = response
login({
username: username.trim(),
password: password
}).then(response => {
const {
data
} = response
commit('SET_TOKEN', data.token)
setToken(data.token)
resolve()
Expand All @@ -37,16 +57,24 @@ const actions = {
},

// get user info
getInfo({ commit, state }) {
getInfo({
commit,
state
}) {
return new Promise((resolve, reject) => {
getInfo(state.token).then(response => {
const { data } = response
const {
data
} = response

if (!data) {
reject('Verification failed, please Login again.')
}

const { name, avatar } = data
const {
name,
avatar
} = data

commit('SET_NAME', name)
commit('SET_AVATAR', avatar)
Expand All @@ -58,7 +86,10 @@ const actions = {
},

// user logout
logout({ commit, state }) {
logout({
commit,
state
}) {
return new Promise((resolve, reject) => {
logout(state.token).then(() => {
commit('SET_TOKEN', '')
Expand All @@ -72,7 +103,9 @@ const actions = {
},

// remove token
resetToken({ commit }) {
resetToken({
commit
}) {
return new Promise(resolve => {
commit('SET_TOKEN', '')
removeToken()
Expand All @@ -87,4 +120,3 @@ export default {
mutations,
actions
}

10 changes: 5 additions & 5 deletions src/styles/element-ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// to fixed https://github.com/ElemeFE/element/issues/2461
.el-dialog {
transform: none;
left: 0;
position: relative;
margin: 0 auto;
left : 0;
position : relative;
margin : 0 auto;
}

// refine element ui upload
Expand All @@ -30,7 +30,7 @@
width: 100%;

.el-upload-dragger {
width: 100%;
width : 100%;
height: 200px;
}
}
Expand All @@ -41,4 +41,4 @@
a {
display: block
}
}
}
26 changes: 13 additions & 13 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
@import './sidebar.scss';

body {
height: 100%;
height : 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
-webkit-font-smoothing : antialiased;
text-rendering : optimizeLegibility;
font-family : Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
}

label {
font-weight: 700;
}

html {
height: 100%;
height : 100%;
box-sizing: border-box;
}

Expand All @@ -39,8 +39,8 @@ a:active {
a,
a:focus,
a:hover {
cursor: pointer;
color: inherit;
cursor : pointer;
color : inherit;
text-decoration: none;
}

Expand All @@ -51,15 +51,15 @@ div:focus {
.clearfix {
&:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
display : block;
font-size : 0;
content : " ";
clear : both;
height : 0;
}
}

// main-container global css
.app-container {
padding: 20px;
}
}
10 changes: 5 additions & 5 deletions src/styles/mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
&:after {
content: "";
display: table;
clear: both;
clear : both;
}
}

Expand All @@ -16,13 +16,13 @@
}

&::-webkit-scrollbar-thumb {
background: #99a9bf;
background : #99a9bf;
border-radius: 20px;
}
}

@mixin relative {
position: relative;
width: 100%;
height: 100%;
}
width : 100%;
height : 100%;
}
Loading

0 comments on commit d04e213

Please sign in to comment.