refactor(version): 版本号收敛到 MPHX/BL.php 单一数据源
8 个文件变更
+74
-14
13172193298@163.com
| •MPHX/BL.php | +18 -0 |
| •README.md | +2 -2 |
| •admin/api/bt.php | +1 -1 |
| •docs/guide/changelog.md | +7 -1 |
| •docs/index.md | +2 -2 |
| •install/index.php | +9 -5 |
| •install/install.api.php | +3 -3 |
| •tools/sync-version.sh | +32 -0 |
变更内容
diff --git a/MPHX/BL.php b/MPHX/BL.php
index c645a40..8f77b29 100644
--- a/MPHX/BL.php
+++ b/MPHX/BL.php
@@ -1,4 +1,22 @@
<?php
$WEBQB='1850';
$SQLQB='1310';
+
+// 版本号唯一数据源是上面的 $WEBQB(如 1850 => V1.85)。
+// 全项目对外显示版本一律走下面两个函数,发版只改 $WEBQB 这一处。
+// BL.php 会被多处 include(非 once),所以用 function_exists 兜住重复定义。
+if (!function_exists('mnbt_version_num')) {
+ // 纯数字串:1850 => "1.85"
+ function mnbt_version_num()
+ {
+ return sprintf('%.2f', (int)($GLOBALS['WEBQB'] ?? 0) / 1000);
+ }
+}
+if (!function_exists('mnbt_version')) {
+ // 带前缀显示:1850 => "V1.85"
+ function mnbt_version($prefix = 'V')
+ {
+ return $prefix . mnbt_version_num();
+ }
+}
?>
\ No newline at end of file
diff --git a/README.md b/README.md
index b1ed0b7..2bb4b44 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
-# 梦奈宝塔主机系统 (MNBT) V1.83
+# 梦奈宝塔主机系统 (MNBT) V1.85
基于宝塔面板 API 的虚拟主机分销管理系统,支持多节点宝塔面板统一管理、用户自主开通主机、一键部署网站程序、在线文件管理、Gzip/缓存配置、URL/资源监控告警、违禁词扫描、**可切换前端主题**、**PHP 业务插件**等功能。



