Skip to content

Commit fcfe1a8

Browse files
committed
preivew环境
1 parent 9eb6d23 commit fcfe1a8

File tree

15 files changed

+209
-115
lines changed

15 files changed

+209
-115
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ jobs:
2323
node-version: 22
2424
cache: "pnpm"
2525

26-
- name: Deploy
26+
- name: Install Dependencies
27+
run: |
28+
pnpm install
29+
# install yq
30+
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
31+
tar xz && mv ${BINARY} /usr/local/bin/yq
32+
33+
- name: Deploy Production Version
2734
env:
2835
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
2936
run: |
3037
# build application
31-
pnpm install
38+
yq -i '.d1_databases[0].database_id = "${{ secrets.CLOUDFLARE_DATABASE_ID }}"' wrangler.toml
39+
yq -i '.vars.MODE = "mixed"' wrangler.toml
40+
yq -i '.vars.PROVIDER_CLOUDFLARE_BUILTIN = false' wrangler.toml
3241
pnpm build:worker
33-
cp wrangler.toml.example wrangler.toml
34-
sed -i "s/{{DATABASE_ID}}/${{ secrets.CLOUDFLARE_DATABASE_ID }}/g" wrangler.toml
3542
3643
# build website
3744
cd docs
@@ -40,4 +47,13 @@ jobs:
4047
cp -r ./out/ ../dist/home
4148
cd ..
4249
50+
# deploy to cloudflare
51+
pnpm deploy:worker
52+
53+
- name: Deploy Preview Version
54+
run: |
55+
yq -i '.name = "typix-preview"' wrangler.toml
56+
yq -i '.vars.MODE = "client"' wrangler.toml
57+
yq -i '.vars.PROVIDER_CLOUDFLARE_BUILTIN = true' wrangler.toml
58+
pnpm build:worker
4359
pnpm deploy:worker

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ tsconfig.tsbuildinfo
2929
.wrangler
3030
.env
3131
.bin
32-
/wrangler.toml
3332
db.sqlite
3433
/.files/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ RUN npm i -g pnpm
44
COPY ./package.json pnpm-lock.yaml ./
55
RUN pnpm install
66
COPY . .
7-
RUN pnpm build && pnpm build:backend
7+
RUN pnpm build:node
88
EXPOSE 3000
99
CMD ["node", ".bin/node.js"]

