优化身体图文管理

This commit is contained in:
Anyon 2020-08-18 10:52:49 +08:00
parent dd0d825e2a
commit b8f914cec1
2 changed files with 13 additions and 18 deletions

View File

@ -41,33 +41,28 @@
{block name='script'}
<script>
$('body').on('mouseenter', '.news-item', function () {
$('body').off('mouseenter', '.news-item').on('mouseenter', '.news-item', function () {
$(this).find('.news-tools').removeClass('layui-hide');
}).on('mouseleave', '.news-item', function () {
}).off('mouseleave', '.news-item').on('mouseleave', '.news-item', function () {
$(this).find('.news-tools').addClass('layui-hide');
});
require(['jquery.masonry'], function (Masonry) {
var item = document.querySelector('#news-box');
var msnry = new Masonry(item, {itemSelector: '.news-item', columnWidth: 0});
msnry.layout();
$('body').on('click', '[data-news-del]', function () {
var that = this;
var dialogIndex = $.msg.confirm('确定要删除图文吗?', function () {
$.form.load('{:url("remove")}', {value: 0, field: 'delete', id: that.getAttribute('data-news-del')}, 'post', function (ret) {
var newsbox = document.querySelector('#news-box');
var msnry = new Masonry(newsbox, {itemSelector: '.news-item', columnWidth: 0});
msnry.layout(), $('body').on('click', '[data-news-del]', function (event) {
$.msg.confirm('确定要删除图文吗?', function (index) {
$.msg.close(index), $.form.load('{:url("remove")}', {value: 0, field: 'delete', id: $(event.target).data('news-del')}, 'post', function (ret) {
if (ret.code) {
$(that).parents('.news-item').remove();
msnry = new Masonry(item, {itemSelector: '.news-item', columnWidth: 0});
return $.msg.success(ret.msg), msnry.layout(), false;
$(event.target).parents('.news-item').remove();
msnry = new Masonry(newsbox, {itemSelector: '.news-item', columnWidth: 0});
return msnry.layout(), (msnry.items.length < 1 && $.form.open('{:url("index")}')), $.msg.success(ret.info), false;
} else {
return $.msg.error(ret.info), false;
}
return $.msg.error(ret.msg), false;
});
$.msg.close(dialogIndex);
});
});
});
</script>
{/block}

View File

@ -28,7 +28,7 @@ return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => 'server.cuci.cc',
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'admin_v6',
// 用户名