更新到1.2.2版本
This commit is contained in:
@@ -1,4 +1,39 @@
|
||||
/* 后台样式 */
|
||||
.flm-critical-warning {
|
||||
font-size: 16px !important;
|
||||
font-weight: bold !important;
|
||||
border-left: 5px solid #dc3232 !important;
|
||||
background-color: #fef7f7 !important;
|
||||
padding: 15px 20px !important;
|
||||
margin: 20px 0 25px 0 !important;
|
||||
box-shadow: 0 2px 8px rgba(220, 50, 50, 0.2) !important;
|
||||
border-radius: 4px !important;
|
||||
animation: flm-warning-pulse 2s infinite !important;
|
||||
}
|
||||
|
||||
.flm-critical-warning p {
|
||||
margin: 0 !important;
|
||||
line-height: 1.5 !important;
|
||||
color: #dc3232 !important;
|
||||
}
|
||||
|
||||
.flm-critical-warning strong {
|
||||
font-size: 18px !important;
|
||||
color: #b71c1c !important;
|
||||
}
|
||||
|
||||
@keyframes flm-warning-pulse {
|
||||
0% {
|
||||
box-shadow: 0 2px 8px rgba(220, 50, 50, 0.2);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 2px 12px rgba(220, 50, 50, 0.4);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 2px 8px rgba(220, 50, 50, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.flm-admin-container {
|
||||
display: flex;
|
||||
gap: 2rem;
|
||||
@@ -33,11 +68,23 @@
|
||||
}
|
||||
|
||||
.form-group input[type="text"],
|
||||
.form-group input[type="url"] {
|
||||
.form-group input[type="url"],
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.form-group textarea {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.form-group input::placeholder,
|
||||
.form-group textarea::placeholder {
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#flm-sortable-links {
|
||||
@@ -57,11 +104,43 @@
|
||||
border-left: 4px solid #6667ab;
|
||||
}
|
||||
|
||||
.flm-link-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 30px;
|
||||
}
|
||||
|
||||
.flm-link-checkbox input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.flm-link-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 200px;
|
||||
cursor: move;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.flm-link-preview:hover {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.flm-drag-handle {
|
||||
color: #999;
|
||||
font-size: 18px;
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.flm-drag-handle:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.flm-link-icon {
|
||||
@@ -79,20 +158,80 @@
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.flm-import-export {
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #eee;
|
||||
/* 拖拽排序样式 */
|
||||
.flm-link-item-placeholder {
|
||||
background-color: #f0f0f0;
|
||||
border: 2px dashed #ccc;
|
||||
height: 60px;
|
||||
margin: 8px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.flm-import-export h3 {
|
||||
.ui-sortable-helper {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.flm-top-actions {
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.flm-top-actions .button {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.flm-top-section {
|
||||
margin-bottom: 25px;
|
||||
padding: 20px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 4px;
|
||||
border-left: 4px solid #6667ab;
|
||||
}
|
||||
|
||||
.flm-top-section h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.flm-top-section .form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.flm-export, .flm-import {
|
||||
margin-bottom: 15px;
|
||||
.flm-top-section .form-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.flm-top-section select {
|
||||
width: 200px;
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.flm-top-section input[type="file"] {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.flm-top-section .description {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 前端展示样式 */
|
||||
.flm-links-container {
|
||||
display: grid;
|
||||
@@ -110,8 +249,13 @@
|
||||
}
|
||||
|
||||
.flm-link-card:hover {
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 12px rgba(0,0,0,0.15);
|
||||
border-color: #555599;
|
||||
}
|
||||
|
||||
/* 确保hover时横线仍然可见 */
|
||||
.flm-link-card:hover .flm-link-description {
|
||||
border-bottom-color: #ddd;
|
||||
}
|
||||
|
||||
.flm-link-icon-container {
|
||||
@@ -130,6 +274,37 @@
|
||||
font-weight: bold;
|
||||
color: inherit; /* 使用主题默认颜色 */
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
border: none !important;
|
||||
border-bottom: none !important;
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.flm-link-description {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 0;
|
||||
line-height: 1.4;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #eee !important;
|
||||
}
|
||||
|
||||
/* 确保没有描述时完全不显示横线 */
|
||||
.flm-link-card:not(:has(.flm-link-description)) .flm-link-name {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* 彻底移除链接卡片内所有不必要的边框 */
|
||||
.flm-link-card a,
|
||||
.flm-link-card a *,
|
||||
.flm-link-icon-container,
|
||||
.flm-link-icon {
|
||||
border: none !important;
|
||||
border-bottom: none !important;
|
||||
border-top: none !important;
|
||||
border-left: none !important;
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.flm-link-card a {
|
||||
@@ -141,7 +316,7 @@
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 1024px) {
|
||||
.flm-links-container {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-columns: repeat(2, 1fr) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +330,7 @@
|
||||
}
|
||||
|
||||
.flm-links-container {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
.flm-link-item {
|
||||
|
||||
@@ -1,15 +1,168 @@
|
||||
jQuery(document).ready(function($) {
|
||||
// 显示消息函数
|
||||
function flm_show_message(message, type) {
|
||||
var className = type === 'success' ? 'notice-success' : 'notice-error';
|
||||
var $notice = $('<div class="notice ' + className + ' is-dismissible"><p>' + message + '</p></div>');
|
||||
|
||||
$('.wrap h1').after($notice);
|
||||
|
||||
// 3秒后自动隐藏
|
||||
setTimeout(function() {
|
||||
$notice.fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 使链接可排序
|
||||
$('#flm-sortable-links').sortable({
|
||||
handle: '.flm-link-preview',
|
||||
placeholder: 'flm-link-item-placeholder',
|
||||
axis: 'y',
|
||||
update: function() {
|
||||
// 更新排序后可以在这里添加AJAX保存逻辑
|
||||
update: function(event, ui) {
|
||||
// 获取排序后的ID顺序
|
||||
var linkIds = [];
|
||||
$('#flm-sortable-links .flm-link-item').each(function(index) {
|
||||
var linkId = $(this).find('input[name="link_ids[]"]').val();
|
||||
linkIds.push(linkId);
|
||||
});
|
||||
|
||||
// AJAX保存排序
|
||||
$.ajax({
|
||||
url: flm_vars.ajax_url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'flm_update_sort_order',
|
||||
link_ids: linkIds,
|
||||
nonce: flm_vars.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// 显示成功消息
|
||||
if (typeof flm_show_message === 'function') {
|
||||
flm_show_message('排序已保存', 'success');
|
||||
}
|
||||
} else {
|
||||
if (typeof flm_show_message === 'function') {
|
||||
flm_show_message('排序保存失败', 'error');
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
if (typeof flm_show_message === 'function') {
|
||||
flm_show_message('排序保存失败', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
// 拖拽结束后,重新索引所有字段以确保数据一致性
|
||||
$('#flm-sortable-links .flm-link-item').each(function(index) {
|
||||
// 更新link_ids字段的值顺序,确保与DOM顺序一致
|
||||
// 这里不需要改变,因为link_ids的值本身就是ID
|
||||
// 但需要确保其他字段在提交时能正确对应
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 删除链接
|
||||
// 自动获取头像切换
|
||||
$('#auto_get_icon').on('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#icon_field').hide();
|
||||
} else {
|
||||
$('#icon_field').show();
|
||||
}
|
||||
});
|
||||
|
||||
// 多选删除功能
|
||||
function updateBatchDeleteButton() {
|
||||
var selectedCount = $('.flm-select-link:checked').length;
|
||||
var $batchButton = $('.flm-batch-delete');
|
||||
|
||||
if (selectedCount > 0) {
|
||||
$batchButton.prop('disabled', false).text('批量删除 (' + selectedCount + ')');
|
||||
} else {
|
||||
$batchButton.prop('disabled', true).text('批量删除');
|
||||
}
|
||||
}
|
||||
|
||||
// 复选框变化时更新批量删除按钮
|
||||
$(document).on('change', '.flm-select-link', function() {
|
||||
updateBatchDeleteButton();
|
||||
});
|
||||
|
||||
// 表单提交前确保数据顺序正确
|
||||
$('#flm-links-form').on('submit', function(e) {
|
||||
// PHP代码现在使用 array_values() 来处理数组,所以不需要重新索引
|
||||
// 让表单正常提交,PHP会按顺序处理数组
|
||||
});
|
||||
|
||||
// 批量删除
|
||||
$('.flm-batch-delete').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var selectedIds = [];
|
||||
$('.flm-select-link:checked').each(function() {
|
||||
selectedIds.push($(this).val());
|
||||
});
|
||||
|
||||
if (selectedIds.length === 0) {
|
||||
alert('请先选择要删除的链接');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('确定要删除选中的 ' + selectedIds.length + ' 个链接吗?此操作不可撤销!')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $button = $(this);
|
||||
|
||||
$.ajax({
|
||||
url: flm_vars.ajax_url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'flm_batch_delete_links',
|
||||
link_ids: selectedIds,
|
||||
nonce: flm_vars.nonce
|
||||
},
|
||||
beforeSend: function() {
|
||||
$button.prop('disabled', true).text('删除中...');
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// 移除已删除的链接项
|
||||
var $itemsToRemove = $('.flm-select-link:checked').closest('.flm-link-item');
|
||||
var totalItems = $itemsToRemove.length;
|
||||
var removedItems = 0;
|
||||
|
||||
$itemsToRemove.fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
removedItems++;
|
||||
|
||||
// 只有当所有项目都被移除后才更新按钮状态
|
||||
if (removedItems === totalItems) {
|
||||
updateBatchDeleteButton();
|
||||
}
|
||||
});
|
||||
|
||||
var message = '成功删除 ' + response.data.deleted_count + ' 个链接';
|
||||
if (response.data.error_count > 0) {
|
||||
message += ',' + response.data.error_count + ' 个删除失败';
|
||||
}
|
||||
alert(message);
|
||||
} else {
|
||||
alert('批量删除失败:' + (response.data || '请重试'));
|
||||
$button.prop('disabled', false).text('批量删除');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('批量删除失败,请重试');
|
||||
$button.prop('disabled', false).text('批量删除');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 删除单个链接
|
||||
$('.flm-delete-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -31,10 +184,16 @@ jQuery(document).ready(function($) {
|
||||
beforeSend: function() {
|
||||
$button.prop('disabled', true).text('删除中...');
|
||||
},
|
||||
success: function() {
|
||||
$button.closest('.flm-link-item').fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$button.closest('.flm-link-item').fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
updateBatchDeleteButton();
|
||||
});
|
||||
} else {
|
||||
alert('删除失败,请重试');
|
||||
$button.prop('disabled', false).text('删除');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('删除失败,请重试');
|
||||
|
||||
Reference in New Issue
Block a user