-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
450 additions
and
1,287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
src/components/menu/RightMenuWindows/RightMenuWindows.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import React, {Component} from 'react' | ||
import { Nav,Icon } from '@alifd/next' | ||
|
||
const { Item, SubNav } = Nav | ||
|
||
const NavItem = (props) => { | ||
const { openWindow,refreshCurrentPage } = require("../../../windows/common/rightMenu") | ||
let logo = null | ||
if(props.row.logo){ | ||
switch (props.row.logo.type){ | ||
case 'point': | ||
if(props.row.logo.value){ | ||
logo = <p/> | ||
} | ||
break; | ||
case 'icon': | ||
logo = <Icon size="xs" type={props.row.logo.value}/> | ||
break; | ||
case 'image': | ||
logo = <img src={props.row.logo.value} alt={props.row.logo.type}/> | ||
break; | ||
default: | ||
logo = null; | ||
break; | ||
} | ||
} | ||
return ( | ||
<div | ||
className={props.row.line?"right_menu_windows_li right_menu_windows_line":"right_menu_windows_li"} | ||
onClick={()=>{ | ||
props.row.func && props.row.func.type === 'openWindow' && openWindow(props.row.func.runFunctionType, props.row.func.value) | ||
props.row.func && props.row.func.type === 'refresh' && props.row.func.runFunctionType === 'refreshCurrentPage' && refreshCurrentPage() | ||
}} | ||
> | ||
<div className="right_menu_windows_li_img"> | ||
{logo} | ||
</div> | ||
<div>{props.row.name}</div> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
class RightMenuWindows extends Component { | ||
|
||
state = { | ||
contextStyle:{} | ||
} | ||
componentDidMount(){ | ||
this.init_menu(this.props.contextStyle) | ||
} | ||
shouldComponentUpdate(newProps, newState) { | ||
if(newProps.contextStyle !== this.props.contextStyle){ | ||
this.init_menu(newProps.contextStyle) | ||
} | ||
|
||
return true | ||
} | ||
render() { | ||
const { | ||
mainContextMenu, | ||
set_context_menu | ||
} = this.props | ||
const {contextStyle} = this.state | ||
const navStyle={ | ||
width: 180 | ||
} | ||
return ( | ||
<div | ||
className="right_menu_windows" | ||
ref={node=>this.right_menu=node} | ||
style={contextStyle} | ||
onMouseEnter={()=>{set_context_menu(mainContextMenu,true,this.right_menu,2,true)}} | ||
onMouseLeave={()=>{set_context_menu(mainContextMenu,true,this.right_menu,2,false)}} | ||
> | ||
<Nav style={navStyle} mode="popup" popupAlign="follow" triggerType="hover"> | ||
{this.tree(mainContextMenu)} | ||
</Nav> | ||
</div> | ||
) | ||
} | ||
init_menu = (style) => { | ||
if(style.left + 180 > window.innerWidth){ | ||
style.left -=180 | ||
} | ||
if(style.top + this.right_menu.offsetHeight > window.innerHeight - 37){ | ||
style.top -= this.right_menu.offsetHeight | ||
} | ||
this.setState({ | ||
contextStyle:style | ||
}) | ||
} | ||
tree = (data) => { | ||
return data.map((row)=>{ | ||
if(row.children){ | ||
return ( | ||
<SubNav | ||
key={row.type} | ||
label={ | ||
<NavItem row={row}/> | ||
} | ||
> | ||
{this.tree(row.children)} | ||
</SubNav> | ||
) | ||
}else{ | ||
return ( | ||
<Item key={row.type} className="right_menu_windows_sub_nav"> | ||
<NavItem row={row}/> | ||
</Item> | ||
) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
|
||
export default RightMenuWindows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, {Component} from 'react' | ||
import { Animate } from '@alifd/next' | ||
import RightMenuWindows from "./RightMenuWindows" | ||
import "../../../public/style/components/menu/right_menu_windows.scss" | ||
|
||
|
||
class index extends Component { | ||
|
||
state = {} | ||
render() { | ||
const { | ||
isOpenContextMenu | ||
} = this.props | ||
return ( | ||
<Animate animation="right_menu_expand" | ||
beforeEnter={this.beforeEnter} | ||
onEnter={this.onEnter} | ||
afterEnter={this.afterEnter} | ||
beforeLeave={this.beforeLeave} | ||
onLeave={this.onLeave} | ||
afterLeave={this.afterLeave}> | ||
{isOpenContextMenu ? | ||
<RightMenuWindows {...this.props}/> | ||
: null | ||
} | ||
</Animate> | ||
) | ||
} | ||
beforeEnter(node) { | ||
node.style.opacity = 0 | ||
} | ||
|
||
onEnter(node) { | ||
node.style.opacity = 1 | ||
} | ||
|
||
afterEnter(node) { | ||
// node.style.height = null; | ||
} | ||
|
||
beforeLeave(node) { | ||
node.style.opacity = 1 | ||
} | ||
|
||
onLeave(node) { | ||
node.style.opacity = 0 | ||
} | ||
|
||
afterLeave(node) { | ||
// node.style.height = null; | ||
} | ||
|
||
} | ||
|
||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
$height:24px; | ||
$color:#111111; | ||
|
||
.right_menu_expand-enter { | ||
overflow: hidden; | ||
} | ||
|
||
.right_menu_expand-enter-active { | ||
transition: opacity 0.3s ease-out; | ||
} | ||
|
||
.right_menu_expand-leave { | ||
overflow: hidden; | ||
} | ||
|
||
.right_menu_expand-leave-active { | ||
transition: opacity 0.15s ease-out; | ||
} | ||
|
||
@mixin item{ | ||
padding: 0 5px!important; | ||
height: $height; | ||
line-height: $height; | ||
.next-menu-item-inner{ | ||
color:$color; | ||
height: $height; | ||
i{ | ||
color:$color; | ||
} | ||
.next-menu-item-text{ | ||
.right_menu_windows_li{ | ||
height: $height; | ||
.right_menu_windows_li_img{ | ||
margin: 2px 5px 0 0; | ||
width: 18px; | ||
height: 18px; | ||
display: block; | ||
float: left; | ||
line-height: 17px; | ||
i{ | ||
margin-left: 5px; | ||
} | ||
p{ | ||
line-height: $height; | ||
margin:6px auto; | ||
background-color: black; | ||
width: 6px; | ||
height: 6px; | ||
border-radius: 3px; | ||
} | ||
img{ | ||
width: 18px; | ||
height: 18px; | ||
} | ||
} | ||
>div{ | ||
float:left; | ||
} | ||
} | ||
} | ||
.right_menu_windows_line{ | ||
border-bottom: 1px solid #929292; | ||
} | ||
} | ||
} | ||
|
||
.right_menu_windows{ | ||
z-index: 1000; | ||
position: absolute; | ||
-webkit-font-smoothing: antialiased; | ||
background-color: #F2F2F2; | ||
color:$color; | ||
.next-menu{ | ||
.next-menu-item{ | ||
@include item; | ||
} | ||
} | ||
} | ||
.right_menu_windows_sub_nav{ | ||
-webkit-font-smoothing: antialiased; | ||
@include item; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import store from "../store" | ||
import {actionCreators as homeActionCreators} from "../pages/Home/store"; | ||
import {actionCreators as mainActionCreators} from "../store/main"; | ||
|
||
/* | ||
* 打开窗口的处理方法 | ||
*/ | ||
export const openWindow = (type,value) => { | ||
if(type==='openDesktopSet'){ | ||
const openWindowList = store.getState().toJS().homeWindows.openWindowList | ||
const data = value | ||
console.log(data) | ||
data.url += '/'+ store.getState().toJS().homeWindows.background.type | ||
store.dispatch(mainActionCreators.set_context_menu_box([],false,null)) //关闭右键菜单 | ||
store.dispatch(homeActionCreators.setWindowOpenList(data,openWindowList)) //打开窗口 | ||
} | ||
} | ||
|
||
/* | ||
* 关闭右键菜单 | ||
*/ | ||
export const closeContextMenu = () => { | ||
if(store.getState().toJS().mainWindows.isOpenContextMenu && !store.getState().toJS().mainWindows.isEnterContextMenu){ | ||
store.dispatch(mainActionCreators.set_context_menu_box([],false,null)) | ||
} | ||
} | ||
|
||
/* | ||
* 刷新功能 | ||
*/ | ||
export const refreshCurrentPage = () => { | ||
window.location.reload() | ||
// this.forceUpdate() | ||
} |
Oops, something went wrong.