+ 前台展示 +
+ID | +上传人 | +描述 | +路径 | +播放 | +上传时间 | +操作 | +
---|---|---|---|---|---|---|
#(audio.id ??) | +#(audio.user_id ??) | +#(audio.description ??) | +#(audio.path ??) | ++ + + | +#(audio.created ??) | ++ |
ID | +头像 | +登录名 | +昵称 | +点赞数 | +手机 | +创建时间 | +操作 | +
---|---|---|---|---|---|---|---|
#(user.id) | +![]() |
+ #(user.username ?? '无登录名') | +#(user.nickname ??) | +#(user.remark ??) | +#(user.mobile ??) | +#date(user.created) | ++ 编辑资料 + 用户权限 + | +
+ #date(article.created, 'yyyy-MM-dd') + #(article.view_count) + #(article.comment_count) +
+#maxLength(article.text, 50)
+ diff --git a/jpress-template/src/main/webapp/templates/daotian/_carousel.html b/jpress-template/src/main/webapp/templates/daotian/_carousel.html new file mode 100644 index 0000000000000000000000000000000000000000..d611fbb2a8328dcef53fe11a5341cf6fdf47c690 --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/_carousel.html @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/jpress-template/src/main/webapp/templates/daotian/_comment.html b/jpress-template/src/main/webapp/templates/daotian/_comment.html new file mode 100644 index 0000000000000000000000000000000000000000..6332454596f8fec7cccf70575f3a9506e8d5bb2e --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/_comment.html @@ -0,0 +1,112 @@ +#define script() + + + + + + + + + +#end + +#commentPage() ++ #(WEB_COPYRIGHT ?? 'Copyright @ 2017~现在') | + #(WEB_IPC_NO) +
+ +#include("_footer.html") + +#end \ No newline at end of file diff --git a/jpress-template/src/main/webapp/templates/daotian/js/admin.js b/jpress-template/src/main/webapp/templates/daotian/js/admin.js new file mode 100644 index 0000000000000000000000000000000000000000..1cd199acb9b69fd65558a542e9a699dc00b94048 --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/js/admin.js @@ -0,0 +1,34 @@ +(function(){ + Vue.config.silent = false; + Vue.config.devtools = true; + $('[data-vue]').each(function(){ + var data = this.getAttribute('data-vue'); + window.datax = new Vue({ + el: '#daotian_banner', + data: { + data: data && JSON.parse(data) || [], + }, + methods: { + loadImg: function (index) { + var that = this; + layer.open({ + type: 2, + title: '选择图片', + anim: 2, + shadeClose: true, + shade: 0.5, + area: ['90%', '90%'], + content: jpress.cpath + '/admin/attachment/browse', + end: function () { + that.$set(that.data, index, layer.data.src); + }, + }); + }, + addImg: function() { + this.data.push(''); + this.loadImg(this.data.length - 1); + }, + } + }); + }); +})(); \ No newline at end of file diff --git a/jpress-template/src/main/webapp/templates/daotian/js/app.js b/jpress-template/src/main/webapp/templates/daotian/js/app.js new file mode 100644 index 0000000000000000000000000000000000000000..697561d7bf33df3bfc4f1359484b09b2fe22b9b1 --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/js/app.js @@ -0,0 +1,117 @@ +(function(){ + +// 底部导航 +$('.dt-footer a').each(function() { + var a = $(this); + if(a.attr('href') === location.pathname) { + a.addClass('active'); + return false; + } +}); + +// 音乐播放,多个音乐进行切换 TODO: 加载优化 +$(document.body).on('click', '.music-player', function(e){ + e.preventDefault(); + var music = $(this); + var audio = music.find('audio'); + if (!audio) { + return; + } + if (music.hasClass('playing')) { + audio[0].pause(); + music.removeClass('playing'); + return; + } + $('.music-player').removeClass('playing').find('audio').each(function(){ + this.pause(); + }); + audio[0].load(); + audio[0].play(); + music.addClass('playing'); +}); + +// 首页轮播,兼容手机样式 +$('.carousel').swipe({ + swipeLeft: function() { $(this).carousel('next'); }, + swipeRight: function() { $(this).carousel('prev'); }, +}); + +var canCancel = false; +var already = '我们已经收到您的点赞了呦~'; +// 点赞 +$(document.body).on('click', '.btn-star', function(){ + var btn = $(this); + var user = +btn.attr('data-user'); + var star = btn.find('.star'); + if (!user || btn.hasClass('voting')) { + return; + } + + if (!canCancel && btn.hasClass('voted')) { // 不能取消点赞 + window.toastr.clear(); + window.toastr.warning(already); + return; + } + + btn.addClass('voting'); + var num = +star.html() || 0; + star.html(Math.max(0, num + (btn.hasClass('voted') ? -1 : 1))); + btn.toggleClass('voted'); + $.post('/daotian/sso/doStar', { + user: user, + }, function(rst) { + rst = rst || ''; + btn.removeClass('voting'); + if (rst.state === 'ok') { + if (rst.data === 1) { + // TODO: 更新数字,后台返回最新点赞 + window.toastr.clear(); + window.toastr.info('您的点赞是对我们最大的鼓励~'); + } else { + star.html(num); + window.toastr.clear(); + window.toastr.warning(already); + } + } else { + window.toastr.clear(); + window.toastr.error('点赞失败:' + rst.message); + btn.toggleClass('voted'); + star.html(num); + if (rst.code === 301) { + setTimeout(function() { + location.href = '/user/login'; + }, 1000); + } + } + }); +}); + +var starContainer = $('.star-container'); +if (starContainer.length) { + $.get('/daotian/sso/getMyVote', function(rst) { + var stars = rst && rst.data || []; + if (stars.length > 0) { + starContainer.find('.btn-star').each(function(){ + var btn = $(this); + var user = +btn.attr('data-user'); + if (stars.indexOf(user) > -1) { + btn.addClass('voted'); + } + }); + } + }); +} + +// 修正留言分页,后端不认识的路由 +$('#commentPagination a.page-link').each(function(){ + var a = $(this); + var href = a.attr('href'); + if (href && /^\/message-/.test(href)) { + a.attr('href', '/article' + href); + } + if (href && /^\/news-/.test(href)) { + a.attr('href', '/article/category/news' + href); + } +}); + +})(); \ No newline at end of file diff --git a/jpress-template/src/main/webapp/templates/daotian/js/audio.js b/jpress-template/src/main/webapp/templates/daotian/js/audio.js new file mode 100644 index 0000000000000000000000000000000000000000..618934238335a394c0f3b0882d109d3ac8b03050 --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/js/audio.js @@ -0,0 +1,312 @@ +;!function(factory){ + // AMD模块化加载 + if (typeof define === "function" && define.amd) { + define([ "jquery" ], factory); + } else { + factory(jQuery); + } +}(function($){ + $.extend({ + // 判断是否为对象 + isObject: function (v) { + return Object.prototype.toString.call(v) === "[object Object]"; + }, + // 判断是否为字符串 + isString: function (v) { + return Object.prototype.toString.call(v) === "[object String]"; + }, + // 判断是否为数组 + isArray:function (v) { + return Object.prototype.toString.call(v) === "[object Array]"; + }, + // 判断是否为数字 + isNumber:function (v) { + return Object.prototype.toString.call(v) === "[object Number]"; + }, + // 判断是否为布尔 + isBool: function (v) { + return Object.prototype.toString.call(v) === "[object Boolean]"; + }, + // 判断是否为函数 + isFun: function(v) { + return Object.prototype.toString.call(v) === "[object Function]"; + }, + isWeixin: function(v){ + return v.match(/MicroMessenger/i) === "micromessenger" + }, + // 初始化audio + getAudio: function(audio){ + return $(audio).lzaudio(); + } + }); + + // 创建播放器构造函数 + var Audio = function (el){ + var me = this; + me.$parcel = $(el); + me.$el = $(el).find('audio'); + me.el = me.$el[0]; + }; + + // 创建内部工具函数 + var _Tool = function(_this){ + this.el = _this; + } + + _Tool.prototype = { + // 监听播放暂停状态 + _playState: function(statusBtn){ + var me = this.el; + //初始化监听事件 + me.$el.on('play',function(){ + me.state = true + }).on('pause ended.state',function(){ + me.state = false + }); + }, + + // 规定控制器范围 + _findMoudle: function(moudle){ + var me = this.el, + moudle = me.$parcel.parent().find('[data-lzmoudle=' + moudle + ']'); + return moudle.size() ? moudle : me.$parcel.parent(); + }, + + // 时间格式化 + _timeFormatting: function(second){ + return [~~(second / 60 % 60), ~~(second % 60)].join(":") + .replace(/\b(\d)\b/g, "0$1") + }, + + // 移动端自动播放兼容 + _autoplayCompatibility: function(){ + var me = this.el, + ua = navigator.userAgent.toLowerCase(); + // 微信下自动播放 + if(ua.match(/MicroMessenger/i) == 'micromessenger'){ + wx.config({ + debug: false, + appId: '', + timestamp: 1, + nonceStr: '', + signature: '', + jsApiList: [] + }); + wx.ready(function () { + me.el.autoplay && (me.el.play()) + }); + }else{ + me.el.load(); + me.el.play(); + } + }, + + // 原型指回 + constructor: _Tool + }; + + + Audio.prototype = { + // 默认初始化设置 + setAudio: function(data,callback){ + var me = this, + tool = new _Tool(me); + tool._playState(); + $.isFun(data) && (callback = data); + // 缺省设置 + if($.isString(data)){ + var src= data; + data = {}; + data.src = src, + data.auto = true; + data.loop = true + } + // 默认初始化设置 + if($.isObject(data)){ + if(!!data.src){ + if(!!data.auto || data.auto ==null){ + me.el.src = $.isArray(data.src) ? data.src[0] : data.src; + me.el.autoplay = 'autoplay' + }else if(!!data.srcFlog || data.srcFlog == null){ + me.el.src = $.isArray(data.src) ? data.src[0] : data.src; + }; + if((!!data.load || data.load ==null) && (!data.auto && data.auto!=null) && me.el.src) + me.el.preload = data.preload ==null ? 'load' : data.preload; + (!!data.loop || data.loop ==null) && (me.el.loop = 'loop'); + me.src = data.src; + } + }; + (me.el.autoplay && data.mobile) && tool._autoplayCompatibility(); + $.isFun(callback) && callback.call(me); + return me + }, + + // 控制面板设置 + control: function(data){ + var me = this, + tool = new _Tool(me), + dom = tool._findMoudle('control'); + if($.isObject(data)){ + $.isObject(data.clickBtn) && me.clickBtn(dom.find(data.clickBtn.select),data.clickBtn.callback,dom); + $.isObject(data.setDuration) && me.setDuration(dom.find(data.setDuration.select)); + $.isObject(data.setCurrentTime) && me.setCurrentTime(dom.find(data.setCurrentTime.select)); + $.isObject(data.progressCtrl) && me.progressCtrl([ + dom.find(data.progressCtrl.select[0]), + dom.find(data.progressCtrl.select[1]), + dom.find(data.progressCtrl.select[2]) + ],data.progressCtrl.callback) + } + return me + }, + + // 播放列表 + list: function(data){ + var me = this, + tool = new _Tool(me), + dom = tool._findMoudle('list'); + if($.isObject(data)){ + $.isObject(data.clickBtn) && me.clickBtn(dom.find(data.clickBtn.select),data.clickBtn.callback,dom); + $.isObject(data.end) && me.end(data.end.state,data.end.callback); + } + return me + }, + + // 播放暂停按钮交互 + clickBtn: function(statusBtn,callback,$dom){ + var me = this, + bool = true, btn,moudle; + me.state = me.el.autoplay ? false : true; + // 缺省设置 + (!$.isString(statusBtn) && !statusBtn.size()) && (bool = false); + $.isFun(statusBtn) && (callback = statusBtn); + $dom && (moudle = $dom.data('lzmoudle')); + // 添加监听 + if(bool){ + me.$playBtn = me.$parcel.parent().find(statusBtn); + me.$playBtn.off('click').on('click',function(){ + !$.isNumber(me.el.musicIndex) && (me.el.musicIndex = 0); + moudle == 'list' && (me.el.musicIndex = $(this).index()); + if(!!me.el.src) + !me.state ? me.el.play() : me.el.pause(); + $.isFun(callback) && callback.call(me,me.el.musicIndex,this); + }) + } + me.el.autoplay && (me.el.musicIndex = 0); + $.isFun(callback) && callback.call(me,me.el.musicIndex); + me.el.musicIndex = null; + me.state = false; + return me; + }, + + // 设置总时长 + setDuration: function(durationDom){ + var me = this,dom =me.$parcel.find(durationDom), + tool = new _Tool(me); + if(!!dom.length){ + me.$el.off('durationchange.setDuration').on("durationchange.setDuration", function(){ + dom.html(tool._timeFormatting(me.el.duration)) + }) + } + return me + }, + + // 设置当前时间 + setCurrentTime: function(currentTimeDom){ + var me = this,dom =me.$parcel.find(currentTimeDom), + tool = new _Tool(); + if(!!dom.length){ + me.$el.off('timeupdate.setCurrentTime').on("timeupdate.setCurrentTime", function(){ + dom.html(tool._timeFormatting(me.el.currentTime)); + }); + } + return me; + }, + + // 进度控制 + progressCtrl: function($selectArr,callback){ + var me = this, + tool = new _Tool(me), + flag = false, + progressLength = $selectArr[0].width(), + durationVal,currentTime,touch,move; + // 计算总时长 + me.$el.off('durationchange.progressCtrl').on("durationchange.progressCtrl", function(){ + durationVal = me.el.duration + }); + // 根据当前时长与总时长比例设置进度 + me.$el.off('timeupdate.progressCtrl').on("timeupdate.progressCtrl", function(){ + currentTime = me.el.currentTime / durationVal * 100; + $.isArray($selectArr) && $selectArr[1].css('width',currentTime + '%'); + }); + // 点击进度条某个位置 + $($selectArr[0]).off('click touchstart').on('click touchstart',function(e){ + if(e.target !== $selectArr[2][0] && me.el.src){ + touch = $.isArray(e.originalEvent.touches) ? e.originalEvent.touches[0] : e; + move = touch.offsetX - 5; + move = move < 0 ? 0 : move > progressLength ? progressLength : move; + me.el.currentTime = move / progressLength * durationVal; + } + return false; + }); + // 鼠标或手指点击进度条手柄开关 + $selectArr[2].off('mousedown touchstart').on('mousedown touchstart',function(){ + me.el.src && (flag = true); + }); + // 拖拽滑动进度条 + $(document).off('mousemove touchmove').on('mousemove touchmove',function(e){ + e.preventDefault(); + touch = $.isArray(e.originalEvent.touches) ? e.originalEvent.touches[0] : e; + if(flag){ + move = touch.pageX - $selectArr[0].offset().left - 5; + move = move < 0 ? 0 : move > progressLength ? progressLength : move; + me.el.currentTime = move / progressLength * durationVal; + me.el.currentTime == durationVal && (flag = false); + } + }).off('mouseup touchend').on('mouseup touchend',function(){ + // 鼠标或手指松开进度条手柄开关 + flag = false; + }); + $.isFun(callback) && callback.call(me); + return me; + }, + + // 播放结束后 + end: function(state,callback){ + var me = this, + index, + flag = $.isFun(callback) ? true : false; + me.$el.off('ended.end').on('ended.end',function(){ + if($.isString(state)){ + me.loop == 'loop' && console.warn('参数冲突: 当前单曲循环与列表播放正同时开启'); + index = me.el.musicIndex; + !index && (index = 0); + if(state=='next'){ + index++; + index > me.src.length - 1 && (index = 0); + me.el.src=me.src[index]; + me.el.load(); + me.el.play(); + flag && callback.call(me,index); + me.el.musicIndex = index; + }else if(state=='end'|| !state){ + flag && callback.call(me,index) + } + } + return me; + }); + }, + + // 原型指回 + constructor: Audio + } + + // jQ对象级拓展 原型实例化 + $.fn.extend({ + lzaudio:function(){ + var audio; + audio = new Audio(this); + return audio + } + }) + +}); \ No newline at end of file diff --git a/jpress-template/src/main/webapp/templates/daotian/js/comment.js b/jpress-template/src/main/webapp/templates/daotian/js/comment.js new file mode 100644 index 0000000000000000000000000000000000000000..837113703bc6e16b11bbda6c9518488bdc52362f --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/js/comment.js @@ -0,0 +1,58 @@ +window.hljs && window.hljs.initHighlightingOnLoad(); +$('#commentForm').on('submit', function () { + var content = $('#content').val().trim(); + var title = $('#title'); + if (title.length && !title.val().trim()) { + window.toastr.clear(); + window.toastr.warning('评论标题不能为空'); + return false; + } + if (!content) { + window.toastr.clear(); + window.toastr.warning('评论内容不能为空'); + return false; + } + $(this).ajaxSubmit({ + type: 'post', + success: function (data) { + if (data.state == 'ok') { + doRenderComment(data, content); + } else { + window.toastr.clear(); + window.toastr.warning('评论失败:' + data.message); + if (data.errorCode == 9) { + location.href = '/user/login'; // TODO, #(CPATH) + } + } + $('#content, #title').val(''); + }, + error: function () { + window.toastr.clear(); + window.toastr.warning('网络错误,请稍后重试'); + } + }); + return false; +}); + +function doRenderComment(data, content) { + if (data.code == 0) { + data = Object.assign({ + nickname: '游客', + avatar: '/static/commons/img/avatar.png', + content: content, + }, data.user, data.comment); + var tmpl = $.templates('#commentTmpl'); + var html = tmpl.render(data); + $('#newComment').append(html); + } else { + window.toastr.clear(); + window.toastr.info('评论发布成功,管理审核后即可正常显示。'); + } +} + +$('body').on('click','.toReply', function () { + $('#pid').val($(this).attr('data-cid')); + $('#title').val('回复 ' + $(this).attr('data-title')); + $('#content').val('回复 @' + $(this).attr('data-author') + ' :').focus(); +}); + diff --git a/jpress-template/src/main/webapp/templates/daotian/js/highlight.pack.js b/jpress-template/src/main/webapp/templates/daotian/js/highlight.pack.js new file mode 100755 index 0000000000000000000000000000000000000000..b45386be52db55e5ee39f514a00256e7e8c60712 --- /dev/null +++ b/jpress-template/src/main/webapp/templates/daotian/js/highlight.pack.js @@ -0,0 +1,2 @@ +/*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ +!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"+this._get(e,"weekHeader")+" | ":"",x=0;7>x;x++)C=(x+u)%7,N+="=5?" class='ui-datepicker-week-end'":"")+">"+""+p[C]+" | ";for(M+=N+"
---|---|
"+this._get(e,"calculateWeek")(H)+" | ":"",x=0;7>x;x++)O=g?g.apply(e.input?e.input[0]:null,[H]):[!0,""],j=H.getMonth()!==Z,W=j&&!y||!O[0]||$&&$>H||X&&H>X,E+=""+(j&&!v?" ":W?""+H.getDate()+"":""+H.getDate()+"")+" | ",H.setDate(H.getDate()+1),H=this._daylightSavingAdjust(H);M+=E+"
精选#(article.style == 'message' ? '留言' : '评论')
+ #for(comment : commentPage.list) + #if(comment.parent == null) +