Commit fd2fe1e4 by 张立顺

feat 菜单栏图标替换

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