Commit 69b92326dd319d214472b217c26eef018cfa1ac8
1 parent
f92b8717
解决pjax和angularJs的冲突
Showing
8 changed files
with
296 additions
and
193 deletions
src/main/java/com/bsth/StartCommand.java
| 1 | -package com.bsth; | |
| 2 | - | |
| 3 | - | |
| 4 | -import java.util.concurrent.Executors; | |
| 5 | -import java.util.concurrent.ScheduledExecutorService; | |
| 6 | -import java.util.concurrent.TimeUnit; | |
| 7 | - | |
| 8 | -import org.slf4j.Logger; | |
| 9 | -import org.slf4j.LoggerFactory; | |
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | -import org.springframework.boot.CommandLineRunner; | |
| 12 | -import org.springframework.stereotype.Component; | |
| 13 | - | |
| 14 | -import com.bsth.gpsdata.thread.GpsBufferRefreshThread; | |
| 15 | -import com.bsth.security.SecurityMetadataSourceService; | |
| 16 | - | |
| 17 | -/** | |
| 18 | - * 随应用启动运行 | |
| 19 | - * @author PanZhao | |
| 20 | - * | |
| 21 | - */ | |
| 22 | -@Component | |
| 23 | -public class StartCommand implements CommandLineRunner{ | |
| 24 | - | |
| 25 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 26 | - | |
| 27 | - @Autowired | |
| 28 | - SecurityMetadataSourceService invocationSecurityMetadataSourceService; | |
| 29 | - | |
| 30 | - public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - GpsBufferRefreshThread gpsRefreshThread; | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void run(String... arg0){ | |
| 37 | - | |
| 38 | - try { | |
| 39 | - //启动时加载所有资源 | |
| 40 | - invocationSecurityMetadataSourceService.loadResourceDefine(); | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 定时GPS实时数据更新线程,每次执行完成4秒后开始下一次 | |
| 44 | - * 如果抛出异常,后续执行将被取消 | |
| 45 | - */ | |
| 46 | - //scheduler.scheduleWithFixedDelay(gpsRefreshThread, 0, 4, TimeUnit.SECONDS); | |
| 47 | - } catch (Exception e) { | |
| 48 | - e.printStackTrace(); | |
| 49 | - } | |
| 50 | - } | |
| 51 | -} | |
| 1 | +package com.bsth; | |
| 2 | + | |
| 3 | + | |
| 4 | +import java.util.concurrent.Executors; | |
| 5 | +import java.util.concurrent.ScheduledExecutorService; | |
| 6 | + | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.boot.CommandLineRunner; | |
| 11 | +import org.springframework.stereotype.Component; | |
| 12 | + | |
| 13 | +import com.bsth.gpsdata.thread.GpsBufferRefreshThread; | |
| 14 | +import com.bsth.security.SecurityMetadataSourceService; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 随应用启动运行 | |
| 18 | + * @author PanZhao | |
| 19 | + * | |
| 20 | + */ | |
| 21 | +@Component | |
| 22 | +public class StartCommand implements CommandLineRunner{ | |
| 23 | + | |
| 24 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + SecurityMetadataSourceService invocationSecurityMetadataSourceService; | |
| 28 | + | |
| 29 | + public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); | |
| 30 | + | |
| 31 | + @Autowired | |
| 32 | + GpsBufferRefreshThread gpsRefreshThread; | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public void run(String... arg0){ | |
| 36 | + | |
| 37 | + try { | |
| 38 | + //启动时加载所有资源 | |
| 39 | + invocationSecurityMetadataSourceService.loadResourceDefine(); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 定时GPS实时数据更新线程,每次执行完成4秒后开始下一次 | |
| 43 | + * 如果抛出异常,后续执行将被取消 | |
| 44 | + */ | |
| 45 | + //scheduler.scheduleWithFixedDelay(gpsRefreshThread, 0, 4, TimeUnit.SECONDS); | |
| 46 | + } catch (Exception e) { | |
| 47 | + e.printStackTrace(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | +} | ... | ... |
src/main/java/com/bsth/controller/IndexController.java
0 → 100644
| 1 | +package com.bsth.controller; | |
| 2 | + | |
| 3 | +import java.io.BufferedInputStream; | |
| 4 | +import java.io.IOException; | |
| 5 | +import java.io.InputStream; | |
| 6 | + | |
| 7 | +import javax.servlet.http.HttpServletResponse; | |
| 8 | + | |
| 9 | +import org.apache.commons.lang3.StringUtils; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 13 | +import org.springframework.web.bind.annotation.RestController; | |
| 14 | + | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("/") | |
| 17 | +public class IndexController { | |
| 18 | + | |
| 19 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | + | |
| 21 | + String indexSource; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 构造函数 | |
| 25 | + */ | |
| 26 | + public IndexController() { | |
| 27 | + BufferedInputStream bis = null; | |
| 28 | + | |
| 29 | + try { | |
| 30 | + InputStream is = IndexController.class.getClassLoader().getResourceAsStream("static/index.html"); | |
| 31 | + bis = new BufferedInputStream(is); | |
| 32 | + StringBuilder source = new StringBuilder(); | |
| 33 | + byte[] buffer = new byte[bis.available()]; | |
| 34 | + | |
| 35 | + while (bis.read(buffer) != -1) { | |
| 36 | + source.append(new String(buffer)); | |
| 37 | + } | |
| 38 | + | |
| 39 | + indexSource = source.toString(); | |
| 40 | + } catch (Exception e) { | |
| 41 | + logger.error("", e); | |
| 42 | + } finally { | |
| 43 | + try { | |
| 44 | + bis.close(); | |
| 45 | + } catch (IOException e) { | |
| 46 | + logger.error("", e); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * | |
| 53 | + * @Title: index | |
| 54 | + * @Description: TODO(输出首页 index.html) | |
| 55 | + */ | |
| 56 | + @RequestMapping | |
| 57 | + public void index(String initFragment, HttpServletResponse resp) { | |
| 58 | + | |
| 59 | + // 初始打开的片段地址 | |
| 60 | + String outStr = StringUtils.replace(indexSource, "^_^initFragment^_^", | |
| 61 | + initFragment == null ? "" : initFragment); | |
| 62 | + | |
| 63 | + resp.setContentType("text/html;charset=UTF-8"); | |
| 64 | + try { | |
| 65 | + resp.getOutputStream().write(outStr.getBytes()); | |
| 66 | + } catch (IOException e) { | |
| 67 | + logger.error("", e); | |
| 68 | + } | |
| 69 | + | |
| 70 | + } | |
| 71 | +} | ... | ... |
src/main/java/com/bsth/filter/ResourceFilter.java
| ... | ... | @@ -41,8 +41,9 @@ public class ResourceFilter extends BaseFilter { |
| 41 | 41 | |
| 42 | 42 | File f = new File(fPath); |
| 43 | 43 | |
| 44 | + | |
| 44 | 45 | if (f.exists() && f.isFile() ){ |
| 45 | - response.sendRedirect("/?_=" + joinParam(request)); | |
| 46 | + request.getRequestDispatcher("/?initFragment=" + joinParam(request)).forward(request, response);; | |
| 46 | 47 | }else |
| 47 | 48 | response.sendRedirect("/"); |
| 48 | 49 | } | ... | ... |
src/main/resources/static/assets/bower_components/angular/angular.js
| ... | ... | @@ -5873,7 +5873,23 @@ function Browser(window, document, $log, $sniffer) { |
| 5873 | 5873 | // the new location.href if a reload happened or if there is a bug like in iOS 9 (see |
| 5874 | 5874 | // https://openradar.appspot.com/22186109). |
| 5875 | 5875 | // - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172 |
| 5876 | - return pendingLocation || location.href.replace(/%27/g,"'"); | |
| 5876 | + | |
| 5877 | + /** | |
| 5878 | + * 2016年05月18号 潘钊 | |
| 5879 | + * ######################### | |
| 5880 | + */ | |
| 5881 | + if(!pendingLocation){ | |
| 5882 | + var h = location.href; | |
| 5883 | + if(h.indexOf('pages') != -1 | |
| 5884 | + && location.hash == ''){ | |
| 5885 | + return h.substr(0, h.indexOf('pages')).replace(/%27/g,"'"); | |
| 5886 | + } | |
| 5887 | + } | |
| 5888 | + /** | |
| 5889 | + * ####################### | |
| 5890 | + */ | |
| 5891 | + | |
| 5892 | + return pendingLocation || location.href.replace(/%27/g,"'"); | |
| 5877 | 5893 | } |
| 5878 | 5894 | }; |
| 5879 | 5895 | |
| ... | ... | @@ -11714,7 +11730,7 @@ function trimEmptyHash(url) { |
| 11714 | 11730 | |
| 11715 | 11731 | |
| 11716 | 11732 | function stripFile(url) { |
| 11717 | - return url.substr(0, stripHash(url).lastIndexOf('/') + 1); | |
| 11733 | + return url.substr(0, stripHash(url).lastIndexOf('/') + 1); | |
| 11718 | 11734 | } |
| 11719 | 11735 | |
| 11720 | 11736 | /* return the server only (scheme://host:port) */ |
| ... | ... | @@ -12595,6 +12611,7 @@ function $LocationProvider() { |
| 12595 | 12611 | |
| 12596 | 12612 | $rootScope.$evalAsync(function() { |
| 12597 | 12613 | var newUrl = $location.absUrl(); |
| 12614 | + | |
| 12598 | 12615 | var defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl, |
| 12599 | 12616 | $location.$$state, oldState).defaultPrevented; |
| 12600 | 12617 | |
| ... | ... | @@ -12606,7 +12623,12 @@ function $LocationProvider() { |
| 12606 | 12623 | $location.$$parse(oldUrl); |
| 12607 | 12624 | $location.$$state = oldState; |
| 12608 | 12625 | } else { |
| 12609 | - if (urlOrStateChanged) { | |
| 12626 | + //if (urlOrStateChanged ) { | |
| 12627 | + /** | |
| 12628 | + * 2016年05月18 潘钊修改 | |
| 12629 | + * 忽略stste里携带pjax标记的 (!oldState || !oldState.pjax) | |
| 12630 | + */ | |
| 12631 | + if (urlOrStateChanged && (!oldState || !oldState.pjax)) { | |
| 12610 | 12632 | setBrowserUrlWithFallback(newUrl, currentReplace, |
| 12611 | 12633 | oldState === $location.$$state ? null : $location.$$state); |
| 12612 | 12634 | } | ... | ... |
src/main/resources/static/assets/plugins/jquery.pjax.js
| ... | ... | @@ -286,6 +286,11 @@ function pjax(options) { |
| 286 | 286 | container: context.selector, |
| 287 | 287 | fragment: options.fragment, |
| 288 | 288 | timeout: options.timeout |
| 289 | + /** | |
| 290 | + * 2016年05月18 潘钊修改 | |
| 291 | + * 添加一个pjax的标记,供angular.js路由判断 | |
| 292 | + */ | |
| 293 | + ,pjax: true | |
| 289 | 294 | } |
| 290 | 295 | |
| 291 | 296 | if (options.push || options.replace) { |
| ... | ... | @@ -364,6 +369,7 @@ function pjax(options) { |
| 364 | 369 | // Cache current container element before replacing it |
| 365 | 370 | cachePush(pjax.state.id, cloneContents(context)) |
| 366 | 371 | |
| 372 | + //window.history.pushState(null, "", options.requestUrl) | |
| 367 | 373 | window.history.pushState(null, "", options.requestUrl) |
| 368 | 374 | } |
| 369 | 375 | |
| ... | ... | @@ -421,6 +427,23 @@ if ('state' in window.history) { |
| 421 | 427 | // You probably shouldn't use pjax on pages with other pushState |
| 422 | 428 | // stuff yet. |
| 423 | 429 | function onPjaxPopstate(event) { |
| 430 | + debugger | |
| 431 | + | |
| 432 | +/** | |
| 433 | + * 2016年05月18 潘钊修改 | |
| 434 | + */ | |
| 435 | +if(document.location.hash){ | |
| 436 | + event.stopPropagation(); | |
| 437 | + | |
| 438 | + var oldUrl = $.url() | |
| 439 | + ,newUrl = oldUrl.attr('protocol') + '://' + oldUrl.attr('host') + ':' + oldUrl.attr('port'); | |
| 440 | + history.replaceState({}, document.title, newUrl + '/' + document.location.hash); | |
| 441 | + | |
| 442 | + return; | |
| 443 | +} | |
| 444 | +/** | |
| 445 | + * -----end------ | |
| 446 | + */ | |
| 424 | 447 | |
| 425 | 448 | // Hitting back or forward should override any pending PJAX request. |
| 426 | 449 | if (!initialPop) { |
| ... | ... | @@ -564,6 +587,15 @@ function cloneContents(container) { |
| 564 | 587 | var cloned = container.clone() |
| 565 | 588 | // Unmark script tags as already being eval'd so they can get executed again |
| 566 | 589 | // when restored from cache. HAXX: Uses jQuery internal method. |
| 590 | + /** | |
| 591 | + * 2016年05月19 潘钊修改 | |
| 592 | + * 在缓存里打一个标记 | |
| 593 | + * ################## | |
| 594 | + */ | |
| 595 | + cloned.append('<input type="hidden" id="historyCache" value="1"/>') | |
| 596 | + /** | |
| 597 | + * ################## | |
| 598 | + */ | |
| 567 | 599 | cloned.find('script').each(function(){ |
| 568 | 600 | if (!this.src) jQuery._data(this, 'globalEval', false) |
| 569 | 601 | }) | ... | ... |
src/main/resources/static/index.html
| ... | ... | @@ -6,29 +6,33 @@ |
| 6 | 6 | <meta name=”renderer” content=”webkit”> |
| 7 | 7 | <meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″ > |
| 8 | 8 | |
| 9 | +<meta http-equiv="Pragma" content="no-cache"> | |
| 10 | +<meta http-equiv="Cache-control" content="no-cache"> | |
| 11 | +<meta http-equiv="Cache" content="no-cache"> | |
| 12 | + | |
| 9 | 13 | <!-- Font Awesome 图标字体 --> |
| 10 | -<link href="metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> | |
| 14 | +<link href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> | |
| 11 | 15 | <!-- Bootstrap style --> |
| 12 | -<link href="metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| 16 | +<link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| 13 | 17 | <!-- jsTree 数插件 --> |
| 14 | -<link href="metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css" /> | |
| 15 | -<!-- multi-select 多选下拉框美化 --> | |
| 16 | -<link href="metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css" rel="stylesheet" type="text/css" /> | |
| 17 | -<!-- metronic style --> | |
| 18 | -<link href="metronic_v4.5.4/layout4/css/themes/default.min.css" rel="stylesheet" type="text/css" id="style_color" /> | |
| 19 | -<link href="metronic_v4.5.4/css/components.css" rel="stylesheet" type="text/css" /> | |
| 20 | -<link href="metronic_v4.5.4/css/plugins.css" rel="stylesheet" type="text/css" /> | |
| 21 | -<link href="metronic_v4.5.4/layout4/css/layout.min.css" rel="stylesheet" type="text/css" /> | |
| 22 | -<link href="metronic_v4.5.4/layout4/css/custom.min.css" rel="stylesheet" type="text/css" /> | |
| 18 | +<link href="/metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css" /> | |
| 19 | +<!-- MULTI-select 多选下拉框美化 --> | |
| 20 | +<link href="/metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css" rel="stylesheet" type="text/css" /> | |
| 21 | +<!-- METRONIC style --> | |
| 22 | +<link href="/metronic_v4.5.4/layout4/css/themes/default.min.css" rel="stylesheet" type="text/css" id="style_color" /> | |
| 23 | +<link href="/metronic_v4.5.4/css/components.css" rel="stylesheet" type="text/css" /> | |
| 24 | +<link href="/metronic_v4.5.4/css/plugins.css" rel="stylesheet" type="text/css" /> | |
| 25 | +<link href="/metronic_v4.5.4/layout4/css/layout.min.css" rel="stylesheet" type="text/css" /> | |
| 26 | +<link href="/metronic_v4.5.4/layout4/css/custom.min.css" rel="stylesheet" type="text/css" /> | |
| 23 | 27 | <!-- select2 下拉框插件 --> |
| 24 | -<link href="metronic_v4.5.4/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" /> | |
| 25 | -<link href="metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| 28 | +<link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" /> | |
| 29 | +<link href="/metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| 26 | 30 | <!-- layer 弹层 插件 --> |
| 27 | -<link href="assets/plugins/layer-v2.2/layer/skin/layer.css" rel="stylesheet" type="text/css" /> | |
| 31 | +<link href="/assets/plugins/layer-v2.2/layer/skin/layer.css" rel="stylesheet" type="text/css" /> | |
| 28 | 32 | <!-- iCheck 单选框和复选框 --> |
| 29 | -<link href="metronic_v4.5.4/plugins/icheck/skins/all.css" rel="stylesheet" type="text/css" /> | |
| 33 | +<link href="/metronic_v4.5.4/plugins/icheck/skins/all.css" rel="stylesheet" type="text/css" /> | |
| 30 | 34 | <!-- 日期控件 --> |
| 31 | -<link href="metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" /> | |
| 35 | +<link href="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" /> | |
| 32 | 36 | |
| 33 | 37 | <style type="text/css"> |
| 34 | 38 | .searchForm{ |
| ... | ... | @@ -137,33 +141,6 @@ tr.row-active td { |
| 137 | 141 | </li> |
| 138 | 142 | <li> |
| 139 | 143 | <ul class="dropdown-menu-list scroller" style="height: 250px;" data-handle-color="#637283"> |
| 140 | - <li> | |
| 141 | - <a href="javascript:;"> | |
| 142 | - <span class="time">现在</span> | |
| 143 | - <span class="details"> | |
| 144 | - <span class="label label-sm label-icon label-info"> </span> | |
| 145 | - W1B-020 成山路请求出场 | |
| 146 | - </span> | |
| 147 | - </a> | |
| 148 | - </li> | |
| 149 | - <li> | |
| 150 | - <a href="javascript:;"> | |
| 151 | - <span class="time">10分钟前</span> | |
| 152 | - <span class="details"> | |
| 153 | - <span class="label label-sm label-icon label-success"> </span> | |
| 154 | - W1B-375 速度正常,超速约10分钟 | |
| 155 | - </span> | |
| 156 | - </a> | |
| 157 | - </li> | |
| 158 | - <li> | |
| 159 | - <a href="javascript:;"> | |
| 160 | - <span class="time">20分钟前</span> | |
| 161 | - <span class="details"> | |
| 162 | - <span class="label label-sm label-icon label-danger"> </span> | |
| 163 | - W1B-375 超速警报 | |
| 164 | - </span> | |
| 165 | - </a> | |
| 166 | - </li> | |
| 167 | 144 | </ul> |
| 168 | 145 | </li> |
| 169 | 146 | </ul> |
| ... | ... | @@ -202,7 +179,7 @@ tr.row-active td { |
| 202 | 179 | </div> |
| 203 | 180 | <div class="page-content-wrapper"> |
| 204 | 181 | <div class="page-content"> |
| 205 | - <div id="pjax-container"></div> | |
| 182 | + <div id="pjax-container" ></div> | |
| 206 | 183 | <div id="route-container"> |
| 207 | 184 | <div ng-app="ScheduleApp"> |
| 208 | 185 | <div ng-controller="ScheduleAppController"> |
| ... | ... | @@ -211,8 +188,6 @@ tr.row-active td { |
| 211 | 188 | </div> |
| 212 | 189 | </div> |
| 213 | 190 | </div> |
| 214 | - | |
| 215 | - | |
| 216 | 191 | </div> |
| 217 | 192 | </div> |
| 218 | 193 | |
| ... | ... | @@ -249,80 +224,82 @@ tr.row-active td { |
| 249 | 224 | |
| 250 | 225 | </script> |
| 251 | 226 | <!--[if lt IE 9]> |
| 252 | -<script src="assets/plugins/respond.min.js"></script> | |
| 253 | -<script src="assets/plugins/excanvas.min.js"></script> | |
| 227 | +<script src="/assets/plugins/respond.min.js"></script> | |
| 228 | +<script src="/assets/plugins/excanvas.min.js"></script> | |
| 254 | 229 | <![endif]--> |
| 255 | -<!-- jquery --> | |
| 256 | -<script src="metronic_v4.5.4/plugins/jquery.min.js" ></script> | |
| 230 | +<!-- jQuery --> | |
| 231 | +<script src="/metronic_v4.5.4/plugins/jquery.min.js" ></script> | |
| 257 | 232 | <!-- bootstrap --> |
| 258 | -<script src="metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js" ></script> | |
| 259 | -<!-- metronic js --> | |
| 260 | -<script src="metronic_v4.5.4/scripts/app.min.js" ></script> | |
| 261 | -<script src="metronic_v4.5.4/layout4/scripts/layout.min.js" ></script> | |
| 233 | +<script src="/metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js" ></script> | |
| 234 | +<!-- MTRONIC JS --> | |
| 235 | +<script src="/metronic_v4.5.4/scripts/app.min.js" ></script> | |
| 236 | +<script src="/metronic_v4.5.4/layout4/scripts/layout.min.js" ></script> | |
| 262 | 237 | <!-- 虚拟滚动条 --> |
| 263 | -<script src="metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js" ></script> | |
| 238 | +<script src="/metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js" ></script> | |
| 264 | 239 | <!-- jsTree 树插件 --> |
| 265 | -<script src="metronic_v4.5.4/plugins/jstree/dist/jstree.min.js" ></script> | |
| 266 | -<!-- bootstrap-hover-dropdown --> | |
| 267 | -<script src="metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" ></script> | |
| 240 | +<script src="/metronic_v4.5.4/plugins/jstree/dist/jstree.min.js" ></script> | |
| 241 | +<!-- bootstrap-hover-dropDown --> | |
| 242 | +<script src="/metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" ></script> | |
| 268 | 243 | <!-- jquery.validate 表单验证 --> |
| 269 | -<script src="metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script> | |
| 270 | -<script src="metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script> | |
| 244 | +<script src="/metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script> | |
| 245 | +<script src="/metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script> | |
| 271 | 246 | <!-- 向导式插件 --> |
| 272 | -<script src="metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script> | |
| 247 | +<script src="/metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script> | |
| 273 | 248 | <!-- iCheck 单选框和复选框 --> |
| 274 | -<script src="metronic_v4.5.4/plugins/icheck/icheck.min.js" type="text/javascript"></script> | |
| 249 | +<script src="/metronic_v4.5.4/plugins/icheck/icheck.min.js" ></script> | |
| 275 | 250 | <!-- select2 下拉框 --> |
| 276 | -<script src="metronic_v4.5.4/plugins/select2/js/select2.full.min.js" type="text/javascript"></script> | |
| 277 | -<!-- multi-select 多选下拉框美化 --> | |
| 278 | -<script src="metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js" type="text/javascript"></script> | |
| 279 | -<!-- pjax --> | |
| 280 | -<script src="assets/plugins/jquery.pjax.js"></script> | |
| 251 | +<script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js" ></script> | |
| 252 | +<!-- MULTI SELECT 多选下拉框 --> | |
| 253 | +<script src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js" ></script> | |
| 254 | +<!-- PJAX --> | |
| 255 | +<script src="/assets/plugins/jquery.pjax.js"></script> | |
| 281 | 256 | <!-- layer 弹层 --> |
| 282 | -<script src="assets/plugins/layer-v2.2/layer/layer.js"></script> | |
| 283 | -<!-- jquery.purl url解析 --> | |
| 284 | -<script src="assets/plugins/purl.js"></script> | |
| 285 | -<!-- jquery.serializejson json序列化插件 --> | |
| 286 | -<script src="assets/plugins/jquery.serializejson.js"></script> | |
| 257 | +<script src="/assets/plugins/layer-v2.2/layer/layer.js"></script> | |
| 258 | +<!-- jquery.purl URL解析 --> | |
| 259 | +<script src="/assets/plugins/purl.js"></script> | |
| 260 | +<!-- jquery.serializejson JSON序列化插件 --> | |
| 261 | +<script src="/assets/plugins/jquery.serializejson.js"></script> | |
| 287 | 262 | <!-- art-template 模版引擎 --> |
| 288 | -<script src="assets/plugins/template.js"></script> | |
| 263 | +<script src="/assets/plugins/template.js"></script> | |
| 289 | 264 | <!-- jquery.pageinator 分页 --> |
| 290 | -<script src="assets/plugins/jqPaginator.min.js"></script> | |
| 265 | +<script src="/assets/plugins/jqPaginator.min.js"></script> | |
| 291 | 266 | <!-- moment.js 日期处理类库 --> |
| 292 | -<script src="assets/plugins/moment-with-locales.js"></script> | |
| 267 | +<script src="/assets/plugins/moment-with-locales.js"></script> | |
| 293 | 268 | |
| 294 | -<script src="assets/plugins/pinyin.js"></script> | |
| 269 | +<script src="/assets/plugins/pinyin.js"></script> | |
| 295 | 270 | <!-- 日期控件 --> |
| 296 | -<script src="metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script> | |
| 271 | +<script src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script> | |
| 297 | 272 | |
| 298 | 273 | <!-- 地图相关 --> |
| 299 | 274 | <!-- 百度 --> |
| 300 | -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT" ></script> | |
| 275 | +<!-- <script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT" ></script> | |
| 301 | 276 | <script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js" ></script> |
| 302 | -<!-- 高德 --> | |
| 303 | -<script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> | |
| 277 | +高德 | |
| 278 | +<script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> --> | |
| 304 | 279 | |
| 305 | -<script src="assets/js/common.js"></script> | |
| 306 | -<!-- d3.js --> | |
| 280 | +<script src="/assets/js/common.js"></script> | |
| 281 | +<!-- d3 --> | |
| 307 | 282 | <script src="http://apps.bdimg.com/libs/d3/3.4.8/d3.min.js"></script> |
| 283 | + | |
| 308 | 284 | <!-- TODO:angularJS相关库 --> |
| 309 | 285 | |
| 310 | 286 | <!-- angularJS相关库 --> |
| 311 | -<script src="assets/bower_components/angular/angular.min.js"></script> | |
| 312 | -<script src="assets/bower_components/angular-resource/angular-resource.min.js"></script> | |
| 313 | -<script src="assets/bower_components/angular-sanitize/angular-sanitize.min.js"></script> | |
| 314 | -<script src="assets/bower_components/angular-touch/angular-touch.min.js"></script> | |
| 315 | -<script src="assets/bower_components/angular-ui-router/release/angular-ui-router.min.js"></script> | |
| 316 | -<script src="assets/bower_components/oclazyload/dist/ocLazyLoad.min.js"></script> | |
| 317 | -<script src="assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> | |
| 318 | - | |
| 319 | -<!-- schedule计划调度AngularJS模块主js --> | |
| 320 | -<script src="pages/scheduleApp/module/main.js"></script> | |
| 321 | - | |
| 287 | +<script src="/assets/bower_components/angular/angular.js"></script> | |
| 288 | +<script src="/assets/bower_components/angular-resource/angular-resource.min.js"></script> | |
| 289 | +<script src="/assets/bower_components/angular-sanitize/angular-sanitize.min.js"></script> | |
| 290 | +<script src="/assets/bower_components/angular-touch/angular-touch.min.js"></script> | |
| 291 | +<script src="/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js"></script> | |
| 292 | +<script src="/assets/bower_components/oclazyload/dist/ocLazyLoad.min.js"></script> | |
| 293 | +<script src="/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> | |
| 294 | +<!-- schedule计划调度AngularJS模块主JS --> | |
| 295 | +<script src="/pages/scheduleApp/module/main.js"></script> | |
| 322 | 296 | |
| 323 | 297 | <script type="text/javascript"> |
| 324 | - | |
| 298 | +//初始打开的片段地址 | |
| 299 | +var initFragment = "^_^initFragment^_^"; | |
| 300 | +//静态文件目录 | |
| 325 | 301 | var dir = '/pages/'; |
| 302 | +//片段容器 | |
| 326 | 303 | var pjaxContainer = '#pjax-container' |
| 327 | 304 | ,angJsContainer = '#route-container'; |
| 328 | 305 | |
| ... | ... | @@ -334,15 +311,13 @@ $(function(){ |
| 334 | 311 | $(document).on('click','#leftMenuSidebar a[data-pjax]', function(){ |
| 335 | 312 | $('#leftMenuSidebar li.nav-item.active').removeClass('active'); |
| 336 | 313 | $(this).parent().addClass('active'); |
| 337 | - | |
| 338 | 314 | showPjax(); |
| 339 | 315 | }); |
| 340 | 316 | |
| 341 | 317 | //angularjs左菜单点击事件 |
| 342 | - $(document).on('click','#leftMenuSidebar a[data-angularjs]', function(){ | |
| 318 | + $(document).on('click','#leftMenuSidebar a[data-angularjs]', function(){ | |
| 343 | 319 | $('#leftMenuSidebar li.nav-item.active').removeClass('active'); |
| 344 | 320 | $(this).parent().addClass('active'); |
| 345 | - | |
| 346 | 321 | showAngJs(); |
| 347 | 322 | }); |
| 348 | 323 | |
| ... | ... | @@ -355,24 +330,20 @@ $(function(){ |
| 355 | 330 | }); |
| 356 | 331 | var menuHtml = template('menu_list_temp', {list: treeArray}); |
| 357 | 332 | $('#leftMenuSidebar').html(menuHtml); |
| 358 | - | |
| 359 | - /* | |
| 360 | - * ----------- 检查URL ---------------- | |
| 361 | - */ | |
| 362 | - var p = $.url().param('_') | |
| 363 | - ,h = location.hash; | |
| 364 | - if(p && p.indexOf(dir) != -1){ | |
| 333 | + | |
| 334 | + //----------- 检查URL ---------------- | |
| 335 | + var h = location.hash; | |
| 336 | + if(initFragment && initFragment != ''){ | |
| 365 | 337 | showPjax(); |
| 366 | 338 | //普通片段 |
| 367 | - loadPage(p); | |
| 339 | + loadPage(initFragment); | |
| 368 | 340 | //选中菜单 |
| 369 | 341 | $.each($('#leftMenuSidebar a'), function(i, item){ |
| 370 | - if(urlPattern($(item).attr('href'), p)){ | |
| 342 | + if(urlPattern($(item).attr('href'), initFragment)){ | |
| 371 | 343 | activeLeftMenu(item); |
| 372 | 344 | } |
| 373 | 345 | }); |
| 374 | - } | |
| 375 | - else if(h){ | |
| 346 | + }else if(h){ | |
| 376 | 347 | //angularjs片段 |
| 377 | 348 | showAngJs(); |
| 378 | 349 | //选中菜单 |
| ... | ... | @@ -384,18 +355,19 @@ $(function(){ |
| 384 | 355 | } |
| 385 | 356 | else{ |
| 386 | 357 | //加载主页 |
| 387 | - loadPage('pages/home.html'); | |
| 358 | + loadPage('/pages/home.html'); | |
| 388 | 359 | } |
| 389 | 360 | }); |
| 390 | 361 | }); |
| 391 | 362 | |
| 363 | + | |
| 392 | 364 | //modal关闭时销毁dom |
| 393 | 365 | $(document).on('hidden.bs.modal', '.modal', function(){ |
| 394 | 366 | $(this).remove(); |
| 395 | 367 | }); |
| 396 | 368 | |
| 397 | 369 | function loadPage(url){ |
| 398 | - $.pjax({url: url, container: pjaxContainer}); | |
| 370 | + $.pjax({url: url, container: pjaxContainer}) | |
| 399 | 371 | } |
| 400 | 372 | |
| 401 | 373 | function urlPattern(a , b){ |
| ... | ... | @@ -409,15 +381,11 @@ $(function(){ |
| 409 | 381 | } |
| 410 | 382 | |
| 411 | 383 | function showPjax(){ |
| 412 | - console.log("showPjax"); | |
| 413 | - | |
| 414 | 384 | $(angJsContainer).hide(); |
| 415 | 385 | $(pjaxContainer).show(); |
| 416 | 386 | } |
| 417 | 387 | |
| 418 | 388 | function showAngJs(){ |
| 419 | - console.log("showAngJs"); | |
| 420 | - | |
| 421 | 389 | $(pjaxContainer).html('').hide(); |
| 422 | 390 | $(angJsContainer).show(); |
| 423 | 391 | } | ... | ... |
src/main/resources/static/pages/permission/resource/edit.html
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | <ul class="page-breadcrumb breadcrumb"> |
| 8 | 8 | <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> |
| 9 | 9 | <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> |
| 10 | - <li><a href="list.html" data-pjax>资源管理</a> <i class="fa fa-circle"></i></li> | |
| 10 | + <li><a href="javascript:;" class="back" data-pjax>资源管理</a> <i class="fa fa-circle"></i></li> | |
| 11 | 11 | <li><span class="active">编辑资源</span></li> |
| 12 | 12 | </ul> |
| 13 | 13 | |
| ... | ... | @@ -82,7 +82,7 @@ |
| 82 | 82 | <div class="row"> |
| 83 | 83 | <div class="col-md-offset-3 col-md-4"> |
| 84 | 84 | <button type="submit" class="btn green" ><i class="fa fa-check"></i> 保存</button> |
| 85 | - <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a> | |
| 85 | + <a type="button" class="btn default back" href="javascript:;" ><i class="fa fa-times"></i> 取消</a> | |
| 86 | 86 | </div> |
| 87 | 87 | </div> |
| 88 | 88 | </div> |
| ... | ... | @@ -93,6 +93,10 @@ |
| 93 | 93 | |
| 94 | 94 | <script> |
| 95 | 95 | $(function(){ |
| 96 | + $('a.back').on('click', function(){ | |
| 97 | + history.back(); | |
| 98 | + }); | |
| 99 | + | |
| 96 | 100 | var id = $.url().param('no'); |
| 97 | 101 | |
| 98 | 102 | if(!id){ | ... | ... |
src/main/resources/static/pages/permission/resource/list.html
| ... | ... | @@ -151,14 +151,40 @@ |
| 151 | 151 | |
| 152 | 152 | <script type="text/javascript"> |
| 153 | 153 | $(function(){ |
| 154 | - | |
| 155 | 154 | var page = 0, initPagination; |
| 156 | 155 | var icheckOptions = { |
| 157 | 156 | checkboxClass: 'icheckbox_flat-blue', |
| 158 | 157 | increaseArea: '20%' |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | - jsDoQuery(null,true); | |
| 160 | + var init = function(){ | |
| 161 | + jsDoQuery(null,true); | |
| 162 | + | |
| 163 | + //模块下拉框 | |
| 164 | + getModuleTreeData(function(treeData){ | |
| 165 | + var options = '<option value="">请选择...</option>'; | |
| 166 | + $.each(treeData, function(i, g){ | |
| 167 | + var dArray = g.children; | |
| 168 | + | |
| 169 | + for(var i = 0,d; d = dArray[i++];){ | |
| 170 | + options += '<optgroup label="'+d.name+'">'; | |
| 171 | + if(!d.children) | |
| 172 | + continue; | |
| 173 | + | |
| 174 | + $.each(d.children, function(i, m){ | |
| 175 | + options += '<option value="'+m.id+'">'+m.name+'</option>' | |
| 176 | + }); | |
| 177 | + options += '</optgroup>'; | |
| 178 | + } | |
| 179 | + }); | |
| 180 | + $('#moduleSelect').html(options)/* .select2() */; | |
| 181 | + }); | |
| 182 | + } | |
| 183 | + | |
| 184 | + //if($('#historyCache').length == 0){ | |
| 185 | + init(); | |
| 186 | + //} | |
| 187 | + | |
| 162 | 188 | |
| 163 | 189 | //重置 |
| 164 | 190 | $('tr.filter .filter-cancel').on('click', function(){ |
| ... | ... | @@ -184,26 +210,6 @@ $(function(){ |
| 184 | 210 | jsDoQuery(params, true); |
| 185 | 211 | }); |
| 186 | 212 | |
| 187 | - //模块下拉框 | |
| 188 | - getModuleTreeData(function(treeData){ | |
| 189 | - var options = '<option value="">请选择...</option>'; | |
| 190 | - $.each(treeData, function(i, g){ | |
| 191 | - var dArray = g.children; | |
| 192 | - | |
| 193 | - for(var i = 0,d; d = dArray[i++];){ | |
| 194 | - options += '<optgroup label="'+d.name+'">'; | |
| 195 | - if(!d.children) | |
| 196 | - continue; | |
| 197 | - | |
| 198 | - $.each(d.children, function(i, m){ | |
| 199 | - options += '<option value="'+m.id+'">'+m.name+'</option>' | |
| 200 | - }); | |
| 201 | - options += '</optgroup>'; | |
| 202 | - } | |
| 203 | - }); | |
| 204 | - $('#moduleSelect').html(options).select2(); | |
| 205 | - }); | |
| 206 | - | |
| 207 | 213 | /* |
| 208 | 214 | * 获取数据 p: 要提交的参数, pagination: 是否重新分页 |
| 209 | 215 | */ | ... | ... |