Commit d8d8969c0ef159fe6f8a6bb93928e7233cbe6046

Authored by 潘钊
1 parent fda87554

集成 angularjs

src/main/java/com/bsth/entity/sys/Module.java
... ... @@ -35,6 +35,9 @@ public class Module {
35 35  
36 36 private String icon;
37 37  
  38 + //页面容器
  39 + private String container;
  40 +
38 41 /**
39 42 * 1:组
40 43 * 2:目录
... ... @@ -152,4 +155,12 @@ public class Module {
152 155 // TODO Auto-generated method stub
153 156 return this.id.equals(((Module)obj).getId());
154 157 }
  158 +
  159 + public String getContainer() {
  160 + return container;
  161 + }
  162 +
  163 + public void setContainer(String container) {
  164 + this.container = container;
  165 + }
155 166 }
... ...
src/main/java/com/bsth/filter/ResourceFilter.java
... ... @@ -42,7 +42,7 @@ public class ResourceFilter extends BaseFilter {
42 42 File f = new File(fPath);
43 43  
44 44 if (f.exists() && f.isFile() ){
45   - response.sendRedirect("/#" + joinParam(request));
  45 + response.sendRedirect("/?_=" + joinParam(request));
46 46 }else
47 47 response.sendRedirect("/");
48 48 }
... ...
src/main/resources/static/index.html
... ... @@ -89,6 +89,10 @@ tr.row-active td {
89 89 .mt-element-list .list-simple.mt-list-container ul > .mt-list-item {
90 90 padding: 3.3px 0;
91 91 }
  92 +
  93 +#route-container{
  94 + display: none;
  95 +}
92 96 </style>
93 97  
94 98 <!-- ocLazyLoading载入文件的位置 -->
... ... @@ -223,9 +227,15 @@ tr.row-active td {
223 227 <ul class="sub-menu">
224 228 {{each dir.children as module s}}
225 229 <li class="nav-item ">
226   - <a href="/pages/{{module.path}}" class="nav-link " data-pjax>
227   - <span class="title">{{module.name}}</span>
228   - </a>
  230 + {{if module.container=="pjax-container"}}
  231 + <a href="/pages/{{module.path}}" class="nav-link " data-pjax>
  232 + <span class="title">{{module.name}}</span>
  233 + </a>
  234 + {{else}}
  235 + <a href="{{module.path}}" class="nav-link " data-angularjs>
  236 + <span class="title">{{module.name}}</span>
  237 + </a>
  238 + {{/if}}
229 239 </li>
230 240 {{/each}}
231 241 </ul>
... ... @@ -233,25 +243,6 @@ tr.row-active td {
233 243 {{/each}}
234 244 {{/each}}
235 245  
236   -<li class="heading">
237   - <h3 class="uppercase">测试用例</h3>
238   -</li>
239   -<li class="nav-item">
240   - <a href="javascript:;" class="nav-link nav-toggle ">
241   - <i class="fa fa-cloud"></i>
242   - <span class="title">用例组1</span>
243   - <span class="arrow"></span>
244   - </a>
245   - <ul class="sub-menu">
246   - <li class="nav-item ">
247   - <a href="#/busConfig.html" class="nav-link ">
248   - <span class="title">用例1</span>
249   - </a>
250   - </li>
251   - </ul>
252   -</li>
253   -
254   -
255 246 </script>
256 247 <!--[if lt IE 9]>
257 248 <script src="assets/plugins/respond.min.js"></script>
... ... @@ -300,14 +291,13 @@ tr.row-active td {
300 291 <!-- 日期控件 -->
301 292 <script src="metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
302 293  
303   -<!-- 地图相关(地图JS现在在子页面引入有问题,先全部放在index) -->
  294 +<!-- 地图相关 -->
304 295 <!-- 百度 -->
305 296 <script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT" ></script>
306 297 <script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js" ></script>
307 298 <!-- 高德 -->
308 299 <script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script>
309 300  
310   -
311 301 <script src="assets/js/common.js"></script>
312 302 <!-- d3.js -->
313 303 <script src="http://apps.bdimg.com/libs/d3/3.4.8/d3.min.js"></script>
... ... @@ -329,18 +319,25 @@ tr.row-active td {
329 319 <script type="text/javascript">
330 320  
331 321 var dir = '/pages/';
332   -var pjaxContainer = '#pjax-container';
  322 +var pjaxContainer = '#pjax-container'
  323 + ,angJsContainer = '#route-container';
333 324  
334 325 $(function(){
335 326 //带 data-pjax 的链接由pjax加载
336 327 $(document).pjax('a[data-pjax]', pjaxContainer);
337 328  
338   - //左菜单点击事件
  329 + //pjax左菜单点击事件
339 330 $(document).on('click','#leftMenuSidebar a[data-pjax]', function(){
340 331 $('#leftMenuSidebar li.nav-item.active').removeClass('active');
341 332 $(this).parent().addClass('active');
342 333 });
343 334  
  335 + //angularjs左菜单点击事件
  336 + $(document).on('click','#leftMenuSidebar a[data-angularjs]', function(){
  337 + $('#leftMenuSidebar li.nav-item.active').removeClass('active');
  338 + $(this).parent().addClass('active');
  339 + });
  340 +
344 341 //加载左菜单栏
345 342 $get('/module/findByCurrentUser', null,
346 343 function(ms){
... ... @@ -351,15 +348,29 @@ $(function(){
351 348 var menuHtml = template('menu_list_temp', {list: treeArray});
352 349 $('#leftMenuSidebar').html(menuHtml);
353 350  
354   - // 检查Hash值
355   - var h = location.hash;
356   - if(h && h.indexOf(dir) != -1){
357   - var path = h.substring(1, h.length);
358   - loadPage(path);
359   - //选中对应菜单项
  351 + /*
  352 + * ----------- 检查URL ----------------
  353 + */
  354 + var p = $.url().param('_')
  355 + ,h = location.hash;
  356 + if(p && p.indexOf(dir) != -1){
  357 + showPjax();
  358 + //普通片段
  359 + loadPage(p);
  360 + //选中菜单
  361 + $.each($('#leftMenuSidebar a'), function(i, item){
  362 + if(urlPattern($(item).attr('href'), p)){
  363 + activeLeftMenu(item);
  364 + }
  365 + });
  366 + }
  367 + else if(h){
  368 + //angularjs片段
  369 + showAngJs();
  370 + //选中菜单
360 371 $.each($('#leftMenuSidebar a'), function(i, item){
361   - if(urlPattern($(item).attr('href'), path)){
362   - $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open');
  372 + if($(item).attr('href') == h){
  373 + activeLeftMenu(item);
363 374 }
364 375 });
365 376 }
... ... @@ -388,7 +399,20 @@ $(function(){
388 399 }
389 400 return r;
390 401 }
391   -
  402 +
  403 + function showPjax(){
  404 + $(angJsContainer).html('').hide();
  405 + $(pjaxContainer).show();
  406 + }
  407 +
  408 + function showAngJs(){
  409 + $(pjaxContainer).html('').hide();
  410 + $(angJsContainer).show();
  411 + }
  412 +
  413 + function activeLeftMenu(item){
  414 + $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open');
  415 + }
392 416 </script>
393 417 </body>
394 418 </html>
395 419 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/module/add_modal.html
... ... @@ -43,6 +43,15 @@
43 43 </div>
44 44 </div>
45 45 <div class="form-group">
  46 + <label class="col-md-3 control-label">片段渲染容器</label>
  47 + <div class="col-md-9">
  48 + <select class="form-control input-medium" name="container">
  49 + <option value="pjax-container">pjax-container</option>
  50 + <option value="route-container">route-container</option>
  51 + </select>
  52 + </div>
  53 + </div>
  54 + <div class="form-group">
46 55 <label class="col-md-3 control-label">映射地址</label>
47 56 <div class="col-md-9">
48 57 <input type="text" class="form-control input-medium"
... ...
src/main/resources/static/pages/permission/module/edit_modal.html
... ... @@ -45,6 +45,15 @@
45 45 </div>
46 46 </div>
47 47 <div class="form-group">
  48 + <label class="col-md-3 control-label">片段渲染容器</label>
  49 + <div class="col-md-9">
  50 + <select class="form-control input-medium" name="container">
  51 + <option value="pjax-container">pjax-container</option>
  52 + <option value="route-container">route-container</option>
  53 + </select>
  54 + </div>
  55 + </div>
  56 + <div class="form-group">
48 57 <label class="col-md-3 control-label">映射</label>
49 58 <div class="col-md-9">
50 59 <input type="text" class="form-control input-medium"
... ...