我圈 后台管理使用手册

1 访问与登录 项 值 入口 /admin/(重写到 admin/index.html) 后台接口前缀 /api/index.php/admin/...;本手册表格内简写为 /admin/... 登录态 前台登录取得的 JWT,Authorization: Bearer 或 httpOnly Coo…

最后更新 2026-11-23 阅读约 42 分钟

1 访问与登录#

项值
入口/admin/(重写到 admin/index.html)
后台接口前缀/api/index.php/admin/...;本手册表格内简写为 /admin/...
登录态前台登录取得的 JWT,Authorization: Bearer 或 httpOnly Cookie hublog_token
登录态确认GET /api/auth/me
接口中间件RateLimitMiddleware、AuthMiddleware、CsrfMiddleware、AdminMiddleware、LicenseMiddleware
账号类型后台范围
admin全部 32 个页面
圈主(is_circle_owner)仅「活动管理」,接口仅放行 /admin/activities、/admin/my-circles
user / reviewer重定向前台
接口返回条件
401「请先登录」无 token
401「登录状态已失效,请重新登录」token_version 不符
403「账号异常,无法操作」status != 1
403「权限不足」非 admin 或非圈主越权

前台登录入口:POST /api/auth/login、/api/auth/login-phone、/api/auth/wx-mini-login、/api/app/auth/wx-app-login。

2 页面与功能#

