修复官网选购咨询入口与图片失败降级

This commit is contained in:
cieanyau committed 2026-11-06 04:48:38 +08:00
1 parent d8224ec5b7
commit 08ffc51894
5 files changed
+463 -89

No files matched your search

+47 -11
View File
@@ -25,7 +25,7 @@ var n = {
},
{
label: `订购产品`,
href: `/cart`,
href: `/products`,
is_show: !0,
},
{
@@ -68,7 +68,7 @@ var n = {
},
],
buttonLabel: `浏览产品服务`,
buttonHref: `/login?redirect=%2Fproducts`,
buttonHref: `/products`,
secondaryLabel: `了解基础设施`,
secondaryHref: `#infrastructure`,
metric: {
@@ -124,7 +124,7 @@ var n = {
},
],
buttonLabel: `查看云服务器`,
href: `/login?redirect=%2Fcloud-servers`,
href: `/products/cloud-server`,
is_show: !0,
},
{
@@ -149,7 +149,7 @@ var n = {
},
],
buttonLabel: `查看物理服务器`,
href: `/login?redirect=%2Fdedicated-servers`,
href: `/products/dedicated-server`,
is_show: !0,
},
{
@@ -173,8 +173,8 @@ var n = {
is_show: !0,
},
],
buttonLabel: `了解机柜托管`,
href: `/login?redirect=%2Fcolocations`,
buttonLabel: `登录咨询机柜托管`,
href: `/tickets/create`,
is_show: !0,
},
],
@@ -251,7 +251,7 @@ var n = {
title: `为你的下一个项目选好基础设施`,
description: `浏览可用产品方案,或进入客户中心配置服务、管理实例与订单。`,
buttonLabel: `前往产品目录`,
buttonHref: `/login?redirect=%2Fproducts`,
buttonHref: `/products`,
secondaryLabel: `登录客户中心`,
secondaryHref: `/login`,
},
@@ -263,17 +263,17 @@ var n = {
links: [
{
label: `云服务器`,
href: `/login?redirect=%2Fcloud-servers`,
href: `/products/cloud-server`,
is_show: !0,
},
{
label: `物理服务器`,
href: `/login?redirect=%2Fdedicated-servers`,
href: `/products/dedicated-server`,
is_show: !0,
},
{
label: `机柜托管`,
href: `/login?redirect=%2Fcolocations`,
href: `/tickets/create`,
is_show: !0,
},
],
@@ -359,8 +359,44 @@ function i(e, t) {
function a() {
return JSON.parse(JSON.stringify(n));
}
// 只迁移已确认的站内旧购买目的地;CMS 自定义外链、文案及其余账号入口保持原样。
const purchaseDestinations = new Map([
["/products", "/products"],
["/cloud-servers", "/products/cloud-server"],
["/dedicated-servers", "/products/dedicated-server"],
["/colocations", "/tickets/create"],
]);
function purchaseHref(value) {
if (typeof value !== "string" || !/^\/(?!\/)/.test(value)) return value;
try {
const url = new URL(value, window.location.origin);
const target =
url.pathname === "/login"
? new URL(
url.searchParams.get("redirect") || "/",
window.location.origin,
)
: url;
if (target.origin !== window.location.origin) return value;
const destination = purchaseDestinations.get(target.pathname);
return destination ? destination + target.search + target.hash : value;
} catch {
return value;
}
}
// 在 CMS 入模处处理所有链接字段,头尾、商品卡及主按钮不会各自保留不同的旧规则。
function normalizeLinks(value) {
if (Array.isArray(value)) return value.map(normalizeLinks);
if (!r(value)) return value;
return Object.fromEntries(
Object.entries(value).map(([key, entry]) => [
key,
/href$/i.test(key) ? purchaseHref(entry) : normalizeLinks(entry),
]),
);
}
function o(e) {
return i(n, e);
return normalizeLinks(i(n, e));
}
// 链接允许站内路径、锚点、HTTP(S)/mailto/tel;未知协议和反斜杠回落为不可跳转的 #。
function s(e) {