Commit 1845613c by 汤强勇

调整

parent 8effed3d
import { Http } from '@/http'
class Global extends Http {
getMenus (params) {
return this.get('getMenus', params)
}
}
export default new Global(true)
import global from './global'
export const globalApi = global
<template lang="pug"> <template lang="pug">
el-container.header-container el-container.header-container
nav.header-nav nav.header-nav.clear
ul.clear ul.clear
li.nav-item.fl li.nav-item.fl('@click'="handleShowMemus('show',$event)")
a.link a.link
i.fa.fa-th-list i.fa.fa-th-list
li.nav-item.fl li.nav-item.fl
...@@ -24,6 +24,30 @@ ...@@ -24,6 +24,30 @@
li.nav-item.fr li.nav-item.fr
a.link a.link
i.fa.fa-comments i.fa.fa-comments
el-row.meuns-nav
el-menu&attributes({
'default-active':"2",
'class':"el-menu-vertical",
'@open':"handleOpen",
'@close':"handleClose",
})
el-submenu.menus-body.clear(index="1")
el-menu-item-group.menus-groups.fl('v-for'="(item,index) in menus",':key'="index")
template(slot="title")
.main-menus
i(class="fa",':class'="item.ico", style={'margin-right':'5px'})
span.main-menus-title {{item.name}}
el-menu-item&attributes({
':index':"idx | pipeString(index)",
'v-for':'(it,idx) in item.children',
':key':"idx"
}) {{it.name}}
el-menu-item-group.menus-tags('v-for'="(i,inx) in it.children",':key'="inx")
<!--template(slot="title") {{i.name}}-->
el-menu-item&attributes({
':index':"inx | pipeString(index,idx)",
':key':"inx"
}) {{i.name}}
</template> </template>
<style lang="stylus"> <style lang="stylus">
.header-container .header-container
...@@ -32,11 +56,14 @@ ...@@ -32,11 +56,14 @@
right 0 right 0
top 0 top 0
z-index 99 z-index 99
box-shadow 0px 1px 1px rgba(0,0,0,.2) box-shadow 0 1px 1px rgba(0,0,0,.2)
.header-nav .header-nav
background #EDEDED position relative
background #ededed
width 100% width 100%
padding-left 70px margin-left 70px
.el-submenu__title
display none
.nav-item .nav-item
display inline-block display inline-block
position relative position relative
...@@ -57,6 +84,22 @@ ...@@ -57,6 +84,22 @@
margin-left 15px margin-left 15px
</style> </style>
<style lang="stylus" scoped> <style lang="stylus" scoped>
.meuns-nav
position absolute
left 0
right 0
bottom 0
top 70px
z-index 9
.menus-body
display flex
.menus-groups
width 200px
.main-menus
color #2a3f54
font-size 15px
font-weight bold
text-align left
.history-item .history-item
line-height 1.7 line-height 1.7
border 1px solid #73879c border 1px solid #73879c
...@@ -66,6 +109,7 @@ ...@@ -66,6 +109,7 @@
& + & & + &
margin-left 15px margin-left 15px
&:hover &:hover
cursor pointer
color inherit color inherit
border-color inherit border-color inherit
background-color inherit background-color inherit
...@@ -80,8 +124,12 @@ ...@@ -80,8 +124,12 @@
margin-right 5px margin-right 5px
i.fa.fa-angle-down i.fa.fa-angle-down
font-size 15px font-size 15px
.el-menu-item
height auto
line-height 1.5
</style> </style>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
name: 'headerNav', name: 'headerNav',
data () { data () {
...@@ -98,8 +146,10 @@ export default { ...@@ -98,8 +146,10 @@ export default {
if (num) { if (num) {
return array return array
} }
console.log(array.slice(0, num))
return array.slice(0, num) return array.slice(0, num)
},
pipeString (...args) {
return args.join('-')
} }
}, },
props: ['icon', 'link', 'type', 'id', 'sort', 'name', 'pid', 'grade'], props: ['icon', 'link', 'type', 'id', 'sort', 'name', 'pid', 'grade'],
...@@ -111,11 +161,20 @@ export default { ...@@ -111,11 +161,20 @@ export default {
} else { } else {
return [...historys] return [...historys]
} }
} },
...mapGetters({menus: 'getMenus'})
}, },
methods: { methods: {
clickItem () { clickItem () {
console.log(this) console.log(this)
},
handleOpen () {},
handleClose () {},
handleShowMemus (type) {
this.$nextTick(() => {
let dom = document.querySelector('.el-submenu__title')
dom.click()
})
} }
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.sidebar('@mouseover'="showUnfoldBtn()",'@mouseout'="hiddenUnfoldBtn()") .sidebar('@mouseover'="showUnfoldBtn()",'@mouseout'="hiddenUnfoldBtn()")
.logo .logo
img(':src'="logo") img(':src'="logo")
.item('v-for'="(item,itemIndex) in menuList" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:currentMenusIndex === itemIndex}") .item('v-if'="menus.length",'v-for'="(item,itemIndex) in menus" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:currentMenusIndex === itemIndex}")
sidebar-item&attributes({ sidebar-item&attributes({
':icon':'item.ico', ':icon':'item.ico',
':link':'item.link', ':link':'item.link',
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
img(class='icon-arrow',':class'="{right:!unfold}","src"='@/assets/images/sidebar/left-arrow-gray.png') img(class='icon-arrow',':class'="{right:!unfold}","src"='@/assets/images/sidebar/left-arrow-gray.png')
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import sidebarItem from '../sidebarItem' import sidebarItem from '../sidebarItem'
const logo = require('@/assets/images/sidebar/logo-blue.png') const logo = require('@/assets/images/sidebar/logo-blue.png')
export default { export default {
...@@ -46,11 +47,8 @@ export default { ...@@ -46,11 +47,8 @@ export default {
currentRouteIndex: 0, currentRouteIndex: 0,
logo, logo,
unfold: false, // 水平展开 unfold: false, // 水平展开
menus: [],
unfoldBtn: false, // 展开按钮 unfoldBtn: false, // 展开按钮
currentMenus: null, currentMenusIndex: -1
currentMenusIndex: -1,
menuList: []
} }
}, },
filters: { filters: {
...@@ -64,14 +62,15 @@ export default { ...@@ -64,14 +62,15 @@ export default {
components: { components: {
sidebarItem sidebarItem
}, },
mounted () { mounted () {},
this.axios.get('http://rap2api.taobao.org/app/mock/115626/getMenus').then(res => {
this.menuList = res.data.data
this.currentMenus = this.menuList[0]
})
},
computed: { computed: {
...mapGetters({menus: 'getMenus'}),
currentMenus: {
get () {
const currentIndex = this.currentMenusIndex
return currentIndex === -1 ? this.getCurrentMenus(0) : this.getCurrentMenus(currentIndex)
}
}
}, },
created () { created () {
}, },
...@@ -80,7 +79,6 @@ export default { ...@@ -80,7 +79,6 @@ export default {
* 选择边测菜单主菜单 * 选择边测菜单主菜单
*/ */
choseMenu (selectItem, selectItemIndex) { choseMenu (selectItem, selectItemIndex) {
this.currentMenus = selectItem
this.currentMenusIndex = selectItemIndex this.currentMenusIndex = selectItemIndex
if (!this.unfold) { if (!this.unfold) {
this.toggleUnfold(true) this.toggleUnfold(true)
...@@ -114,6 +112,9 @@ export default { ...@@ -114,6 +112,9 @@ export default {
}, },
choseSubChildren (...args) { choseSubChildren (...args) {
console.log(args) console.log(args)
},
getCurrentMenus (index) {
return this.menus[index]
} }
} }
} }
......
import axios from 'axios' import axios from 'axios'
// import qs from 'qs' // import qs from 'qs'
import store from '@/store' import store from '@/store'
import config from '../../config/index' import config from '../config/index'
// Add a request interceptor // Add a request interceptor
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
// Do something before request is sent // Do something before request is sent
...@@ -33,7 +33,7 @@ const api = axios.create({ ...@@ -33,7 +33,7 @@ const api = axios.create({
}) })
const mockApi = axios.create({ const mockApi = axios.create({
baseURL: 'http://rap2api.taobao.org/app/mock/115626' baseURL: 'http://rap2api.taobao.org/app/mock/115626/'
}) })
api.interceptors.request.use(function (config) { api.interceptors.request.use(function (config) {
......
...@@ -7,14 +7,13 @@ import ElementUI from 'element-ui' ...@@ -7,14 +7,13 @@ import ElementUI from 'element-ui'
import './assets/styles/reset.css' import './assets/styles/reset.css'
import './assets/styles/common.css' import './assets/styles/common.css'
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import store from './store'
import Axios from 'axios' import Axios from 'axios'
import * as filters from './filters' import * as filters from './filters'
import { http } from './plugin'
// 引入echarts // 引入echarts
import echarts from 'echarts' import echarts from 'echarts'
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(http)
Object.keys(filters).forEach(key => { Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key]) Vue.filter(key, filters[key])
}) })
...@@ -27,6 +26,7 @@ Vue.prototype.$echarts = echarts ...@@ -27,6 +26,7 @@ Vue.prototype.$echarts = echarts
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
store,
components: { App }, components: { App },
template: '<App/>' template: '<App/>'
}) })
export const stringFilter = {
filter: {
pipeString (...args) {
return args.join('-')
}
}
}
import { stringFilter } from './common'
export const stringFilterMixin = stringFilter
...@@ -14,12 +14,21 @@ ...@@ -14,12 +14,21 @@
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from 'vuex'
import HomeSidebar from 'components/Sidebar' import HomeSidebar from 'components/Sidebar'
import HomeHeader from 'components/Header' import HomeHeader from 'components/Header'
export default { export default {
components: { components: {
HomeSidebar, HomeSidebar,
HomeHeader HomeHeader
},
created () {
this.getMenus()
},
methods: {
...mapActions([
'getMenus'
])
} }
} }
</script> </script>
......
import { Http } from './baseHttp'
class HttpService {
install (Vue, options) {
// 4. 添加实例方法
Vue.prototype.$Http = Http
}
}
export default new HttpService()
import momentPlugin from './moment' import momentPlugin from './moment'
import utils from './underscore' import utils from './underscore'
import http from './http' import http from '../http'
export { export {
momentPlugin, momentPlugin,
utils, utils,
......
import * as types from './mutations_types'
export default {
show_loading: ({
commit
}) => {
return new Promise((resolve, reject) => {
commit(types.SHOW_LOADING)
resolve()
})
},
hide_loading: ({
commit
}) => {
return new Promise((resolve, reject) => {
commit(types.HIDE_LOADING)
resolve()
})
}
}
export default {
getLoadStatus (state) {
return state.ajax_loading
}
}
import state from './state' import { globalApi } from '@/api'
import mutations from './mutations'
import getters from './getters' // 获取菜单数据
import actions from './actions' const GET_MEUMS = 'GET_MEUMS'
const state = {
menus: []
}
const actions = {
async getMenus ({
commit, dispatch
}, parmas) {
let res = await globalApi.getMenus(parmas)
let menus = res.data.data
commit(GET_MEUMS, menus)
}
}
const getters = {
getMenus (state) {
return state.menus
}
}
const mutations = {
[GET_MEUMS] (state, menus) {
state.menus = menus
}
}
export default { export default {
state, state,
mutations, mutations,
getters, actions,
actions getters
} }
import * as types from './mutations_types'
// import { store } from 'utils/'
export default {
[types.SHOW_LOADING] (state) {
state.ajax_loading = true
},
[types.HIDE_LOADING] (state) {
state.ajax_loading = false
}
}
// 显示加载
export const SHOW_LOADING = 'SHOW_LOADING'
// 关闭加载
export const HIDE_LOADING = 'HIDE_LOADING'
export default {
ajax_loading: false
}
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import state from './state'
import mutations from './mutations'
import createLogger from 'vuex/dist/logger'
import createLogger from 'vuex/dist/logger'
import global from './global'
Vue.use(Vuex) Vue.use(Vuex)
const debug = process.env.NODE_ENV !== 'production' const debug = process.env.NODE_ENV !== 'production'
export default new Vuex.Store({ export default new Vuex.Store({
actions, modules: {
getters, global
state, },
mutations,
strict: debug, strict: debug,
plugins: debug ? [createLogger()] : [] plugins: debug ? [createLogger()] : []
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment