Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianzhuanghu
ant-design-pro-vue
Commits
de7c4ca0
Unverified
Commit
de7c4ca0
authored
Dec 29, 2018
by
Anan Yang
Committed by
GitHub
Dec 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #36 from sendya/dev
feat: sp tablet
parents
88d83e56
abbfb429
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
72 deletions
+94
-72
README.md
README.md
+1
-1
App.vue
src/App.vue
+22
-18
GlobalLayout.vue
src/components/page/GlobalLayout.vue
+22
-19
main.js
src/main.js
+3
-1
app.js
src/store/modules/app.js
+9
-11
device.js
src/utils/device.js
+27
-16
permission.js
src/utils/helper/permission.js
+1
-1
mixin.js
src/utils/mixin.js
+9
-5
No files found.
README.md
View file @
de7c4ca0
...
@@ -89,7 +89,7 @@ yarn run lint
...
@@ -89,7 +89,7 @@ yarn run lint
其他说明
其他说明
----
----
-
**关于 Issue 反馈 (重要!重要!重要!) 请在开 *Issue* 时,描述清楚您的使用环境,所使用 Pro 版本或分支,出现的情况等...**
另外,若有疑问也可加入 QQ群 (Ant Design Vue 原作者使用讨论群 217490093),本项目的几位维护者也在该群
-
**关于 Issue 反馈 (重要!重要!重要!) 请在开 *Issue* 时,描述清楚您的使用环境,所使用 Pro 版本或分支,出现的情况等...**
另外,若有疑问也可加入 QQ群 (Ant Design Vue 原作者使用讨论群 217490093
,
**非 Pro 群**
),本项目的几位维护者也在该群
-
项目使用的
[
vue-cli3
](
https://cli.vuejs.org/guide/
)
, 请更新您的 cli
-
项目使用的
[
vue-cli3
](
https://cli.vuejs.org/guide/
)
, 请更新您的 cli
...
...
src/App.vue
View file @
de7c4ca0
...
@@ -5,9 +5,10 @@
...
@@ -5,9 +5,10 @@
</div>
</div>
</a-locale-provider>
</a-locale-provider>
</
template
>
</
template
>
<
script
>
<
script
>
import
zhCN
from
'ant-design-vue/lib/locale-provider/zh_CN'
import
zhCN
from
'ant-design-vue/lib/locale-provider/zh_CN'
import
enquireScreen
from
'@/utils/device'
import
{
deviceEnquire
,
DEVICE_TYPE
}
from
'@/utils/device'
import
{
version
}
from
'ant-design-vue'
import
{
version
}
from
'ant-design-vue'
export
default
{
export
default
{
...
@@ -17,25 +18,28 @@
...
@@ -17,25 +18,28 @@
version
version
}
}
},
},
crea
ted
()
{
moun
ted
()
{
const
that
=
this
const
{
$store
}
=
this
console
.
log
(
'use Ant-Design Of Vue:'
,
version
)
console
.
log
(
'use Ant-Design Of Vue:'
,
version
)
enquireScreen
(
deviceType
=>
{
deviceEnquire
(
deviceType
=>
{
// tablet
if
(
deviceType
===
0
)
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'mobile'
)
that
.
$store
.
dispatch
(
'setSidebar'
,
false
)
}
// mobile
else
if
(
deviceType
===
1
)
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'mobile'
)
that
.
$store
.
dispatch
(
'setSidebar'
,
false
)
}
else
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'desktop'
)
that
.
$store
.
dispatch
(
'setSidebar'
,
true
)
}
switch
(
deviceType
)
{
case
DEVICE_TYPE
.
DESKTOP
:
$store
.
commit
(
'TOGGLE_DEVICE'
,
'desktop'
)
$store
.
dispatch
(
'setSidebar'
,
true
)
break
case
DEVICE_TYPE
.
TABLET
:
console
.
log
(
'tablet'
)
$store
.
dispatch
(
'ToggleDevice'
,
'tablet'
)
$store
.
dispatch
(
'setSidebar'
,
false
)
break
case
DEVICE_TYPE
.
MOBILE
:
default
:
$store
.
commit
(
'TOGGLE_DEVICE'
,
'mobile'
)
$store
.
dispatch
(
'setSidebar'
,
false
)
break
}
console
.
log
(
'deviceType'
,
deviceType
)
})
})
}
}
}
}
...
...
src/components/page/GlobalLayout.vue
View file @
de7c4ca0
<
template
>
<
template
>
<a-layout
class=
"layout"
:class=
"[device]"
>
<a-layout
class=
"layout"
:class=
"[device]"
>
<template
v-if=
"
layoutMode === 'sidemenu'
"
>
<template
v-if=
"
isSideMenu()
"
>
<a-drawer
<a-drawer
v-if=
"
device === 'mobile'
"
v-if=
"
isMobile()
"
:wrapClassName=
"'drawer-sider ' + navTheme"
:wrapClassName=
"'drawer-sider ' + navTheme"
placement=
"left"
@
close=
"() => this.collapsed = false"
:closable=
"false"
:closable=
"false"
:visible=
"collapsed"
:visible=
"collapsed"
placement=
"left"
@
close=
"() => this.collapsed = false"
>
>
<side-menu
<side-menu
mode=
"inline"
:menus=
"menus"
:menus=
"menus"
@
menuSelect=
"menuSelect"
:theme=
"navTheme"
:theme=
"navTheme"
:collapsed=
"false"
:collapsed=
"false"
:collapsible=
"true"
></side-menu>
:collapsible=
"true"
mode=
"inline"
@
menuSelect=
"menuSelect"
></side-menu>
</a-drawer>
</a-drawer>
<side-menu
<side-menu
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
<!-- 下次优化这些代码 -->
<!-- 下次优化这些代码 -->
<
template
v-else
>
<
template
v-else
>
<a-drawer
<a-drawer
v-if=
"
device === 'mobile'
"
v-if=
"
isMobile()
"
:wrapClassName=
"'drawer-sider ' + navTheme"
:wrapClassName=
"'drawer-sider ' + navTheme"
placement=
"left"
placement=
"left"
@
close=
"() => this.collapsed = false"
@
close=
"() => this.collapsed = false"
...
@@ -38,23 +38,23 @@
...
@@ -38,23 +38,23 @@
:visible=
"collapsed"
:visible=
"collapsed"
>
>
<side-menu
<side-menu
mode=
"inline"
:menus=
"menus"
:menus=
"menus"
@
menuSelect=
"menuSelect"
:theme=
"navTheme"
:theme=
"navTheme"
:collapsed=
"false"
:collapsed=
"false"
:collapsible=
"true"
></side-menu>
:collapsible=
"true"
mode=
"inline"
@
menuSelect=
"menuSelect"
></side-menu>
</a-drawer>
</a-drawer>
</
template
>
</
template
>
<a-layout
:class=
"[layoutMode, `content-width-${contentWidth}`]"
:style=
"{ paddingLeft: fixSiderbar && isDesktop() ? `${sidebarOpened ? 256 : 80}px` : '0' }"
>
<a-layout
:class=
"[layoutMode, `content-width-${contentWidth}`]"
:style=
"{ paddingLeft: fixSiderbar && isDesktop() ? `${sidebarOpened ? 256 : 80}px` : '0' }"
>
<!-- layout header -->
<!-- layout header -->
<global-header
<global-header
:mode=
"layoutMode"
:mode=
"layoutMode"
:menus=
"menus"
:menus=
"menus"
:theme=
"navTheme"
:theme=
"navTheme"
:collapsed=
"collapsed"
:collapsed=
"collapsed"
:device=
"device"
:device=
"device"
@
toggle=
"toggle"
@
toggle=
"toggle"
/>
/>
...
@@ -104,11 +104,14 @@
...
@@ -104,11 +104,14 @@
},
},
watch
:
{
watch
:
{
sidebarOpened
(
val
)
{
sidebarOpened
(
val
)
{
console
.
log
(
'sidebarOpened'
,
val
)
this
.
collapsed
=
!
val
this
.
collapsed
=
!
val
},
},
},
},
created
()
{
created
()
{
this
.
menus
=
this
.
mainMenu
.
find
((
item
)
=>
item
.
path
===
'/'
).
children
this
.
menus
=
this
.
mainMenu
.
find
((
item
)
=>
item
.
path
===
'/'
).
children
console
.
log
(
'created/sidebarOpened'
,
this
.
sidebarOpened
)
this
.
collapsed
=
!
this
.
sidebarOpened
},
},
methods
:
{
methods
:
{
...
mapActions
([
'setSidebar'
]),
...
mapActions
([
'setSidebar'
]),
...
@@ -140,7 +143,7 @@
...
@@ -140,7 +143,7 @@
min-height
:
100vh
;
min-height
:
100vh
;
overflow-x
:
hidden
;
overflow-x
:
hidden
;
&.mobile
{
&.mobile
,&.tablet
{
.ant-layout-content
{
.ant-layout-content
{
...
@@ -301,7 +304,7 @@
...
@@ -301,7 +304,7 @@
}
}
}
}
&
.mobile
{
&
.mobile
,&
.tablet
{
.top-nav-header-index
{
.top-nav-header-index
{
.header-index-wide
{
.header-index-wide
{
...
...
src/main.js
View file @
de7c4ca0
...
@@ -40,7 +40,7 @@ Vue.use(PermissionHelper)
...
@@ -40,7 +40,7 @@ Vue.use(PermissionHelper)
new
Vue
({
new
Vue
({
router
,
router
,
store
,
store
,
moun
ted
()
{
crea
ted
()
{
store
.
commit
(
'SET_SIDEBAR_TYPE'
,
Vue
.
ls
.
get
(
SIDEBAR_TYPE
,
true
))
store
.
commit
(
'SET_SIDEBAR_TYPE'
,
Vue
.
ls
.
get
(
SIDEBAR_TYPE
,
true
))
store
.
commit
(
'TOGGLE_THEME'
,
Vue
.
ls
.
get
(
DEFAULT_THEME
,
config
.
navTheme
))
store
.
commit
(
'TOGGLE_THEME'
,
Vue
.
ls
.
get
(
DEFAULT_THEME
,
config
.
navTheme
))
store
.
commit
(
'TOGGLE_LAYOUT_MODE'
,
Vue
.
ls
.
get
(
DEFAULT_LAYOUT_MODE
,
config
.
layout
))
store
.
commit
(
'TOGGLE_LAYOUT_MODE'
,
Vue
.
ls
.
get
(
DEFAULT_LAYOUT_MODE
,
config
.
layout
))
...
@@ -52,6 +52,8 @@ new Vue({
...
@@ -52,6 +52,8 @@ new Vue({
store
.
commit
(
'TOGGLE_COLOR'
,
Vue
.
ls
.
get
(
DEFAULT_COLOR
,
config
.
primaryColor
))
store
.
commit
(
'TOGGLE_COLOR'
,
Vue
.
ls
.
get
(
DEFAULT_COLOR
,
config
.
primaryColor
))
store
.
commit
(
'SET_TOKEN'
,
Vue
.
ls
.
get
(
ACCESS_TOKEN
))
store
.
commit
(
'SET_TOKEN'
,
Vue
.
ls
.
get
(
ACCESS_TOKEN
))
console
.
log
(
'.... created ()'
)
removeLoadingAnimate
(
'preloadingWrapper'
)
removeLoadingAnimate
(
'preloadingWrapper'
)
},
},
render
:
h
=>
h
(
App
)
render
:
h
=>
h
(
App
)
...
...
src/store/modules/app.js
View file @
de7c4ca0
...
@@ -13,10 +13,7 @@ import {
...
@@ -13,10 +13,7 @@ import {
const
app
=
{
const
app
=
{
state
:
{
state
:
{
sidebar
:
{
sidebar
:
true
,
opened
:
true
,
withoutAnimation
:
false
},
device
:
'desktop'
,
device
:
'desktop'
,
theme
:
''
,
theme
:
''
,
layout
:
''
,
layout
:
''
,
...
@@ -29,13 +26,14 @@ const app = {
...
@@ -29,13 +26,14 @@ const app = {
},
},
mutations
:
{
mutations
:
{
SET_SIDEBAR_TYPE
:
(
state
,
type
)
=>
{
SET_SIDEBAR_TYPE
:
(
state
,
type
)
=>
{
state
.
sidebar
.
opened
=
type
state
.
sidebar
=
type
Vue
.
ls
.
set
(
SIDEBAR_TYPE
,
type
)
Vue
.
ls
.
set
(
SIDEBAR_TYPE
,
type
)
console
.
log
(
'SET_SIDEBAR_TYPE'
,
type
)
},
},
CLOSE_SIDEBAR
:
(
state
,
withoutAnimation
)
=>
{
CLOSE_SIDEBAR
:
(
state
)
=>
{
Vue
.
ls
.
set
(
SIDEBAR_TYPE
,
true
)
Vue
.
ls
.
set
(
SIDEBAR_TYPE
,
true
)
state
.
sidebar
.
opened
=
false
state
.
sidebar
=
false
state
.
sidebar
.
withoutAnimation
=
withoutAnimation
},
},
TOGGLE_DEVICE
:
(
state
,
device
)
=>
{
TOGGLE_DEVICE
:
(
state
,
device
)
=>
{
state
.
device
=
device
state
.
device
=
device
...
@@ -75,11 +73,11 @@ const app = {
...
@@ -75,11 +73,11 @@ const app = {
}
}
},
},
actions
:
{
actions
:
{
setSidebar
:
({
commit
},
type
)
=>
{
setSidebar
({
commit
},
type
)
{
commit
(
'SET_SIDEBAR_TYPE'
,
type
)
commit
(
'SET_SIDEBAR_TYPE'
,
type
)
},
},
CloseSidebar
({
commit
}
,
{
withoutAnimation
}
)
{
CloseSidebar
({
commit
})
{
commit
(
'CLOSE_SIDEBAR'
,
withoutAnimation
)
commit
(
'CLOSE_SIDEBAR'
)
},
},
ToggleDevice
({
commit
},
device
)
{
ToggleDevice
({
commit
},
device
)
{
commit
(
'TOGGLE_DEVICE'
,
device
)
commit
(
'TOGGLE_DEVICE'
,
device
)
...
...
src/utils/device.js
View file @
de7c4ca0
import
enquireJs
from
'enquire.js'
import
enquireJs
from
'enquire.js'
const
enquireScreen
=
function
(
call
)
{
export
const
DEVICE_TYPE
=
{
// tablet
DESKTOP
:
'desktop'
,
const
handler
=
{
TABLET
:
'tablet'
,
match
:
function
()
{
MOBILE
:
'mobile'
,
call
&&
call
(
0
)
}
},
unmatch
:
function
()
{
export
const
deviceEnquire
=
function
(
callback
)
{
call
&&
call
(
-
1
)
const
matchDesktop
=
{
match
:
()
=>
{
callback
&&
callback
(
DEVICE_TYPE
.
DESKTOP
)
}
}
const
matchLablet
=
{
match
:
()
=>
{
callback
&&
callback
(
DEVICE_TYPE
.
TABLET
)
}
}
}
}
// mobile
const
handler2
=
{
const
matchMobile
=
{
match
:
()
=>
{
match
:
()
=>
{
call
&&
call
(
1
)
call
back
&&
callback
(
DEVICE_TYPE
.
MOBILE
)
}
}
}
}
enquireJs
.
register
(
'screen and (max-width: 1087.99px)'
,
handler
)
enquireJs
.
register
(
'screen and (max-width: 767.99px)'
,
handler2
)
}
export
default
enquireScreen
// screen and (max-width: 1087.99px)
\ No newline at end of file
enquireJs
.
register
(
'screen and (max-width: 576px)'
,
matchMobile
)
.
register
(
'screen and (min-width: 576px) and (max-width: 1199px)'
,
matchLablet
)
.
register
(
'screen and (min-width: 1200px)'
,
matchDesktop
)
}
\ No newline at end of file
src/utils/helper/permission.js
View file @
de7c4ca0
...
@@ -7,7 +7,7 @@ const PERMISSION_ENUM = {
...
@@ -7,7 +7,7 @@ const PERMISSION_ENUM = {
'enable'
:
{
key
:
'enable'
,
label
:
'启用'
},
'enable'
:
{
key
:
'enable'
,
label
:
'启用'
},
'disable'
:
{
key
:
'disable'
,
label
:
'禁用'
},
'disable'
:
{
key
:
'disable'
,
label
:
'禁用'
},
'import'
:
{
key
:
'import'
,
label
:
'导入'
},
'import'
:
{
key
:
'import'
,
label
:
'导入'
},
'export'
:
{
key
:
'
import'
,
label
:
'导入
'
},
'export'
:
{
key
:
'
export'
,
label
:
'导出
'
},
}
}
function
plugin
(
Vue
)
{
function
plugin
(
Vue
)
{
...
...
src/utils/mixin.js
View file @
de7c4ca0
// import Vue from 'vue'
// import Vue from 'vue'
import
{
DEVICE_TYPE
}
from
'@/utils/device'
import
{
mapState
}
from
'vuex'
import
{
mapState
}
from
'vuex'
// const mixinsComputed = Vue.config.optionMergeStrategies.computed
// const mixinsComputed = Vue.config.optionMergeStrategies.computed
...
@@ -15,15 +16,15 @@ const mixin = {
...
@@ -15,15 +16,15 @@ const mixin = {
fixSiderbar
:
state
=>
state
.
app
.
fixSiderbar
,
fixSiderbar
:
state
=>
state
.
app
.
fixSiderbar
,
contentWidth
:
state
=>
state
.
app
.
contentWidth
,
contentWidth
:
state
=>
state
.
app
.
contentWidth
,
autoHideHeader
:
state
=>
state
.
app
.
autoHideHeader
,
autoHideHeader
:
state
=>
state
.
app
.
autoHideHeader
,
sidebarOpened
:
state
=>
state
.
app
.
sidebar
.
opened
sidebarOpened
:
state
=>
state
.
app
.
sidebar
})
})
},
},
methods
:
{
methods
:
{
isTop
m
enu
()
{
isTop
M
enu
()
{
return
this
.
layoutMode
===
'topmenu'
return
this
.
layoutMode
===
'topmenu'
},
},
isSideMenu
()
{
isSideMenu
()
{
return
!
this
.
isTop
m
enu
()
return
!
this
.
isTop
M
enu
()
}
}
}
}
}
}
...
@@ -36,10 +37,13 @@ const mixinDevice = {
...
@@ -36,10 +37,13 @@ const mixinDevice = {
},
},
methods
:
{
methods
:
{
isMobile
()
{
isMobile
()
{
return
this
.
device
===
'mobile'
return
this
.
device
===
DEVICE_TYPE
.
MOBILE
},
},
isDesktop
()
{
isDesktop
()
{
return
this
.
device
===
'desktop'
return
this
.
device
===
DEVICE_TYPE
.
DESKTOP
},
isTablet
()
{
return
this
.
device
===
DEVICE_TYPE
.
TABLET
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment