refactor: 更新风险监控页面标题为国际化支持,优化风险池控制台的标题处理
This commit is contained in:
40
src/hooks/use-admin-play-type-catalog.ts
Normal file
40
src/hooks/use-admin-play-type-catalog.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { getAdminPlayTypes } from "@/api/admin-config";
|
||||
import {
|
||||
formatAdminPlayCodeLabel,
|
||||
getAdminPlayTypesLoadPromise,
|
||||
resolveAdminPlayTypeDisplayName,
|
||||
} from "@/lib/admin-play-types";
|
||||
|
||||
export function useAdminPlayTypeCatalog(): void {
|
||||
useEffect(() => {
|
||||
void getAdminPlayTypesLoadPromise(getAdminPlayTypes);
|
||||
}, []);
|
||||
}
|
||||
|
||||
/** 返回按当前界面语言解析的玩法标签(显示名 + 编码) */
|
||||
export function useAdminPlayCodeLabel(): (playCode: string | null | undefined) => string {
|
||||
const { i18n } = useTranslation();
|
||||
useAdminPlayTypeCatalog();
|
||||
|
||||
return useCallback(
|
||||
(playCode: string | null | undefined) => formatAdminPlayCodeLabel(playCode, i18n.language),
|
||||
[i18n.language],
|
||||
);
|
||||
}
|
||||
|
||||
/** 仅显示名,不含编码(用于下拉选项等) */
|
||||
export function useAdminPlayCodeDisplayName(): (playCode: string | null | undefined) => string {
|
||||
const { i18n } = useTranslation();
|
||||
useAdminPlayTypeCatalog();
|
||||
|
||||
return useCallback(
|
||||
(playCode: string | null | undefined) =>
|
||||
resolveAdminPlayTypeDisplayName(playCode, i18n.language),
|
||||
[i18n.language],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user