Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
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
杨昕
media-resource
Commits
02940855
Commit
02940855
authored
Feb 01, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
控制用户权限
parent
069ed4f3
Pipeline
#13693
passed with stages
in 40 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
10 deletions
+70
-10
functions.php
app/Helpers/functions.php
+25
-0
ModuleModel.php
app/Model/ModuleModel.php
+31
-0
toast.js
public/xadmin/extra/toast/js/toast.js
+1
-1
commonMedia.blade.php
resources/views/admin/common/commonMedia.blade.php
+1
-1
media_list.blade.php
resources/views/admin/media/media_list.blade.php
+12
-8
No files found.
app/Helpers/functions.php
View file @
02940855
...
...
@@ -258,6 +258,31 @@ function getAdmin(){
return
$user
;
}
/**
* 控制页面显示
* @param string $keyName
* @param string $subKey
* @return bool
*/
function
permissionExist
(
$keyName
=
"manager_media"
,
$subKey
=
"media_model_list"
){
$user
=
\Illuminate\Support\Facades\Auth
::
user
();
$permissions
=
$user
->
permission
;
if
(
$user
->
name
==
'offcn'
){
return
true
;
}
foreach
(
$permissions
as
$key
=>
$val
)
{
if
(
$val
[
'key_name'
]
===
$keyName
)
{
$flag
=
array_search
(
$subKey
,
array_column
(
$val
[
'son'
],
'key_name'
));
if
(
$flag
!==
false
){
return
true
;
}
return
false
;
}
}
return
false
;
}
function
parse_custom_str
(
$str
,
$handle
=
'/'
)
{
$str
=
substr
(
$str
,
strpos
(
$str
,
$handle
)
+
1
);
...
...
app/Model/ModuleModel.php
View file @
02940855
...
...
@@ -15,9 +15,40 @@ class ModuleModel extends Eloquent
if
(
$user
[
'name'
]
==
'offcn'
){
$module
=
file_get_contents
(
public_path
(
'module.json'
));
}
else
{
if
(
$user
[
'media_show'
]){
$module
=
file_get_contents
(
public_path
(
'sub_admin.json'
));
}
else
{
$module
=
file_get_contents
(
public_path
(
'media_category.json'
));
}
$tmp
=
json_decode
(
$module
,
true
);
$result
=
[];
/**
* 控制大类显示
*/
foreach
(
$tmp
as
$key
=>
&
$value
){
if
(
$value
[
'show'
]
){
/**
* 控制子类显示
*/
$res
=
[];
foreach
(
$value
[
'son'
]
as
$item
){
if
(
$item
[
'have'
]){
$res
[]
=
$item
;
}
}
$value
[
'son'
]
=
$res
;
$result
[]
=
$value
;
}
}
if
(
Auth
::
user
()){
Auth
::
user
()
->
permission
=
$result
;
}
$module
=
json_encode
(
$result
);
}
return
json_decode
(
$module
,
true
);
}
...
...
public/xadmin/extra/toast/js/toast.js
View file @
02940855
...
...
@@ -20,7 +20,7 @@
}
}
// loadStyles(baseurl+
"/xadmin/extra/toast/css/animate.css");
loadStyles
(
"/xadmin/extra/toast/css/animate.css"
);
//显示提示信息 toast
$
.
fn
.
toast
=
function
(
options
){
...
...
resources/views/admin/common/commonMedia.blade.php
View file @
02940855
...
...
@@ -6,7 +6,7 @@
<meta
name=
"robots"
content=
"all,follow"
>
<title>
后台管理系统
</title>
<link
rel=
"shortcut icon"
href=
"img/test.ico"
>
<link
rel=
"shortcut icon"
>
<script
src=
"{{ asset('xadmin/js/jquery.min.js')}}"
></script>
<script
src=
"{{ asset('xadmin/js/jquery.cookie.js')}}"
></script>
...
...
resources/views/admin/media/media_list.blade.php
View file @
02940855
...
...
@@ -31,11 +31,11 @@
<!--***** CONTENT *****-->
<div
class=
"row ml20"
>
<div
class=
"xblock"
>
@if(permissionExist("manager_media","media_create"))
<button
class=
"btn btn-primary"
onclick=
"x_admin_show('/web/media_model/create')"
>
添加
</button>
@endif
<form>
<input
type=
"text"
name=
"media_name"
class=
"form-input"
placeholder=
"请输入媒资名称"
value=
"{{$media_name}}"
autocomplete=
"off"
>
<input
type=
"text"
name=
"username"
class=
"form-input"
placeholder=
"请输入创建人"
value=
"{{$username}}"
autocomplete=
"off"
>
...
...
@@ -74,17 +74,26 @@
<td
style=
"max-width: 100px;"
>
{{$media['create_time']}}
</td>
<td
class=
"td-manage"
>
@if(permissionExist("manager_media","media_edit"))
<a
title=
"编辑"
href=
"/web/media_model/{{$media['_id']}}/edit"
>
<i
class=
"iconfont"
>

</i>
</a>
@endif
{{--
<a
onclick=
"x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)"
title=
"修改密码"
--
}}
{{
--href=
"javascript:;"
>
--}}
{{--
<i
class=
"iconfont"
>

</i>
--}}
{{--
</a>
--}}
@if(permissionExist("manager_media","media_model_destroy"))
<a
title=
"删除"
onclick=
"member_del(this,'{{$media["
_id
"]}}')"
href=
"javascript:;"
>
<i
class=
"iconfont"
>

</i>
</a>
@endif
<a
title=
"生成"
onclick=
"member_del(this,'{{$media["
_id
"]}}')"
href=
"javascript:;"
>
<i
class=
"iconfont"
>

</i>
</a>
</td>
</tr>
@endforeach
...
...
@@ -130,17 +139,13 @@
function
member_del
(
row
,
id
){
$
.
confirm
({
// confirmButtonClass: 'btn-info',
// cancelButtonClass: 'btn-info',
cancelButtonClass
:
'btn-info'
,
confirmButtonClass
:
'btn-danger'
,
content
:
'确认要刪除吗?'
,
confirmButton
:
'确认'
,
cancelButton
:
'取消'
,
confirm
:
function
()
{
fetch_response
(
'DELETE'
,
"/web/media_model/"
+
id
).
then
(
function
(
res
)
{
if
(
res
.
code
==
200
)
{
...
...
@@ -162,7 +167,6 @@
});
}
})
},
cancel
:
function
()
{
$
(
'body'
).
toast
({
...
...
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