Skip to content

Commit 43ced2f

Browse files
committed
update using react and go
1 parent 50a29e4 commit 43ced2f

File tree

519 files changed

+23042
-49765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

519 files changed

+23042
-49765
lines changed

.gitignore

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Dependencies
2+
**/node_modules
3+
.pnpm-store/
4+
5+
# Build outputs
6+
dist/
7+
build/
8+
*.dist
9+
10+
# Environment variables
11+
.env
12+
.env.local
13+
.env.development.local
14+
.env.test.local
15+
.env.production.local
16+
17+
# IDE and editor files
18+
.vscode/
19+
.idea/
20+
*.swp
21+
*.swo
22+
*~
23+
24+
# OS generated files
25+
.DS_Store
26+
.DS_Store?
27+
._*
28+
.Spotlight-V100
29+
.Trashes
30+
ehthumbs.db
31+
Thumbs.db
32+
33+
# Logs
34+
logs
35+
*.log
36+
npm-debug.log*
37+
yarn-debug.log*
38+
yarn-error.log*
39+
pnpm-debug.log*
40+
lerna-debug.log*
41+
42+
# Runtime data
43+
pids
44+
*.pid
45+
*.seed
46+
*.pid.lock
47+
*.bak
48+
49+
# Coverage directory used by tools like istanbul
50+
coverage/
51+
*.lcov
52+
53+
# nyc test coverage
54+
.nyc_output
55+
56+
# Dependency directories
57+
jspm_packages/
58+
59+
# TypeScript cache
60+
*.tsbuildinfo
61+
62+
# Optional npm cache directory
63+
.npm
64+
65+
# Optional eslint cache
66+
.eslintcache
67+
68+
# Microbundle cache
69+
.rpt2_cache/
70+
.rts2_cache_cjs/
71+
.rts2_cache_es/
72+
.rts2_cache_umd/
73+
74+
# Optional REPL history
75+
.node_repl_history
76+
77+
# Output of 'npm pack'
78+
*.tgz
79+
80+
# Yarn Integrity file
81+
.yarn-integrity
82+
83+
# parcel-bundler cache (https://parceljs.org/)
84+
.cache
85+
.parcel-cache
86+
87+
# Next.js build output
88+
.next
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
93+
# Gatsby files
94+
.cache/
95+
96+
# Storybook build outputs
97+
.out
98+
.storybook-out
99+
100+
# Temporary folders
101+
tmp/
102+
temp/
103+
104+
# Database
105+
*.db
106+
*.sqlite
107+
*.sqlite3

.gitkeep

Whitespace-only changes.

.prettierignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Dependencies
2+
node_modules/
3+
.pnpm-store/
4+
5+
# Build outputs
6+
dist/
7+
build/
8+
*.dist
9+
10+
# Generated files
11+
*.tsbuildinfo
12+
coverage/
13+
14+
# Package files
15+
package-lock.json
16+
pnpm-lock.yaml
17+
18+
# Database
19+
*.db
20+
*.sqlite
21+
*.sqlite3
22+
23+
# Logs
24+
*.log
25+
26+
# Environment files
27+
.env*
28+
29+
# IDE files
30+
.vscode/
31+
.idea/
32+
33+
# OS files
34+
.DS_Store
35+
Thumbs.db

.prettierrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"bracketSameLine": false,
10+
"arrowParens": "avoid",
11+
"endOfLine": "lf",
12+
"quoteProps": "as-needed",
13+
"jsxSingleQuote": false,
14+
"proseWrap": "preserve"
15+
}

License.pdf

-252 KB
Binary file not shown.

README.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1.0, maximum-scale=1" />
9+
<title>Bo Li Portfolio Refactor</title>
10+
<!-- THIS IS THE START OF A COMMENT BLOCK, BLOCK TO BE DELETED: Google Fonts here, example:
11+
<link rel="preconnect" href="https://fonts.googleapis.com" />
12+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
13+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
14+
THIS IS THE END OF A COMMENT BLOCK, BLOCK TO BE DELETED -->
15+
</head>
16+
17+
<body>
18+
<div id="root"></div>
19+
<script type="module" src="/src/main.tsx"></script>
20+
<script
21+
defer
22+
src="%VITE_ANALYTICS_ENDPOINT%/umami"
23+
data-website-id="%VITE_ANALYTICS_WEBSITE_ID%"></script>
24+
</body>
25+
26+
</html>