页面名称功能主要接口
dashboard数据概览admin/index.html 常驻骨架页,统计卡片、程序版本与服务器信息/admin/dashboard、/admin/version-check
activities.html活动管理活动列表、创建、编辑、删除;圈主限定所属圈子/admin/activities、/admin/my-circles
app-versions.html版本管理App 版本列表、发布新版本/admin/app-versions
app-center.html应用中心连接中心、应用市场、安装与基线校验;配置地址后侧栏入口才显示/admin/appcenter/*(见 docs/应用中心-站点端接入说明.md)
appeals.html申诉管理5 状态筛选(全部/待处理/处理中/已解决/已驳回),类型筛选/admin/appeals、/admin/appeal-handle
attachments.html附件管理附件列表、状态变更、删除、孤儿文件清理/admin/attachments、/admin/attachments/status、/admin/posts/cleanup-orphan-uploads
badges.html徽章管理徽章配置、用户徽章、神评标记、操作日志/admin/badges、/admin/badge-save、/admin/badge-toggle、/admin/badge-scan、/admin/user-badges、/admin/user-badge-grant、/admin/badge-logs
categories.html分类管理分类增删改、层级与排序/admin/categories
chat.html私信管理存储统计、会话、消息、删除审计、清理工具、上传设置/admin/chat/storage-stats、/admin/chat/conversations、/admin/chat/messages、/admin/chat/deletions、/admin/chat/cleanup-expired、/admin/chat/settings
circles.html圈子管理圈子、成员角色、入圈申请、转让、内容审核/admin/circles、/admin/circles/members、/admin/circles/requests、/admin/circles/moderate
comments.html评论管理评论列表、删除/admin/comments
crash-logs.html客户端异常高频异常 Top 20、异常明细与详情/admin/crash-logs、/admin/crash-alert-threshold
content-pay.html内容付费单篇商品与专栏配置、条目管理、订单查询、手动开通权益/admin/content-pay/orders、/admin/content-pay/columns、/admin/content-pay/product、/admin/content-pay/column、/admin/content-pay/item、/admin/content-pay/grant
export.html数据导出按 type / format 导出/admin/export
featured.html精华管理首页楼层精选、排序、推荐理由/admin/featured、/admin/featured/toggle
filter-logs.html命中记录敏感词命中日志,按场景筛选/admin/filter-logs
finance.html财务与会员会员订单、钱包流水、积分任务、支付配置、人工调整/admin/vip-orders、/admin/wallet-logs、/admin/point-tasks、/admin/points-adjust、/admin/wallet-adjust、/admin/grant-vip
friend-links.html友情链接增删改/admin/friend-links
license.html授权管理授权状态、授权码激活、验签模式与远程验签配置/admin/license、/admin/license/activate、/admin/license/refresh-hashes、/admin/license/save-settings
pages.html单页管理通用单页(关于 / 帮助 / 协议等)增删改、发布与草稿;免费基础能力,无 data-module/admin/pages、/admin/pages/publish
plugins.html扩展管理外观主题切换、主题外观选项、功能插件启停/admin/plugins、/admin/themes、/admin/theme-options、/admin/theme-options/upload
plugin-settings.html插件设置插件声明的设置页与菜单入口,由插件后台声明动态生成;免费基础能力,无 data-module/admin/plugin-admin-config、/admin/plugin-config、/admin/plugin-settings-page
posts.html内容管理状态筛选、分类与关键词搜索、批量删除/隐藏/显示/置顶、编辑动态/admin/posts、/admin/posts/status、/admin/posts/pin、/admin/posts/batch
realname.html实名认证核验服务配置、认证记录审核/admin/realname、/admin/realname/review
reports.html举报管理4 状态筛选(全部/待处理/已处理/已驳回)、处理/admin/reports、/admin/reports/resolve
sensitive-words.html敏感词库词库、批量导入、命中记录、禁言/admin/sensitive-words、/admin/sensitive-words/import、/admin/filter-logs、/admin/users/mute
settings.html系统设置6 主 tab:站点与界面、权限与内容、上传与存储、安全限流、外部服务、功能开关/admin/settings、/admin/settings、/admin/upload-homepage-cover、/admin/ai/*、/admin/mail/test、/admin/storage/test-connection
shop.html商城管理商品上架、订单发货、折扣卡/admin/shop-products、/admin/shop-product-save、/admin/shop-orders、/admin/shop-ship、/admin/shop-coupons
stats.html数据统计发布趋势、分类分布、热门话题 Top 10/admin/stats
topics.html话题管理话题增删改/admin/topics
upgrade.html系统升级版本检测、在线升级、回滚恢复/admin/version-check、/admin/upgrade、/admin/rollback
users.html用户管理用户列表、编辑、状态、删除/admin/users、/admin/users/update、/admin/users/status

插件设置页不是静态侧栏项:管理员鉴权通过后,GET /admin/plugin-admin-config 返回插件后台声明,admin/js/nav-ui.js 据此动态注入菜单(无 data-module,不进模块开关与授权门禁)。应用中心入口同样只在配置中心地址后显示。

3 系统设置#

3.1 读写接口#

操作接口说明
读取GET /admin/settings返回扁平 key => value 映射,附加 module_catalog;敏感值以 ******HUBLOG_SENSITIVE_MASKED:<key> 占位
保存PUT /admin/settings仅接受 $allowed 白名单内键;布尔键归一为 1/0;列表键按逗号串过滤;写入后清 site_settings 缓存
外观选项GET /admin/theme-options返回 {theme, fields, values},字段含 key/type/label/default/options,type 支持 text/textarea/color/select/switch/number/image(image 类型字段配合 POST /admin/theme-options/upload 上传后回填 URL)
保存外观PUT /admin/theme-options按主题 settings.json 的 optionsSchema 校验

保存后需失效的缓存键:site_settings、ai_comment_settings。

3.2 设置键分组#

分组键
站点信息site_name、site_url、site_desc、site_icp、site_keywords、site_description、site_stats_code、seo_robots_txt、homepage_cover、active_theme
权限总闸allow_register、allow_post、allow_like、allow_comment、allow_guest_download_attachment、allow_upload_image、allow_upload_video、allow_upload_attachment、allow_mention、allow_location、allow_anonymous_post、allow_circle
发布能力与站点模式post_types、post_tools、site_mode、module_flags、feature_guard_mode
上传限制upload_max_images、upload_max_videos、upload_max_size、upload_max_video_size、upload_compress、upload_max_width、upload_max_attachments、upload_max_attachment_size、upload_attachment_exts、upload_max_avatar_size
内容策略post_max_length、post_collapse_length、post_title_preview_length、category_required、title_required、url_rewrite、forbidden_nicknames、allowed_email_domains、mention_max_count
限流rate_limit_requests、rate_limit_window
导航nav_search_enabled、nav_messages_enabled、nav_favorites_enabled、nav_profile_enabled
水印watermark_enabled、watermark_type、watermark_text、watermark_font_size、watermark_color、watermark_opacity、watermark_position、watermark_margin、watermark_rotate、watermark_shadow、watermark_image、watermark_image_scale、watermark_min_size、watermark_apply_avatar、watermark_font_path
AI 评论ai_comment_enabled、ai_comment_provider、ai_comment_api_url、ai_comment_api_key、ai_comment_model、ai_comment_prompt、ai_comment_max_length、ai_comment_timeout
AI 审核ai_audit_enabled、ai_audit_provider、ai_audit_api_url、ai_audit_api_key、ai_audit_model、ai_audit_custom_words
云存储直传upload_driver、upload_sign_ttl、upload_dir_prefix、upload_cdn_common_domain、upload_oss_*、upload_cos_*、upload_qiniu_*
邮件mail_enabled、mail_host、mail_port、mail_username、mail_password、mail_from_name、mail_from_email、mail_encryption
密码策略password_min_length、password_require_upper、password_require_lower、password_require_digit、password_require_special
语言site_language、allow_language_switch
实名认证realname_enabled、realname_provider、realname_appcode、realname_api_url、realname_tencent_*、realname_baidu_*
短信服务sms_provider、sms_aliyun_*、sms_tencent_*、sms_baidu_*
定位amap_web_key
定时任务cron_secret(留空即关闭外部调度入口)
会员与支付vip_price_1、vip_price_2、vip_price_3、point_rate、pay_enabled、pay_wxpay_enabled、pay_alipay_enabled、wxpay_*、alipay_*
商城与转盘wheel_cost、wheel_free_daily、mall_switch、shop_user_post、shop_notice

3.3 默认值#

键默认值
site_name我圈
site_desc / site_description轻量级多用户社区博客系统 / 轻量级多用户社区博客系统,分享生活点滴。
site_keywords我圈,博客,社区,朋友圈
site_icp / site_stats_code空串
allow_register / allow_post / allow_like / allow_comment1
allow_guest_download_attachment / allow_mention / allow_location / allow_anonymous_post / allow_circle1
upload_max_images9
upload_max_size / upload_max_avatar_size10 / 5(MB)
upload_max_attachments / upload_max_attachment_size5 / 50
upload_attachment_extszip,rar,7z,pdf,doc,docx,xls,xlsx,ppt,pptx,txt
upload_compress / upload_max_width1 / 1920
upload_max_videos3
post_max_length / post_collapse_length2000 / 300
post_title_preview_length / mention_max_count150 / 10
title_required / url_rewrite0 / 0
rate_limit_requests / rate_limit_window1500 / 60
ai_comment_enabled / ai_audit_enabled0 / 0
ai_comment_provider / ai_audit_providerollama
ai_comment_api_url / ai_audit_api_urlhttp://localhost:11434/v1/chat/completions
ai_comment_model / ai_audit_modelllama3.2
ai_comment_max_length / ai_comment_timeout200 / 30
upload_sign_ttl600(上限 3600)
point_rate10(每 10 积分抵 1 元)

3.4 枚举与白名单#

键合法值
post_typesnormal、poll、question、team、checkin
post_toolsimage、video、emoji、location、mention、anonymous、link、attachment、topic、draft、schedule、category
site_languagezh-CN、en
feature_guard_modeoff、log、on

4 功能开关与下发#

新增或调整开关需同步三处,缺一处会导致后台可配但前台不生效。

#位置作用
1AdminSettingsController::settings()$allowed 白名单,决定后台能否保存
2AppController::config()下发到 App / 前台
3PostCrudTrait::create()、PostSettingsTrait 权限辅助create() 与权限辅助的兜底校验
$allowed 键config() 下发键兜底位置
allow_registerregister_open登录注册流程
allow_post—checkUserPermission('allow_post')
allow_like / allow_comment—PostCommentTrait
allow_locationallow_locationPostCrudTrait
allow_mentionallow_mentionPostCrudTrait
allow_anonymous_postgateMap['anonymous']PostCrudTrait
allow_circleallow_circle圈子发布流程
allow_upload_image / _video / _attachment`gateMap['image''video'
post_max_length 与 upload_max_*limits.*PostCrudTrait
title_required / category_requiredlimits.*PostCrudTrait
post_types / post_toolspost_types / post_toolsisPostTypeEnabled()
site_mode / module_flags / feature_guard_modeFeatureFlags::publicPayload()FeatureGuardMiddleware

站点模式由 saveSiteMode() 落 module_flags JSON、反查 site_mode 并写 feature_guard_mode。

4.1 站点模式与模块预设#

后台「系统设置 → 功能开关」顶部有独立「站点模式」卡片(admin/pages/settings.html),真值源为 api/core/ModuleCatalog.php(后台只渲染,不硬编码)。

模式说明开启的模块
social社交模式,全部模块开启15 个模块全开
blog博客模式,纯内容站comments、friend_links、reports、appeals、safety_filter
news资讯模式,内容 + 话题 / 精华运营blog 基础上加 topics、featured
content内容商业化,单篇买断 / 专栏订阅变现news 基础上加 finance、contentpay

custom(自定义)是手动微调后的状态,不是预设;切换预设还会套用前台帖子类型 / 发布页工具栏 / 底部导航(FRONTEND_PRESETS)。切换只改开关、不删数据。

15 个可关模块(ModuleCatalog::MODULES):comments、topics、featured、friend_links、circles、chat、activities、badges、realname、reports、appeals、shop、finance、contentpay、safety_filter。依赖:appeals 依赖 reports,shop、contentpay 依赖 finance。ALWAYS_ON_PAGES 的 13 页(dashboard、users、posts、categories、attachments、settings、stats、export、plugins、license、upgrade、app-versions、crash-logs)任何模式下都保留。

三层关系共用同一份模块注册表:

层位置作用
数据层saveSiteMode() 写 site_mode、module_flags(JSON)、feature_guard_mode开关落库,并校验依赖
菜单过滤ModuleCatalog::pageMap()(经 FeatureFlags::publicPayload() 下发 module_pages)关掉模块的后台页不显示,常驻骨架页始终可见
运行守卫FeatureGuardMiddleware + ModuleCatalog::routePrefixes()feature_guard_mode=on 时被关模块 API 返回 4230;off 只影响菜单,log 仅记录不拦截

5 模块授权#

5.1 模块清单#

key名称拦截路径
aiAI 智能辅助/api/ai/、/api/admin/ai/
scheduled定时发布/api/posts(含 scheduled_at 参数)、/api/cron/scheduled
dataops数据运维/api/admin/export、/backup、/stats、/upgrade、/rollback、/version-check、/app-versions
circles圈子/api/circles、/api/admin/circles、/api/admin/my-circles
shop商城/api/shop、/api/admin/shop
finance财务会员/api/pay、/api/admin/pay、/vip-orders、/wallet-*、/recharge-orders、/grant-vip;/api/pay/notify/ 除外
activities活动/api/activities、/api/activity、/api/admin/activities
realname实名认证/api/realname、/api/admin/realname

免费核心能力:badges、points、moderation,不受授权拦截。

5.2 档位#

档位可用模块
trial(试用)全部(限额)
personal(个人版)ai、scheduled、circles、realname
business(商业版)全部
enterprise(企业版)全部

未授权拒绝模块:scheduled、dataops、circles、shop、finance、activities、realname;ai 走限量子试用。

5.3 后台操作边界#

操作结果
查看授权状态、激活授权码、停用授权GET /admin/license、/admin/license/activate、/admin/license/deactivate
配置验签仅可写 license_verify_mode、license_remote_url、license_remote_pubkey、license_remote_ssl_verify、license_bind_domain、license_remote_timeout
调整档位、额度、功能开放范围后台无入口,由授权码判定

未授权接口返回业务码 402,消息含 module: <key>。

6 内容审核#

状态statusaudit_state触发
正常发布10 或 2未命中审核 / 重审通过
管理员下架00后台「内容管理」隐藏
命中待审01敏感词 DFA、后台词库 review/block、AI 审核
重审通过12审核放行

编辑已发布动态会重新进入审核。命中待审时清除 scheduled_at,清 timeline / popular 命名空间版本,并向作者发站内信。

后台页面处理对象接口
posts.html待审 / 下架(status=0 页签)、批量显示与隐藏/admin/posts?status=、/admin/posts/status、/admin/posts/batch
reports.html举报/admin/reports、/admin/reports/resolve
appeals.html申诉/admin/appeals、/admin/appeal-handle
sensitive-words.html词库、命中记录、禁言/admin/sensitive-words、/admin/filter-logs、/admin/users/mute

7 定时任务与运维#

7.1 cron#

频率命令
每 5 分钟curl -X POST -H 'X-Cron-Token: <cron_secret>' https://<域名>/api/cron/scheduled
每小时第 10 分钟curl -X POST -H 'X-Cron-Token: <cron_secret>' https://<域名>/api/cron/badges
每分钟curl -X POST -H 'X-Cron-Token: <cron_secret>' https://<域名>/api/cron/jobs
每天一次curl -X POST -H 'X-Cron-Token: <cron_secret>' https://<域名>/api/cron/archive(只增日志表滚动归档)
每天一次curl -X POST -H 'X-Cron-Token: <cron_secret>' https://<域名>/api/cron/circle-subscribes(付费圈子订阅到期清退 + 提醒)
每小时php /path/to/woquan/bin/reconcile-counters.php

cron_secret 支持请求体 secret 或头 X-Cron-Token;留空时外部调度入口关闭。后台「系统设置」提供命令复制与「立即执行」。

bin/reconcile-counters.php 对账 4 列:posts.comment_count、posts.like_count、circles.member_count、circles.post_count。

7.2 健康检查#

TEXT
GET /health
{"code":200,"message":"success","data":{
  "status":"ok",
  "time":"2026-11-15T...",
  "checks":{
    "db":{"status":"ok","detail":"connected"},
    "cache":{"status":"ok","detail":"file"},
    "disk":{"status":"ok","detail":"63.2% free","free_mb":...,"total_mb":...},
    "migration":{"status":"ok","detail":"..."}
  }}}

status 取值:ok / degraded / down。

两条路径等价,由 Web 服务器转发方式决定用哪条:nginx location = /health 直转时用 /health;重写 / PATH_INFO 场景(/api/index.php/health)用 /api/health。

7.3 在线升级与回滚#

步骤接口 / 行为
版本检测GET /admin/version-check
立即升级POST /admin/upgrade,上传 zip(上限 100MB),返回 data.db_backup / data.code_backup
回滚恢复POST /admin/rollback,读取 backups/index.json 最近一次含 upgrade=true 的记录

升级执行顺序:备份数据库 → 备份代码 → 覆盖(保护 config.php、.env、uploads/、cache/、logs/、backups/)→ 同步版本 → 记录备份索引 → 执行数据库迁移 → 写文件指纹 → 清缓存。任一步失败自动回滚。备份文件为 backups/hublog_db_{Ymd_His}.sql 与 backups/hublog_code_{Ymd_His}.zip,仅保留最近 2 次。

7.4 后台前端缓存指纹#

改动 admin/ 下 CSS / JS / HTML 后,以下 6 处字面量需同步为同一值(当前均为 202611211;SiteModeCatalogTest 断言同值):

文件位置
admin/index.htmltheme-boot.js?v=、css/admin.css?v=、js/main.js?v=
admin/js/main.jsimport nav-ui.js?v=、import('./icons.js?v=')
admin/js/nav-ui.jsconst PAGE_VER

8 数据导出与备份#

操作入口取值
数据导出GET /admin/export?type=&format=type: users / posts / comments / all;format: json / csv
私信导出/admin/chat/exportCSV
用户自助导出/api/user/export-data当前用户数据
手动备份/admin/backup7 张表 JSON,不含 DDL

token= 不再参与鉴权:AdminToolsController::exportData() 只经 requireAdmin() 走 Cookie / Bearer,不读取 URL 中的 token;admin/js/export.js 仍拼 token= 仅为前端兼容,可省略(与 v2.16.13 移除 ?token= 鉴权回退一致)。

导出文件名:hublog_{type}_{Y-m-d}.json / .csv;CSV 带 UTF-8 BOM。

9 自检清单#

#检查项
1/admin/ 可访问,GET /api/auth/me 返回 role=admin
232 个页面均可打开且无控制台报错
3GET /admin/settings 返回 module_catalog,敏感值为掩码占位
4修改设置后前台 GET /api/app/config 同步变化
5新增开关已同步 $allowed、config()、create() 三处,且 site_settings 缓存已失效
6GET /admin/license 授权状态与预期档位一致,未授权模块访问返回 402
7内容审核命中后 status=0 且 audit_state=1,放行后 status=1 且 audit_state=2
8五条 cron 均可执行,/health 的 db / cache / disk / migration 均为 ok
9升级前 backups/ 有可写权限,backups/index.json 可更新
10改动后台前端后 6 处缓存指纹同值