Skip to content

Commit 3e19682

Browse files
author
huangyf
committed
feat(frontend): Next.js 16 app with movie listing, detail pages, comments, favorites, hot page, i18n, dark mode, responsive layout
1 parent 7c491a7 commit 3e19682

43 files changed

Lines changed: 11791 additions & 0 deletions

Some content is hidden

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

frontend/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

frontend/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ============================================================
2+
# Gying Movie Frontend - Multi-stage Docker Build
3+
# ============================================================
4+
FROM node:20-alpine AS deps
5+
WORKDIR /app
6+
COPY package.json package-lock.json ./
7+
RUN npm ci --only=production
8+
9+
FROM node:20-alpine AS builder
10+
WORKDIR /app
11+
COPY package.json package-lock.json ./
12+
RUN npm ci
13+
COPY . .
14+
15+
# Build-time env vars (baked into the static output)
16+
ARG NEXT_PUBLIC_API_URL=""
17+
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
18+
19+
RUN npm run build
20+
21+
# Production stage
22+
FROM node:20-alpine AS runner
23+
WORKDIR /app
24+
ENV NODE_ENV=production
25+
26+
RUN addgroup --system --gid 1001 nodejs && \
27+
adduser --system --uid 1001 nextjs
28+
29+
COPY --from=builder /app/public ./public
30+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
31+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
32+
33+
USER nextjs
34+
EXPOSE 3000
35+
ENV PORT=3000
36+
ENV HOSTNAME="0.0.0.0"
37+
38+
CMD ["node", "server.js"]

frontend/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
- 开发环境:复制 .env.local.example 为 .env.local,保持 http://localhost:8880
18+
- 生产环境:空 NEXT_PUBLIC_API_URL,通过 nginx 等反向代理将 /api 转发到后端
19+
20+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
21+
22+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
23+
24+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
25+
26+
## Learn More
27+
28+
To learn more about Next.js, take a look at the following resources:
29+
30+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
31+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
32+
33+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
34+
35+
## Deploy on Vercel
36+
37+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
38+
39+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

frontend/eslint.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import nextVitals from "eslint-config-next/core-web-vitals";
3+
import nextTs from "eslint-config-next/typescript";
4+
5+
const eslintConfig = defineConfig([
6+
...nextVitals,
7+
...nextTs,
8+
// Override default ignores of eslint-config-next.
9+
globalIgnores([
10+
// Default ignores of eslint-config-next:
11+
".next/**",
12+
"out/**",
13+
"build/**",
14+
"next-env.d.ts",
15+
]),
16+
]);
17+
18+
export default eslintConfig;

frontend/i18n.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import i18n from 'i18next';
2+
import { initReactI18next } from 'react-i18next';
3+
4+
import enTranslations from './public/locales/en/common.json';
5+
import zhTranslations from './public/locales/zh/common.json';
6+
7+
const getInitialLanguage = () => {
8+
if (typeof window === 'undefined') return 'en';
9+
const saved = window.localStorage.getItem('i18nextLng');
10+
if (saved) return saved;
11+
return window.navigator.language.toLowerCase().startsWith('zh') ? 'zh' : 'en';
12+
};
13+
14+
i18n
15+
.use(initReactI18next)
16+
.init({
17+
resources: {
18+
en: {
19+
common: enTranslations,
20+
},
21+
zh: {
22+
common: zhTranslations,
23+
},
24+
},
25+
fallbackLng: 'en',
26+
lng: getInitialLanguage(),
27+
defaultNS: 'common',
28+
interpolation: {
29+
escapeValue: false,
30+
},
31+
});
32+
33+
if (typeof window !== 'undefined') {
34+
i18n.on('languageChanged', (lng) => {
35+
window.localStorage.setItem('i18nextLng', lng);
36+
document.documentElement.lang = lng === 'zh' ? 'zh-CN' : 'en';
37+
});
38+
}
39+
40+
export default i18n;

frontend/next-i18next.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
i18n: {
3+
defaultLocale: 'en',
4+
locales: ['en', 'zh'],
5+
},
6+
};

frontend/next.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
reactCompiler: true,
5+
output: "standalone",
6+
images: {
7+
// Allow images from MinIO / OSS / CDN in production
8+
remotePatterns: [
9+
{ protocol: "http", hostname: "localhost" },
10+
{ protocol: "https", hostname: "**.aliyuncs.com" },
11+
{ protocol: "https", hostname: "**.myqcloud.com" },
12+
],
13+
},
14+
};
15+
16+
export default nextConfig;

0 commit comments

Comments
 (0)