Files
ChangeLog/manage-panel.php

2102 lines
70 KiB
PHP
Raw Normal View History

<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
* 更新日志插件后台管理面板
*/
// 获取配置
$options = Typecho_Widget::widget('Widget_Options');
$config = $options->plugin('ChangeLog');
/**
* 把表单里的"日期"和"时间"两个输入拼成 event_date
*
* 日期输入框给 Y-m-d,时间输入框给 H:i(:s),拼成 Y-m-d H:i:s;
* 时间没填时只传日期,由 Action 按 00:00:00 处理。
* 同时兼容直接提交 2026-10-27T11:07:16 这种 datetime 字符串的情况。
*/
if (!function_exists('changelogJoinDateTime')) {
function changelogJoinDateTime($date, $time = '')
{
$date = trim((string) $date);
$time = trim((string) $time);
if ($date === '') {
return '';
}
if (strpos($date, ' ') !== false || strpos($date, 'T') !== false) {
return str_replace('T', ' ', $date);
}
return $time === '' ? $date : $date . ' ' . $time;
}
}
/**
* 后台列表的日期时间显示:日期后空格显示时分秒
*
* 老数据只存了日期(时间为 00:00:00),这类记录只显示日期。
*/
if (!function_exists('changelogFormatDateTime')) {
function changelogFormatDateTime($value, $dateFormat = 'Y-m-d')
{
$timestamp = strtotime((string) $value);
if ($timestamp === false) {
return '';
}
$date = date($dateFormat, $timestamp);
$time = date('H:i:s', $timestamp);
return $time === '00:00:00' ? $date : $date . ' ' . $time;
}
}
/**
* 后台列表的搜索框(2.0.10)
*
* 有记录时放在表头工具栏的正中间(「已选择 N 条」与「删除选中」之间);
* 搜索无结果时整个表单不渲染,所以再单独输出一份($standalone = true),
* 让用户能直接改关键词,而不是只能点「查看全部记录」。
*
* 注意:这个 input 落在 mainForm 内部,用 form="cl-no-form"(指向不存在的 id)
* 让它脱离表单——否则按回车会提交 mainForm,勾选了记录时会误触发批量删除。
*
* @param string $keyword 当前搜索词
* @param string $panelPath 本面板地址(不含 query)
* @param bool $standalone 是否用于无结果时单独一行
* @return string
*/
if (!function_exists('changelogSearchBox')) {
function changelogSearchBox($keyword, $panelPath, $standalone = false)
{
$kw = htmlspecialchars((string) $keyword, ENT_QUOTES, 'UTF-8');
$path = htmlspecialchars((string) $panelPath, ENT_QUOTES, 'UTF-8');
$idSuffix = $standalone ? '-empty' : '';
$clear = '';
if ($keyword !== '') {
$clear = '<a href="' . $path . '?panel=ChangeLog/manage-panel.php#cl-list-anchor"'
. ' class="cl-search-clear" title="清除搜索,显示全部记录">清除</a>';
}
return '<div class="cl-bulk-search' . ($standalone ? ' cl-bulk-search--block' : '') . '">'
. '<input type="search" id="cl-list-search' . $idSuffix . '"'
. ' class="cl-search-input" form="cl-no-form"'
. ' value="' . $kw . '" placeholder="搜索记录内容…" autocomplete="off">'
. '<button type="button" class="btn btn-sm btn-primary cl-search-btn">搜索</button>'
. $clear
. '</div>';
}
}
// 引入Action类
require_once __DIR__ . '/Action.php';
$action = new ChangeLog_Action();
// 获取当前页码
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$perPage = isset($config->perPage) ? intval($config->perPage) : 10;
if ($perPage < 1) {
$perPage = 10;
}
// 搜索关键词(2.0.10:后台列表按「内容」过滤,跨页生效)
// 长度限一下,避免超长串拼进 LIKE;% 和 _ 不转义,理由见 Action::getEntries()
$keyword = isset($_GET['q']) ? trim((string) $_GET['q']) : '';
if (mb_strlen($keyword, 'UTF-8') > 50) {
$keyword = mb_substr($keyword, 0, 50, 'UTF-8');
}
// 拼在分页 / 重定向链接后面的参数(带 & 前缀,空搜索时不加)
$keywordParam = $keyword === '' ? '' : '&q=' . urlencode($keyword);
// 本面板自己的地址:后台目录可能被改过(/admin/ 或别的),统一从当前请求取路径
$panelPath = strtok((string) $_SERVER['REQUEST_URI'], '?');
if (!$panelPath) {
$panelPath = (string) $_SERVER['PHP_SELF'];
}
// 处理表单提交
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// 处理新增 - 关键:处理完后不重定向,刷新当前页面
// 在manage-panel.php中修改发布处理部分(第29-38行):
// 处理新增
if (!empty($_POST['content'])) {
try {
$action->addEntry(array(
'content' => $_POST['content'],
'event_date' => changelogJoinDateTime(
isset($_POST['event_date']) ? $_POST['event_date'] : '',
isset($_POST['event_time']) ? $_POST['event_time'] : ''
),
'post_cids' => isset($_POST['post_cids']) ? $_POST['post_cids'] : ''
));
$successMsg = '记录添加成功!';
// 添加滚动到列表的锚点(新记录排在最前,固定回到第 1 页)
header('Location: ' . $_SERVER['PHP_SELF'] . '?panel=ChangeLog/manage-panel.php&page=1' . $keywordParam . '#cl-list-anchor');
exit;
} catch (Exception $e) {
// 走到这里是插入前的校验失败或插入本身失败,数据并没有写入,
// 因此必须按"错误"提示,不能再显示成"已添加但有警告"
$errorMsg = htmlspecialchars($e->getMessage());
}
}
// 处理批量删除
if (!empty($_POST['delete_ids']) && is_array($_POST['delete_ids'])) {
$action->deleteEntries($_POST['delete_ids']);
$successMsg = '删除成功!';
// 添加滚动到列表的锚点
header('Location: ' . $_SERVER['PHP_SELF'] . '?panel=ChangeLog/manage-panel.php&page=' . $page . $keywordParam . '#cl-list-anchor');
exit;
}
// 处理编辑
if (!empty($_POST['edit_id'])) {
$action->updateEntry(array(
'edit_id' => $_POST['edit_id'],
'edit_content' => $_POST['edit_content'],
'edit_event_date' => changelogJoinDateTime(
isset($_POST['edit_event_date']) ? $_POST['edit_event_date'] : '',
isset($_POST['edit_event_time']) ? $_POST['edit_event_time'] : ''
),
'edit_post_cids' => isset($_POST['edit_post_cids']) ? $_POST['edit_post_cids'] : ''
));
$successMsg = '记录更新成功!';
// 添加滚动到列表的锚点
header('Location: ' . $_SERVER['PHP_SELF'] . '?panel=ChangeLog/manage-panel.php&page=' . $page . $keywordParam . '#cl-list-anchor');
exit;
}
// 处理导出
if (isset($_POST['export'])) {
$exportContent = $action->exportData();
$filename = 'changelog_' . date('Ymd_His') . '.txt';
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . strlen($exportContent));
echo $exportContent;
exit;
}
// 处理导入
if (isset($_POST['import']) && !empty($_FILES['import_file']['tmp_name'])) {
$fileContent = file_get_contents($_FILES['import_file']['tmp_name']);
$result = $action->importData($fileContent);
if ($result['imported'] > 0) {
$successMsg = '导入成功!成功导入 ' . $result['imported'] . ' 条记录';
if ($result['failed'] > 0) {
$successMsg .= ',失败 ' . $result['failed'] . ' 条记录';
// 显示失败原因(限制显示前10条)
if (!empty($result['fail_reasons'])) {
$errorDetails = '<strong>失败原因:</strong><br>';
$displayCount = min(10, count($result['fail_reasons']));
for ($i = 0; $i < $displayCount; $i++) {
$errorDetails .= htmlspecialchars($result['fail_reasons'][$i]) . '<br>';
}
if (count($result['fail_reasons']) > 10) {
$errorDetails .= '...还有 ' . (count($result['fail_reasons']) - 10) . ' 条失败记录';
}
$errorMsg = $errorDetails;
}
}
} else {
$errorMsg = '导入失败!未找到可导入的记录或格式不正确';
if (!empty($result['fail_reasons'])) {
$errorMsg .= '<br><strong>失败原因:</strong><br>';
$displayCount = min(10, count($result['fail_reasons']));
for ($i = 0; $i < $displayCount; $i++) {
$errorMsg .= htmlspecialchars($result['fail_reasons'][$i]) . '<br>';
}
}
}
}
}
// 获取记录
// 先数总数再查列表:搜索/删除后页码可能超界(比如停在第 5 页时搜到只有 1 页的关键词),
// 这里把页码夹回有效范围,避免看到「明明有记录却显示空列表」。
$total = $action->getTotalCount($keyword); // 搜索时为匹配条数,供分页用
$totalAll = $action->getTotalCount(); // 全库总数,统计卡片用(搜索时不该跟着变小)
$totalPages = max(1, (int) ceil($total / $perPage));
if ($page < 1) {
$page = 1;
} elseif ($page > $totalPages) {
$page = $totalPages;
}
$entries = $action->getEntries($page, $perPage, $keyword);
?>
<?php include 'header.php'; ?>
<?php include 'menu.php'; ?>
<style>
/* 基础重置 */
* {
box-sizing: border-box;
}
/* 浮动消息提示 */
.floating-message {
position: fixed;
top: 20px;
right: 20px;
z-index: 9999;
max-width: 350px;
opacity: 0;
transform: translateY(-20px);
transition: opacity 0.3s, transform 0.3s;
padding: 14px 20px;
border-radius: 6px;
border: 1px solid transparent;
font-size: 14px;
}
.floating-message.show {
opacity: 1;
transform: translateY(0);
}
.floating-message.success {
color: #0f5132;
background-color: #d1e7dd;
border-color: #badbcc;
}
.floating-message.error {
color: #842029;
background-color: #f8d7da;
border-color: #f5c2c7;
}
/* 表格样式 */
.data-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
margin: 0px 0;
font-size: 14px;
background-color: #fff;
border-radius: 6px;
overflow: hidden;
table-layout: fixed;
}
.data-table th,
.data-table td {
padding: 14px 12px;
border-bottom: 1px solid #f0f0f0;
text-align: left;
vertical-align: middle;
line-height: 1.4;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.data-table th {
background-color: #fafbfc;
font-weight: 600;
color: #333;
border-bottom: 2px solid #e0e0e0;
font-size: 14px;
}
.data-table tbody tr:hover {
background-color: #f8f9fa;
}
.data-table tbody tr:last-child td {
border-bottom: none;
}
/* 复选框列 */
.data-table th:first-child,
.data-table td:first-child {
text-align: center;
width: 50px;
min-width: 50px;
max-width: 50px;
padding: 14px 8px;
}
.data-table th:first-child input[type="checkbox"],
.data-table td:first-child input[type="checkbox"] {
margin: 0;
vertical-align: middle;
width: 16px;
height: 16px;
cursor: pointer;
}
/* ID列样式 - 固定宽度 */
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
text-align: center;
width: 70px;
min-width: 70px;
max-width: 70px;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
font-size: 13px;
color: #666;
white-space: nowrap;
}
/* 内容列 - 最大宽度,不换行 */
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
width: auto;
min-width: 250px;
max-width: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 事件时间列 - 固定宽度,不换行(日期 + 空格 + 时分秒,完整显示) */
.data-table th:nth-child(4),
.data-table td:nth-child(4) {
text-align: center;
width: 172px;
min-width: 172px;
max-width: 172px;
padding: 14px 8px;
font-size: 13px;
white-space: nowrap;
overflow: visible;
}
/* 发布时间列 - 固定宽度,不换行(日期 + 空格 + 时分秒,完整显示)- 修复:改为黑色 */
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
text-align: center;
width: 172px;
min-width: 172px;
max-width: 172px;
padding: 14px 8px;
font-size: 13px;
white-space: nowrap;
overflow: visible;
color: #000; /* 改为黑色 */
}
/* 文章关联列 - 固定宽度 */
.data-table th:nth-child(6),
.data-table td:nth-child(6) {
text-align: left; /* 改为左对齐,以便显示多个CID */
width: 180px; /* 增加宽度以便显示多个CID */
min-width: 180px;
max-width: 180px;
font-size: 13px;
white-space: normal; /* 允许多行显示 */
overflow: visible; /* 允许内容溢出 */
}
/* 操作列样式 */
.data-table th:last-child,
.data-table td:last-child {
text-align: center;
width: 80px;
min-width: 80px;
max-width: 80px;
padding: 14px 8px;
white-space: nowrap;
}
/* 日期样式 */
.date-badge {
display: inline-block;
background-color: #f0f7ff;
color: #0066cc;
padding: 4px 10px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
white-space: nowrap;
}
/* 发布时间样式 - 修复:改为普通黑色文字 */
.publish-time {
color: #000;
font-size: 13px;
}
/* CID徽章样式 */
.cid-badge {
display: inline-block;
background-color: #e8f5e8;
color: #2e7d32;
padding: 3px 8px;
margin: 2px;
border-radius: 3px;
font-size: 11px;
font-weight: 500;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
white-space: nowrap;
border: 1px solid #c8e6c9;
line-height: 1;
}
.cid-container {
display: flex;
flex-wrap: wrap; /* 允许多行显示 */
gap: 3px;
max-height: 60px;
overflow-y: auto;
}
.no-cid {
color: #999;
font-size: 12px;
font-style: italic;
}
/* 批量操作区域 */
.bulk-actions-header, .bulk-actions-footer {
padding: 15px;
background-color: #f8f9fa;
border: 1px solid #e0e0e0;
display: flex;
justify-content: space-between;
align-items: center;
}
.bulk-actions-footer {
border-top: none;
border-bottom: 2px solid #e0e0e0;
}
/* 2.0.10:表头改成三列 grid —— 左右各 1fr、中间 auto,
这样搜索框正好落在「已选择 N 条」和「删除选中」的正中间,
不受左右两块宽度差影响(flex + space-between 会偏)。 */
.bulk-actions-header {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 12px;
}
.bulk-actions-header > div:first-child {
justify-self: start;
}
.bulk-actions-header > div:last-child {
justify-self: end;
}
.cl-bulk-search {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 0;
}
/* 搜索无结果时表格不渲染,搜索框单独占一行 */
.cl-bulk-search--block {
padding: 0 15px 15px;
}
.cl-search-input {
width: 320px;
max-width: 100%;
height: 32px;
padding: 0 12px;
border: 1px solid #d0d5dd;
border-radius: 6px;
font-size: 13px;
color: #333;
background: #fff;
outline: none;
transition: border-color .15s, box-shadow .15s;
}
.cl-search-input:focus {
border-color: #2f80ed;
box-shadow: 0 0 0 3px rgba(47,128,237,.12);
}
.cl-search-input::placeholder {
color: #9aa5b1;
}
.cl-search-clear {
font-size: 12px;
color: #8a94a6;
text-decoration: none;
white-space: nowrap;
}
.cl-search-clear:hover {
color: #d9534f;
text-decoration: underline;
}
.cl-search-tip {
font-size: 12px;
font-weight: 400;
color: #8a94a6;
margin-left: 8px;
}
.cl-search-tip strong {
color: #2f80ed;
}
/* 模态框样式 */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #fff;
margin: 8% auto;
padding: 0;
border-radius: 8px;
width: 85%;
max-width: 500px;
box-shadow: 0 5px 25px rgba(0,0,0,0.15);
position: relative;
}
.close {
position: absolute;
right: 20px;
top: 18px;
font-size: 22px;
cursor: pointer;
color: #999;
background: none;
border: none;
padding: 0;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
}
.close:hover {
color: #333;
background-color: #f5f5f5;
}
.modal-header {
margin: 0;
padding: 20px 25px;
border-bottom: 1px solid #e0e0e0;
background-color: #fafbfc;
border-radius: 8px 8px 0 0;
}
.modal-header h3 {
margin: 0;
color: #333;
font-size: 16px;
font-weight: 600;
}
.modal-content form {
padding: 25px;
}
/* 分页样式 */
.pagination {
margin-top: 25px;
margin-bottom:25px;
text-align: center;
}
.pagination ul {
list-style: none;
padding: 0;
margin: 0;
display: inline-flex;
gap: 4px;
}
.pagination li {
display: inline;
}
.pagination a, .pagination span {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 8px 12px;
background-color: #fff;
color: #495057;
text-decoration: none;
border-radius: 4px;
border: 1px solid #dee2e6;
min-width: 36px;
height: 36px;
font-size: 13px;
}
.pagination a:hover {
background-color: #f8f9fa;
border-color: #dee2e6;
}
.pagination .active a, .pagination .active span {
background-color: #007bff;
color: white;
border-color: #007bff;
}
/* 消息提示 */
.message {
padding: 14px 20px;
margin: 18px 0;
border-radius: 6px;
border: 1px solid transparent;
font-size: 14px;
}
.message.success {
color: #0f5132;
background-color: #d1e7dd;
border-color: #badbcc;
}
.message.error {
color: #842029;
background-color: #f8d7da;
border-color: #f5c2c7;
}
/* 表单样式 */
.form-section {
background: #fff;
padding: 25px;
margin-bottom: 22px;
border-radius: 8px;
border: 1px solid #e0e0e0;
}
.form-section h2 {
margin-top: 0;
margin-bottom: 22px;
padding-bottom: 16px;
border-bottom: 1px solid #f0f0f0;
color: #333;
font-size: 18px;
font-weight: 600;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #555;
font-size: 14px;
}
.form-control {
width: 100%;
padding: 10px 14px;
border: 1px solid #ced4da;
border-radius: 4px;
font-size: 14px;
color: #333;
background-color: #fff;
}
.form-control:focus {
outline: none;
border-color: #80bdff;
box-shadow: 0 0 0 0.2rem rgba(0,123,255,.15);
}
textarea.form-control {
resize: vertical;
min-height: 100px;
}
.description {
font-size: 12px;
color: #6c757d;
margin-top: 6px;
}
/* 文章关联输入框样式 */
.post-cids-input-wrapper {
position: relative;
}
.post-cids-input {
width: 100%;
padding: 10px 12px;
border: 1px solid #ced4da;
border-radius: 4px;
font-size: 14px;
color: #333;
background-color: #fff;
}
.post-cids-input:focus {
outline: none;
border-color: #80bdff;
box-shadow: 0 0 0 0.2rem rgba(0,123,255,.15);
}
.post-cids-display {
margin-top: 8px;
font-size: 12px;
color: #6c757d;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 10px 18px;
font-size: 14px;
font-weight: 500;
text-align: center;
cursor: pointer;
border: 1px solid transparent;
border-radius: 4px;
height: 40px;
min-width: 80px;
}
.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.btn-primary:hover {
background-color: #0069d9;
border-color: #0062cc;
}
.btn-secondary {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
background-color: #5a6268;
border-color: #545b62;
}
.btn-danger {
color: #fff;
background-color: #dc3545;
border-color: #dc3545;
}
.btn-danger:hover {
background-color: #c82333;
border-color: #bd2130;
}
.btn-success {
color: #fff;
background-color: #28a745;
border-color: #28a745;
}
.btn-success:hover {
background-color: #218838;
border-color: #1e7e34;
}
.btn-info {
color: #fff;
background-color: #17a2b8;
border-color: #17a2b8;
}
.btn-info:hover {
background-color: #138496;
border-color: #117a8b;
}
.btn-sm {
padding: 6px 12px;
font-size: 12px;
height: 32px;
min-width: 60px;
}
.btn-group {
display: flex;
gap: 10px;
}
/* 主容器样式 */
.main {
padding: 50px 0;
min-height: calc(100vh - 60px);
}
.body.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
.typecho-page-title {
margin-bottom: 25px;
padding-bottom: 18px;
border-bottom: 1px solid #e0e0e0;
}
.typecho-page-title h1 {
margin: 0;
color: #333;
font-size: 24px;
font-weight: 600;
}
/* 全宽布局 */
.typecho-page-main {
display: block;
width: 100%;
}
.table-section {
background: #fff;
padding: 0;
border-radius: 8px;
border: 1px solid #e0e0e0;
margin-bottom: 22px;
overflow: hidden;
}
.table-section h2 {
margin: 0;
padding: 20px 25px;
border-bottom: 1px solid #f0f0f0;
color: #333;
font-size: 18px;
font-weight: 600;
}
/* 统计信息盒子 */
.stats-box {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
padding: 22px;
border-radius: 8px;
margin-bottom: 22px;
border: 1px solid #dee2e6;
}
.stats-box h3 {
margin-top: 0;
margin-bottom: 18px;
color: #495057;
font-size: 16px;
font-weight: 600;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.stat-item {
background: white;
padding: 18px;
border-radius: 6px;
border-left: 4px solid #007bff;
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-item .label {
font-size: 12px;
color: #6c757d;
margin-bottom: 6px;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 500;
}
.stat-item .value {
font-size: 20px;
font-weight: 600;
color: #343a40;
}
/* 导入导出样式 */
.import-export-section {
margin-bottom: 22px;
border-radius: 8px;
}
.import-export-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 22px;
margin-bottom: 22px;
}
.import-box, .export-box {
background: #f8f9fa;
padding: 22px;
border-radius: 6px;
border: 1px solid #dee2e6;
}
.import-box h4, .export-box h4 {
margin-top: 0;
margin-bottom: 16px;
color: #495057;
font-size: 15px;
font-weight: 600;
}
.format-example {
background: #fff;
padding: 16px;
border-radius: 6px;
border-left: 3px solid #007bff;
margin-top: 18px;
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
font-size: 13px;
}
.format-example pre {
margin: 0;
white-space: pre-wrap;
font-size: 12px;
}
.format-example code {
color: #e83e8c;
font-family: inherit;
font-size: 12px;
}
.format-example strong {
color: #333;
font-weight: 600;
margin-bottom: 8px;
display: block;
}
/* 锚点定位样式 */
.anchor-target {
scroll-margin-top: 20px;
}
/* 响应式设计 */
@media (max-width: 768px) {
.body.container {
padding: 0 15px;
}
.import-export-grid {
grid-template-columns: 1fr;
}
.bulk-actions-header, .bulk-actions-footer {
flex-direction: column;
gap: 10px;
}
/* 2.0.10:窄屏下 search 的 grid 三列会挤,改回纵向堆叠、搜索框占满一行 */
.bulk-actions-header {
display: flex;
}
.bulk-actions-header > div:first-child,
.bulk-actions-header > div:last-child {
justify-self: auto;
}
.cl-bulk-search {
width: 100%;
}
.cl-search-input {
width: 100%;
}
.floating-message {
left: 20px;
right: 20px;
max-width: none;
}
/* 响应式调整关联文章列 */
.data-table th:nth-child(6),
.data-table td:nth-child(6) {
width: 140px;
min-width: 140px;
max-width: 140px;
}
}
/* ===================================================================
ChangeLog 后台深浅色适配 —— 更新日志管理页
配色、层级、兜底思路全部对齐 UrlNav / Memo 插件(#newadmin.dark 一套值)。
原则和它们一致:浅色一律保持插件原样,只在 #newadmin.dark 下逐条覆盖
深色值;规则都带 #newadmin 前缀且放在本文件最末,能稳定压过上面所有
原始配色。class 由 NewAdmin 的 Alpine 实时切换
(<div id="newadmin" :class="{'dark':$store.ze.dark}">),点右上角
☀ / 🌙 立即生效、不用刷新,全站后台页面共用同一个 cookie。
=================================================================== */
/* ---------- 顶部工具条层级修复(浅色深色都要) ----------
后台右侧顶部的 ☀ / 🌙 在 .newadmin 里,它默认只有 z-index:20,
本页任何 z-index 大于 20 的浮层都会盖住它、导致点不动:
· .floating-message 固定 9999 且贴 top:20/right:20,正好压在按钮上;
· .modal 是 1000,弹窗遮罩会把工具条一起罩住。
这套取值照抄 UrlNav / Memo:工具条 9000 → 弹窗 10000 → 提示条 99999,
遮罩/侧栏顺带抬到 9010/9020,保持"遮罩 < 侧栏"的原有关系。 */
#newadmin > .newadmin{ z-index:9000; }
#newadmin > .zhezhao{ z-index:9010; }
#newadmin > .side{ z-index:9020; }
/* 弹窗必须高于工具条,否则遮罩盖不住顶部(原来 1000 会被 9000 反压) */
#newadmin .modal{ z-index:10000; }
/* 浮动提示条:层级抬到工具条之上,但往下挪到工具条下方,
不再贴 top:20px 压住 ☀ / 🌙 切换按钮(注意 #newadmin 的
.newadmin 是 position:sticky;top:20px,高度约 56px)。 */
#newadmin .floating-message{ z-index:99999; top:84px; }
/* ---------- 深色基础 ----------
给 #newadmin.dark 打上 color-scheme:dark,一次性解决 date 控件、
checkbox、滚动条(CID 容器 / 弹窗内容 / 文件选择框)等原生控件的
深浅色,省得一条条挑。 */
#newadmin.dark{ color-scheme:dark; }
/* ---------- 统计信息盒子 ---------- */
#newadmin.dark .stats-box{
/* 原样式是 linear-gradient 渐变,这里必须用 background 简写才能
一并抹掉渐变图,只写 background-color 会被渐变盖住 */
background:#17212f;
border-color:#2b3a4d;
}
#newadmin.dark .stats-box h3{ color:#e6edf3; }
#newadmin.dark .stat-item{
background:#17212f;
border-left-color:#4e92e3;
box-shadow:0 1px 3px rgba(0,0,0,.35);
}
#newadmin.dark .stat-item .label{ color:#9cb0c6; }
#newadmin.dark .stat-item .value{ color:#e6edf3; }
/* ---------- 徽章 ---------- */
#newadmin.dark .date-badge{
background:rgba(78,146,227,.16);
color:#8bbcf5;
}
#newadmin.dark .publish-time{ color:#c3d1de; }
#newadmin.dark .cl-id{ color:#9cb0c6; }
#newadmin.dark .cid-badge{
background:rgba(40,167,69,.16);
border-color:rgba(40,167,69,.4);
color:#57d17a;
}
#newadmin.dark .no-cid{ color:#6b7684; }
/* ---------- 导入 / 导出卡片 ---------- */
#newadmin.dark .import-box,
#newadmin.dark .export-box{
background:#17212f;
border-color:#2b3a4d;
}
#newadmin.dark .import-box h4,
#newadmin.dark .export-box h4{ color:#e6edf3; }
#newadmin.dark .format-example{
background:#101a26;
border-left-color:#4e92e3;
color:#c3d1de;
}
#newadmin.dark .format-example pre{
/* main.css 给全局 pre 写死了 background:#3a3a3a(后台自带代码块底色),
浅色深色都用它;深色下跟本块 #101a26 的内嵌底撞在一起显脏,这里抹平 */
background:transparent;
color:#c3d1de;
}
#newadmin.dark .format-example code{ color:#f28cb4; }
#newadmin.dark .format-example strong{ color:#e6edf3; }
#newadmin.dark .description{ color:#9cb0c6; }
#newadmin.dark .post-cids-display{ color:#9cb0c6; }
/* ---------- 发布表单 ---------- */
#newadmin.dark .form-section{
background:#17212f;
border-color:#2b3a4d;
}
#newadmin.dark .form-section h2{
color:#e6edf3;
border-bottom-color:#23303f;
}
#newadmin.dark .form-group label{ color:#c3d1de; }
#newadmin.dark .form-control,
#newadmin.dark .post-cids-input,
#newadmin.dark input[type="date"].form-control{
background-color:#1a2634;
border-color:#2b3a4d;
color:#e6edf3;
}
#newadmin.dark .form-control::placeholder{ color:#6b7684; }
#newadmin.dark .form-control:focus,
#newadmin.dark .post-cids-input:focus{
border-color:#4e92e3;
box-shadow:0 0 0 0.2rem rgba(78,146,227,.25);
outline:none;
}
#newadmin.dark input[type="checkbox"]{ accent-color:#4e92e3; }
#newadmin.dark input[type="file"].form-control{ color:#c3d1de; }
/* ---------- 按钮 ---------- */
#newadmin.dark .btn{
background:#17212f;
border-color:#2b3a4d;
color:#e6edf3;
}
#newadmin.dark .btn:hover{ background:#1c2a3b; color:#e6edf3; }
#newadmin.dark .btn-primary,
#newadmin.dark .btn-primary:hover{
background:#4e92e3;
border-color:#4e92e3;
color:#fff;
}
#newadmin.dark .btn-primary:hover{ background:#3f80cf; border-color:#3f80cf; }
#newadmin.dark .btn-secondary{ background:#2b3a4d; border-color:#3a4a5e; color:#e6edf3; }
#newadmin.dark .btn-secondary:hover{ background:#34465c; border-color:#445870; color:#e6edf3; }
#newadmin.dark .btn-success,
#newadmin.dark .btn-success:hover{ background:#1e7e34; border-color:#1e7e34; color:#fff; }
#newadmin.dark .btn-success:hover{ background:#17702c; border-color:#17702c; }
#newadmin.dark .btn-danger,
#newadmin.dark .btn-danger:hover{ background:#c0392b; border-color:#c0392b; color:#fff; }
#newadmin.dark .btn-danger:hover{ background:#a93226; border-color:#a93226; }
#newadmin.dark .btn-info,
#newadmin.dark .btn-info:hover{ background:#12808f; border-color:#12808f; color:#fff; }
#newadmin.dark .btn-info:hover{ background:#0f6d79; border-color:#0f6d79; }
/* ---------- 更新记录列表 ---------- */
#newadmin.dark .table-section{
background:#17212f;
border-color:#2b3a4d;
}
#newadmin.dark .table-section h2{
color:#e6edf3;
border-bottom-color:#23303f;
}
#newadmin.dark .message.info{ color:#9cb0c6; }
/* ---------- 表格 ---------- */
#newadmin.dark .data-table{ background-color:transparent; }
#newadmin.dark .data-table th{
background-color:#1f2937;
color:#c3d1de;
border-bottom-color:#23303f;
}
#newadmin.dark .data-table td{
border-bottom-color:#23303f;
color:#e6edf3;
}
#newadmin.dark .data-table td:nth-child(2){ color:#9cb0c6; }
#newadmin.dark .data-table tbody tr:hover{ background-color:#1c2a3b; }
/* ---------- 批量操作 / 分页 ---------- */
#newadmin.dark .bulk-actions-header,
#newadmin.dark .bulk-actions-footer{
background-color:#1f2937;
border-color:#23303f;
}
#newadmin.dark .bulk-actions-footer{
border-bottom-color:#23303f;
border-top-color:#23303f;
}
#newadmin.dark .selected-info{ color:#9cb0c6; }
#newadmin.dark .cl-search-input{
background-color:#17212f;
border-color:#2b3a4d;
color:#e6edf5;
}
#newadmin.dark .cl-search-input::placeholder{ color:#7a8a9c; }
#newadmin.dark .cl-search-input:focus{
border-color:#ff8a5c;
box-shadow:0 0 0 3px rgba(255,138,92,.16);
}
#newadmin.dark .cl-search-clear{ color:#9cb0c6; }
#newadmin.dark .cl-search-clear:hover{ color:#ff9d6e; }
#newadmin.dark .cl-search-tip{ color:#9cb0c6; }
#newadmin.dark .cl-search-tip strong{ color:#ff9d6e; }
#newadmin.dark .pagination a,
#newadmin.dark .pagination span{
background-color:#17212f;
border-color:#2b3a4d;
color:#c3d1de;
}
#newadmin.dark .pagination a:hover{
background-color:#1c2a3b;
border-color:#31404f;
color:#e6edf3;
}
#newadmin.dark .pagination .active a,
#newadmin.dark .pagination .active span{
background-color:#4e92e3;
border-color:#4e92e3;
color:#fff;
}
/* ---------- 编辑弹窗 ---------- */
#newadmin.dark .modal{ background-color:rgba(0,0,0,.6); }
#newadmin.dark .modal-content{
background-color:#17212f;
color:#e6edf3;
border:1px solid #2b3a4d;
box-shadow:0 12px 40px rgba(0,0,0,.5);
}
#newadmin.dark .modal-header{
background-color:#1f2937;
border-bottom-color:#2b3a4d;
}
#newadmin.dark .modal-header h3{ color:#e6edf3; }
#newadmin.dark .close{ color:#9cb0c6; }
#newadmin.dark .close:hover{ color:#e6edf3; background-color:#1c2a3b; }
/* ---------- 提示条 ---------- */
#newadmin.dark .floating-message.success,
#newadmin.dark .message.success{
background-color:rgba(40,167,69,.16);
border-color:rgba(40,167,69,.45);
color:#57d17a;
}
#newadmin.dark .floating-message.error,
#newadmin.dark .message.error{
background-color:rgba(220,53,69,.16);
border-color:rgba(220,53,69,.45);
color:#ff8b95;
}
/* ---------- 内联样式兜底 ----------
本页 HTML 里有大量写死的 style="color:#000" / "color: #666" /
"border-top: 1px solid #eee" 之类(导出说明、"全选本页"标签、
内容预览、弹窗按钮栏),改类名成本高还容易漏,这里按属性选择器兜一层。
只在深色下生效,浅色保持原样;必须带 !important 才能压过内联声明。
空格有/无两种写法都要写,因为源码里两种混着用。 */
#newadmin.dark [style*="color:#000"],
#newadmin.dark [style*="color: #000"],
#newadmin.dark [style*="color:#333"],
#newadmin.dark [style*="color: #333"]{ color:#e6edf3!important; }
#newadmin.dark [style*="color:#666"],
#newadmin.dark [style*="color: #666"],
#newadmin.dark [style*="color:#999"],
#newadmin.dark [style*="color: #999"],
#newadmin.dark [style*="color:#6c757d"],
#newadmin.dark [style*="color: #6c757d"]{ color:#9cb0c6!important; }
#newadmin.dark [style*="color:#495057"],
#newadmin.dark [style*="color: #495057"]{ color:#c3d1de!important; }
#newadmin.dark [style*="border-top: 1px solid #eee"],
#newadmin.dark [style*="border-top:1px solid #eee"],
#newadmin.dark [style*="border-top: 1px solid #f0f0f0"],
#newadmin.dark [style*="border-top:1px solid #f0f0f0"]{ border-top-color:#23303f!important; }
</style>
<div class="main">
<div class="body container">
<!-- 浮动消息提示 -->
<?php if (isset($successMsg)): ?>
<div id="floatingMessage" class="floating-message success show">
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
<div style="flex-grow: 1;">
<strong>✓ 成功</strong>
<div style="margin-top: 5px;"><?php echo $successMsg; ?></div>
</div>
<button type="button" onclick="hideMessage()" style="background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; margin-left: 10px; padding: 0 5px;">&times;</button>
</div>
</div>
<?php endif; ?>
<?php if (isset($errorMsg)): ?>
<div id="floatingMessage" class="floating-message error show">
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
<div style="flex-grow: 1;">
<strong>✗ 错误</strong>
<div style="margin-top: 5px;"><?php echo $errorMsg; ?></div>
</div>
<button type="button" onclick="hideMessage()" style="background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; margin-left: 10px; padding: 0 5px;">&times;</button>
</div>
</div>
<?php endif; ?>
<div class="typecho-page-main" role="main">
<!-- 统计信息 -->
<div class="stats-box">
<div class="stats-grid">
<div class="stat-item">
<div class="label">总记录数</div>
<div class="value"><?php echo $totalAll; ?> 条</div>
</div>
<div class="stat-item">
<div class="label">当前页数</div>
<div class="value"><?php echo $page; ?> / <?php echo $totalPages; ?></div>
</div>
<div class="stat-item">
<div class="label">每页显示</div>
<div class="value"><?php echo $perPage; ?> 条</div>
</div>
</div>
</div>
<!-- 导入导出功能 -->
<div class="import-export-section">
<div class="import-export-grid">
<!-- 导出功能 -->
<div class="export-box">
<h4>导出数据</h4>
<p style="margin-bottom: 15px;color:#000;">导出所有更新记录为文本文件格式</p>
<form method="post" action="">
<input type="hidden" name="action" value="changelog">
<button type="submit" name="export" class="btn btn-success">
导出为 TXT 文件
</button>
</form>
<div class="format-example">
<strong>导出格式示例:</strong>
<pre>2025.12.21 10:30:00 网站正式上线
2025.12.25 14:05:12 新增用户注册功能
2025.12.28 09:18:46 优化了网站性能</pre>
</div>
</div>
<!-- 导入功能 -->
<div class="import-box">
<h4>导入数据</h4>
<p style="margin-bottom: 15px;color:#000;">从文本文件导入更新记录</p>
<form method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="action" value="changelog">
<div class="form-group" style="margin-bottom: 15px;">
<label for="import_file">选择文件</label>
<input type="file" id="import_file" name="import_file" class="form-control" required accept=".txt,.text">
<p class="description">支持 .txt 文本文件格式</p>
</div>
<button type="submit" name="import" class="btn btn-info">
导入 TXT 文件
</button>
</form>
<div class="format-example">
<strong>导入格式要求:</strong>
<pre>每行一条记录,格式为:<code>日期 [时分秒] 内容</code>
日期格式:YYYY.M[M].D[D](支持单数字月份和日期)
时分秒可省略,省略时按 00:00:00 处理
例如:<code>2023.12.9 网站更新</code>
例如:<code>2023.8.8 新功能上线</code>
例如:<code>2023.8.8 10:30:00 新功能上线</code></pre>
<p style="margin-top: 10px; font-size: 12px; color: #666;">
提示:请确保文件编码为 UTF-8,每行一条记录
</p>
</div>
</div>
</div>
</div>
<!-- 发布表单 -->
<div class="form-section">
<h2>发布新日志</h2>
<!-- 修复:表单action设为空字符串,提交到当前页面 -->
<form method="post" action="" id="publishForm">
<div class="form-group">
<label for="content">内容 *</label>
<textarea id="content" name="content" class="form-control" rows="4" required
placeholder="请输入详细网站更新日志内容"></textarea>
</div>
<div class="form-group">
<label for="event_date">日期 *</label>
<div class="btn-group">
<input type="date" id="event_date" name="event_date" class="form-control"
value="<?php echo date('Y-m-d'); ?>" required>
<input type="time" id="event_time" name="event_time" class="form-control"
step="1" style="width:140px;flex:0 0 140px;"
value="<?php echo date('H:i:s'); ?>" title="时分秒">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('event_date').value = '<?php echo date('Y-m-d'); ?>'">
今天
</button>
</div>
</div>
<div class="form-group">
<label for="post_cids">关联文章CID(可选)</label>
<div class="post-cids-input-wrapper">
<input type="text" id="post_cids" name="post_cids" class="form-control post-cids-input"
placeholder="输入文章CID,多个用逗号分隔,如:123,456">
</div>
<p class="description post-cids-display">
可关联多个文章,输入文章CID,用逗号分隔
</p>
</div>
<div style="text-align: center;">
<button type="reset" class="btn btn-secondary" style="margin-right: 10px;">重置</button>
<button type="submit" class="btn btn-primary" id="publishBtn">发布</button>
</div>
</form>
</div>
<!-- 锚点目标,用于滚动定位 -->
<div id="cl-list-anchor" class="anchor-target"></div>
<!-- 更新记录列表 -->
<div class="table-section">
<h2>
更新记录列表
<?php if ($keyword !== ''): ?>
<span class="cl-search-tip">
搜索「<?php echo htmlspecialchars($keyword, ENT_QUOTES, 'UTF-8'); ?>」· 匹配 <strong><?php echo $total; ?></strong> 条
</span>
<?php endif; ?>
</h2>
<?php if (empty($entries)): ?>
<?php if ($keyword !== ''): ?>
<?php echo changelogSearchBox($keyword, $panelPath, true); ?>
<div class="message info" style="text-align: center; padding: 30px;">
没有找到包含「<?php echo htmlspecialchars($keyword, ENT_QUOTES, 'UTF-8'); ?>」的记录,
<a href="<?php echo htmlspecialchars($panelPath, ENT_QUOTES, 'UTF-8'); ?>?panel=ChangeLog/manage-panel.php#cl-list-anchor">查看全部记录</a>
</div>
<?php else: ?>
<div class="message info" style="text-align: center; padding: 30px;">
暂无更新记录,请先添加记录
</div>
<?php endif; ?>
<?php else: ?>
<form method="post" action="" id="mainForm">
<!-- 表头多选操作栏 -->
<div class="bulk-actions-header">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="display: flex; align-items: center;">
<input type="checkbox" id="header-select-all" style="margin: 0; width: 16px; height: 16px;">
<label for="header-select-all" style="color:#000;margin-left: 8px; font-weight: 500; font-size: 14px;">
全选本页
</label>
</div>
<div class="selected-info">
<span class="description">
已选择 <strong id="selected-count-text">0</strong> 条记录
</span>
</div>
</div>
<!-- 2.0.10:记录搜索,居中放在「已选择」与「删除选中」之间 -->
<?php echo changelogSearchBox($keyword, $panelPath); ?>
<div>
<button type="button" id="header-delete-btn" class="btn btn-danger btn-sm">
删除选中
</button>
</div>
</div>
<table class="data-table">
<thead>
<tr>
<th>
<input type="checkbox" id="thead-select-all" title="全选/全不选">
</th>
<th>ID</th>
<th>内容</th>
<th>更新时间</th>
<th>发布时间</th>
<th>文章关联</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($entries as $entry):
$cids = !empty($entry['post_cids']) ? explode(',', $entry['post_cids']) : array();
?>
<tr>
<td>
<input type="checkbox" name="delete_ids[]" value="<?php echo $entry['id']; ?>" class="row-checkbox">
</td>
<td>
<span class="cl-id">#<?php echo $entry['id']; ?></span>
</td>
<td title="<?php echo htmlspecialchars($entry['content']); ?>">
<div style="font-size: 13px; color: #333; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
<?php echo htmlspecialchars($entry['content']); ?>
</div>
</td>
<td>
<span class="date-badge">
<?php echo changelogFormatDateTime($entry['event_date']); ?>
</span>
</td>
<td>
<!-- 修复:发布时间改为黑色普通文字 -->
<span class="publish-time">
<?php echo changelogFormatDateTime($entry['created']); ?>
</span>
</td>
<td>
<?php if (!empty($cids)): ?>
<div class="cid-container">
<?php foreach ($cids as $cid):
$cid = trim($cid);
if (!empty($cid)): ?>
<span class="cid-badge" title="文章CID: <?php echo $cid; ?>">
<?php echo $cid; ?>
</span>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php else: ?>
<span class="no-cid">-</span>
<?php endif; ?>
</td>
<td>
<button type="button" class="btn btn-sm btn-primary edit-btn"
data-entry='<?php echo htmlspecialchars(json_encode($entry), ENT_QUOTES, 'UTF-8'); ?>'
style="padding: 4px 10px; font-size: 12px;">
编辑
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- 表尾多选操作栏 -->
<div class="bulk-actions-footer">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="display: flex; align-items: center;">
<input type="checkbox" id="footer-select-all" style="margin: 0; width: 16px; height: 16px;">
<label for="footer-select-all" style="color:#000;margin-left: 8px; font-weight: 500; font-size: 14px;">
全选本页
</label>
</div>
<div class="selected-info">
<span class="description">
已选择 <strong id="footer-selected-count">0</strong> 条记录
</span>
</div>
</div>
<div>
<button type="button" id="footer-delete-btn" class="btn btn-danger btn-sm">
删除选中
</button>
</div>
</div>
<!-- 隐藏的提交按钮 -->
<input type="submit" id="hidden-submit" style="display: none;">
</form>
<!-- 分页 -->
<?php if ($totalPages > 1): ?>
<div class="pagination">
<ul>
<?php if ($page > 1): ?>
<li><a href="?panel=ChangeLog/manage-panel.php&page=<?php echo $page-1; ?><?php echo $keywordParam; ?>#cl-list-anchor">&laquo; 上一页</a></li>
<?php endif; ?>
<?php
$start = max(1, $page - 2);
$end = min($totalPages, $page + 2);
if ($start > 1) {
echo '<li><a href="?panel=ChangeLog/manage-panel.php&page=1' . $keywordParam . '#cl-list-anchor">1</a></li>';
if ($start > 2) echo '<li><span>...</span></li>';
}
for ($i = $start; $i <= $end; $i++): ?>
<li <?php if ($i == $page) echo 'class="active"'; ?>>
<a href="?panel=ChangeLog/manage-panel.php&page=<?php echo $i; ?><?php echo $keywordParam; ?>#cl-list-anchor"><?php echo $i; ?></a>
</li>
<?php endfor; ?>
<?php if ($end < $totalPages): ?>
<?php if ($end < $totalPages - 1): ?>
<li><span>...</span></li>
<?php endif; ?>
<li><a href="?panel=ChangeLog/manage-panel.php&page=<?php echo $totalPages; ?><?php echo $keywordParam; ?>#cl-list-anchor"><?php echo $totalPages; ?></a></li>
<?php endif; ?>
<?php if ($page < $totalPages): ?>
<li><a href="?panel=ChangeLog/manage-panel.php&page=<?php echo $page+1; ?><?php echo $keywordParam; ?>#cl-list-anchor">下一页 &raquo;</a></li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!-- 编辑模态框 -->
<div id="editModal" class="modal" style="display:none;">
<div class="modal-content">
<button type="button" class="close" onclick="closeModal()">&times;</button>
<div class="modal-header">
<h3>编辑更新记录</h3>
</div>
<form id="editForm" method="post" action="">
<div class="form-group">
<label for="edit_content">内容 *</label>
<textarea id="edit_content" name="edit_content" class="form-control" rows="5" required></textarea>
</div>
<div class="form-group">
<label for="edit_event_date">日期 *</label>
<div class="btn-group">
<input type="date" id="edit_event_date" name="edit_event_date" class="form-control" required>
<input type="time" id="edit_event_time" name="edit_event_time" class="form-control"
step="1" style="width:140px;flex:0 0 140px;" title="时分秒">
</div>
</div>
<div class="form-group">
<label for="edit_post_cids">关联文章CID(可选)</label>
<div class="post-cids-input-wrapper">
<input type="text" id="edit_post_cids" name="edit_post_cids" class="form-control post-cids-input"
placeholder="输入文章CID,多个用逗号分隔,如:123,456">
</div>
<p class="description post-cids-display">
可关联多个文章,输入文章CID,用逗号分隔
</p>
</div>
<input type="hidden" name="edit_id" id="edit_id">
<div style="text-align:right;margin-top:20px; padding-top: 15px; border-top: 1px solid #eee;">
<button type="button" class="btn btn-secondary" onclick="closeModal()" style="margin-right:10px;">
取消
</button>
<button type="submit" class="btn btn-primary">保存修改</button>
</div>
</form>
</div>
</div>
<script>
/* 记录搜索(2.0.10)
不走 form 提交:搜索框位于 #mainForm 内部,一旦真的 submit 就会连带提交
delete_ids(勾选中的记录),造成误删。这里统一拼 URL 跳转。 */
(function () {
var base = <?php echo json_encode($panelPath, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>
+ '?panel=ChangeLog/manage-panel.php';
function go(input) {
var kw = input && input.value ? input.value.replace(/^\s+|\s+$/g, '') : '';
window.location.href = base + (kw === '' ? '' : '&q=' + encodeURIComponent(kw)) + '#cl-list-anchor';
}
function bind() {
var inputs = document.querySelectorAll('.cl-search-input');
Array.prototype.forEach.call(inputs, function (input) {
// 回车:拦下默认的「提交表单」行为
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.keyCode === 13) {
e.preventDefault();
e.stopPropagation();
go(input);
}
});
var box = input.parentNode;
var btn = box ? box.querySelector('.cl-search-btn') : null;
if (btn) {
btn.addEventListener('click', function () {
go(input);
});
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', bind);
} else {
bind();
}
})();
// 页面加载后自动滚动到锚点
document.addEventListener('DOMContentLoaded', function() {
if (window.location.hash === '#cl-list-anchor') {
setTimeout(function() {
var anchor = document.getElementById('cl-list-anchor');
if (anchor) {
anchor.scrollIntoView({ behavior: 'smooth' });
}
}, 100);
}
// 自动隐藏浮动消息
var floatingMessage = document.getElementById('floatingMessage');
if (floatingMessage) {
setTimeout(function() {
hideMessage();
}, 5000);
}
});
// 隐藏浮动消息
function hideMessage() {
var message = document.getElementById('floatingMessage');
if (message) {
message.classList.remove('show');
setTimeout(function() {
if (message.parentNode) {
message.parentNode.removeChild(message);
}
}, 300);
}
}
// 更新选中数量函数
function updateSelectedCount() {
var checkboxes = document.querySelectorAll('.row-checkbox:checked');
var count = checkboxes.length;
// 搜索无结果时表格整块不渲染,这些节点不存在,判空后再写
var selectedText = document.getElementById('selected-count-text');
var footerSelectedText = document.getElementById('footer-selected-count');
var headerBtn = document.getElementById('header-delete-btn');
var footerBtn = document.getElementById('footer-delete-btn');
if (selectedText) { selectedText.textContent = count; }
if (footerSelectedText) { footerSelectedText.textContent = count; }
if (!headerBtn || !footerBtn) { return count; }
if (count > 0) {
headerBtn.textContent = '删除选中(' + count + ')';
footerBtn.textContent = '删除选中(' + count + ')';
} else {
headerBtn.textContent = '删除选中';
footerBtn.textContent = '删除选中';
}
var allCheckboxes = document.querySelectorAll('.row-checkbox');
var headerCheckboxes = document.querySelectorAll('#header-select-all, #thead-select-all, #footer-select-all');
if (allCheckboxes.length > 0) {
var allChecked = count === allCheckboxes.length;
var someChecked = count > 0 && count < allCheckboxes.length;
headerCheckboxes.forEach(function(checkbox) {
checkbox.checked = allChecked;
checkbox.indeterminate = someChecked;
});
}
return count;
}
// 全选/全不选功能
function setupSelectAll(selector, targetSelector) {
var selectAll = document.querySelector(selector);
if (selectAll) {
selectAll.addEventListener('change', function(e) {
var checkboxes = document.querySelectorAll(targetSelector);
checkboxes.forEach(function(checkbox) {
checkbox.checked = e.target.checked;
});
updateSelectedCount();
});
}
}
// 为行复选框添加事件监听
function setupRowCheckboxes() {
var checkboxes = document.querySelectorAll('.row-checkbox');
checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', updateSelectedCount);
});
}
// 统一的删除确认函数
function confirmDelete() {
var checkboxes = document.querySelectorAll('.row-checkbox:checked');
var count = checkboxes.length;
if (count === 0) {
alert('请先选择要删除的记录!');
return false;
}
var confirmMsg = '确定要删除选中的 ' + count + ' 条记录吗?此操作不可恢复!';
if (!confirm(confirmMsg)) {
return false;
}
document.getElementById('hidden-submit').click();
return true;
}
// 初始化选择功能
document.addEventListener('DOMContentLoaded', function() {
setupSelectAll('#header-select-all', '.row-checkbox');
setupSelectAll('#thead-select-all', '.row-checkbox');
setupSelectAll('#footer-select-all', '.row-checkbox');
setupRowCheckboxes();
var headerDeleteBtn = document.getElementById('header-delete-btn');
var footerDeleteBtn = document.getElementById('footer-delete-btn');
if (headerDeleteBtn) {
headerDeleteBtn.addEventListener('click', function(e) {
e.preventDefault();
confirmDelete();
});
}
if (footerDeleteBtn) {
footerDeleteBtn.addEventListener('click', function(e) {
e.preventDefault();
confirmDelete();
});
}
updateSelectedCount();
});
// 编辑更新记录
document.addEventListener('DOMContentLoaded', function() {
var editButtons = document.querySelectorAll('.edit-btn');
editButtons.forEach(function(button) {
button.addEventListener('click', function() {
try {
var entryData = JSON.parse(this.getAttribute('data-entry'));
editEntry(entryData);
} catch (e) {
console.error('解析更新记录数据失败:', e);
alert('编辑失败:数据格式错误');
}
});
});
});
function editEntry(entry) {
document.getElementById('edit_id').value = entry.id;
document.getElementById('edit_content').value = entry.content;
// event_date 现在是 "Y-m-d H:i:s",直接按字符串拆分,
// 避免 new Date() 在不同浏览器/时区下解析结果不一致
var raw = (entry.event_date || '').replace('T', ' ');
var datePart = raw.split(' ')[0] || '';
var timePart = raw.split(' ')[1] || '00:00:00';
document.getElementById('edit_event_date').value = datePart;
document.getElementById('edit_event_time').value = timePart;
document.getElementById('edit_post_cids').value = entry.post_cids || '';
document.getElementById('editModal').style.display = 'block';
}
// 关闭模态框
function closeModal() {
document.getElementById('editModal').style.display = 'none';
}
// 点击模态框外部关闭
window.onclick = function(event) {
var modal = document.getElementById('editModal');
if (event.target == modal) {
closeModal();
}
}
// 表单验证
document.querySelectorAll('form').forEach(function(form) {
if (form.querySelector('button[name="export"]')) return;
form.addEventListener('submit', function(e) {
var requiredFields = form.querySelectorAll('[required]');
var valid = true;
requiredFields.forEach(function(field) {
if (!field.value.trim()) {
valid = false;
field.style.borderColor = '#dc3545';
field.style.boxShadow = '0 0 0 0.2rem rgba(220,53,69,.25)';
} else {
field.style.borderColor = '#ced4da';
field.style.boxShadow = 'none';
}
});
if (!valid) {
e.preventDefault();
alert('请填写所有必填字段!');
}
});
});
// 导入文件验证
var importForm = document.querySelector('form[enctype="multipart/form-data"]');
if (importForm) {
importForm.addEventListener('submit', function(e) {
var fileInput = document.getElementById('import_file');
if (fileInput.files.length === 0) {
e.preventDefault();
alert('请选择要导入的文件!');
return;
}
var file = fileInput.files[0];
if (file.size > 5 * 1024 * 1024) {
e.preventDefault();
alert('文件大小不能超过5MB!');
return;
}
if (!file.name.toLowerCase().endsWith('.txt')) {
if (!confirm('文件不是.txt格式,确定要导入吗?')) {
e.preventDefault();
}
}
});
}
</script>
<script>
/* ===================================================================
深浅色联动:让右上角 ☀ / 🌙 切换的是"整套后台",而不是只切本页
背景:NewAdmin 的深浅色其实是两套互相独立的机制
1) #newadmin 上的 .dark 类(Alpine 的 $store.ze.dark 驱动)
2) <link id="darkcss"> 这条深色样式表(它才是真正把侧栏、顶栏、
页面底色整体换成深色的那一套)
点按钮时 NewAdmin 会先改 ①,再在 document.startViewTransition 的
回调里异步改 ②。只要这两步有一次没对上,就会出现"插件页面(跟着
① 走)变深色、整套后台(跟着 ② 走)还是浅色"的现象,而且在
cookie 不存在时 NewAdmin 的 x-init 会把 store 设成字符串 'light'
(真值),一进页面就是反相的,之后再点也是一直反着切。
本脚本不改 NewAdmin 的代码,只在本页把 ①② 和 cookie 三个状态
收口,谁先变都以最终目标值为准,因此不会和 NewAdmin 打架。
没有装 NewAdmin 时(取不到 #newadmin / #darkcss)直接不介入。
与 Memo 插件用的是同一套实现。
=================================================================== */
(function () {
var box = document.getElementById('newadmin');
var link = document.getElementById('darkcss');
if (!box || !link) { return; }
/* pinned=false:还只是"进页面时的被动对齐",不写 cookie。
否则首次访问会被强行钉成浅色,NewAdmin 原本"没 cookie 就跟随
系统偏好"的默认行为就失效了。 */
var pinned = false;
function isDark() {
return box.classList.contains('dark');
}
/* 三处状态一次性对齐:store + .dark 类 + dark.css + cookie */
function setTheme(on, writeCookie) {
if (window.Alpine && Alpine.store('ze')) {
try { Alpine.store('ze').dark = on ? true : false; } catch (err) {}
}
box.classList.toggle('dark', on);
/* 用 DOM 属性开关样式表,比改 disabled="false" 这种写法可靠 */
if (link.disabled === !!on) { link.disabled = !on; }
if (writeCookie) {
document.cookie = (on ? 'dark=dark' : 'dark=light') + ';path=/;max-age=31536000';
}
}
/* 期望状态:进页面时以服务端按 cookie 渲染出来的 dark.css 开关为准,
顺手把被 x-init 弄反的 .dark 类纠正回来。 */
var intent = !link.disabled;
/* 把界面拉回 intent:只有真的存在偏差时才写,
避免和下面的 MutationObserver 互相触发形成死循环 */
function enforce() {
if (link.disabled !== !intent || isDark() !== intent) {
setTheme(intent, pinned);
}
}
function setIntent(on) {
intent = !!on;
pinned = true;
setTheme(intent, true);
}
/* 1) 进页面先对一次 */
setTheme(intent, false);
setTimeout(enforce, 0);
setTimeout(enforce, 200);
/* 2) 状态守卫:NewAdmin 那次异步改动是在 view transition 回调里做的,
页面重的时候可能晚于下面几个定时器落点,落晚了又会把状态翻反。
这里盯住 dark.css 的 disabled 属性和 #newadmin 的 class,
只要和 intent 不一致就立刻拉回来 —— 持续生效,不依赖时间点。 */
if (window.MutationObserver) {
var guard = new MutationObserver(enforce);
guard.observe(link, { attributes: true, attributeFilter: ['disabled'] });
guard.observe(box, { attributes: true, attributeFilter: ['class'] });
}
/* 3) 点 ☀ / 🌙:捕获阶段只"记目标",不动任何状态。
这里千万不能在点击当时就把 store/dark.css 改掉:NewAdmin 的
@click="darkmode(!$store.ze.dark)" 紧接着要读 $store.ze.dark
来决定往哪边切、并据此广播,我们先改会让它算出相反方向,
于是它广播出去的值和我们的目标正好相反,又把自己翻回去。
所以目标先记下,等这一轮事件走完(0ms)再收口。 */
document.addEventListener('click', function (e) {
var btn = (e.target && e.target.closest) ? e.target.closest('.rightmore > button') : null;
if (!btn) { return; }
intent = !intent;
pinned = true;
setTimeout(enforce, 0);
setTimeout(enforce, 120);
}, true);
/* 4) 跟随系统 / 其它标签页切换时同样收口
(NewAdmin 用 BroadcastChannel 'zeze_channel' 广播) */
try {
var dhChannel = new BroadcastChannel('zeze_channel');
dhChannel.onmessage = function (ev) {
var data = null;
try { data = JSON.parse(ev.data); } catch (err) { return; }
if (!data || !data.DarkMode) { return; }
if (data.DarkMode === 'auto') {
/* NewAdmin 收到 auto 时会自己按系统偏好切,这里跟着定目标 */
setIntent(window.matchMedia('(prefers-color-scheme: dark)').matches);
return;
}
setIntent(data.DarkMode === 'dark');
};
} catch (err) {}
/* 5) 系统偏好变化(NewAdmin 只在 x-init 里挂过监听,切系统时不会广播) */
try {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function (ev) {
var cookie = document.cookie.indexOf('dark=dark') > -1;
var cookieLight = document.cookie.indexOf('dark=light') > -1;
/* 用户手动选过深浅就不跟系统走 */
if (cookie || cookieLight) { return; }
setIntent(ev.matches);
});
} catch (err) {}
})();
</script>
<?php include 'footer.php'; ?>