6b92979c7c
Build and Release / Build (push) Has been cancelled
- 新增家庭共享订阅管理 - 新增用户邀请统计 - 新增签名和订阅模式设置表单 - 更新 API 服务层和国际化文件 - UI 组件优化(enhanced-input、pro-table)
79 lines
2.0 KiB
TypeScript
79 lines
2.0 KiB
TypeScript
type TranslateFn = (...args: any[]) => any;
|
|
|
|
function normalizeEnumValue(value?: string) {
|
|
return (value || "").trim().toLowerCase();
|
|
}
|
|
|
|
export function isFamilyStatusActive(status?: string) {
|
|
return normalizeEnumValue(status) === "active";
|
|
}
|
|
|
|
export function isFamilyRoleOwner(role?: string) {
|
|
return normalizeEnumValue(role) === "owner";
|
|
}
|
|
|
|
export function isFamilyMemberStatusActive(status?: string) {
|
|
return normalizeEnumValue(status) === "active";
|
|
}
|
|
|
|
export function getFamilyStatusLabel(t: TranslateFn, status?: string) {
|
|
const normalized = normalizeEnumValue(status);
|
|
if (!normalized) return "--";
|
|
|
|
switch (normalized) {
|
|
case "active":
|
|
return t("statusActive", "Active");
|
|
case "disabled":
|
|
return t("familyDisabled", "Disabled");
|
|
default:
|
|
return status || "--";
|
|
}
|
|
}
|
|
|
|
export function getFamilyRoleLabel(t: TranslateFn, role?: string) {
|
|
const normalized = normalizeEnumValue(role);
|
|
if (!normalized) return "--";
|
|
|
|
switch (normalized) {
|
|
case "owner":
|
|
return t("owner", "Owner");
|
|
case "member":
|
|
return t("familyMember", "Member");
|
|
default:
|
|
return role || "--";
|
|
}
|
|
}
|
|
|
|
export function getFamilyMemberStatusLabel(t: TranslateFn, status?: string) {
|
|
const normalized = normalizeEnumValue(status);
|
|
if (!normalized) return "--";
|
|
|
|
switch (normalized) {
|
|
case "active":
|
|
return t("statusActive", "Active");
|
|
case "left":
|
|
return t("familyMemberLeft", "Left");
|
|
case "removed":
|
|
return t("familyMemberRemoved", "Removed");
|
|
default:
|
|
return status || "--";
|
|
}
|
|
}
|
|
|
|
export function getFamilyJoinSourceLabel(t: TranslateFn, joinSource?: string) {
|
|
const normalized = normalizeEnumValue(joinSource);
|
|
if (!normalized) return "--";
|
|
|
|
switch (normalized) {
|
|
case "owner_init":
|
|
return t("familyJoinSourceOwnerInit", "Owner Initialization");
|
|
case "bind_email_with_verification":
|
|
return t(
|
|
"familyJoinSourceBindEmailWithVerification",
|
|
"Bind Email With Verification"
|
|
);
|
|
default:
|
|
return joinSource || "--";
|
|
}
|
|
}
|