client/public/.gitkeep

Whitespace-only changes.

client/src/App.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Toaster } from "@/components/ui/sonner";
2+
import { TooltipProvider } from "@/components/ui/tooltip";
3+
import { Route, Switch } from "wouter";
4+
import ErrorBoundary from "./components/ErrorBoundary";
5+
import { ThemeProvider } from "./contexts/ThemeContext";
6+
import Home from "./pages/Home";
7+
import NotFound from "@/pages/NotFound";
8+
9+
function Router() {
10+
return (
11+
<Switch>
12+
<Route path={"/"} component={Home} />
13+
<Route path={"/404"} component={NotFound} />
14+
{/* Final fallback route */}
15+
<Route component={NotFound} />
16+
</Switch>
17+
);
18+
}
19+
20+
function App() {
21+
return (
22+
<ErrorBoundary>
23+
<ThemeProvider defaultTheme="light">
24+
<TooltipProvider>
25+
<Toaster />
26+
<Router />
27+
</TooltipProvider>
28+
</ThemeProvider>
29+
</ErrorBoundary>
30+
);
31+
}
32+
33+
export default App;

client/src/_core/hooks/useAuth.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { getLoginUrl } from "@/const";
2+
import { trpc } from "@/lib/trpc";
3+
import { TRPCClientError } from "@trpc/client";
4+
import { useCallback, useEffect, useMemo } from "react";
5+
6+
type UseAuthOptions = {
7+
redirectOnUnauthenticated?: boolean;
8+
redirectPath?: string;
9+
};
10+
11+
export function useAuth(options?: UseAuthOptions) {
12+
const { redirectOnUnauthenticated = false, redirectPath = getLoginUrl() } =
13+
options ?? {};
14+
const utils = trpc.useUtils();
15+
16+
const meQuery = trpc.auth.me.useQuery(undefined, {
17+
retry: false,
18+
refetchOnWindowFocus: false,
19+
});
20+
21+
const logoutMutation = trpc.auth.logout.useMutation({
22+
onSuccess: () => {
23+
utils.auth.me.setData(undefined, null);
24+
},
25+
});
26+
27+
const logout = useCallback(async () => {
28+
try {
29+
await logoutMutation.mutateAsync();
30+
} catch (error: unknown) {
31+
if (
32+
error instanceof TRPCClientError &&
33+
error.data?.code === "UNAUTHORIZED"
34+
) {
35+
return;
36+
}
37+
throw error;
38+
} finally {
39+
utils.auth.me.setData(undefined, null);
40+
await utils.auth.me.invalidate();
41+
}
42+
}, [logoutMutation, utils]);
43+
44+
const state = useMemo(() => {
45+
localStorage.setItem(
46+
"manus-runtime-user-info",
47+
JSON.stringify(meQuery.data)
48+
);
49+
return {
50+
user: meQuery.data ?? null,
51+
loading: meQuery.isLoading || logoutMutation.isPending,
52+
error: meQuery.error ?? logoutMutation.error ?? null,
53+
isAuthenticated: Boolean(meQuery.data),
54+
};
55+
}, [
56+
meQuery.data,
57+
meQuery.error,
58+
meQuery.isLoading,
59+
logoutMutation.error,
60+
logoutMutation.isPending,
61+
]);
62+
63+
useEffect(() => {
64+
if (!redirectOnUnauthenticated) return;
65+
if (meQuery.isLoading || logoutMutation.isPending) return;
66+
if (state.user) return;
67+
if (typeof window === "undefined") return;
68+
if (window.location.pathname === redirectPath) return;
69+
70+
window.location.href = redirectPath
71+
}, [
72+
redirectOnUnauthenticated,
73+
redirectPath,
74+
logoutMutation.isPending,
75+
meQuery.isLoading,
76+
state.user,
77+
]);
78+
79+
return {
80+
...state,
81+
refresh: () => meQuery.refetch(),
82+
logout,
83+
};
84+
}

0 commit comments

Comments
 (0)