docs: annotate all shared frontend modules in Chinese
This commit is contained in:
1 parent
2be21c1c62
commit
408f8e5c98
55 files changed
+349
No files matched your search
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* 后端菜单到前端路由的适配层:兼容旧页面地址、限制可用路由和参数,并生成导航分组。
|
||||
* 菜单可见性不是权限校验,所有实际操作仍须由后端按当前身份授权。
|
||||
*/
|
||||
// 合并旧账单入口与财务入口;全树最多保留一个由 /bills 转换得到的财务项。
|
||||
function e(e) {
|
||||
let t = (e) =>
|
||||
e.some(
|
||||
@@ -36,6 +41,7 @@ function e(e) {
|
||||
}
|
||||
return r(e);
|
||||
}
|
||||
/** 路径长度和匹配 query 数量决定激活优先级,避免父菜单与更具体子菜单同时高亮。 */
|
||||
function t(e, t, n = []) {
|
||||
let r =
|
||||
t.path === `/products/cvm`
|
||||
@@ -54,6 +60,7 @@ function t(e, t, n = []) {
|
||||
let a = i(e);
|
||||
return a >= 0 && !n.some((e) => i(e.to) > a);
|
||||
}
|
||||
// 只映射前端已实现的路由;旧版 .htm/插件入口必须显式登记,不透传任意路径。
|
||||
var n = new Set(
|
||||
`/./products./products/cloud-server./products/dedicated-server./cart./cloud-servers./dedicated-servers./security/groups./security/ssh-keys./security/domains./transfer./finance./orders./bills./invoices./invoices/settings./invoices/request./recommend./vouchers./account./account/api-keys./account/connections./account/realname./messages./logbook./tickets./tickets/create./help./notices./news./resources`.split(
|
||||
`.`,
|
||||
@@ -99,6 +106,7 @@ var n = new Set(
|
||||
(e) => ![`/`, `/security/groups`, `/vouchers`, `/logbook`].includes(e),
|
||||
),
|
||||
);
|
||||
// 图标由本地 Lucide 名称决定,不直接采用后端传入的任意图标实现。
|
||||
function o(e) {
|
||||
let t = e.to?.split(`?`)[0];
|
||||
return (
|
||||
@@ -134,6 +142,7 @@ function o(e) {
|
||||
: `lucide:circle-help`)
|
||||
);
|
||||
}
|
||||
/** 根据服务器模块菜单纠正列表类型或补齐唯一模块 m;多模块时不擅自替用户选择。 */
|
||||
function s(e, t) {
|
||||
if (![`/cloud-servers`, `/dedicated-servers`].includes(t.path)) return;
|
||||
let n = new Set(),
|
||||
@@ -168,6 +177,7 @@ function s(e, t) {
|
||||
},
|
||||
};
|
||||
}
|
||||
// 把已规范化的后端菜单装入现有分组,账户子页和资源中心有固定归属,其他落到末组。
|
||||
function c(e, t, n) {
|
||||
let r = e.map((e) => ({
|
||||
...e,
|
||||
@@ -199,6 +209,7 @@ function c(e, t, n) {
|
||||
}
|
||||
return r.filter((e) => e.items.length);
|
||||
}
|
||||
// 遍历树生成面包屑;相同路径时选择包含更多匹配 query 的最具体节点。
|
||||
function l(e, n) {
|
||||
let r = [];
|
||||
function i(e, a) {
|
||||
@@ -222,6 +233,7 @@ function l(e, n) {
|
||||
}
|
||||
return (i(e, []), r.sort((e, t) => t.score - e.score)[0]?.labels ?? []);
|
||||
}
|
||||
// 使用后端菜单时移除已被接管的前端默认入口,避免同一功能重复出现。
|
||||
function u(e, t) {
|
||||
let n = new Set(),
|
||||
r = (e) =>
|
||||
@@ -250,6 +262,7 @@ function u(e, t) {
|
||||
}))
|
||||
.filter((e) => e.items.length);
|
||||
}
|
||||
/** 外链只允许无用户名/密码的 HTTP(S) URL;控制字符和反斜杠直接拒绝。 */
|
||||
function d(e) {
|
||||
if (
|
||||
typeof e != `string` ||
|
||||
@@ -264,6 +277,10 @@ function d(e) {
|
||||
return ``;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 规范化后端菜单树:最多三层、每层最多 100 项,文本最多 100 字。
|
||||
* 无法适配的菜单保留禁用原因而非猜测跳转;二次提醒 second_reminder 作为确认标记保留。
|
||||
*/
|
||||
function f(e, t = ``, a = 0) {
|
||||
if (!Array.isArray(e) || a > 2) return [];
|
||||
let o = e.slice(0, 100).flatMap((e, o) => {
|
||||
@@ -307,6 +324,7 @@ function f(e, t = ``, a = 0) {
|
||||
let [e, t = ``] = (h || u).split(`?`),
|
||||
n = new URLSearchParams(l.split(`?`)[1] ?? ``),
|
||||
r = new URLSearchParams(t);
|
||||
// 只保留各页面明确支持且值域有效的单值 query,不能透传后端提供的任意参数。
|
||||
for (let t of {
|
||||
"/bills": [`status`],
|
||||
"/orders": [`status`],
|
||||
@@ -351,6 +369,7 @@ function f(e, t = ``, a = 0) {
|
||||
return [s];
|
||||
}),
|
||||
s = o.filter((e) => e.to === `/account`);
|
||||
// 旧后台可能把多个入口映射到 /account;合并后仍保留任一入口要求的二次确认。
|
||||
return s.length < 2
|
||||
? o
|
||||
: o.flatMap((e) =>
|
||||
|
||||
Reference in new issue
Block a user