Commit fd2fe1e4 by 张立顺

feat 菜单栏图标替换

1 parent f4362e08
Showing 78 changed files with 203 additions and 129 deletions

416 Bytes | W: | H:

1.1 KB | W: | H:

public/menuIcon/contentManager.png
public/menuIcon/contentManager.png
public/menuIcon/contentManager.png
public/menuIcon/contentManager.png
  • 2-up
  • Swipe
  • Onion skin

453 Bytes | W: | H:

661 Bytes | W: | H:

public/menuIcon/financeManage.png
public/menuIcon/financeManage.png
public/menuIcon/financeManage.png
public/menuIcon/financeManage.png
  • 2-up
  • Swipe
  • Onion skin

438 Bytes | W: | H:

1006 Bytes | W: | H:

public/menuIcon/flowManage.png
public/menuIcon/flowManage.png
public/menuIcon/flowManage.png
public/menuIcon/flowManage.png
  • 2-up
  • Swipe
  • Onion skin

406 Bytes | W: | H:

809 Bytes | W: | H:

public/menuIcon/goods.png
public/menuIcon/goods.png
public/menuIcon/goods.png
public/menuIcon/goods.png
  • 2-up
  • Swipe
  • Onion skin

410 Bytes | W: | H:

910 Bytes | W: | H:

public/menuIcon/index.png
public/menuIcon/index.png
public/menuIcon/index.png
public/menuIcon/index.png
  • 2-up
  • Swipe
  • Onion skin

528 Bytes | W: | H:

891 Bytes | W: | H:

public/menuIcon/orderManage.png
public/menuIcon/orderManage.png
public/menuIcon/orderManage.png
public/menuIcon/orderManage.png
  • 2-up
  • Swipe
  • Onion skin

502 Bytes | W: | H:

999 Bytes | W: | H:

public/menuIcon/pointManagement.png
public/menuIcon/pointManagement.png
public/menuIcon/pointManagement.png
public/menuIcon/pointManagement.png
  • 2-up
  • Swipe
  • Onion skin

601 Bytes | W: | H:

785 Bytes | W: | H:

public/menuIcon/purchaseManage.png
public/menuIcon/purchaseManage.png
public/menuIcon/purchaseManage.png
public/menuIcon/purchaseManage.png
  • 2-up
  • Swipe
  • Onion skin

410 Bytes | W: | H:

734 Bytes | W: | H:

public/menuIcon/residentManage.png
public/menuIcon/residentManage.png
public/menuIcon/residentManage.png
public/menuIcon/residentManage.png
  • 2-up
  • Swipe
  • Onion skin

360 Bytes | W: | H:

898 Bytes | W: | H:

public/menuIcon/rightsAndInterestsManage.png
public/menuIcon/rightsAndInterestsManage.png
public/menuIcon/rightsAndInterestsManage.png
public/menuIcon/rightsAndInterestsManage.png
  • 2-up
  • Swipe
  • Onion skin

406 Bytes | W: | H:

427 Bytes | W: | H:

public/menuIcon/stockManage.png
public/menuIcon/stockManage.png
public/menuIcon/stockManage.png
public/menuIcon/stockManage.png
  • 2-up
  • Swipe
  • Onion skin

360 Bytes | W: | H:

678 Bytes | W: | H:

public/menuIcon/systemConfig.png
public/menuIcon/systemConfig.png
public/menuIcon/systemConfig.png
public/menuIcon/systemConfig.png
  • 2-up
  • Swipe
  • Onion skin
