fix(admin): 后台校验文件避免 301,并让搜索引擎读到 noindex

serve -s 会把 .html 301 去后缀,百度站长验证失败;同时放开 robots 抓取,避免旧标题一直留在 SERP。
This commit is contained in:
2026-09-01 09:11:43 +08:00
parent f35e1a3ba5
commit eeee55e215
12 changed files with 42 additions and 23 deletions
+4 -2
View File
@@ -3,8 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex, nofollow, noarchive" />
<title>杜康好客 · HQ 管理后台</title>
<meta name="robots" content="noindex, nofollow, noarchive, nosnippet" />
<meta name="baiduspider" content="noindex, nofollow, noarchive, nosnippet" />
<meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet" />
<title>管理后台</title>
</head>
<body>
<div id="root"></div>
@@ -0,0 +1 @@
1aacdfe9dcc03f68e4dd855f8c4c8f33
+1 -1
View File
@@ -1,2 +1,2 @@
User-agent: *
Disallow: /
Allow: /
+7
View File
@@ -0,0 +1,7 @@
{
"cleanUrls": false,
"trailingSlash": false,
"rewrites": [
{ "source": "**", "destination": "/index.html" }
]
}
+2 -1
View File
@@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<meta name="robots" content="noindex, nofollow, noarchive" />
<meta name="robots" content="noindex, nofollow, noarchive, nosnippet" />
<meta name="baiduspider" content="noindex, nofollow, noarchive, nosnippet" />
<title>城市合伙人</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+1 -1
View File
@@ -1,2 +1,2 @@
User-agent: *
Disallow: /
Allow: /
+2 -1
View File
@@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="robots" content="noindex, nofollow, noarchive" />
<meta name="robots" content="noindex, nofollow, noarchive, nosnippet" />
<meta name="baiduspider" content="noindex, nofollow, noarchive, nosnippet" />
<title>门店管理中心</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+1 -1
View File
@@ -1,2 +1,2 @@
User-agent: *
Disallow: /
Allow: /
+2 -1
View File
@@ -46,10 +46,11 @@ module.exports = {
exec_mode: 'fork',
},
{
// cleanUrls:false 见 apps/admin-web/serve.json;否则百度校验 .html 会被 301 去后缀
name: 'dukang-admin-web',
cwd: `${APP_ROOT}/apps/admin-web`,
script: 'npx',
args: 'serve -s dist -l 8094',
args: 'serve dist -l 8094 -c serve.json',
interpreter: 'none',
instances: 1,
exec_mode: 'fork',
+1 -1
View File
@@ -46,7 +46,7 @@ module.exports = {
name: 'dukang-stg-admin-web',
cwd: `${APP_ROOT}/apps/admin-web`,
script: 'npx',
args: 'serve -s dist -l 8194',
args: 'serve dist -l 8194 -c serve.json',
interpreter: 'none',
instances: 1,
exec_mode: 'fork',
+6 -5
View File
@@ -1,11 +1,12 @@
# 禁止搜索引擎抓取shop / partner / admin,含测试域)
# 合规爬虫读 robots.txtX-Robots-Tag 覆盖不先读 robots.txt 的抓取器
# 禁止搜索引擎收录shop / partner / admin,含测试域)
# 必须允许抓取页面:Disallow:/ 会让百度无法读到 noindex,旧标题会一直留在 SERP。
# X-Robots-Tag 覆盖不先读 robots.txt / 不执行 JS 的抓取器。
add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
add_header X-Robots-Tag "noindex, nofollow, noarchive, nosnippet" always;
location = /robots.txt {
default_type text/plain;
charset utf-8;
add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
return 200 "User-agent: *\nDisallow: /\n";
add_header X-Robots-Tag "noindex, nofollow, noarchive, nosnippet" always;
return 200 "User-agent: *\nAllow: /\n";
}
+14 -9
View File
@@ -138,19 +138,26 @@ if [[ "$SKIP_BUILD" == false ]]; then
if [[ -f "$APP_ROOT/apps/mini-user/serve.json" ]]; then
cp -f "$APP_ROOT/apps/mini-user/serve.json" "$APP_ROOT/apps/mini-user/dist/serve.json"
fi
if [[ -f "$APP_ROOT/apps/admin-web/serve.json" ]]; then
cp -f "$APP_ROOT/apps/admin-web/serve.json" "$APP_ROOT/apps/admin-web/dist/serve.json"
fi
else
echo "==> 4. 跳过构建"
if [[ -f "$APP_ROOT/apps/mini-user/serve.json" && -d "$APP_ROOT/apps/mini-user/dist" ]]; then
cp -f "$APP_ROOT/apps/mini-user/serve.json" "$APP_ROOT/apps/mini-user/dist/serve.json"
fi
if [[ -f "$APP_ROOT/apps/admin-web/serve.json" && -d "$APP_ROOT/apps/admin-web/dist" ]]; then
cp -f "$APP_ROOT/apps/admin-web/serve.json" "$APP_ROOT/apps/admin-web/dist/serve.json"
fi
fi
echo "==> 5. 重启 PM2 ($ECOSYSTEM_FILE)"
if pm2 describe "$PM2_API" &>/dev/null; then
pm2 delete "$PM2_USER" 2>/dev/null || true
pm2 delete "$PM2_ADMIN" 2>/dev/null || true
pm2 start "$DEPLOY_DIR/$ECOSYSTEM_FILE" --only "$PM2_USER"
pm2 restart "$PM2_API" "$PM2_SHOP" "$PM2_PARTNER" "$PM2_ADMIN" 2>/dev/null \
|| pm2 restart "$PM2_API" "$PM2_SHOP" "$PM2_PARTNER"
pm2 start "$DEPLOY_DIR/$ECOSYSTEM_FILE" --only "$PM2_ADMIN"
pm2 restart "$PM2_API" "$PM2_SHOP" "$PM2_PARTNER" 2>/dev/null || true
else
pm2 start "$DEPLOY_DIR/$ECOSYSTEM_FILE"
fi
@@ -173,11 +180,9 @@ APP_ROOT="$APP_ROOT" DEPLOY_TRIGGER="${DEPLOY_TRIGGER:-manual}" DUKANG_ENV_FILE=
echo "==> 发版完成 ($DUKANG_DEPLOY_ENV)"
if [[ "$DUKANG_DEPLOY_ENV" == "staging" ]]; then
echo "==> 8. 重载 nginxstaging"
if command -v nginx >/dev/null 2>&1 && nginx -t 2>/dev/null; then
systemctl reload nginx || echo "WARN: nginx reload failed"
else
echo "WARN: nginx 未安装或配置校验失败,跳过重载"
fi
echo "==> 8. 重载 nginxrobots.txt / 校验文件等 include 配置)"
if command -v nginx >/dev/null 2>&1 && nginx -t 2>/dev/null; then
systemctl reload nginx || echo "WARN: nginx reload failed"
else
echo "WARN: nginx 未安装或配置校验失败,跳过重载"
fi