fix(admin): replicate reference comment settings page 1:1

- Rewrite post_list/comment schema (PHP + JS) with the reference theme's
  field set, order, defaults and dependencies; smilie, comment location
  and quick-reply fields excluded
- Map PostDisplay::get_comment_display_settings() to the new keys without
  legacy fallback: close_comments, comment_paginate_type (ajax_lists),
  user_edit_comment master switch, WP comment_order for sorting
- Wire comment_box_hide visibility gate (signin / vip / vip_2 / auth)
- Drop dead comment settings (order/per_page/depth/avatar/hot threshold/
  empty text/city), the dead post_close_comments field, and city readers
  now fully owned by the IP-geo extension
- Add comment settings reference contract test
This commit is contained in:
2026-09-24 13:43:51 +08:00
parent 264f2c51b2
commit c331b2aeef
11 changed files with 382 additions and 200 deletions
@@ -2,102 +2,80 @@ export const commentSchema = {
key: 'post_list.comment',
title: '评论设置',
icon: 'fa fas fa-comment-dots',
description: '配置评论区的排序、分页、权限、工具栏与互动方式。',
description: '配置评论模块的显隐条件、翻页模式、输入工具栏与互动方式。',
defaults: {
comment_order: 'asc',
comment_per_page: 20,
comment_pagination_type: 'numbered',
close_comments: false,
comment_box_hide: '',
comment_paginate_type: 'default',
comment_paging_ajax_ias_s: true,
comment_paging_ajax_ias_max: 3,
comment_nested_depth: 3,
comment_avatar_size: 48,
comment_close_comments: false,
comment_edit_window: 10,
comment_code: true,
comment_img: true,
comment_upload_img: false,
comment_link: false,
comment_like_s: true,
comment_hot_threshold: 10,
comment_city_s: true,
comment_city_type: 'province_city',
comment_user_url_s: false,
comment_author_tag: true,
user_edit_comment: true,
comment_like_s: true,
comment_user_url_s: false,
comment_corderby: true,
comment_empty_text: '暂无评论,来做第一个评论的人吧~',
comment_title: '评论',
comment_submit_text: '提交评论',
comment_text: '欢迎您留下宝贵的见解!',
},
groups: [
{
key: 'display',
title: '评论展示',
icon: 'fa fas fa-comment',
key: 'comment',
title: '',
fields: [
{ key: 'comment_order', label: '评论排序', type: 'radio', default: 'asc', options: [
{ label: '正序 (旧→新)', value: 'asc' },
{ label: '倒序 (新→旧)', value: 'desc' },
]},
{ key: 'comment_per_page', label: '每页评论数', type: 'number', default: 20, min: 5, max: 100 },
{ key: 'comment_pagination_type', label: '分页方式', type: 'radio', default: 'numbered', options: [
{ label: '翻页', value: 'numbered' },
{ label: '加载更多', value: 'load_more' },
{ label: '无限滚动', value: 'infinite' },
]},
{ key: 'comment_paging_ajax_ias_s', label: '评论自动加载', type: 'switch', default: true, help: '评论无限滚动时自动触发加载' },
{ key: 'comment_paging_ajax_ias_max', label: '评论最大加载页数', type: 'number', default: 3, min: 0, max: 10, help: '0 = 不限' },
{ key: 'comment_nested_depth', label: '回复嵌套深度', type: 'number', default: 3, min: 1, max: 10 },
{ key: 'comment_avatar_size', label: '头像大小 (px)', type: 'number', default: 48, min: 24, max: 96 },
],
},
{
key: 'permissions',
title: '评论设置',
icon: 'fa fas fa-lock',
fields: [
{ key: 'comment_close_comments', label: '关闭评论', type: 'switch', default: false },
{ key: 'comment_edit_window', label: '作者自助编辑时限 (分钟)', type: 'number', default: 10, min: 0, max: 1440 },
],
},
{
key: 'toolbar',
title: '评论工具栏',
icon: 'fa fas fa-wrench',
fields: [
{ key: 'comment_code', label: '代码插入', type: 'switch', default: true },
{ key: 'comment_img', label: '图片按钮', type: 'switch', default: true },
{ key: 'comment_link', label: '链接按钮', type: 'switch', default: false },
{ key: 'comment_upload_img', label: '评论图片上传', type: 'switch', default: false },
],
},
{
key: 'interaction',
title: '互动功能',
icon: 'fa fas fa-heart',
fields: [
{ key: 'comment_hot_threshold', label: '神评点赞阈值', type: 'number', default: 10, min: 1, max: 999, help: '点赞数达到该值后显示「神评」徽章', dependsOn: { key: 'comment_like_s', value: true } },
{ key: 'comment_like_s', label: '评论点赞', type: 'switch', default: true },
{ key: 'comment_user_url_s', label: '匿名者网址', type: 'switch', default: false, help: '用户未登录评论时,允许输入用户博客地址' },
{ key: 'comment_city_s', label: '评论城市', type: 'switch', default: true },
{ key: 'comment_city_type', label: '城市显示格式', type: 'radio', default: 'province_city', options: [
{ label: '省份+城市', value: 'province_city' },
{ label: '仅省份', value: 'province' },
{ label: '国家+省份', value: 'country_province' },
], dependsOn: { key: 'comment_city_s', value: true } },
{ key: 'comment_author_tag', label: '作者标签', type: 'switch', default: true },
{ key: 'comment_corderby', label: '评论排序切换', type: 'switch', default: true, help: '前台显示最新/最早/最热切换按钮' },
],
},
{
key: 'text',
title: '文案配置',
icon: 'fa fas fa-font',
fields: [
{ key: 'comment_empty_text', label: '空评论提示', type: 'input', default: '暂无评论,来做第一个评论的人吧~' },
{ key: 'comment_title', label: '评论区标题', type: 'input', default: '评论' },
{ key: 'comment_submit_text', label: '提交按钮文案', type: 'input', default: '提交评论' },
{ key: 'comment_text', label: '评论框提示', type: 'input', default: '欢迎您留下宝贵的见解!' },
{
key: 'comment_discussion_notice',
label: '',
type: 'content',
ui_only: true,
dependsOn: { key: 'close_comments', value: false },
content: '<p style="margin:0;font-size:12px;color:var(--aksrt-color-muted);line-height:1.6;"><i class="fa fas fa-fw fa-info-circle"></i> WordPress默认关闭评论翻页功能,如需启用请按此进行设置:<br/>1. 进入WP讨论设置,勾选 <code>分页显示评论</code><br/>2. 设置默认显示 <code>最前</code>一页<br/>3. 设置在每个页面顶部显示 <code>旧的</code>评论<br/>4. 根据需要设置每一页显示数量<br/>5. 根据需要设置评论嵌套(推荐开启并设置为3层)<br/>6. wp默认开启免登陆评论,如需关闭则勾选<code>需要登录后才能发表评论</code><br/><a href="options-discussion.php">【去设置】</a></p>',
},
{ key: 'close_comments', label: '关闭文章评论功能', type: 'switch', default: false, description: '部分网站无需交互,或需备案审核,可在此关闭所有文章的评论功能。同时每一篇文章可单独关闭评论功能' },
{
key: 'comment_box_hide',
label: '隐藏评论模块',
type: 'radio',
default: '',
dependsOn: { key: 'close_comments', value: false },
options: [
{ label: '不隐藏', value: '' },
{ label: '登录后显示', value: 'signin' },
{ label: '所有会员显示', value: 'vip' },
{ label: '二级会员显示', value: 'vip_2' },
{ label: '认证用户显示', value: 'auth' },
],
description: '当用户满足条件时,文章评论功能及模块才会显示',
},
{
key: 'comment_paginate_type',
label: '评论列表翻页模式',
type: 'radio',
default: 'default',
dependsOn: { key: 'close_comments', value: false },
options: [
{ label: 'AJAX追加列表翻页', value: 'ajax_lists' },
{ label: '数字翻页按钮', value: 'default' },
],
},
{ key: 'comment_paging_ajax_ias_s', label: 'AJAX翻页自动加载', type: 'switch', default: true, dependsOn: { key: 'comment_paginate_type', value: 'ajax_lists' }, description: '页面滚动到列表尽头时,自动加载下一页' },
{ key: 'comment_paging_ajax_ias_max', label: '自动加载页数', type: 'number', default: 3, min: 0, max: 10, unit: '页', dependsOn: { all: [{ key: 'comment_paginate_type', value: 'ajax_lists' }, { key: 'comment_paging_ajax_ias_s', value: true }] }, description: 'AJAX翻页自动加载最多加载几页(为0则不限制,直到加载全部评论)' },
{ key: 'comment_code', label: '允许插入代码', type: 'switch', default: true, dependsOn: { key: 'close_comments', value: false }, help: '为了防止恶意评论,建议在后台-设置-讨论:开启“用户必须登录后才能发表评论”' },
{ key: 'comment_img', label: '允许插入图片', type: 'switch', default: true, dependsOn: { key: 'close_comments', value: false } },
{ key: 'comment_upload_img', label: '允许上传图片', type: 'switch', default: false, dependsOn: { all: [{ key: 'close_comments', value: false }, { key: 'comment_img', value: true }] } },
{ key: 'comment_link', label: '允许插入链接', type: 'switch', default: false },
{ key: 'comment_author_tag', label: '显示“作者”标签', type: 'switch', default: true, dependsOn: { key: 'close_comments', value: false } },
{ key: 'user_edit_comment', label: '允许用户编辑评论', type: 'switch', default: true, dependsOn: { key: 'close_comments', value: false } },
{ key: 'comment_like_s', label: '评论点赞功能', type: 'switch', default: true, dependsOn: { key: 'close_comments', value: false } },
{ key: 'comment_user_url_s', label: '匿名评论允许输入链接', type: 'switch', default: false, dependsOn: { key: 'close_comments', value: false }, description: '用户未登录评论时,允许输入用户博客地址' },
{ key: 'comment_corderby', label: '评论排序功能', type: 'switch', default: true, dependsOn: { all: [{ key: 'close_comments', value: false }, { key: 'comment_like_s', value: true }] }, description: '显示“最新、最热”排序按钮' },
{ key: 'comment_title', label: '自定义评论标题', type: 'textarea', default: '评论', rows: 1, dependsOn: { key: 'close_comments', value: false } },
{ key: 'comment_submit_text', label: '自定义评论提交按钮文案', type: 'textarea', default: '提交评论', rows: 1, dependsOn: { key: 'close_comments', value: false } },
{ key: 'comment_text', label: '自定义评论框占位符文案', type: 'input', default: '欢迎您留下宝贵的见解!', dependsOn: { key: 'close_comments', value: false } },
],
},
],