style: lint

This commit is contained in:
Slinetrac
2025-11-06 12:14:30 +08:00
Unverified
parent c76d33a103
commit 1ce192dfeb
17 changed files with 285 additions and 257 deletions

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -1,27 +1,27 @@
import shared from "./shared.json";
import connections from "./connections.json";
import home from "./home.json";
import layout from "./layout.json";
import logs from "./logs.json";
import profiles from "./profiles.json";
import proxies from "./proxies.json";
import connections from "./connections.json";
import tests from "./tests.json";
import logs from "./logs.json";
import rules from "./rules.json";
import home from "./home.json";
import unlock from "./unlock.json";
import settings from "./settings.json";
import layout from "./layout.json";
import shared from "./shared.json";
import tests from "./tests.json";
import unlock from "./unlock.json";
const resources = {
"shared": shared,
"profiles": profiles,
"proxies": proxies,
"connections": connections,
"tests": tests,
"logs": logs,
"rules": rules,
"home": home,
"unlock": unlock,
"settings": settings,
"layout": layout,
shared: shared,
profiles: profiles,
proxies: proxies,
connections: connections,
tests: tests,
logs: logs,
rules: rules,
home: home,
unlock: unlock,
settings: settings,
layout: layout,
};
export default resources;

View File

@@ -17,6 +17,24 @@ export const supportedLanguages = [
"zhtw",
];
const FALLBACK_LANGUAGE = "zh";
type LocaleModule = {
default: Record<string, unknown>;
};
const localeModules = import.meta.glob<LocaleModule>("@/locales/*/index.ts");
const localeLoaders = Object.entries(localeModules).reduce<
Record<string, () => Promise<LocaleModule>>
>((acc, [path, loader]) => {
const match = path.match(/[/\\]locales[/\\]([^/\\]+)[/\\]index\.ts$/);
if (match) {
acc[match[1]] = loader;
}
return acc;
}, {});
export const languages: Record<string, any> = supportedLanguages.reduce(
(acc, lang) => {
acc[lang] = {};
@@ -27,14 +45,27 @@ export const languages: Record<string, any> = supportedLanguages.reduce(
export const loadLanguage = async (language: string) => {
try {
const module = await import(`@/locales/${language}/index.ts`);
const loader = localeLoaders[language];
if (!loader) {
throw new Error(`Locale loader not found for language "${language}"`);
}
const module = await loader();
return module.default;
} catch (error) {
console.warn(
`Failed to load language ${language}, fallback to zh, ${error}`,
);
const fallback = await import("@/locales/zh/index.ts");
return fallback.default;
if (language !== FALLBACK_LANGUAGE) {
console.warn(
`Failed to load language ${language}, fallback to ${FALLBACK_LANGUAGE}, ${error}`,
);
const fallbackLoader = localeLoaders[FALLBACK_LANGUAGE];
if (!fallbackLoader) {
throw new Error(
`Fallback language "${FALLBACK_LANGUAGE}" resources are missing.`,
);
}
const fallback = await fallbackLoader();
return fallback.default;
}
throw error;
}
};