docs/src/components/features.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function Features() {
5656
const Icon = feature.icon;
5757

5858
return (
59-
<div key={index} className="group relative">
59+
<div key={feature.key} className="group relative">
6060
{/* Feature Card */}
6161
<div className="linear-card glow h-full p-6 transition-all duration-300 hover:scale-105 sm:p-8">
6262
{/* Icon Section */}
@@ -76,8 +76,8 @@ export function Features() {
7676
</div>
7777

7878
{/* Decorative Elements */}
79-
<div className="absolute top-4 right-4 h-2 w-2 rounded-full bg-primary/30 opacity-0 transition-opacity duration-300 group-hover:opacity-100"></div>
80-
<div className="absolute bottom-4 left-4 h-1 w-1 rounded-full bg-primary/20 opacity-0 transition-opacity delay-100 duration-300 group-hover:opacity-100"></div>
79+
<div className="absolute top-4 right-4 h-2 w-2 rounded-full bg-primary/30 opacity-0 transition-opacity duration-300 group-hover:opacity-100" />
80+
<div className="absolute bottom-4 left-4 h-1 w-1 rounded-full bg-primary/20 opacity-0 transition-opacity delay-100 duration-300 group-hover:opacity-100" />
8181
</div>
8282
</div>
8383
);

docs/src/components/theme-toggle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export function ThemeToggle() {
5252
// Only change the icon based on current applied theme after mounting
5353
return (
5454
<button
55+
type="button"
5556
onClick={handleToggle}
5657
className="group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full border border-border/20 backdrop-blur-sm transition-all duration-300 hover:border-border/40 hover:bg-accent/10 hover:backdrop-blur-md disabled:cursor-default"
5758
aria-label="Toggle theme"

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"scripts": {
77
"dev": "vite",
88
"dev:worker": "wrangler dev",
9-
"build": "tsc -b && vite build",
10-
"build:worker": "tsc -b && cross-env VITE_RUNTIME=cloudflare vite build",
11-
"build:backend": "tsup --minify",
9+
"build": "tsc -b && cross-env RUNTIME=cloudflare vite build",
10+
"build:node": "tsc -b && vite build && tsup --minify",
1211
"analyze": "vite build --mode analyze",
1312
"lint": "eslint .",
1413
"preview": "vite preview",
@@ -18,7 +17,7 @@
1817
"db:migrate:worker": "wrangler d1 migrations apply --remote typix",
1918
"db:push": "drizzle-kit push",
2019
"db:studio": "drizzle-kit studio",
21-
"deploy:worker": "wrangler deploy"
20+
"deploy": "wrangler deploy"
2221
},
2322
"dependencies": {
2423
"@hono/node-server": "^1.18.0",
@@ -73,6 +72,7 @@
7372
"@biomejs/biome": "^1.9.4",
7473
"@cloudflare/workers-types": "^4.20250525.0",
7574
"@hono/vite-dev-server": "^0.19.1",
75+
"@iarna/toml": "^2.2.5",
7676
"@tanstack/router-plugin": "^1.120.10",
7777
"@types/node": "^22.15.21",
7878
"@types/react": "^19.1.2",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/hooks/useAuth.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import { authClient } from "@/app/lib/auth-client";
2+
import { mode } from "@/server/lib/env";
23

34
// Custom hook that wraps BetterAuth's useSession
45
export function useAuth() {
6+
if (mode === "client") {
7+
// In client mode, do not do anything
8+
return {
9+
user: null,
10+
isLogin: false,
11+
isLoading: false,
12+
error: null,
13+
logout: () => Promise.resolve(),
14+
signIn: () => Promise.resolve(),
15+
signUp: () => Promise.resolve(),
16+
};
17+
}
18+
519
const session = authClient.useSession();
620

721
return {

src/app/routes/__root.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ function RootComponent() {
133133
// Initialize database
134134
const db = await initDb();
135135
if (db) {
136-
initContext({ db: db }); // AI context can be set later if needed
136+
initContext({
137+
db: db,
138+
PROVIDER_CLOUDFLARE_BUILTIN: import.meta.env.PROVIDER_CLOUDFLARE_BUILTIN === true,
139+
});
137140
await initSettings();
138141
isMobileCleanup = initIsMobile();
139142
}

src/app/routes/chat/-components/sidebar/ChatSidebar.tsx

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ScrollArea } from "@/app/components/ui/scroll-area";
1111
import { Sheet, SheetContent } from "@/app/components/ui/sheet";
1212
import { useAuth } from "@/app/hooks/useAuth";
1313
import { cn } from "@/app/lib/utils";
14+
import { mode } from "@/server/lib/env";
1415
import type { chatService } from "@/server/service/chat";
1516
import { useNavigate } from "@tanstack/react-router";
1617
import { MoreVertical, Palette, PanelLeftClose, PanelRightClose, Plus, Settings, Trash2 } from "lucide-react";
@@ -199,49 +200,51 @@ export function ChatSidebar({
199200
</div>
200201
</div>
201202
{/* BOTTOM SECTION - Fixed height at bottom (User Profile or Login) */}
202-
<div className="mt-auto flex-shrink-0 border-border border-t bg-muted/30">
203-
<div className="p-4">
204-
{isAuthenticated ? (
205-
/* Logged in user profile */
206-
<div className="flex items-center gap-3">
207-
<Avatar className="h-9 w-9 ring-2 ring-primary/20">
208-
<AvatarImage src={user.avatar} alt={t("user.avatar")} />
209-
<AvatarFallback className="bg-gradient-to-br from-primary to-primary/80 font-semibold text-primary-foreground text-sm">
210-
{user.nickname.charAt(0).toUpperCase()}
211-
</AvatarFallback>
212-
</Avatar>
213-
<div className="flex-1 overflow-hidden">
214-
<div className="truncate font-medium text-sm leading-tight">{user.nickname}</div>
215-
<div className="mt-1 flex items-center gap-1.5">
216-
<div className="h-2 w-2 rounded-full bg-green-500" />
217-
<span className="text-muted-foreground text-xs">{t("user.online")}</span>
203+
{mode !== "client" && (
204+
<div className="mt-auto flex-shrink-0 border-border border-t bg-muted/30">
205+
<div className="p-4">
206+
{isAuthenticated ? (
207+
/* Logged in user profile */
208+
<div className="flex items-center gap-3">
209+
<Avatar className="h-9 w-9 ring-2 ring-primary/20">
210+
<AvatarImage src={user.avatar} alt={t("user.avatar")} />
211+
<AvatarFallback className="bg-gradient-to-br from-primary to-primary/80 font-semibold text-primary-foreground text-sm">
212+
{user.nickname.charAt(0).toUpperCase()}
213+
</AvatarFallback>
214+
</Avatar>
215+
<div className="flex-1 overflow-hidden">
216+
<div className="truncate font-medium text-sm leading-tight">{user.nickname}</div>
217+
<div className="mt-1 flex items-center gap-1.5">
218+
<div className="h-2 w-2 rounded-full bg-green-500" />
219+
<span className="text-muted-foreground text-xs">{t("user.online")}</span>
220+
</div>
218221
</div>
222+
<Button
223+
variant="ghost"
224+
size="sm"
225+
onClick={() => {
226+
navigate({ to: "/settings", search: {} });
227+
if (isMobile) closeSidebar();
228+
}}
229+
className="h-8 w-8 transition-colors hover:bg-accent"
230+
title={t("settings.title")}
231+
>
232+
<Settings className="h-4 w-4" />
233+
</Button>
219234
</div>
220-
<Button
221-
variant="ghost"
222-
size="sm"
223-
onClick={() => {
224-
navigate({ to: "/settings", search: {} });
225-
if (isMobile) closeSidebar();
226-
}}
227-
className="h-8 w-8 transition-colors hover:bg-accent"
228-
title={t("settings.title")}
229-
>
230-
<Settings className="h-4 w-4" />
231-
</Button>
232-
</div>
233-
) : (
234-
/* Login prompt for non-authenticated users */
235-
<div className="space-y-3">
236-
<div className="text-center">
237-
<p className="font-medium text-sm">{t("auth.welcomeMessage")}</p>
238-
<p className="text-muted-foreground text-xs">{t("auth.loginToSave")}</p>
235+
) : (
236+
/* Login prompt for non-authenticated users */
237+
<div className="space-y-3">
238+
<div className="text-center">
239+
<p className="font-medium text-sm">{t("auth.welcomeMessage")}</p>
240+
<p className="text-muted-foreground text-xs">{t("auth.loginToSave")}</p>
241+
</div>
242+
<LoginButton className="w-full" />
239243
</div>
240-
<LoginButton className="w-full" />
241-
</div>
242-
)}
244+
)}
245+
</div>
243246
</div>
244-
</div>
247+
)}
245248
</div>
246249
);
247250
// Mobile: Use Sheet (drawer) - controlled by hooks

0 commit comments

Comments
 (0)