fix: add basename
This commit is contained in:
6
src/modules/Redirect.tsx
Normal file
6
src/modules/Redirect.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { basename } from './basename';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
|
||||
export const Redirect = (({ to }) => {
|
||||
return <Navigate to={`${to}`} />;
|
||||
}) as any as typeof Navigate;
|
||||
1
src/modules/basename.ts
Normal file
1
src/modules/basename.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const basename = DEV_SERVER ? '' : '/root/center';
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NavigateFunction, To, useNavigate } from 'react-router-dom';
|
||||
import { basename } from './basename';
|
||||
/**
|
||||
* 如果有basepath,刚好给path加上basepath
|
||||
* @returns NavigateFunction
|
||||
@@ -6,6 +7,7 @@ import { NavigateFunction, To, useNavigate } from 'react-router-dom';
|
||||
export const useNewNavigate = (): NavigateFunction => {
|
||||
const navigate = useNavigate();
|
||||
const fn = (path: To, data?: any) => {
|
||||
// navigate(basename + '/' + path, data);
|
||||
navigate(path, data);
|
||||
};
|
||||
return fn as NavigateFunction;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { DialogModal } from '@kevisual/ui';
|
||||
import '@kevisual/ui/dist/index.css';
|
||||
|
||||
import { basename } from './basename';
|
||||
const content = document.createElement('div');
|
||||
|
||||
const loginHref = `${basename}/user/login`;
|
||||
content.innerHTML = `
|
||||
<div class="bg-white p-8 rounded-sm shadow-md w-full max-w-md text-center">
|
||||
<h2 class="text-2xl font-bold mb-4">Token 无效</h2>
|
||||
<p class="mb-6">您的登录凭证已失效,请重新登录。</p>
|
||||
<a href="/user/login" class="inline-block bg-red-500 text-white py-2 px-4 rounded-sm hover:bg-red-600 transition duration-200">确定</a>
|
||||
<a href="${loginHref}" class="inline-block bg-red-500 text-white py-2 px-4 rounded-sm hover:bg-red-600 transition duration-200">确定</a>
|
||||
</div>
|
||||
`;
|
||||
export const modal = DialogModal.render(content, {
|
||||
|
||||
Reference in New Issue
Block a user