Skip to content

Commit 67fb43f

Browse files
committed
feat: 优化代码风格
1 parent 3f7609a commit 67fb43f

12 files changed

Lines changed: 63 additions & 58 deletions

File tree

src/component/layout/reuse-tab.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="reuse-tab-item"
77
:class="item.path === $route.path ? 'active' : ''"
88
:to="item.path"
9-
@contextmenu.prevent.native="onTags(index, $event)"
9+
@contextmenu.prevent="onTags(index, $event)"
1010
>
1111
<i v-if="!filterIcon(stageList[item.stageId].icon)" :class="stageList[item.stageId].icon"></i>
1212
<img v-else :src="stageList[item.stageId].icon" style="width:16px;" />
@@ -69,7 +69,7 @@ export default {
6969
ele.routePath = to.matched[to.matched.length - 1].path
7070
this.histories = [ele, ...histories]
7171
},
72-
logined(val) {
72+
loggedIn(val) {
7373
if (val) {
7474
return
7575
}
@@ -103,8 +103,8 @@ export default {
103103
}
104104
},
105105
computed: {
106-
logined() {
107-
return this.$store.state.logined
106+
loggedIn() {
107+
return this.$store.state.loggedIn
108108
},
109109
defaultRoute() {
110110
return this.$store.state.defaultRoute

src/lin/util/storage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import storage from 'good-storage'
22

33
const LOGIN_KEY = '__login__'
44

5-
export function setLogined(flag) {
5+
export function setLoggedIn(flag) {
66
storage.session.set(LOGIN_KEY, flag)
77
return flag
88
}
99

10-
export function loadLogined() {
10+
export function loadLoggedIn() {
1111
return storage.session.get(LOGIN_KEY, '')
1212
}
1313

14-
export function cleanLogined() {
14+
export function cleanLoggedIn() {
1515
storage.session.remove(LOGIN_KEY)
1616
}

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ app.component('l-icon', LIcon)
2626
app.component('sticky-top', StickyTop)
2727
app.component('source-code', SourceCode)
2828

29-
app.use(router)
3029
app.use(store)
30+
app.use(router)
3131

3232
app.directive('permission', permissionDirective)
3333

src/model/.gitkeep

Whitespace-only changes.

src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const router = createRouter({
4545

4646
router.beforeEach((to, from, next) => {
4747
// 登录验证
48-
if (isLoginRequired(to.name) && !store.state.logined) {
48+
if (isLoginRequired(to.name) && !store.state.loggedIn) {
4949
next({ path: '/login' })
5050
return
5151
}

src/store/action.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import { removeToken } from '@/lin/util/token'
33

44
export default {
55
setUserAndState({ commit }, user) {
6-
// 如果登陆成功,设置logined标志位
7-
commit(types.SET_LOGINED, true)
8-
// 设置全局用户状态
96
commit(types.SET_USER, user)
7+
commit(types.SET_LOGGED_IN, true)
108
},
119

1210
loginOut({ commit }) {
1311
removeToken()
14-
commit(types.REMOVE_LOGINED, false)
12+
commit(types.REMOVE_LOGGED_IN, false)
1513
},
1614

1715
readMessage({ commit }, message) {

src/store/getter.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const deepTravel = (obj, fuc) => {
1919
}
2020
}
2121

22-
export const logined = state => state.logined
22+
export const loggedIn = state => state.loggedIn
2323

2424
export const user = state => state.user
2525

26-
export const readedMessages = state => state.readedMessages
26+
export const alreadyReadMessages = state => state.alreadyReadMessages
2727

2828
export const unreadMessages = state => state.unreadMessages
2929

@@ -80,8 +80,8 @@ export const permissionStageConfig = state => {
8080

8181
// 获取侧边栏配置
8282
export const sideBarList = (state, getter) => {
83-
const { sideBarLevel } = state // eslint-disable-line
84-
const { permissionStageConfig } = getter // eslint-disable-line
83+
const { sideBarLevel } = state
84+
const { permissionStageConfig } = getter
8585

8686
function deepGetSideBar(target, level = 3) {
8787
// 集合节点处理
@@ -132,6 +132,7 @@ export const sideBarList = (state, getter) => {
132132
}
133133
return sideConfig
134134
}
135+
135136
// 最后一层, 都当做子节点处理
136137
if (level <= 0) {
137138
const sideConfig = {}
@@ -151,19 +152,17 @@ export const sideBarList = (state, getter) => {
151152
return sideBar
152153
}
153154

154-
// 获取有权限的所有节点配置对象
155-
// eslint-disable-next-line
156-
export const getStageByName = () => {
157-
return name => stageMap[name]
158-
}
155+
/**
156+
* 获取有权限的所有节点配置对象
157+
*/
158+
export const getStageByName = () => name => stageMap[name]
159159

160-
// 获取有权限的所有节点配置对象
161-
// eslint-disable-next-line
162-
export const getStageByRoute = () => {
163-
return path => {
164-
const result = Object.getOwnPropertySymbols(stageMap).find(key => stageMap[key].route === path)
165-
return stageMap[result]
166-
}
160+
/**
161+
* 获取有权限的所有节点配置对象
162+
*/
163+
export const getStageByRoute = () => path => {
164+
const result = Object.getOwnPropertySymbols(stageMap).find(key => stageMap[key].route === path)
165+
return stageMap[result]
167166
}
168167

169168
export const stageList = () => stageMap

src/store/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Vuex from 'vuex'
1+
import { createStore } from 'vuex'
22
import createLogger from 'vuex/dist/logger'
33
import VuexPersistence from 'vuex-persist'
44
import mutations from './mutation'
@@ -10,15 +10,15 @@ const vuexLocal = new VuexPersistence({
1010
storage: window.localStorage,
1111
reducer: stateData => ({
1212
// eslint-disable-line
13-
logined: stateData.logined,
13+
loggedIn: stateData.loggedIn,
1414
user: stateData.user,
1515
permissions: stateData.permissions,
1616
}),
1717
})
1818

1919
const debug = process.env.NODE_ENV !== 'production'
2020

21-
export default Vuex.createStore({
21+
export default createStore({
2222
state,
2323
getters,
2424
mutations,

src/store/mutation-type.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export const SET_LOGINED = 'SET_LOGINED'
1+
export const SET_LOGGED_IN = 'SET_LOGGED_IN'
22

3-
export const REMOVE_LOGINED = 'REMOVE_LOGINED'
3+
export const REMOVE_LOGGED_IN = 'REMOVE_LOGGED_IN'
44

55
export const SET_USER = 'SET_USER'
66

@@ -12,4 +12,4 @@ export const ADD_UNREAD_MESSAGE = 'ADD_UNREAD_MESSAGE'
1212

1313
export const SET_USER_PERMISSIONS = 'SET_USER_PERMISSIONS'
1414

15-
export const SET_REFERSH_OPTION = 'SET_REFERSH_OPTION'
15+
export const SET_REFRESH_OPTION = 'SET_REFRESH_OPTION'

src/store/mutation.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as types from './mutation-type'
22

33
export default {
4-
[types.SET_LOGINED](state) {
4+
[types.SET_LOGGED_IN](state) {
55
/* eslint no-param-reassign: 0 */
6-
state.logined = true
6+
state.loggedIn = true
77
},
88

9-
[types.REMOVE_LOGINED](state) {
10-
state.logined = false
9+
[types.REMOVE_LOGGED_IN](state) {
10+
state.loggedIn = false
1111
state.user = null
1212
},
1313

@@ -16,7 +16,7 @@ export default {
1616
},
1717

1818
[types.ADD_READED_MESSAGE](state, payload) {
19-
state.readedMessages.push(payload)
19+
state.alreadyReadMessages.push(payload)
2020
},
2121

2222
[types.ADD_UNREAD_MESSAGE](state, payload) {
@@ -44,7 +44,7 @@ export default {
4444
state.permissions = _permissions
4545
},
4646

47-
[types.SET_REFERSH_OPTION](state, option) {
47+
[types.SET_REFRESH_OPTION](state, option) {
4848
state.refreshOptions = option
4949
},
5050
}

0 commit comments

Comments
 (0)