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
fb67e6e2
Commit
fb67e6e2
authored
Dec 14, 2018
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add action check
parent
e6cb6a1a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
main.js
src/main.js
+2
-0
permission.js
src/utils/helper/permission.js
+54
-0
TableList.vue
src/views/list/TableList.vue
+0
-0
No files found.
src/main.js
View file @
fb67e6e2
...
...
@@ -12,6 +12,7 @@ import 'ant-design-vue/dist/antd.less'; // or 'ant-design-vue/dist/antd.less'
import
'@/permission'
// permission control
import
'@/utils/filter'
// base filter
import
PermissionHelper
from
'@/utils/helper/permission'
import
{
ACCESS_TOKEN
,
...
...
@@ -33,6 +34,7 @@ Vue.use(Storage, config.storageOptions)
Vue
.
use
(
Antd
)
Vue
.
use
(
VueAxios
,
router
)
Vue
.
use
(
Viser
)
Vue
.
use
(
PermissionHelper
)
new
Vue
({
router
,
...
...
src/utils/helper/permission.js
0 → 100644
View file @
fb67e6e2
const
PERMISSION_ENUM
=
{
'add'
:
{
key
:
'add'
,
label
:
'新增'
},
'delete'
:
{
key
:
'delete'
,
label
:
'删除'
},
'edit'
:
{
key
:
'edit'
,
label
:
'修改'
},
'query'
:
{
key
:
'query'
,
label
:
'查询'
},
'get'
:
{
key
:
'get'
,
label
:
'详情'
},
'enable'
:
{
key
:
'enable'
,
label
:
'启用'
},
'disable'
:
{
key
:
'disable'
,
label
:
'禁用'
},
'import'
:
{
key
:
'import'
,
label
:
'导入'
},
'export'
:
{
key
:
'import'
,
label
:
'导入'
},
};
function
plugin
(
Vue
)
{
if
(
plugin
.
installed
)
{
return
;
}
!
Vue
.
prototype
.
$auth
&&
Object
.
defineProperties
(
Vue
.
prototype
,
{
$auth
:
{
get
()
{
const
_this
=
this
;
return
(
permissions
)
=>
{
let
[
permission
,
action
]
=
permissions
.
split
(
'.'
);
const
permissionList
=
_this
.
$store
.
getters
.
roles
.
permissions
;
permissionList
.
find
((
val
)
=>
{
return
val
.
permissionId
===
permission
}).
actionList
.
findIndex
((
val
)
=>
{
return
val
===
action
});
return
false
}
}
}
});
!
Vue
.
prototype
.
$enum
&&
Object
.
defineProperties
(
Vue
.
prototype
,
{
$enum
:
{
get
()
{
// const _this = this;
return
(
val
)
=>
{
let
result
=
PERMISSION_ENUM
;
val
&&
val
.
split
(
'.'
).
forEach
(
v
=>
{
result
=
result
&&
result
[
v
]
||
null
});
return
result
}
}
}
});
}
export
default
plugin
\ No newline at end of file
src/views/list/TableList.vue
View file @
fb67e6e2
This diff is collapsed.
Click to expand it.
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