Skip to content

Commit c79a2ee

Browse files
committed
init
1 parent 3c072e9 commit c79a2ee

32 files changed

+5499
-0
lines changed

.babelrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: ["next/babel"],
3+
plugins: [
4+
["@babel/plugin-proposal-decorators", { legacy: true }],
5+
],
6+
};

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

.npmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
phantomjs_cdnurl=http://cnpmjs.org/downloads
2+
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
3+
registry=https://registry.npm.taobao.org

.vscode/launch.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Chrome",
9+
"type": "chrome",
10+
"request": "launch",
11+
"url": "http://localhost:8080",
12+
"webRoot": "${workspaceFolder}",
13+
"sourceMaps":true,
14+
// "sourceMapPathOverrides": {
15+
// "webpack:///src/*": "${webRoot}/*"
16+
// }
17+
},
18+
{
19+
"type": "node",
20+
"request": "launch",
21+
"name": "auto-get-module",
22+
"program": "${workspaceFolder}/scripts/auto-get-module/index.js"
23+
},
24+
{
25+
"type": "node",
26+
"request": "launch",
27+
"name": "npm run dev",
28+
"runtimeExecutable": "npm",
29+
"runtimeArgs": [
30+
"run-script",
31+
"dev"
32+
],
33+
"port": 8080
34+
},
35+
36+
{
37+
"type": "node",
38+
"request": "launch",
39+
"name": "build",
40+
"program": "${workspaceFolder}/scripts/build.js"
41+
},
42+
{
43+
"type": "node",
44+
"request": "launch",
45+
"name": "build_dll",
46+
"program": "${workspaceFolder}/scripts/build_dll.js"
47+
},
48+
{
49+
"type": "node",
50+
"request": "launch",
51+
"name": "create page",
52+
"program": "${workspaceFolder}/scripts/create-module/index.js"
53+
},
54+
]
55+
}

.vscode/settings.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"git.ignoreLimitWarning": true,
3+
"editor.fontSize": 18,
4+
"prettier.singleQuote": true,
5+
"prettier.useTabs": true,
6+
"prettier.trailingComma": "all",
7+
"javascript.implicitProjectConfig.experimentalDecorators": true,
8+
"emmet.includeLanguages": {
9+
"javascript": "javascriptreact"
10+
},
11+
"files.associations": {
12+
"*.html": "html"
13+
},
14+
"emmet.showExpandedAbbreviation": "always",
15+
"emmet.triggerExpansionOnTab": true,
16+
"editor.foldingStrategy": "indentation",
17+
"eslint.autoFixOnSave": true,
18+
"files.autoSave": "off",
19+
"eslint.validate": [
20+
"html",
21+
{
22+
"language": "javascript",
23+
"autoFix": true
24+
},
25+
{
26+
"language": "javascriptreact",
27+
"autoFix": true
28+
},
29+
{
30+
"language": "typescript",
31+
"autoFix": true
32+
},
33+
{
34+
"language": "typescriptreact",
35+
"autoFix": true
36+
}
37+
],
38+
"diffEditor.ignoreTrimWhitespace": true,
39+
"css.validate": false,
40+
"scss.validate": false,
41+
"less.validate": false,
42+
"stylelint.enable": true,
43+
"editor.codeActionsOnSave": {
44+
"source.fixAll.eslint": true,
45+
"source.fixAll.stylelint": true
46+
},
47+
"stylelint.autoFixOnSave": true
48+
}

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/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+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

components/layout.module.css

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.container {
2+
max-width: 36rem;
3+
padding: 0 1rem;
4+
margin: 3rem auto 6rem;
5+
}
6+
7+
.header {
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
}
12+
13+
.headerImage {
14+
width: 6rem;
15+
height: 6rem;
16+
}
17+
18+
.headerHomeImage {
19+
width: 8rem;
20+
height: 8rem;
21+
}
22+
23+
.backToHome {
24+
margin: 3rem 0 0;
25+
}

components/layout.tsx

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import Head from 'next/head'
2+
import styles from './layout.module.css'
3+
import utilStyles from '../styles/utils.module.css'
4+
import Link from 'next/link'
5+
6+
const name = '微言'
7+
export const siteTitle = 'Next.js Sample Website'
8+
9+
type LayoutProps = {
10+
children: React.ReactChildren;
11+
home?: boolean;
12+
}
13+
14+
export default function Layout({ children, home = false }) {
15+
return (
16+
<div className={styles.container}>
17+
<Head>
18+
<link rel="icon" href="/favicon.ico" />
19+
<meta
20+
name="description"
21+
content="Learn how to build a personal website using Next.js"
22+
/>
23+
<meta
24+
property="og:image"
25+
content={`https://og-image.now.sh/${encodeURI(
26+
siteTitle
27+
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
28+
/>
29+
<meta name="og:title" content={siteTitle} />
30+
<meta name="twitter:card" content="summary_large_image" />
31+
</Head>
32+
<header className={styles.header}>
33+
{home ? (
34+
<>
35+
<img
36+
src="/images/profile.jpg"
37+
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
38+
alt={name}
39+
/>
40+
<h1 className={utilStyles.heading2Xl}>{name}</h1>
41+
</>
42+
) : (
43+
<>
44+
<Link href="/">
45+
<a>
46+
<img
47+
src="/images/profile.jpg"
48+
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
49+
alt={name}
50+
/>
51+
</a>
52+
</Link>
53+
<h2 className={utilStyles.headingLg}>
54+
<Link href="/">
55+
<a className={utilStyles.colorInherit}>{name}</a>
56+
</Link>
57+
</h2>
58+
</>
59+
)}
60+
</header>
61+
<main>{children}</main>
62+
{!home && (
63+
<div className={styles.backToHome}>
64+
<Link href="/">
65+
<a>← Back to home</a>
66+
</Link>
67+
</div>
68+
)}
69+
</div>
70+
)
71+
}

http/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import axios from 'axios';
2+
3+
4+
5+
6+
const http = axios.create({
7+
timeout: 30000,
8+
baseURL: '',
9+
});
10+
11+
12+
export default http;

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "react-ssr-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start"
9+
},
10+
"dependencies": {
11+
"axios": "^0.21.1",
12+
"natur": "^2.1.1-beta2",
13+
"natur-persist": "^1.2.2",
14+
"natur-promise-watcher": "^1.0.1",
15+
"natur-service": "^2.1.2",
16+
"next": "10.0.4",
17+
"react": "17.0.1",
18+
"react-dom": "17.0.1"
19+
},
20+
"devDependencies": {
21+
"@babel/core": "^7.12.10",
22+
"@babel/plugin-proposal-decorators": "^7.12.12",
23+
"@types/node": "^14.14.16",
24+
"@types/react": "^17.0.0",
25+
"eslint": "^7.16.0",
26+
"typescript": "^4.1.3"
27+
}
28+
}

pages/_app.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { initStore } from "../store";
2+
import "../styles/globals.css";
3+
import "../services";
4+
5+
export default function App(props) {
6+
if (!process.browser) {
7+
(global as any).store = props.store || (global as any).store;
8+
}
9+
const { Component, pageProps } = props;
10+
return <Component {...pageProps} />;
11+
}
12+
13+
App.getInitialProps = ({ ctx, pathname }) => {
14+
ctx.req.store = initStore(pathname || "/");
15+
return { store: ctx.req.store };
16+
};

pages/api/hello.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
3+
export default (req, res) => {
4+
res.statusCode = 200;
5+
res.json({ name: "John Doe" });
6+
};

0 commit comments

Comments
 (0)