// 创建 el-menu-item
export function elMenuItem(createElement, menu) {
return createElement('el-menu-item', { props: { index: menu.path } }, [
return createElement("el-menu-item", { props: { index: menu.path } }, [
...(menu.icon
? [createElement('i', { attrs: { class: `el-icon-${menu.icon}` } })]
? [createElement("i", { attrs: { class: `el-icon-${menu.icon}` } })]
: []),
...((menu.icon === undefined) & !menu.iconSvg
...(menu.icon === undefined && !menu.iconSvg && menu.title == "总览"
? [
// createElement('img', { attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement('img', {
attrs: {
src:
// createElement('img', { attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement("img", {
attrs: {
src:
`${process.env.VUE_APP_PUBLIC_PATH}menuIcon/` +
menu.path.slice(1) +
'.png'
}
})
]
".png",
width: "22px",
height: "20px"
}
})
]
: []),
...(menu.iconSvg
? [createElement('d2-icon-svg', { props: { name: menu.iconSvg } })]
? [createElement("d2-icon-svg", { props: { name: menu.iconSvg } })]
: []),
createElement('span', { slot: 'title' }, menu.title || '未命名菜单')
createElement("span", { slot: "title" }, menu.title || "未命名菜单")
])
}
// 创建 el-submenu
export function elSubmenu(createElement, menu) {
return createElement('el-submenu', { props: { index: menu.path } }, [
return createElement("el-submenu", { props: { index: menu.path } }, [
...(menu.icon
? [
createElement('i', {
slot: 'title',
attrs: { class: `el-icon-${menu.icon}` }
})
]
createElement("i", {
slot: "title",
attrs: { class: `el-icon-${menu.icon}` }
})
]
: []),
...((menu.icon === undefined) & !menu.iconSvg
? [
// createElement('img', { slot: 'title', attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement('img', {
slot: 'title',
attrs: {
src:
// createElement('img', { slot: 'title', attrs: { src: './menuIcon/' + menu.path.slice(1) + '.png' } })
// public 文件需要使用绝对路径引入
createElement("img", {
slot: "title",
attrs: {
src:
`${process.env.VUE_APP_PUBLIC_PATH}menuIcon/` +
menu.path.slice(1) +
'.png'
}
})
]
".png",
width: "22px",
height: "20px"
}
})
]
: []),
...(menu.iconSvg
? [
createElement('d2-icon-svg', {
slot: 'title',
props: { name: menu.iconSvg }
})
]
createElement("d2-icon-svg", {
slot: "title",
props: { name: menu.iconSvg }
})
]
: []),
createElement('span', { slot: 'title' }, menu.title || '未命名菜单'),
createElement("span", { slot: "title" }, menu.title || "未命名菜单"),
...menu.children.map((child, childIndex) =>
child.sideHidden
? ''
? ""
: (child.children === undefined ? elMenuItem : elSubmenu).call(
this,
createElement,
child
)
this,
createElement,
child
)
)
])
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
import { mapState } from "vuex"
import menuMixin from "../mixin/menu"
import { elMenuItem, elSubmenu } from "../libs/util.menu"
export default {
name: 'd2-layout-header-aside-menu-header',
mixins: [
menuMixin
],
name: "d2-layout-header-aside-menu-header",
mixins: [menuMixin],
render(createElement) {
return createElement('div', {
attrs: { flex: 'cross:center' },
class: { 'd2-theme-header-menu': true, 'is-scrollable': this.isScroll },
ref: 'page'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__content', flex: '', 'flex-box': '1' },
ref: 'content'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__scroll', 'flex-box': '0' },
style: { transform: `translateX(${this.currentTranslateX}px)` },
ref: 'scroll'
}, [
createElement('el-menu', {
props: { mode: 'horizontal', defaultActive: this.active },
on: { select: this.handleMenuSelect }
}, this.header.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu)))
])
]),
...this.isScroll
? [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__prev', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('left') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-left' } })
]),
createElement('div', {
attrs: { class: 'd2-theme-header-menu__next', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('right') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-right' } })
])
]
: []
])
return createElement(
"div",
{
attrs: { flex: "cross:center" },
class: { "d2-theme-header-menu": true, "is-scrollable": this.isScroll },
ref: "page"
},
[
createElement(
"div",
{
attrs: {
class: "d2-theme-header-menu__content",
flex: "",
"flex-box": "1"
},
ref: "content"
},
[
createElement(
"div",
{
attrs: {
class: "d2-theme-header-menu__scroll",
"flex-box": "0"
},
style: { transform: `translateX(${this.currentTranslateX}px)` },
ref: "scroll"
},
[
createElement(
"el-menu",
{
props: { mode: "horizontal", defaultActive: this.active },
on: { select: this.handleMenuSelect }
},
this.header.map((menu) =>
(menu.children === undefined || menu.title != "总览"
? elMenuItem
: elSubmenu
).call(this, createElement, menu)
)
)
]
)
]
),
...(this.isScroll
? [
createElement(
"div",
{
attrs: {
class: "d2-theme-header-menu__prev",
flex: "main:center cross:center",
"flex-box": "0"
},
on: { click: () => this.scroll("left") }
},
[createElement("i", { attrs: { class: "el-icon-arrow-left" } })]
),
createElement(
"div",
{
attrs: {
class: "d2-theme-header-menu__next",
flex: "main:center cross:center",
"flex-box": "0"
},
on: { click: () => this.scroll("right") }
},
[
createElement("i", {
attrs: { class: "el-icon-arrow-right" }
})
]
)
]
: [])
]
)
},
computed: {
...mapState('d2admin/menu', [
'header'
])
...mapState("d2admin/menu", ["header"])
},
data() {
return {
active: '',
active: "",
isScroll: false,
scrollWidth: 0,
contentWidth: 0,
......@@ -62,7 +102,7 @@ export default {
}
},
watch: {
'$route.matched': {
"$route.matched": {
handler(val) {
this.active = val[val.length - 1].path
},
......@@ -71,12 +111,15 @@ export default {
},
methods: {
scroll(direction) {
if (direction === 'left') {
if (direction === "left") {
// 向右滚动
this.currentTranslateX = 0
} else {
// 向左滚动
if (this.contentWidth * 2 - this.currentTranslateX <= this.scrollWidth) {
if (
this.contentWidth * 2 - this.currentTranslateX <=
this.scrollWidth
) {
this.currentTranslateX -= this.contentWidth
} else {
this.currentTranslateX = this.contentWidth - this.scrollWidth
......@@ -121,14 +164,14 @@ export default {
mounted() {
// 初始化判断
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
window.addEventListener('load', this.checkScroll)
window.addEventListener("load", this.checkScroll)
// 全局窗口变化监听,判断父元素和子元素的大小,从而控制isScroll的开关
this.throttledCheckScroll = _.throttle(this.checkScroll, 300)
window.addEventListener('resize', this.throttledCheckScroll)
window.addEventListener("resize", this.throttledCheckScroll)
},
beforeDestroy() {
// 取消监听
window.removeEventListener('resize', this.throttledCheckScroll)
window.removeEventListener('load', this.checkScroll)
window.removeEventListener("resize", this.throttledCheckScroll)
window.removeEventListener("load", this.checkScroll)
}
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
import BScroll from 'better-scroll'
import { mapState } from "vuex"
import menuMixin from "../mixin/menu"
import { elMenuItem, elSubmenu } from "../libs/util.menu"
import BScroll from "better-scroll"
export default {
name: 'd2-layout-header-aside-menu-side',
mixins: [
menuMixin
],
name: "d2-layout-header-aside-menu-side",
mixins: [menuMixin],
render(createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [
createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu',
on: { select: this.handleMenuSelect }
}, this.aside.map(menu => ((menu.children === undefined || menu.children.every(i => i.sideHidden === true)) ? elMenuItem : elSubmenu).call(this, createElement, menu))),
...this.aside.length === 0 && !this.asideCollapse
? [
createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [
createElement('d2-icon', { props: { name: 'inbox' } }),
createElement('span', {}, '没有侧栏菜单')
])
]
: []
])
return createElement(
"div",
{ attrs: { class: "d2-layout-header-aside-menu-side" } },
[
createElement(
"el-menu",
{
props: {
collapse: this.asideCollapse,
uniqueOpened: true,
defaultActive: this.active
},
ref: "menu",
on: { select: this.handleMenuSelect }
},
this.aside.map((menu) =>
(menu.children === undefined ||
menu.children.every((i) => i.sideHidden === true)
? elMenuItem
: elSubmenu
).call(this, createElement, menu)
)
),
...(this.aside.length === 0 && !this.asideCollapse
? [
createElement(
"div",
{
attrs: {
class: "d2-layout-header-aside-menu-empty",
flex: "dir:top main:center cross:center"
}
},
[
createElement("d2-icon", { props: { name: "inbox" } }),
createElement("span", {}, "没有侧栏菜单")
]
)
]
: [])
]
)
},
data() {
return {
active: '',
active: "",
asideHeight: 300,
BS: null
}
},
computed: {
...mapState('d2admin/menu', [
'aside',
'asideCollapse'
])
...mapState("d2admin/menu", ["aside", "asideCollapse"])
},
watch: {
// 折叠和展开菜单的时候销毁 better scroll
......@@ -47,9 +69,11 @@ export default {
}, 500)
},
// 监听路由 控制侧边栏激活状态
'$route.matched': {
"$route.matched": {
handler(val) {
this.active = val[val.length - 1].meta.hasOwnProperty('activePath') ? val[val.length - 1].meta.activePath : val[val.length - 1].path
this.active = val[val.length - 1].meta.hasOwnProperty("activePath")
? val[val.length - 1].meta.activePath
: val[val.length - 1].path
},
immediate: true
}
......
......@@ -15,7 +15,9 @@ export const routerName = {
title: "总览",
authId: "907",
parentId: "1",
cache: false
icon: "s-home",
cache: false,
sideHidden: false
},
auth: [
{
......@@ -69,7 +71,7 @@ export const routerName = {
category: "Button",
handle: "handleOutputImport",
label: "导入"
},
}
],
component: _import("index")
},
......
......@@ -28,7 +28,8 @@ export const home = {
title: "总览",
authId: "907",
parentId: "1",
cache: false
cache: false,
sideHidden: false
},
auth: [
{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!