mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-13 17:46:02 +00:00
fix(frontend): keep sidebar links absolute when basePath is empty
The dashboard sidebar built tab keys as basePath + 'panel/...'. In dev the window-injected basePath is '' so the resulting key was a relative path like 'panel/settings'. When the browser resolved that against the current /panel/settings URL it produced /panel/panel/settings — visible as broken navigation between Dashboard and Settings. Force a leading slash so the keys are always absolute regardless of whether the host injected a basePath. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
3ecdae7c92
commit
f7f97bf9e5
1 changed files with 12 additions and 5 deletions
|
|
@ -35,12 +35,19 @@ const iconByName = {
|
||||||
logout: LogoutOutlined,
|
logout: LogoutOutlined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// basePath comes from Go (`/` by default, `/myprefix/` when configured) so
|
||||||
|
// these concatenations land on absolute paths. In dev we synthesize the prop
|
||||||
|
// from a window global which can be empty — force a leading slash so the
|
||||||
|
// browser doesn't resolve the link relative to the current pathname (which
|
||||||
|
// would turn /panel/settings + 'panel/...' into /panel/panel/...).
|
||||||
|
const prefix = props.basePath?.startsWith('/') ? props.basePath : `/${props.basePath || ''}`;
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ key: `${props.basePath}panel/`, icon: 'dashboard', title: 'Dashboard' },
|
{ key: `${prefix}panel/`, icon: 'dashboard', title: 'Dashboard' },
|
||||||
{ key: `${props.basePath}panel/inbounds`, icon: 'user', title: 'Inbounds' },
|
{ key: `${prefix}panel/inbounds`, icon: 'user', title: 'Inbounds' },
|
||||||
{ key: `${props.basePath}panel/settings`, icon: 'setting', title: 'Settings' },
|
{ key: `${prefix}panel/settings`, icon: 'setting', title: 'Settings' },
|
||||||
{ key: `${props.basePath}panel/xray`, icon: 'tool', title: 'Xray' },
|
{ key: `${prefix}panel/xray`, icon: 'tool', title: 'Xray' },
|
||||||
{ key: `${props.basePath}logout/`, icon: 'logout', title: 'Logout' },
|
{ key: `${prefix}logout/`, icon: 'logout', title: 'Logout' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const activeTab = ref([props.requestUri]);
|
const activeTab = ref([props.requestUri]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue