Skip to content

Commit 0230206

Browse files
committed
【Doe_V1.1.0】 修改左边菜单加载方式
1 parent 7fabad5 commit 0230206

File tree

12 files changed

+46
-29
lines changed

12 files changed

+46
-29
lines changed

mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/HomeController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ public class HomeController {
2929
@RequestMapping("/index")
3030
public String index(Model model) {
3131

32-
model.addAttribute("mid", "f16001000");
33-
34-
return "/pages/v3/easyCnt.html";
32+
// open easyCnt page defaultly.
33+
return index("f16001100", model);
3534
}
3635

3736
@RequestMapping("/main")
3837
public String index(String mid, Model model) {
38+
3939
// you can do something here, such as auth validation,,,
4040
Integer menuId = Integer.valueOf(mid.substring(1));
4141
String path = menuService.getUrl(menuId);
42+
String menuHtml = menuService.getHtml();
4243

4344
model.addAttribute("mid", mid);
45+
model.addAttribute("menuHtml", menuHtml);
4446

4547
return path;
4648

mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/MenuService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ public interface MenuService {
2222
* @return the menu mrl
2323
*/
2424
String getUrl(Integer mid);
25+
26+
/**
27+
* get the menu text.
28+
* @return
29+
*/
30+
String getHtml();
2531
}

mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/MenuServiceImpl.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ public class MenuServiceImpl implements MenuService {
5050
* cache urls.
5151
*/
5252
private Map<Integer, String> cacheMap;
53+
/**
54+
* the html text.
55+
*/
56+
private String html;
57+
58+
@Override
59+
public String getHtml() {
60+
return html;
61+
}
5362

5463
@Override
5564
public String getUrl(Integer mid) {
@@ -80,6 +89,7 @@ private void createFile() throws IOException {
8089
root = buildTree(tree, -1);
8190
} catch (Exception e) {
8291
log.error("fail to build the menu tree:", e);
92+
return;
8393
}
8494
String html = toHtml("", root);
8595
String projectRealPath = getProjectRealPath();
@@ -94,7 +104,9 @@ private void createFile() throws IOException {
94104

95105
private String getProjectRealPath() throws FileNotFoundException {
96106

97-
String path = ResourceUtils.getURL("classpath:").getPath();
107+
// useless when you run doe in the jar way, so comment these code.
108+
// String path = ResourceUtils.getURL("classpath:").getPath();
109+
String path = "/app/doe/";
98110
path = path + STATIC_MENU_PATH;
99111
return path;
100112
}
@@ -116,7 +128,7 @@ private void createFile(String projectRealPath, String html) throws Exception {
116128
// 写入权限菜单
117129
PrintWriter out = new PrintWriter(file);
118130
String content = ""
119-
+ "<div th:fragment=\"lefter\" xmlns:th=\"http://www.thymeleaf.org\">"
131+
// + "<div th:fragment=\"lefter\" xmlns:th=\"http://www.thymeleaf.org\">"
120132
+ "\n<div class=\"sidebar\" id=\"sidebar\" > \n"
121133
+ "\n <script type=\"text/javascript\"> \n"
122134
+ "\n try{ace.settings.check('sidebar' , 'fixed')}catch(e){} \n"
@@ -132,9 +144,10 @@ private void createFile(String projectRealPath, String html) throws Exception {
132144
+ "\n <script type=\"text/javascript\"> \n"
133145
+ "\n try{ace.settings.check('sidebar' , 'collapsed')}catch(e){} \n"
134146
+ "\n </script> \n"
135-
+ "\n</div>"
147+
// + "\n</div>"
136148
+ "</div>";
137149

150+
this.html = content;
138151
out.append(content);
139152
out.flush();
140153
out.close();

mmc-dubbo-doe/src/main/resources/application-prd.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@ spring:
1010
prefix: classpath:/templates
1111
suffix: .html
1212
redis:
13-
# 数据库索引
14-
database: 0
15-
host: 10.204.52.155
16-
port: 8080
17-
password: K6CJDjjnE9d0OxRjYNKZ
18-
jedis:
19-
pool:
20-
# 最大连接数
21-
max-active: 8
22-
# 最大空闲
23-
max-idle: 8
24-
# 最小空闲
25-
min-idle: 4
26-
# 连接超时时间
27-
timeout: 10000
13+
cluster:
14+
nodes: 10.204.58.11:8080,10.204.58.12:8080,10.204.58.13:8080,10.204.58.14:8080,10.204.58.15:8080,10.204.58.16:8080
15+
password: K6CJDjjnE9d0OxRjYNKZ
16+
pool:
17+
max-active: 8
18+
max-idle: 8
19+
max-wait: -1
20+
min-idle: 4
21+
timeout: 10000
2822

2923
# ====================doe====================
3024
doe:

mmc-dubbo-doe/src/main/resources/templates/pages/v3/addJar.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
<div class="main-container-inner">
2424

25-
<div th:replace="/pages/v3/menu::lefter"></div>
25+
<!-- useless when you run doe in the jar way, so comment these code. -->
26+
<!--<div th:replace="/pages/v3/menu::lefter"></div>-->
27+
<div th:utext="${menuHtml}"></div>
2628

2729
<div class="main-content">
2830
<div th:replace="/pages/tpl/bread::breader"></div>

mmc-dubbo-doe/src/main/resources/templates/pages/v3/caseCnt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<div class="main-container-inner">
2424

25-
<div th:replace="/pages/v3/menu::lefter"></div>
25+
<div th:utext="${menuHtml}"></div>
2626

2727
<div class="main-content">
2828
<div th:replace="/pages/tpl/bread::breader"></div>

mmc-dubbo-doe/src/main/resources/templates/pages/v3/easyCnt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<div class="main-container-inner">
2424

25-
<div th:replace="/pages/v3/menu::lefter"></div>
25+
<div th:utext="${menuHtml}"></div>
2626

2727
<div class="main-content">
2828
<div th:replace="/pages/tpl/bread::breader"></div>

mmc-dubbo-doe/src/main/resources/templates/pages/v3/editPom.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<div class="main-container-inner">
2424

25-
<div th:replace="/pages/v3/menu::lefter"></div>
25+
<div th:utext="${menuHtml}"></div>
2626

2727
<div class="main-content">
2828
<div th:replace="/pages/tpl/bread::breader"></div>

mmc-dubbo-doe/src/main/resources/templates/pages/v3/listJar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<div class="main-container-inner">
2727

28-
<div th:replace="/pages/v3/menu::lefter"></div>
28+
<div th:utext="${menuHtml}"></div>
2929

3030
<div class="main-content">
3131
<div th:replace="/pages/tpl/bread::breader"></div>

mmc-dubbo-doe/src/main/resources/templates/pages/v3/listZk.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<div class="main-container-inner">
2727

28-
<div th:replace="/pages/v3/menu::lefter"></div>
28+
<div th:utext="${menuHtml}"></div>
2929

3030
<div class="main-content">
3131
<div th:replace="/pages/tpl/bread::breader"></div>

0 commit comments

Comments
 (0)