Refactor TypeScript interfaces and types for consistency and readability
Gitea Auto Deploy / Deploy-Container (push) Successful in 49s
Gitea Auto Deploy / Deploy-Container (push) Successful in 49s
- Reformatted multiple TypeScript interfaces across various files to ensure consistent spacing and indentation. - Updated `changelog.ts`, `enka.ts`, `extraData.ts`, `gloval.d.ts`, `index.ts`, `lightconeDetail.ts`, `metaData.ts`, `mics.ts`, `modelConfig.ts`, `monsterDetail.ts`, `peakDetail.ts`, `pfDetail.ts`, `psConnect.ts`, `relicDetail.ts`, `showcase.ts`, `srtools.ts`, and `zod/index.ts` for improved code clarity. - Ensured all interfaces are properly formatted with consistent line breaks and spacing. - Made minor adjustments to the `tsconfig.json` file for formatting consistency.
This commit is contained in:
+61
-61
@@ -1,62 +1,62 @@
|
||||
import { listCurrentLanguageApi } from "@/constant/constant";
|
||||
import { AvatarDetail } from "@/types";
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
type TFunc = ReturnType<typeof useTranslations>
|
||||
function cleanText(text: string): string {
|
||||
if (!text) return ""
|
||||
return text.replace(/<unbreak>(.*?)<\/unbreak>/g, "$1")
|
||||
}
|
||||
|
||||
export function getNameChar(
|
||||
locale: string,
|
||||
t: TFunc,
|
||||
data: AvatarDetail | undefined
|
||||
): string {
|
||||
if (!data) return "";
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguageApi, locale)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguageApi[locale as keyof typeof listCurrentLanguageApi].toLowerCase();
|
||||
|
||||
let text = data.Name[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.Name["en"] ?? "";
|
||||
}
|
||||
|
||||
if (data.ID > 8000) {
|
||||
text = `${t("trailblazer")} • ${t(data?.BaseType?.toLowerCase() ?? "")}`;
|
||||
}
|
||||
|
||||
return cleanText(text)
|
||||
}
|
||||
|
||||
export function getLocaleName(locale: string, data: Record<string, string> | undefined | null): string {
|
||||
if (!data) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguageApi, locale)) {
|
||||
return ""
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguageApi[locale as keyof typeof listCurrentLanguageApi].toLowerCase();
|
||||
|
||||
let text = data[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data["en"] ?? "";
|
||||
}
|
||||
|
||||
return cleanText(text)
|
||||
}
|
||||
|
||||
export function parseRuby(text: string): string {
|
||||
const rubyRegex = /\{RUBY_B#(.*?)\}(.*?)\{RUBY_E#\}/gs;
|
||||
return text.replace(rubyRegex, (_match, furigana, kanji) => {
|
||||
return `<ruby>${kanji}<rt>${furigana}</rt></ruby>`;
|
||||
});
|
||||
import { listCurrentLanguageApi } from "@/constant/constant";
|
||||
import { AvatarDetail } from "@/types";
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
type TFunc = ReturnType<typeof useTranslations>
|
||||
function cleanText(text: string): string {
|
||||
if (!text) return ""
|
||||
return text.replace(/<unbreak>(.*?)<\/unbreak>/g, "$1")
|
||||
}
|
||||
|
||||
export function getNameChar(
|
||||
locale: string,
|
||||
t: TFunc,
|
||||
data: AvatarDetail | undefined
|
||||
): string {
|
||||
if (!data) return "";
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguageApi, locale)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguageApi[locale as keyof typeof listCurrentLanguageApi].toLowerCase();
|
||||
|
||||
let text = data.Name[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data.Name["en"] ?? "";
|
||||
}
|
||||
|
||||
if (data.ID > 8000) {
|
||||
text = `${t("trailblazer")} • ${t(data?.BaseType?.toLowerCase() ?? "")}`;
|
||||
}
|
||||
|
||||
return cleanText(text)
|
||||
}
|
||||
|
||||
export function getLocaleName(locale: string, data: Record<string, string> | undefined | null): string {
|
||||
if (!data) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(listCurrentLanguageApi, locale)) {
|
||||
return ""
|
||||
}
|
||||
|
||||
const langKey = listCurrentLanguageApi[locale as keyof typeof listCurrentLanguageApi].toLowerCase();
|
||||
|
||||
let text = data[langKey] ?? "";
|
||||
|
||||
if (!text) {
|
||||
text = data["en"] ?? "";
|
||||
}
|
||||
|
||||
return cleanText(text)
|
||||
}
|
||||
|
||||
export function parseRuby(text: string): string {
|
||||
const rubyRegex = /\{RUBY_B#(.*?)\}(.*?)\{RUBY_E#\}/gs;
|
||||
return text.replace(rubyRegex, (_match, furigana, kanji) => {
|
||||
return `<ruby>${kanji}<rt>${furigana}</rt></ruby>`;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user