-
+
---
diff --git a/admin/api/bt.php b/admin/api/bt.php
index f4e33d5..0fb6425 100644
--- a/admin/api/bt.php
+++ b/admin/api/bt.php
@@ -72,7 +72,7 @@ if($egn=='mnbt') {
include_once("../MPHX/github_updater.php");
// 只走 GitHub Release 检查更新,不再回连自建服务器,也不再校验 authcode
$content = mnbt_updater_check();
- $total ='V'.sprintf( "%.2f ",$WEBQB/1000);
+ $total = mnbt_version();
if($content['ok']!=1) {
$cl='mdi-cloud-off';
$gx='暂时无法检查更新:'.$content['error'];
diff --git a/docs/guide/changelog.md b/docs/guide/changelog.md
index 4c170fc..66a8223 100644
--- a/docs/guide/changelog.md
+++ b/docs/guide/changelog.md
@@ -47,7 +47,13 @@ description: MNBT 版本更新记录(V1.85 ~ V1.60)
> 发版时请在 GitHub Release 挂载 zip 附件(内容即为站点根目录文件),否则将走源码包回落路径(自动剥顶层目录)。附件请确保不含本地配置文件的覆盖内容,运行时配置由更新流程的备份还原机制保护。
-## V1.83(当前)
+**版本号单一数据源**
+
+- `$WEBQB`(`MPHX/BL.php`)是版本号唯一来源,新增格式化函数 `mnbt_version_num()`(`1850`→`"1.85"`)与 `mnbt_version()`(→`"V1.85"`)
+- 安装向导(`install/index.php` 的徽章/升级文案、`install/install.api.php` 的接口 `vs` 字段与升级完成提示)、后台版本显示(`admin/api/bt.php`)全部改为从 `$WEBQB` 计算,不再写死字面量;发版改产品内版本只需动 `BL.php` 一处
+- README 与 docs 首页的 shields.io 徽章是静态 Markdown(PHP 渲染不到),由 `tools/sync-version.sh` 从 `$WEBQB` 同步;发版流程:改 `BL.php` → `bash tools/sync-version.sh` → 追加 changelog 段落
+
+## V1.83
**Docker 容器托管**
diff --git a/docs/index.md b/docs/index.md
index 37448f3..b6afa67 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -43,7 +43,7 @@ features:


-
+

---
@@ -52,7 +52,7 @@ features:
| 文档 | 说明 |
|------|------|
-| [更新日志](/guide/changelog) | 版本更新记录(V1.60 → V1.83) |
+| [更新日志](/guide/changelog) | 版本更新记录(V1.60 → V1.85) |
| [集成对接](/integration/idcsmart-hosting) | 魔方财务 server module 对接指南 |
| [插件商店](/store/index) | 插件商店 & 主题商店规格 |
| [PRD 归档](/prd/docker) | 历史产品需求文档归档 |
diff --git a/install/index.php b/install/index.php
index fea1e76..a902fde 100644
--- a/install/index.php
+++ b/install/index.php
@@ -1,3 +1,7 @@
+<?php
+// 版本徽章/文案的唯一来源:MPHX/BL.php 的 $WEBQB,发版只改那里
+include_once __DIR__ . '/../MPHX/BL.php';
+?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
@@ -23,7 +27,7 @@
<p>安装向导 · 欢迎使用</p>
</div>
</div>
- <span class="ver-badge">V<span class="mn-vs">1.84</span></span>
+ <span class="ver-badge">V<span class="mn-vs"><?=mnbt_version_num()?></span></span>
</header>
<!-- 横向步骤条 -->
@@ -78,7 +82,7 @@
</div>
<div>
<h2>欢迎使用 梦奈宝塔主机系统</h2>
- <p>版本 V<span class="mn-vs">1.84</span> · 约需 2 分钟</p>
+ <p>版本 V<span class="mn-vs"><?=mnbt_version_num()?></span> · 约需 2 分钟</p>
</div>
</div>
<p class="welcome-lead">
@@ -260,8 +264,8 @@
<div class="choice-item use-terms mn-upgrade">
<div class="check"><svg viewBox="0 0 11 9" fill="none"><path d="M1 4L4 7L10 1" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>
<div>
- <b>覆盖更新(保留数据升级到 V1.84)<span class="mn-upgrade-detail"></span></b>
- <small>添加 V1.84 新增表和字段,自动补全缺失项,保留所有已有数据</small>
+ <b>覆盖更新(保留数据升级到 <?=mnbt_version()?>)<span class="mn-upgrade-detail"></span></b>
+ <small>添加 <?=mnbt_version()?> 新增表和字段,自动补全缺失项,保留所有已有数据</small>
</div>
</div>
<div class="choice-item use-terms mn-repair">
@@ -445,7 +449,7 @@
$('.mn-repair').parent().show();
} else {
console.log('[升级检测] 数据完整,无需升级');
- $('.mn-upgrade-detail').text('(当前已是 V1.84,无需升级)');
+ $('.mn-upgrade-detail').text('(当前已是 <?=mnbt_version()?>,无需升级)');
$('.mn-upgrade').parent().show();
$('.mn-repair').parent().show();
}
diff --git a/install/install.api.php b/install/install.api.php
index 23903db..0a94c27 100644
--- a/install/install.api.php
+++ b/install/install.api.php
@@ -6,7 +6,7 @@ include("../cf_up.php");
include("../MPHX/BL.php");
include_once("../MPHX/Response.php");
$action = $_GET['action'] ?? 'index';
-$vs = sprintf("%.2f ", $WEBQB / 1000);
+$vs = mnbt_version_num();
function Res(int $code, string $msg = '返回信息', ?array $data = null, ?int $redirect = null)
{
@@ -67,7 +67,7 @@ function mnbt_standard_tables() {
'MN_docker_node','MN_docker_user','MN_docker_plan','MN_docker_order');
}
-// V1.81~V1.84 增量字段定义:表 => (列名 => ALTER 语句)
+// 各版本增量字段定义(随发版追加,勿在此写死当前版本号):表 => (列名 => ALTER 语句)
// 实际表名由调用方传入(兼容大小写迁移场景);仅添加缺失列
function mnbt_upgrade_columns($actual_config, $actual_zj, $actual_bt, $actual_dplan, $actual_duser) {
return array(
@@ -531,7 +531,7 @@ switch ($action) {
@file_put_contents("install.lock", '安装锁');
if ($install_mode === 'upgrade') {
- exit(Res(1, '升级完成!已保留原有数据,成功更新至 V1.84'));
+ exit(Res(1, '升级完成!已保留原有数据,成功更新至 ' . mnbt_version()));
}
if ($skip_sql) {
exit(Res(1, '安装完成(保留原表并更新站点/管理员配置)'));
diff --git a/tools/sync-version.sh b/tools/sync-version.sh
new file mode 100644
index 0000000..c515865
--- /dev/null
+++ b/tools/sync-version.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# 版本同步:以 MPHX/BL.php 的 $WEBQB 为唯一数据源,回写仓库里的 Markdown 版本标记。
+#
+# 为什么需要它:PHP 运行时(安装向导 / 后台 / API)已全部改成从 $WEBQB 计算,
+# 改版本只动 BL.php 一处;但 README 与 docs 的 shields.io 徽章是静态 Markdown,
+# PHP 渲染不到,只能靠脚本同步。发版流程:改 BL.php 的 $WEBQB → 跑这个脚本 → 提交。
+#
+# 用法: bash tools/sync-version.sh
+set -euo pipefail
+
+root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+bl="$root/MPHX/BL.php"
+
+n="$(grep -oE "\\\$WEBQB[[:space:]]*=[[:space:]]*'[0-9]+'" "$bl" | grep -oE '[0-9]+')"
+[ -n "$n" ] || { echo "未能从 BL.php 解析 \$WEBQB" >&2; exit 1; }
+
+# 与 PHP sprintf('%.2f', $WEBQB/1000) 保持一致
+ver="$(awk "BEGIN{printf \"%.2f\", $n/1000}")"
+disp="V$ver"
+
+echo "BL.php \$WEBQB=$n => 显示版本 $disp"
+
+# 1) README 标题行:锚定 "(MNBT) V<旧版本>"(版本在行尾)
+sed -i -E "s/\(MNBT\) V[0-9][0-9.]*/(MNBT) ${disp}/" "$root/README.md"
+
+# 2) 两个文件的 shields.io 版本徽章
+sed -i -E "s#badge/version-[0-9][0-9.]*-green#badge/version-${ver}-green#g" "$root/README.md" "$root/docs/index.md"
+
+# 3) docs 首页更新日志区间:锚定 "→ V<新版本>)"
+sed -i -E "s/→ *V[0-9][0-9.]*)/→ ${disp})/" "$root/docs/index.md"
+
+echo "已同步 README.md 与 docs/index.md(changelog 各版本标题需按发版手工追加)"