fix: add basename
This commit is contained in:
parent
f00c6cc030
commit
0dce78e12f
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/center",
|
"name": "@kevisual/center",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@ -9,8 +9,8 @@
|
|||||||
"dev:kv": "cross-env VITE_USE_KV=true vite",
|
"dev:kv": "cross-env VITE_USE_KV=true vite",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"prepub": "envision switchOrg root",
|
"prepub": "envision switchMe",
|
||||||
"pub": "envision deploy ./dist -k center -v 0.0.3 -u"
|
"pub": "envision deploy ./dist -k center -v 0.0.5 -u"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@abearxiong/flows": "0.0.1-alpha.9",
|
"@abearxiong/flows": "0.0.1-alpha.9",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
||||||
import { ConfigProvider } from 'antd';
|
import { ConfigProvider } from 'antd';
|
||||||
import { App as ContainerApp } from './pages/container';
|
import { App as ContainerApp } from './pages/container';
|
||||||
import { App as MapApp } from './pages/map';
|
import { App as MapApp } from './pages/map';
|
||||||
@ -6,6 +6,8 @@ import { App as UserApp } from './pages/user';
|
|||||||
import { App as UserAppApp } from './pages/app';
|
import { App as UserAppApp } from './pages/app';
|
||||||
import { App as FileApp } from './pages/file';
|
import { App as FileApp } from './pages/file';
|
||||||
import { App as OrgApp } from './pages/org';
|
import { App as OrgApp } from './pages/org';
|
||||||
|
import { basename } from './modules/basename';
|
||||||
|
import { Redirect } from './modules/Redirect';
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
@ -14,9 +16,9 @@ export const App = () => {
|
|||||||
theme={{
|
theme={{
|
||||||
token: {},
|
token: {},
|
||||||
}}>
|
}}>
|
||||||
<Router>
|
<Router basename={basename}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' element={<Navigate to='/container/' />} />
|
<Route path='/' element={<Redirect to='/container/' />} />
|
||||||
<Route path='/container/*' element={<ContainerApp />} />
|
<Route path='/container/*' element={<ContainerApp />} />
|
||||||
<Route path='/map/*' element={<MapApp />} />
|
<Route path='/map/*' element={<MapApp />} />
|
||||||
<Route path='/user/*' element={<UserApp />} />
|
<Route path='/user/*' element={<UserApp />} />
|
||||||
|
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 { NavigateFunction, To, useNavigate } from 'react-router-dom';
|
||||||
|
import { basename } from './basename';
|
||||||
/**
|
/**
|
||||||
* 如果有basepath,刚好给path加上basepath
|
* 如果有basepath,刚好给path加上basepath
|
||||||
* @returns NavigateFunction
|
* @returns NavigateFunction
|
||||||
@ -6,6 +7,7 @@ import { NavigateFunction, To, useNavigate } from 'react-router-dom';
|
|||||||
export const useNewNavigate = (): NavigateFunction => {
|
export const useNewNavigate = (): NavigateFunction => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const fn = (path: To, data?: any) => {
|
const fn = (path: To, data?: any) => {
|
||||||
|
// navigate(basename + '/' + path, data);
|
||||||
navigate(path, data);
|
navigate(path, data);
|
||||||
};
|
};
|
||||||
return fn as NavigateFunction;
|
return fn as NavigateFunction;
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { DialogModal } from '@kevisual/ui';
|
import { DialogModal } from '@kevisual/ui';
|
||||||
import '@kevisual/ui/dist/index.css';
|
import '@kevisual/ui/dist/index.css';
|
||||||
|
import { basename } from './basename';
|
||||||
const content = document.createElement('div');
|
const content = document.createElement('div');
|
||||||
|
|
||||||
|
const loginHref = `${basename}/user/login`;
|
||||||
content.innerHTML = `
|
content.innerHTML = `
|
||||||
<div class="bg-white p-8 rounded-sm shadow-md w-full max-w-md text-center">
|
<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>
|
<h2 class="text-2xl font-bold mb-4">Token 无效</h2>
|
||||||
<p class="mb-6">您的登录凭证已失效,请重新登录。</p>
|
<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>
|
</div>
|
||||||
`;
|
`;
|
||||||
export const modal = DialogModal.render(content, {
|
export const modal = DialogModal.render(content, {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { Main } from './layouts';
|
import { Main } from './layouts';
|
||||||
import { List } from './edit/List';
|
import { List } from './edit/List';
|
||||||
import { AppVersionList } from './edit/AppVersionList';
|
import { AppVersionList } from './edit/AppVersionList';
|
||||||
|
import { Redirect } from '@/modules/Redirect';
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<Main />}>
|
<Route element={<Main />}>
|
||||||
<Route path='/' element={<Navigate to='/app/edit/list' />}></Route>
|
<Route path='/' element={<Redirect to='/app/edit/list' />}></Route>
|
||||||
<Route path='edit/list' element={<List />} />
|
<Route path='edit/list' element={<List />} />
|
||||||
<Route path='/:appKey/version/list' element={<AppVersionList />} />
|
<Route path='/:appKey/version/list' element={<AppVersionList />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { ContainerList } from './edit/List';
|
import { ContainerList } from './edit/List';
|
||||||
import { Main } from './layouts';
|
import { Main } from './layouts';
|
||||||
import { Preview, PreviewWrapper } from './preview';
|
import { Preview, PreviewWrapper } from './preview';
|
||||||
|
import { Redirect } from '@/modules/Redirect';
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<Main />}>
|
<Route element={<Main />}>
|
||||||
<Route path='/' element={<Navigate to='/container/edit/list' />}></Route>
|
<Route path='/' element={<Redirect to='/container/edit/list' />}></Route>
|
||||||
<Route path='edit/list' element={<ContainerList />} />
|
<Route path='edit/list' element={<ContainerList />} />
|
||||||
<Route path='preview/:id/wrapper' element={<PreviewWrapper />} />
|
<Route path='preview/:id/wrapper' element={<PreviewWrapper />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { Main } from './layouts';
|
import { Main } from './layouts';
|
||||||
import { List } from './edit/List';
|
import { List } from './edit/List';
|
||||||
|
import { Redirect } from '@/modules/Redirect';
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<Main />}>
|
<Route element={<Main />}>
|
||||||
<Route path='/' element={<Navigate to='/file/edit/list' />}></Route>
|
<Route path='/' element={<Redirect to='/file/edit/list' />}></Route>
|
||||||
<Route path='edit/list' element={<List />} />
|
<Route path='edit/list' element={<List />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { List } from './edit/List';
|
import { List } from './edit/List';
|
||||||
import { Main } from './layouts';
|
import { Main } from './layouts';
|
||||||
import { UserList } from './edit/UserList';
|
import { UserList } from './edit/UserList';
|
||||||
|
import { Redirect } from '@/modules/Redirect';
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<Main />}>
|
<Route element={<Main />}>
|
||||||
<Route path='/' element={<Navigate to='/org/edit/list' />}></Route>
|
<Route path='/' element={<Redirect to='/org/edit/list' />}></Route>
|
||||||
<Route path='edit/list' element={<List />} />
|
<Route path='edit/list' element={<List />} />
|
||||||
<Route path='edit/user/:id' element={<UserList />} />
|
<Route path='edit/user/:id' element={<UserList />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { List } from './edit/List';
|
import { List } from './edit/List';
|
||||||
import { Main } from './layouts';
|
import { Main } from './layouts';
|
||||||
import { Login } from './login/Login';
|
import { Login } from './login/Login';
|
||||||
import { Login as WxLogin } from './wx/Login';
|
import { Login as WxLogin } from './wx/Login';
|
||||||
import { Profile } from './edit/Profile';
|
import { Profile } from './edit/Profile';
|
||||||
|
import { Redirect } from '@/modules/Redirect';
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<Main />}>
|
<Route element={<Main />}>
|
||||||
<Route path='/' element={<Navigate to='/user/edit/list' />}></Route>
|
<Route path='/' element={<Redirect to='/user/edit/list' />}></Route>
|
||||||
<Route path='edit/list' element={<List />} />
|
<Route path='edit/list' element={<List />} />
|
||||||
<Route path='profile' element={<Profile />} />
|
<Route path='profile' element={<Profile />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -56,6 +56,7 @@ export default defineConfig({
|
|||||||
define: {
|
define: {
|
||||||
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
|
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
|
||||||
},
|
},
|
||||||
|
base: isDev ? '/' : '/root/center/',
|
||||||
server: {
|
server: {
|
||||||
port: 6020,
|
port: 6020,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user