Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
b417470e
Commit
b417470e
authored
Jun 26, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis cache&menu fixed
parent
8466f078
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
35 deletions
+35
-35
MenuController.php
backend/controllers/MenuController.php
+2
-1
_tree.php
backend/views/menu/_tree.php
+28
-27
main.php
common/config/main.php
+5
-7
No files found.
backend/controllers/MenuController.php
View file @
b417470e
...
@@ -134,7 +134,8 @@ class MenuController extends BaseController
...
@@ -134,7 +134,8 @@ class MenuController extends BaseController
$lists
=
Menu
::
find
()
->
orderBy
(
'sort asc'
)
->
where
([
'hide'
=>
0
])
->
asArray
()
->
all
();
$lists
=
Menu
::
find
()
->
orderBy
(
'sort asc'
)
->
where
([
'hide'
=>
0
])
->
asArray
()
->
all
();
$lists
=
ArrayHelper
::
list_to_tree
(
$lists
,
'id'
,
'pid'
);
$lists
=
ArrayHelper
::
list_to_tree
(
$lists
,
'id'
,
'pid'
);
$lists
=
ArrayHelper
::
jstree
(
$lists
);
$lists
=
ArrayHelper
::
jstree
(
$lists
);
echo
json_encode
(
$lists
);
Yii
::
$app
->
response
->
format
=
'json'
;
return
$lists
;
}
}
/**
/**
...
...
backend/views/menu/_tree.php
View file @
b417470e
...
@@ -3,46 +3,46 @@
...
@@ -3,46 +3,46 @@
\backend\assets\TreeAsset
::
register
(
$this
);
\backend\assets\TreeAsset
::
register
(
$this
);
?>
?>
<div
class=
"portlet light portlet-fit portlet-datatable bordered"
>
<div
class=
"portlet light portlet-fit portlet-datatable bordered"
>
<div
class=
"portlet-title"
>
<div
class=
"portlet-title"
>
<div
class=
"caption"
>
<div
class=
"caption"
>
<i
class=
"fa fa-tree font-dark-sunglo"
></i>
<i
class=
"fa fa-tree font-dark-sunglo"
></i>
<span
class=
"caption-subject font-dark sbold uppercase"
>
菜单树
</span>
<span
class=
"caption-subject font-dark sbold uppercase"
>
菜单树
</span>
</div>
<div
class=
"actions"
>
</div>
</div>
</div>
<div
class=
"actions"
>
<div
class=
"portlet-body"
>
<div
id=
"tree_3"
class=
"tree-demo"
style=
"min-width: 190px"
>
</div>
</div>
</div>
</div>
</div>
<div
class=
"portlet-body"
>
<div
id=
"tree_3"
class=
"tree-demo"
style=
"min-width: 190px"
>
</div>
<!-- 定义数据块 -->
</div>
</div>
<!-- 定义数据块 -->
<?php
$this
->
beginBlock
(
'test'
);
?>
<?php
$this
->
beginBlock
(
'test'
);
?>
jQuery(document).ready(function() {
jQuery(document).ready(function() {
$("#tree_3").jstree({
$("#tree_3").jstree({
"plugins" : [ "themes", "state", "types"],
"plugins" : [ "themes", "state", "types"],
"core" : {
"core" : {
'multiple' : false,
'multiple' : false,
'data': {
'data': {
"url" : "
<?=
yii\helpers\Url
::
toRoute
(
'/menu/tree'
);
?>
",
"url" : "
<?=
yii\helpers\Url
::
toRoute
(
'/menu/tree'
);
?>
",
"dataType" : "json"
"dataType" : "json"
},
},
},
},
"state" : { "key" : "demo2" },
"state" : { "key" : "demo2" },
});
});
$("#tree_3").on('activate_node.jstree', function(e, data){
$("#tree_3").on('activate_node.jstree', function(e, data){
var currentNode = data.node;
var currentNode = data.node;
console.log(currentNode);
console.log(currentNode);
});
});
});
});
<?php
$this
->
endBlock
()
?>
<?php
$this
->
endBlock
()
?>
<!-- 将数据块 注入到视图中的某个位置 -->
<!-- 将数据块 注入到视图中的某个位置 -->
<?php
$this
->
registerJs
(
$this
->
blocks
[
'test'
],
\yii\web\View
::
POS_END
);
?>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'test'
],
\yii\web\View
::
POS_END
);
?>
\ No newline at end of file
common/config/main.php
View file @
b417470e
...
@@ -70,14 +70,12 @@ return [
...
@@ -70,14 +70,12 @@ return [
],
],
],
],
'cache'
=>
[
'cache'
=>
[
'class'
=>
'yii\caching\FileCache'
,
'class'
=>
'yii\redis\Cache'
,
'redis'
=>
[
'hostname'
=>
'localhost'
,
'port'
=>
6379
,
],
],
],
// 'cache' => [
// 'class' => 'yii\redis\Connection',
// 'hostname' => 'localhost',
// 'port' => 6379,
// 'database' => 0,
// ],
'i18n'
=>
[
'i18n'
=>
[
'translations'
=>
[
'translations'
=>
[
'*'
=>
[
'*'
=>
[
...
...
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