Files
router-studio/src/modules/basename.ts
xiongxiao 64eabb7aa8 feat: update dependencies and add new features
- Update package.json dependencies (@tanstack/react-query, @kevisual/*, etc.)
- Add openLink utility function in basename.ts
- Add stackQueryClient for React Query in query.ts
- Refactor auth store with serverData and query hooks
- Add demo route and auth hooks
- Add VitePWA plugin and env config
- Update AGENTS.md documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 01:15:03 +08:00

32 lines
886 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @ts-ignore
export const basename = BASE_NAME;
export const wrapBasename = (path: string) => {
const hasEnd = path.endsWith('/')
if (basename) {
return `${basename}${path}` + (hasEnd ? '' : '/');
} else {
return path;
}
}
// 动态计算 basename根据当前 URL 路径
export const getDynamicBasename = (): string => {
const path = window.location.pathname
const [user, key, id] = path.split('/').filter(Boolean)
if (key === 'v1' && id) {
return `/${user}/v1/${id}`
}
// 默认使用构建时的 basename
return basename
}
export const openLink = (path: string, target: string = '_self') => {
if (path.startsWith('http://') || path.startsWith('https://')) {
window.open(path, target);
return;
}
const url = new URL(path, window.location.origin);
url.pathname = wrapBasename(url.pathname);
window.open(url.toString(), target);
}