|
1 |
| -import { |
2 |
| - MemoryRouter as Router, |
3 |
| - Routes, |
4 |
| - Route, |
5 |
| - Link, |
6 |
| - Outlet, |
7 |
| - useNavigate, |
8 |
| -} from 'react-router-dom'; |
9 |
| -import { Button } from 'antd'; |
10 |
| -import { useEffect, useState } from 'react'; |
11 |
| -import Config from './routes/config'; |
12 |
| - |
13 |
| -import { initOssClient, handleOss } from './util'; |
| 1 | +import { Routes, Route, useNavigate } from 'react-router-dom'; |
| 2 | +import { useState } from 'react'; |
| 3 | +import OssConfig from './routes/OssConfig'; |
| 4 | +import ProjectList from './routes/ProjectList'; |
| 5 | +import ProjectVersionList from './routes/ProjectVersionList'; |
| 6 | +import { initOssClient } from './util'; |
14 | 7 | import './App.css';
|
15 | 8 |
|
16 |
| -const Hello = () => { |
| 9 | +export default function App() { |
17 | 10 | const navigate = useNavigate();
|
18 | 11 | const [hasInit, setInit] = useState(false);
|
19 | 12 | const localAk = localStorage.getItem('ak');
|
| 13 | + |
20 | 14 | if (!localAk) {
|
21 | 15 | navigate('/config');
|
22 | 16 | } else if (!hasInit) {
|
23 |
| - if (!hasInit) { |
24 |
| - initOssClient(JSON.parse(localAk)) |
25 |
| - .then((res) => { |
26 |
| - setInit(true); |
27 |
| - return res; |
28 |
| - }) |
29 |
| - .catch((err) => console.log(err)); |
30 |
| - } |
| 17 | + initOssClient(JSON.parse(localAk)) |
| 18 | + .then((res) => { |
| 19 | + setInit(true); |
| 20 | + return res; |
| 21 | + }) |
| 22 | + .catch((err) => console.log(err)); |
31 | 23 | }
|
32 |
| - useEffect(() => { |
33 |
| - async function handle() { |
34 |
| - if (hasInit) { |
35 |
| - const list = await handleOss('list', { |
36 |
| - prefix: '', |
37 |
| - delimiter: '/', |
38 |
| - 'max-keys': 1000, |
39 |
| - }); |
40 |
| - console.log(list); |
41 |
| - } |
42 |
| - } |
43 | 24 |
|
44 |
| - handle(); |
45 |
| - }, [hasInit]); |
46 |
| - return ( |
47 |
| - <div> |
48 |
| - <Button type="primary">eeee</Button> |
49 |
| - <Link to="/config">登录</Link> |
50 |
| - <Outlet /> |
51 |
| - </div> |
52 |
| - ); |
53 |
| -}; |
54 |
| - |
55 |
| -export default function App() { |
56 | 25 | return (
|
57 |
| - <Router> |
58 |
| - <Routes> |
59 |
| - <Route path="/" element={<Hello />} /> |
60 |
| - <Route path="config" element={<Config />} /> |
61 |
| - </Routes> |
62 |
| - </Router> |
| 26 | + <Routes> |
| 27 | + <Route path="/" element={<ProjectList hasInit={hasInit} />}> |
| 28 | + <Route path=":project" element={<ProjectVersionList />} /> |
| 29 | + </Route> |
| 30 | + <Route path="config" element={<OssConfig />} /> |
| 31 | + </Routes> |
63 | 32 | );
|
64 | 33 | }
|
0 commit comments