Skip to content

Commit d4a3fbe

Browse files
committed
fix(next): 修复 StackBlitz 启动及服务端渲染问题
1 parent 01e29bc commit d4a3fbe

5 files changed

Lines changed: 66 additions & 60 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pnpm create tdesign my-app --template react-chat-rsbuild --pm bun
125125
- TSX 模板不支持 `--import-mode on-demand``unplugin-vue-components` 仅对 SFC `<template>` 生效。
126126
- Nuxt 4 模板要求 Node.js 22.12+。
127127
- Next.js 模板使用 App Router 和客户端页面承载 TDesign UI。
128+
- Next.js 模板在 StackBlitz 上使用 Webpack 启动。
128129
- `mobile-vue` 模板在 pnpm v11+ 环境下首次安装会自动放行 `vue-demi` 的构建脚本。
129130

130131
## Development

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "create-tdesign",
33
"version": "0.1.0",
44
"packageManager": "pnpm@11.1.2",
5-
"description": "Scaffold TDesign projects with Vite, Rsbuild, Vike, Nuxt, or Next.",
5+
"description": "Scaffold TDesign projects with Vite, Rsbuild, Vike, Nuxt, or Next.js.",
66
"type": "module",
77
"license": "MIT",
88
"bin": {

templates/react-next/.stackblitzrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"installDependencies": false,
3-
"startCommand": "pnpm install && pnpm dev"
3+
"startCommand": "pnpm install && pnpm exec next dev --webpack"
44
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use client'
2+
3+
import { AppIcon } from 'tdesign-icons-react'
4+
import { Button, Card, Space } from 'tdesign-react'
5+
6+
const sections = [
7+
{
8+
title: 'Starter stack',
9+
description: 'Built with React, TypeScript, Next.js, and TDesign desktop components.',
10+
},
11+
{
12+
title: 'Routing and rendering',
13+
description: 'Use the App Router with server layouts and client UI where needed.',
14+
},
15+
{
16+
title: 'Next step',
17+
description: 'Open app/page.tsx and start shaping __PROJECTNAME__.',
18+
},
19+
]
20+
21+
export default function ClientPage() {
22+
return (
23+
<main className="page-shell">
24+
<section className="hero-grid">
25+
<Card className="hero-card" bordered={false}>
26+
<Space direction="vertical" size={20}>
27+
<p className="eyebrow">
28+
<AppIcon style={{ marginRight: '6px', verticalAlign: 'middle' }} />
29+
__TEMPLATENAME__
30+
</p>
31+
<div className="hero-copy">
32+
<h1 className="hero-title">Create TDesign</h1>
33+
<p className="hero-intro">
34+
Your __PROJECTNAME__ project is ready. Start building with React,
35+
TypeScript, Next.js, and TDesign.
36+
</p>
37+
</div>
38+
<div className="action-row">
39+
<Button theme="primary">Run pnpm dev</Button>
40+
<Button variant="outline">Open app/page.tsx</Button>
41+
</div>
42+
</Space>
43+
</Card>
44+
45+
<Card className="panel-card">
46+
<div className="section-block">
47+
<p className="section-heading">Getting started</p>
48+
<div className="section-list">
49+
{sections.map((item) => (
50+
<div key={item.title} className="section-row">
51+
<span className="section-row-title">{item.title}</span>
52+
<p className="section-row-description">{item.description}</p>
53+
</div>
54+
))}
55+
</div>
56+
</div>
57+
</Card>
58+
</section>
59+
</main>
60+
)
61+
}

templates/react-next/app/page.tsx

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,5 @@
1-
'use client'
2-
3-
import { AppIcon } from 'tdesign-icons-react'
4-
import { Button, Card, Space } from 'tdesign-react'
5-
6-
const sections = [
7-
{
8-
title: 'Starter stack',
9-
description: 'Built with React, TypeScript, Next.js, and TDesign desktop components.',
10-
},
11-
{
12-
title: 'Routing and rendering',
13-
description: 'Use the App Router with server layouts and client UI where needed.',
14-
},
15-
{
16-
title: 'Next step',
17-
description: 'Open app/page.tsx and start shaping __PROJECTNAME__.',
18-
},
19-
]
1+
import ClientPage from './client-page'
202

213
export default function Page() {
22-
return (
23-
<main className="page-shell">
24-
<section className="hero-grid">
25-
<Card className="hero-card" bordered={false}>
26-
<Space direction="vertical" size={20}>
27-
<p className="eyebrow">
28-
<AppIcon style={{ marginRight: '6px', verticalAlign: 'middle' }} />
29-
__TEMPLATENAME__
30-
</p>
31-
<div className="hero-copy">
32-
<h1 className="hero-title">Create TDesign</h1>
33-
<p className="hero-intro">
34-
Your __PROJECTNAME__ project is ready. Start building with React,
35-
TypeScript, Next.js, and TDesign.
36-
</p>
37-
</div>
38-
<div className="action-row">
39-
<Button theme="primary">Run pnpm dev</Button>
40-
<Button variant="outline">Open app/page.tsx</Button>
41-
</div>
42-
</Space>
43-
</Card>
44-
45-
<Card className="panel-card">
46-
<div className="section-block">
47-
<p className="section-heading">Getting started</p>
48-
<div className="section-list">
49-
{sections.map((item) => (
50-
<div key={item.title} className="section-row">
51-
<span className="section-row-title">{item.title}</span>
52-
<p className="section-row-description">{item.description}</p>
53-
</div>
54-
))}
55-
</div>
56-
</div>
57-
</Card>
58-
</section>
59-
</main>
60-
)
4+
return <ClientPage />
615
}

0 commit comments

Comments
 (0)