mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-01 19:52:09 +03:00
fd7b3559bc
Monthly sponsor placements need to change without cutting a panel release. Panels now read 3X/sponsors.json from the MHSanaei/sponsors repo (GitHub Pages on sponsors.sanaei.dev) and show active sponsors in four slots: an overview banner, a rotating sidebar card (max three), the login page and a new Sponsors page that also lists open placements. An entry shows only while enable is not false and until is in the future; links must be https and logos are png/webp/jpg by name only. The list is cached for an hour and the last good copy survives upstream failures; logos are proxied through /sponsors/logo/:name with failures cached, so CSP stays 'self' and admin browsers never reach a third party. Admins can hide a slot for 24h. Under XUI_DEBUG the panel reads a sibling ../sponsors/3X checkout so edits can be previewed before push.
31 lines
856 B
TypeScript
31 lines
856 B
TypeScript
import { useEffect } from 'react';
|
|
import { useLocation } from 'react-router';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
const TITLE_KEYS: Record<string, string> = {
|
|
'/': 'menu.dashboard',
|
|
'/inbounds': 'menu.inbounds',
|
|
'/clients': 'menu.clients',
|
|
'/groups': 'menu.groups',
|
|
'/nodes': 'menu.nodes',
|
|
'/hosts': 'menu.hosts',
|
|
'/settings': 'menu.settings',
|
|
'/xray': 'menu.xray',
|
|
'/outbound': 'menu.outbounds',
|
|
'/routing': 'menu.routing',
|
|
'/api-docs': 'menu.apiDocs',
|
|
'/sponsors': 'menu.sponsors',
|
|
};
|
|
|
|
export function usePageTitle() {
|
|
const { pathname } = useLocation();
|
|
const { t } = useTranslation();
|
|
|
|
useEffect(() => {
|
|
const key = TITLE_KEYS[pathname];
|
|
const title = key ? t(key) : '3X-UI';
|
|
const host = window.location.hostname;
|
|
document.title = host ? `${host} - ${title}` : title;
|
|
}, [pathname, t]);
|
|
}
|