function setCopyBtn(){$(".CopyToClipboard").each(function(){var t=new ZeroClipboard.Client;t.setHandCursor(!0),t.addEventListener("load",function(t){}),t.addEventListener("mouseOver",function(t){var e=t.movie.parentNode.parentNode.parentNode.parentNode.parentNode.nextSibling.innerHTML;e=e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),t.setText(e)}),t.addEventListener("complete",function(t,e){alert("代码已经复制到你的剪贴板。")}),t.glue(this,this.parentNode)})}function computePos(){"object"==typeof toolBar&&(toolBar.setPosX(),toolBar.computePositon())}function getRecommendListUrl(){var t=[[],[]];return $(".recommend-box div.recommend-item-box").each(function(e,o){if($(o).data("url")){var i=$(o).data("url").toLowerCase().split("://"),n=$(o).data("url").toLowerCase().split("article/details/");t[0].push(2==i.length?i[1]:i[0]),t[1].push(2==n.length?"article/details/"+n[1]:n[0])}}),t}function baidudatatemp(t,e){var o=highlight.map(function(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")});o="("+o.join("|")+")";var i=new RegExp(o,"gi"),n=/<[^>]*>/g,a=t["abstract"].replace(n,"").replace(i,"$1"),s=t.dispTime.replace(/^(\d*)-/,""),c=t.linkUrl,r=t.title.replace(n,"").replace(i,"$1"),l='"extra":"{\\"utm_medium\\":\\"distribute.pc_relevant.none-task-blog-baidujs_'+baiduSearchType+"-"+e+'\\"}",',d='
':isBloger=""}function o(){$(document).on("click",".comment-like",function(t){if(!getCookie("UserName"))return window.csdn.loginBox.show(),!1;var e=$(this).hasClass("liked")?"undigg":"digg",o=$(this).data("commentid"),i=this,n={articleId:articleId,commentId:o};$.ajax({url:blogUrl+"phoenix/web/v1/comment/"+e,type:"post",dataType:"json",data:n,xhrFields:{withCredentials:!0},success:function(t){var e=$(i).find("span").text()?parseInt($(i).find("span").text()):0;if($(i).hasClass("liked")){var o=e-1;o=o>0?o:"",$(i).removeClass("liked"),$(i).find(".unclickImg").css("display","inline-block"),$(i).find(".clickedImg").css("display","none"),$(i).find("span").text(o).css("color","#999AAA")}else $(i).addClass("liked"),$(i).find(".unclickImg").css("display","none"),$(i).find(".clickedImg").css("display","inline-block"),$(i).find("span").text(e+1).css("color","#FC5531");$(i).parents(".right-box").children(".comment-like").html($(i).html()),$(".comment-like-img-hover").css("display","none")}})})}function i(t){var e="";return 0==t.length?"":(e=t.replace(//g,">"))}function n(){currentUserName||csdn.loginBox.show()}function a(t){var e=window.location.href.split(t)[1];return null!=e?e:""}var s='
:这篇文章对你有帮助吗?作为一名程序工程师,在评论区留下你的困惑或你的见解,大家一起来交流吧!
';t.prototype.getData=function(t,e){var o=this;o.pageIndex=void 0!==t?t:o.pageIndex;var i=null;$.ajax({url:blogUrl+"phoenix/web/v1/comment/list/"+articleId+"?page="+o.pageIndex+"&size="+o.pageSize+"&commentId="+l,type:"post",xhrFields:{withCredentials:!0},success:function(t){200===t.code&&(i=t.data,i?(o.commentBox.show(),o.commentPagination.show(),o.curFloor=i.floorCount-(o.pageIndex-1)*o.pageSize,$(".comment-sofa-flag").remove()):(o.commentBox.hide(),o.commentPagination.hide()))},complete:function(){e&&e(i,o)}})},t.prototype.init=function(){window.localStorage.getItem("AM_comment_data")&&window.localStorage.getItem("AM_comment_id")==articleId&&(this.txtComment[0].focus(),this.txtComment.val(window.localStorage.getItem("AM_comment_data")),this.commentTxt.val(window.localStorage.getItem("AM_comment_replyId")),$(window).scrollTop(this.txtComment.offset().top));var t=function(t,e){if(null!==t){var o="";if(currentUserName||(o="登录 ",e.commentBox.css({overflow:"hidden"})),e.pageCount=t.pageCount,e.curFloor=t.floorCount,e.commentCount=t.floorCount,e.btnShowMore.html(""+o+"查看 "+t.count+' 条热评
'),e.renderData(t.list),currentUserName?(e.btnShowMore.parent("div.opt-box").remove(),e.showAll=!0,t.floorCount<=e.pageSize?e.commentPagination.addClass("d-none"):0===$("#btnMoreComment").length&&e.commentPagination.removeClass("d-none"),e.showAll||e.countInitHeight()):t.floorCount<=3?(e.btnShowMore.parent("div.opt-box").remove(),e.commentBox.css("max-height","none"),e.showAll=!0):(t.floorCount<=e.pageSize?e.commentPagination.addClass("d-none"):0===$("#btnMoreComment").length&&e.commentPagination.removeClass("d-none"),e.showAll||e.countInitHeight()),null===e.commentPageObj?t.pageCount>0&&(e.commentPageObj=new Paging,e.commentPageObj.init({target:e.commentPagination,pagesize:e.pageSize,count:e.commentCount,current:1,firstTpl:"",lastTpl:"",callback:function(t,o,i){e.getPagination(t)}})):e.commentPageObj.render({count:e.commentCount}),""!==l){var i=$("div.comment-list-box ul.comment-list:first-child").find("li.comment-line-box");$(i).each(function(t,e){if(l==$(e).data("commentid")){var o=$(e).parents("li.replay-box");o.length>0&&o.parent("ul.comment-list").find("a.btn-read-reply").trigger("click");var n=$(document).scrollTop(),a=$("#csdn-toolbar").height(),s=16;n<52&&(a=2*a);var c=$(i)[t].offsetTop-a-s;return setTimeout(function(){$("html,body").animate({scrollTop:c},200)},850),!1}})}}else e.btnShowMore.parent("div.opt-box").remove(),e.showAll=!0};commentscount||!this.firstLoad?this.getData(1,t):($(".comment-sofa-flag").show(),blogMoveHomeArticle&&(this.commentBox.append(s),this.btnShowMore.parent("div.opt-box").remove(),$(".comment-list-container").show()))},t.prototype.countInitHeight=function(){var t=this;t.curH=0,t.commentBox.find(">ul.comment-list:lt(3)").each(function(e){t.curH+=$(this).height()}),t.curH+=27,t.commentBox.css("max-height",t.curH)},t.prototype.initTxt=function(){var t=this;$("#comment_content").focus(function(){t.addId(t),t.commentCountObj.text(1e3-parseInt($(this).val().length)),t.cancelBtnToggle(!1),$(this).addClass("open"),t.commentLineBox.length>0&&t.commentLineBox.find(".comment-edit-box").remove(),$(".bt-comment-show").hide()}),$(document).click(function(e){$(e.target).is("div.comment-edit-box *")||$(e.target).is(".right_recommend_comment_button *")||$(e.target).is(".reply")||($("#comment_content").removeClass("open"),$(".bt-comment-show").show(),$(".comment-emoticon-box").hide(),$(".comment-emoticon-img").attr("src",$(".comment-emoticon-img").data("url")+"emoticon.png"),t.commentCountObj.text(t.commentFontLimit))}),$(document).click(function(t){$(t.target).is(".comment-line-box *")||$("#commentEditBox").remove()}),$(".bt-comment-show").click(function(){$(this).hide(),t.txtComment.addClass("open")}),$(".tool-item-comment").click(function(){setTimeout(function(){$(".bt-comment-show").hide(),$("#comment_content").addClass("open")},0)})},t.prototype.bindBtn=function(){function t(t){return"svg"===this.nodeName||currentUserName?(e.commentBox.css("max-height","none"),e.commentCount>e.pageSize&&e.commentPagination.removeClass("d-none"),$(this).parent("div.opt-box").remove(),$(this).parent().parent("div.opt-box").remove(),e.showAll=!0,e.curH=0,void(window.event?window.event.cancelBubble=!0:t.stopPropagation())):(csdn.loginBox.show(),!1)}var e=this;e.commentBox.click(function(t){var o=$(t.target).data("type");if(void 0!==o)switch(o){case"report":window.csdn.userLogin.loadAjax(function(t){showReport(!0)});break;case"readreply":var i=$(t.target).parents("li").siblings("li.replay-box");$(t.target).hasClass("open")?($(t.target).removeClass("open"),$(t.target).html(c+$(t.target).data("count")),i.hide(),e.curH&&e.commentBox.css("max-height",e.curH)):($(t.target).addClass("open").data("txt",$(t.target).text()),$(t.target).html(c+"收起评论"),i.show(),e.curH&&e.commentBox.css("max-height",e.curH+i.height()+10));break;case"delete":var n=$(t.target).parents("li.comment-line-box"),a=n.data("commentid");e.deleteComment(a)}}),this.btnShowMore.click(t),this.btnShowMore.find("svg").click(t),$(document).on("click",".show_loginbox",function(){if(e.setStorage()){var t=getCookie("UserName"),o=blogUrl+t;window.open(o,"_blank")}})},t.prototype.bindTxt=function(){var t=this;this.txtComment.blur(function(){}),this.txtComment.keyup(function(){var e=t.commentCountObj,o=t.commentFontLimit-$(this).val().length;o<0?e.text(0):e.text(o),$(this).val().length||$(this).data("replayUser")?t.cancelBtnToggle(!0):t.cancelBtnToggle(!1)})},t.prototype.renderData=function(t){var e=this,o="";if(1==$("#rightBox").data("type"))var o='评论将由博主筛选后显示,对所有人可见 |';var i='"+l+""+a):(a=this.replaceNewUBB(d[0]),a=this.getCodeInfo(a))}else{var d=this.getReplyInfo(t.content);s=d[1];var m=d.length>2?this.getQuoteInfo(d[2]):this.getQuoteInfo(d[0]);m.length>1?(c=m[1],l=this.getCodeInfo(m[2]),l=this.replaceNewUBB(l),a=this.getCodeInfo(m[3]),a=this.replaceNewUBB(a),a='引用“'+c+"”的评论:
"+l+""+a):(a=this.replaceNewUBB(m[0]),a=this.getCodeInfo(a))}if(t.tag){var p="https://blog.csdn.net/blogdevteam/article/details/103478461",u=''+t.tag+'
举报

'+(0!==parseInt(t.digg)?""+t.digg+"":"")+"'+i(o.trim())+""});return e},t.prototype.replaceNewUBB=function(t){return t=t.replace(/\[face\]([^\]]+):([^\]]+)\[\/face\]/gi,'举报
取消
确定
举报
取消
确定
搜索 ';$(".csdn-side-toolbar").prepend(o);var i='
提问 ';$(".csdn-side-toolbar").prepend(t);var e='',o="";
$.each(c,function(t,e){o+='
';w.skinBoxshadow.append(e),w.rewardBox.fadeOut(200),w.skinBoxshadow.fadeIn(200),setTimeout(function(){w.skinBoxshadow.fadeOut(200),w.skinBoxshadow.html(""),window.location.reload()},4e3),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&("balance"==rewardCoinType?window.csdn.report.reportClick({mod:"1582594662_001",spm:"1001.2101.3001.4303"}):window.csdn.report.reportClick({mod:"1582594662_002",spm:"1001.2101.3001.4301"}))}else i(!1,t.message)},error:function(t){i(!1,"操作失败,请重试")}})}),w.rewardBox.on("click",".reward-close",function(e){w.rewardBox.fadeOut(200),t($(this).parents(".tool-item"),!1);var o=e||window.e;o&&o.stopPropagation?o.stopPropagation():o.cancelBubble=!0}),$(".tool-subscribe").on("click",function(){$("#bt-click").trigger("click")});var y=!1;$("#btnAttent").on("click",function(){p()}),$(".tool-attend").on("click",function(t){t.originalEvent&&(y=!0),$("#btnAttent").trigger("click")}),$("#health-companies").on("click",function(){$(this).hasClass("active")&&(window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({spm:"1001.2101.3001.4429"}),"block"==$("#is-like-img").css("display")&&n(),"block"==$("#is-collection-img").css("display")&&a(),$(".tool-bt-attend").length>0&&($(".tool-attend").trigger("click"),window.csdn.report&&"function"==typeof window.csdn.report.reportClick&&window.csdn.report.reportClick({mod:"1592215036_002",spm:"1001.2101.3001.4132",extend1:"关注"})),$("#is-like-imgactive-animation-like").show().addClass("active-animation"),$("#is-collection-img-collection").show().addClass("active-animation"),$(".tool-item-follow").show().addClass("active-animation"),setTimeout(function(){$("#is-like-imgactive-animation-like").hide().removeClass("active-animation"),$("#is-collection-img-collection").hide().removeClass("active-animation"),$(".tool-item-follow").hide().removeClass("active-animation")},800))});var k=!1;$(".toolbox-list .tool-item").hover(f,g),$("#blog_detail_zk_collection").hover(f,g),$("#health-companies").on({mouseover:function(){$(this).is(".active")&&($(".triplet-prompt img.close-prompt").css("display","none"),$(".triplet-prompt").css("width","300px"),$(".triplet-prompt").fadeIn(500))},mouseout:function(){$(".triplet-prompt").fadeOut(500)}})}),$(function(){function t(t,e){var o=6,i=new Date;i.setTime(i.getTime()+36e5*o),document.cookie=t+"="+escape(e)+";expires="+i.toGMTString()+";domain=.csdn.net;path=/"}function e(t){var e,o=new RegExp("(^| )"+t+"=([^;]*)(;|$)");return(e=document.cookie.match(o))?unescape(e[2]):null}if(!currentUserName){var o=$("div.article_content"),i=o.offset().top,n=o.height(),a=document.body.clientHeight||document.documentElement.clientHeight,s=$(document).scrollTop();$(document).scroll(function(){s=$(document).scrollTop(),e("unlogin_scroll_step")||e("UserName")||showPcWindowAd||(s+a-i>n/2||s+a-i>2*a)&&(window.csdn.loginBox.show(),t("unlogin_scroll_step",(new Date).getTime()))})}}),"undefined"!=typeof document.addEventListener&&document.addEventListener("DOMContentLoaded",function(){return"undefined"==typeof Chart?void("undefined"!=typeof console&&console.log("ERROR: You must include chart.min.js on this page in order to use Chart.js")):void[].forEach.call(document.querySelectorAll("div.chartjs"),function(t){var e,o;e="undefined"!=typeof chartjs_colors?chartjs_colors:"undefined"!=typeof chartjs_colors_json?JSON.parse(chartjs_colors_json):{fillColor:"rgba(151,187,205,0.5)",strokeColor:"rgba(151,187,205,0.8)",highlightFill:"rgba(151,187,205,0.75)",highlightStroke:"rgba(151,187,205,1)",data:["#B33131","#B66F2D","#B6B330","#71B232","#33B22D","#31B272","#2DB5B5","#3172B6","#3232B6","#6E31B2","#B434AF","#B53071"]},o="undefined"!=typeof chartjs_config?chartjs_config:"undefined"!=typeof chartjs_config_json?JSON.parse(chartjs_config_json):{Bar:{animation:!1},Doughnut:{animateRotate:!1},Line:{animation:!1},Pie:{animateRotate:!1},PolarArea:{animateRotate:!1}};var i=t.getAttribute("data-chart"),n=JSON.parse(t.getAttribute("data-chart-value"));if(n&&n.length&&i){t.innerHTML="";var a=document.createElement("canvas");a.height=t.getAttribute("data-chart-height"),t.appendChild(a);var s=document.createElement("div");s.setAttribute("class","chartjs-legend"),t.appendChild(s);var c,r=a.getContext("2d"),l=new Chart(r);if("bar"!=i)for(c=0;c