diff --git a/conf/enumerate.go b/conf/enumerate.go index 7af755c8..829e52d9 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -7,6 +7,8 @@ import ( "github.com/astaxie/beego" "strconv" "path/filepath" + "os" + "fmt" ) // 登录用户的Session名 @@ -240,11 +242,16 @@ func URLForWithCdnImage(p string) string { return cdn + p } -func URLForWithCdnCss (p string) string { +func URLForWithCdnCss (p string,v ...string) string { cdn := beego.AppConfig.DefaultString("cdncss", "") if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") { return p } + filePath := WorkingDir(p) + + if f,err := os.Stat(filePath); err == nil && !strings.Contains(p, "?") && len(v) > 0 && v[0] == "version" { + p = p + fmt.Sprintf("?v=%s" , f.ModTime().Format("20060102150405")) + } //如果没有设置cdn,则使用baseURL拼接 if cdn == "" { baseUrl := beego.AppConfig.DefaultString("baseurl","") @@ -268,11 +275,18 @@ func URLForWithCdnCss (p string) string { return cdn + p } -func URLForWithCdnJs(p string) string { +func URLForWithCdnJs(p string,v ...string) string { cdn := beego.AppConfig.DefaultString("cdnjs", "") if strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://") { return p } + + filePath := WorkingDir(p) + + if f,err := os.Stat(filePath); err == nil && !strings.Contains(p, "?") && len(v) > 0 && v[0] == "version" { + p = p + fmt.Sprintf("?v=%s" , f.ModTime().Format("20060102150405")) + } + //如果没有设置cdn,则使用baseURL拼接 if cdn == "" { baseUrl := beego.AppConfig.DefaultString("baseurl","") diff --git a/static/js/kancloud.js b/static/js/kancloud.js index 9d5d50c4..12100c99 100644 --- a/static/js/kancloud.js +++ b/static/js/kancloud.js @@ -1,3 +1,60 @@ +var events = function () { + var articleOpen = function (event, $param) { + + var prevState = window.history.state || {}; + if ('pushState' in history) { + + if ($param.$id) { + prevState.$id === $param.$id || window.history.pushState($param, $param.$id, $param.$url); + } else { + window.history.pushState($param, $param.$id, $param.$url); + window.history.replaceState($param, $param.$id, $param.$url); + } + } else { + window.location.hash = $param.$url; + } + + initHighlighting(); + + $(".manual-right").scrollTop(0); + //使用layer相册功能查看图片 + layer.photos({photos: "#page-content"}); + }; + if(window.sessionStorage){ + return { + data: function ($key, $value) { + if(typeof $value === "undefined"){ + var data = window.sessionStorage.getItem($key); + return JSON.parse(data); + } else { + $value = JSON.stringify($value); + return window.sessionStorage.setItem($key,$value); + } + }, + trigger: function ($e, $obj) { + articleOpen($e, $obj); + } + } + }else{ + return { + data : function ($key, $value) { + if(typeof $value === "undefined"){ + return $("body").data($key); + }else{ + return $('body').data($key, $value); + } + }, + trigger: function ($e, $obj) { + if($e === "article.open"){ + articleOpen($e, $obj); + }else { + $('body').trigger('article.open', $obj); + } + } + } + } +}(); + /*** * 加载文档到阅读区 * @param $url @@ -9,25 +66,23 @@ function loadDocument($url, $id, $callback) { url : $url, type : "GET", beforeSend : function (xhr) { - var body = events.data('body_' + $id); - var title = events.data('title_' + $id); - var doc_title = events.data('doc_title_' + $id); - var doc_info = events.data('doc_info_' + $id); - - if (body && title && doc_title) { + var data = events.data("document_" + $id); + if(data) { if (typeof $callback === "function") { - body = $callback(body); + data.body = $callback(data.body); } - $("#page-content").html(body); - $("title").text(title); - $("#article-title").text(doc_title); - $("#article-info").text(doc_info); + $("#page-content").html(data.body); + $("title").text(data.title); + $("#article-title").text(data.doc_title); + $("#article-info").text(data.doc_info); - events.trigger('article.open', { $url : $url, $id : $id }); + events.trigger('article.open', {$url: $url, $id: $id}); return false; + } + NProgress.start(); }, success : function (res) { @@ -47,10 +102,7 @@ function loadDocument($url, $id, $callback) { $("#article-title").text(doc_title); $("#article-info").text(doc_info); - events.data('body_' + $id, body); - events.data('title_' + $id, title); - events.data('doc_title_' + $id, doc_title); - events.data('doc_info_' + $id, doc_info); + events.data('document_' + $id, res.data); events.trigger('article.open', { $url : $url, $id : $id }); } else if (res.errcode === 6000) { @@ -86,7 +138,7 @@ function initHighlighting() { } -var events = $("body"); + $(function () { $(".view-backtop").on("click", function () { @@ -117,13 +169,7 @@ $(function () { } }).on('select_node.jstree', function (node, selected, event) { $(".m-manual").removeClass('manual-mobile-show-left'); - var url = selected.node.a_attr.href; - - if (url === window.location.href) { - return false; - } - - loadDocument(url, selected.node.id); + loadDocument(selected.node.a_attr.href, selected.node.id); }); $("#slidebar").on("click", function () { @@ -145,34 +191,6 @@ $(function () { } }); - // 处理打开事件 - events.on('article.open', function (event, $param) { - - var prevState = window.history.state || {}; - if ('pushState' in history) { - // if ($param.$init === false) { - // window.history.replaceState($param, $param.$id, $param.$url); - // } else { - // window.history.pushState($param, $param.$id, $param.$url); - // } - - if ($param.$id) { - prevState.$id === $param.$id || window.history.pushState($param, $param.$id, $param.$url); - } else { - window.history.pushState($param, $param.$id, $param.$url); - window.history.replaceState($param, $param.$id, $param.$url); - } - } else { - window.location.hash = $param.$url; - } - - initHighlighting(); - - $(".manual-right").scrollTop(0); - //使用layer相册功能查看图片 - layer.photos({photos: "#page-content"}); - }); - $(".navg-item[data-mode]").on("click", function () { var mode = $(this).data('mode'); $(this).siblings().removeClass('active').end().addClass('active'); diff --git a/static/js/markdown.js b/static/js/markdown.js index 0ea1d9fe..e3593849 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -451,15 +451,20 @@ $(function () { $("#btnSaveTemplate").button("reset"); } }); - + /** + * 当添加模板弹窗事件发生 + */ $("#saveTemplateModal").on("show.bs.modal",function () { window.sessionStorage.setItem("saveTemplateModal",$(this).find(".modal-body").html()); var content = window.editor.getMarkdown(); $("#saveTemplateForm").find("input[name='content']").val(content); + $("#saveTemplateForm .show-error-message").html(""); }).on("hidden.bs.modal",function () { $(this).find(".modal-body").html(window.sessionStorage.getItem("saveTemplateModal")); }); - + /** + * 插入自定义模板内容 + */ $("#displayCustomsTemplateList").on("click",".btn-insert",function () { var templateId = $(this).attr("data-id"); diff --git a/views/account/find_password_setp1.tpl b/views/account/find_password_setp1.tpl index df3ccd11..d94ce2d7 100644 --- a/views/account/find_password_setp1.tpl +++ b/views/account/find_password_setp1.tpl @@ -12,7 +12,7 @@ - + - + - + - + - + @@ -279,8 +279,8 @@ - - + +