Fix menu overflow error

pull/4/head
Warinyourself 3 years ago
parent b554775085
commit ba0fcbc2f9

@ -22,7 +22,7 @@ export default class AppBar extends Vue {
} }
render() { render() {
return <div class="app-bar"> return <div class="app-bar active-interface">
<div class="app-bar__time"> { timer.longTime } </div> <div class="app-bar__time"> { timer.longTime } </div>
<div class="app-bar__info"> <div class="app-bar__info">
{ this.showBattery && <BatteryIcon /> } { this.showBattery && <BatteryIcon /> }

@ -7,7 +7,6 @@ import { AppMenuItem, AppMenuPosition } from '@/models/page'
components: { AppIcon } components: { AppIcon }
}) })
export default class AppMenu extends Vue { export default class AppMenu extends Vue {
isActive = false
innerPositioned: AppMenuPosition = { left: 0, top: 0, width: 199 } innerPositioned: AppMenuPosition = { left: 0, top: 0, width: 199 }
get position() { get position() {
@ -15,8 +14,11 @@ export default class AppMenu extends Vue {
} }
get menu() { get menu() {
const menu = PageModule.menu return PageModule.menu
return menu }
get isShow() {
return this.menu.view
} }
@Watch('menu.view') @Watch('menu.view')
@ -37,7 +39,7 @@ export default class AppMenu extends Vue {
return this.$refs.menu as Element return this.$refs.menu as Element
} }
async handleCallback(item: AppMenuItem | string) { async handleCallback(event: MouseEvent, item: AppMenuItem | string) {
if (this.menu.handler) { if (this.menu.handler) {
await this.menu.handler(item) await this.menu.handler(item)
} }
@ -45,12 +47,21 @@ export default class AppMenu extends Vue {
this.closeMenu() this.closeMenu()
} }
handleClickOutside(event: MouseEvent) {
if (!this.isShow) return false
const clickOnMenu = this.$el.contains(event.target as Node)
!clickOnMenu && this.closeMenu()
}
mounted() { mounted() {
window.addEventListener('resize', this.handleResize, { passive: true }) window.addEventListener('resize', this.handleResize, { passive: true })
window.addEventListener('click', this.handleClickOutside)
} }
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.handleResize) window.removeEventListener('resize', this.handleResize)
window.removeEventListener('click', this.handleClickOutside)
} }
handleResize() { handleResize() {
@ -81,18 +92,13 @@ export default class AppMenu extends Vue {
PageModule.ASSIGN_MENU({ view: false }) PageModule.ASSIGN_MENU({ view: false })
} }
stopPreventEvent(event: Event) {
event.stopPropagation()
event.preventDefault()
}
buildElementItem(item: AppMenuItem | string, index: number) { buildElementItem(item: AppMenuItem | string, index: number) {
const isSting = typeof item === 'string' const isSting = typeof item === 'string'
const { text, icon } = isSting ? { text: item, icon: null } : item const { text, icon } = isSting ? { text: item, icon: null } : item
return <li return <li
class='menu-list-item' class='menu-list-item'
key={index} key={index}
onClick={() => { this.handleCallback(item) }} onClick={(event) => { this.handleCallback(event, item) }}
> >
{ text } { text }
{ icon && <AppIcon class='menu-icon' name={icon} /> } { icon && <AppIcon class='menu-icon' name={icon} /> }

@ -73,7 +73,7 @@ export default class LoginComponent extends Vue {
render() { render() {
return <div class={ `block-${this.activeBlock?.id}` }> return <div class={ `block-${this.activeBlock?.id}` }>
<div class={ `login-view login-view--${PageModule.loginPosition}` }> <div class={ `active-interface login-view login-view--${PageModule.loginPosition}` }>
<AppIcon name={ this.currentDesktopIcon } onClick={ this.openSettingsTab } class='desktop-icon'/> <AppIcon name={ this.currentDesktopIcon } onClick={ this.openSettingsTab } class='desktop-icon'/>
<AppIcon name={ AppModule.currentOs } onClick={ this.openSettingsTab } class='system-icon'/> <AppIcon name={ AppModule.currentOs } onClick={ this.openSettingsTab } class='system-icon'/>
<UserAvatar /> <UserAvatar />

@ -77,7 +77,7 @@ export default class SettingsComponent extends Vue {
render() { render() {
return <div class="block-settings login-content-settings"> return <div class="block-settings login-content-settings">
<div class="login-view"> <div class="login-view active-interface">
<AppIcon onClick={ this.openLogin } name='collapse' class='system-icon' /> <AppIcon onClick={ this.openLogin } name='collapse' class='system-icon' />
{ !this.isViewThemeOnly && <UserAvatar /> } { !this.isViewThemeOnly && <UserAvatar /> }

@ -15,7 +15,7 @@ export default class ShutdownBlock extends Vue {
render() { render() {
const button = <div class="shutdown-block active-block"> const button = <div class="shutdown-block active-block">
<ShutdownMenu /> <ShutdownMenu />
<div class="shutdown-button" onClick={ systemActionsObject.shutdown }> <div class="shutdown-button active-interface" onClick={ systemActionsObject.shutdown }>
<AppIcon name="shutdown" /> <AppIcon name="shutdown" />
</div> </div>
</div> </div>

@ -29,7 +29,7 @@ export default class ShutdownMenu extends Vue {
} }
render() { render() {
return <div class="shutdown-menu"> return <div class="shutdown-menu active-interface">
{ this.actions.map((action) => { { this.actions.map((action) => {
return <div class="shutdown-item" onClick={ action.callback }> return <div class="shutdown-item" onClick={ action.callback }>
<AppIcon name={ action.icon } /> <AppIcon name={ action.icon } />

@ -39,9 +39,7 @@ export default class SettingsView extends Vue {
const activeTab = <div key={this.mainTabIndex}> { mapTabs[this.mainTabIndex] } </div> const activeTab = <div key={this.mainTabIndex}> { mapTabs[this.mainTabIndex] } </div>
return <div class='user-settings'> return <div class='user-settings'>
<keep-alive> { activeTab }
{ activeTab }
</keep-alive>
</div> </div>
} }
} }

@ -31,7 +31,7 @@
#app #app
&.blur &.blur
.login-view .active-interface
backdrop-filter blur(10px) backdrop-filter blur(10px)
&.no-transition &.no-transition
* *

@ -67,6 +67,10 @@ export default class HomePage extends Vue {
return !this.isViewThemeOnly && this.isOpenLogin return !this.isViewThemeOnly && this.isOpenLogin
} }
get showMenu() {
return PageModule.menu.view
}
get isSupportFullApi() { get isSupportFullApi() {
return AppModule.isSupportFullApi return AppModule.isSupportFullApi
} }
@ -88,18 +92,24 @@ export default class HomePage extends Vue {
document.addEventListener('mousedown', this.handleClick) document.addEventListener('mousedown', this.handleClick)
} }
closeMenu() {
PageModule.ASSIGN_MENU({ view: false })
}
handleClick(event: MouseEvent) { handleClick(event: MouseEvent) {
if (!this.activeBlock) { if (!this.activeBlock) {
return PageModule.openFirstBlock() return PageModule.openFirstBlock()
} else if (this.showMenu) {
return false
} }
const target = event.target as HTMLElement const target = event.target as HTMLElement
const activeBlocks = document.querySelectorAll(`.block-${this.activeBlock.id}`) const activeBlocks = document.querySelectorAll(`.block-${this.activeBlock.id}`)
const isClickOnAciveBlock = Array.from(activeBlocks).some(node => node.contains(target)) const isClickOnAciveBlock = Array.from(activeBlocks).some(node => node.contains(target))
const isClickOnIgnoreBlock = hasSomeParentClass(target, '.active-block') const ignoreClick = hasSomeParentClass(target, '.active-block')
if (isClickOnIgnoreBlock) { if (ignoreClick) {
return undefined return false
} else if (!isClickOnAciveBlock) { } else if (!isClickOnAciveBlock) {
PageModule.closeBlock() PageModule.closeBlock()
} }

Loading…
Cancel
Save