Skip to content

Commit 22bfc0f

Browse files
committed
chore:update readme
1 parent 2ec1f49 commit 22bfc0f

File tree

8 files changed

+679
-26
lines changed

8 files changed

+679
-26
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<h1 align="center">Viter ⚡</h1>
1+
<p align="center">
2+
<a href="https://viterjs.github.io/" target="_blank" rel="noopener noreferrer">
3+
<img width="180" src="https://img.alicdn.com/imgextra/i4/O1CN01Y566rd1lxNVUjXnfJ_!!6000000004885-0-tps-754-600.jpg" alt="Viter logo">
4+
</a>
5+
</p>
26
<p align="center">小而美的 Vite 中后台开发框架</p>
37
<p align="center">
48
<a href="https://npmjs.com/package/viter"><img src="https://img.shields.io/npm/v/viter.svg" alt="npm package"></a>
@@ -58,7 +62,7 @@ $ npm run dev
5862

5963
在浏览器里打开 [http://localhost:3000/](http://localhost:3000/),能看到以下界面,
6064

61-
![](https://img.alicdn.com/imgextra/i3/O1CN01rRPHKg29KUe8p3EcB_!!6000000008049-0-tps-1284-680.jpg)
65+
![](https://img.alicdn.com/imgextra/i3/O1CN014yo0KO1WG7rjR5gMJ_!!6000000002760-0-tps-1444-982.jpg)
6266

6367
### 修改配置
6468

packages/create-app/README.md

Lines changed: 159 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,163 @@
1-
# `create-viter-app`
1+
<p align="center">
2+
<a href="https://viterjs.github.io/" target="_blank" rel="noopener noreferrer">
3+
<img width="180" src="https://img.alicdn.com/imgextra/i4/O1CN01Y566rd1lxNVUjXnfJ_!!6000000004885-0-tps-754-600.jpg" alt="Viter logo">
4+
</a>
5+
</p>
6+
<p align="center">小而美的 Vite 中后台开发框架</p>
7+
<p align="center">
8+
<a href="https://npmjs.com/package/viter"><img src="https://img.shields.io/npm/v/viter.svg" alt="npm package"></a>
9+
<a href="https://nodejs.org/en/about/releases/"><img src="https://img.shields.io/node/v/vite.svg" alt="node compatibility"></a>
10+
11+
</p>
12+
<br/>
213

3-
> TODO: description
14+
## 快速上手
415

5-
## Usage
16+
### 环境准备
617

7-
```js
8-
npm init @viterjs/app
18+
首先得有 [node](https://nodejs.org/en/),并确保 node 版本是 12 或以上。(mac 下推荐使用 [nvm](https://github.com/creationix/nvm) 来管理 node 版本)
19+
20+
```bash
21+
$ node -v
22+
v12.18.3
23+
```
24+
25+
### 搭建第一个 Viter 项目
26+
27+
使用 NPM:
28+
29+
```bash
30+
$ npm init @viterjs/app
31+
32+
npx: 5 安装成功,用时 4.312 秒
33+
✔ Project name: · viter-project
34+
✔ Select a framework: · react-admin-ts
35+
react-admin-ts
36+
37+
Scaffolding project in /Users/jerry/work-project/viter-project...
38+
39+
Done. Now run:
40+
41+
cd viter-project
42+
npm install
43+
npm run dev
44+
45+
```
46+
47+
### 启动项目
48+
49+
```bash
50+
$ npm run dev
51+
52+
> [email protected] dev /Users/xxx/github-project/xxx
53+
> viter
54+
55+
56+
vite v2.5.1 dev server running at:
57+
58+
> Local: http://localhost:3000/
59+
> Network: use `--host` to expose
60+
61+
```
62+
63+
在浏览器里打开 [http://localhost:3000/](http://localhost:3000/),能看到以下界面,
64+
65+
![](https://img.alicdn.com/imgextra/i3/O1CN014yo0KO1WG7rjR5gMJ_!!6000000002760-0-tps-1444-982.jpg)
66+
67+
### 修改配置
68+
69+
通过修改项目中的 `viter.config.ts` 文件,配置项目。模板中的配置如下:
70+
71+
```ts
72+
import { defineConfig } from 'viter';
73+
import reactRefresh from '@vitejs/plugin-react-refresh';
74+
75+
export default defineConfig({
76+
// 插件配置
77+
plugins: [reactRefresh()],
78+
// 配置路由
79+
routes: [
80+
{
81+
path: '/',
82+
component: '@/layout',
83+
routes: [
84+
{ path: '/', redirect: '/home' },
85+
{ path: '/home', component: './Home' },
86+
{ path: '/about', component: './About' },
87+
{ path: '/404', component: './NotFind' },
88+
{ path: '/*', redirect: '/404' },
89+
],
90+
},
91+
],
92+
// 开启动态加载
93+
dynamicImport: {
94+
loading: '@/loading',
95+
},
96+
});
997
```
98+
99+
更多配置,请前往 [Viter 文档](https://viterjs.github.io/) 查看。
100+
101+
### 部署发布
102+
103+
#### 构建
104+
105+
```bash
106+
$ npm run build
107+
108+
> [email protected] build /Users/jerry/github-project/viter-project
109+
> viter build
110+
111+
vite v2.5.6 building for production...
112+
✓ 44 modules transformed.
113+
dist/index.html 0.45 KiB
114+
dist/assets/index.cb6faa6d.js 0.18 KiB / brotli: 0.12 KiB
115+
dist/assets/index.0662466a.js 0.77 KiB / brotli: 0.33 KiB
116+
dist/assets/index.d5836ef7.js 0.12 KiB / brotli: 0.09 KiB
117+
dist/assets/index.0c87e543.js 0.12 KiB / brotli: 0.09 KiB
118+
dist/assets/index.a851cde7.js 2.38 KiB / brotli: 0.84 KiB
119+
dist/assets/index.588c1ae3.css 0.53 KiB / brotli: 0.25 KiB
120+
dist/assets/vendor.eb369f9e.js 143.59 KiB / brotli: 40.60 KiB
121+
122+
finished in 3202ms.
123+
```
124+
125+
构建产物默认生成到 `./dist` 下。
126+
127+
#### 本地验证
128+
129+
发布之前,可以通过 `serve` 做本地验证,
130+
131+
```bash
132+
$ npm run serve
133+
134+
> [email protected] serve /Users/xxx/github-project/viter-project
135+
> viter preview
136+
137+
138+
vite v2.5.6 build preview server running at:
139+
140+
> Local: http://localhost:5000/
141+
> Network: use `--host` to expose
142+
143+
```
144+
145+
访问 [http://localhost:5000](http://localhost:5000),正常情况下应该是和执行 `npm run dev` 时是一致的。
146+
147+
#### 部署
148+
149+
本地验证完,就可以部署了。你需要把 `dist` 目录部署到服务器上。
150+
151+
### Packages
152+
153+
| Package | Version |
154+
| ------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------- |
155+
| [viter](packages/viter) | ![viter version](https://img.shields.io/npm/v/viter.svg?label=%20) |
156+
| [@viterjs/render](packages/renderer) | ![plugin-vue version](https://img.shields.io/npm/v/@viterjs/renderer.svg?label=%20) |
157+
| [@viterjs/runtime](packages/runtime) | ![runtime version](https://img.shields.io/npm/v/@viterjs/runtime.svg?label=%20) |
158+
| [@viterjs/eslint-config](packages/eslint-config-viter) | ![@viterjs/eslint-config version](https://img.shields.io/npm/v/@viterjs/eslint-config.svg?label=%20) |
159+
| [@viterjs/create-app](packages/create-app) | [![create-vite version](https://img.shields.io/npm/v/@viterjs/create-app.svg?label=%20)](packages/create-vite/CHANGELOG.md) |
160+
161+
### License
162+
163+
[MIT](https://github.com/ykfe/viter/blob/main/LICENSE)

packages/create-app/template-react-admin-ts/src/layout/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import { Outlet } from 'viter';
33

44
function Layout() {
55
return (
6-
<div style={{ backgroundColor: '#fff8c4' }}>
6+
<div
7+
style={{
8+
boxShadow: '10px 10px 5px rgba(165,165,165,0.75)',
9+
width: '50%',
10+
margin: '0 auto',
11+
padding: '5px',
12+
}}
13+
>
714
<Outlet></Outlet>
815
</div>
916
);

packages/create-app/template-react-admin-ts/src/pages/About/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ import { Link } from 'viter';
33

44
function About() {
55
return (
6-
<div>
7-
welcome to about! <br />
8-
go to <Link to={'/home'}>home</Link>.
6+
<div className="Home">
7+
<p align="center">
8+
<a href="https://viterjs.github.io/" target="_blank" rel="noopener noreferrer">
9+
<img
10+
width="180"
11+
src="https://img.alicdn.com/imgextra/i4/O1CN01Y566rd1lxNVUjXnfJ_!!6000000004885-0-tps-754-600.jpg"
12+
alt="Viter logo"
13+
/>
14+
</a>
15+
<h3>About</h3>
16+
<span>
17+
go to <Link to={'/home'}>home</Link>.
18+
</span>
19+
</p>
920
</div>
1021
);
1122
}

packages/create-app/template-react-admin-ts/src/pages/Home/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ import { Link } from 'viter';
44
function Home() {
55
return (
66
<div className="Home">
7-
welcome to home! <br />
8-
go to <Link to={'/about'}>about</Link>.
7+
<p align="center">
8+
<a href="https://viterjs.github.io/" target="_blank" rel="noopener noreferrer">
9+
<img
10+
width="180"
11+
src="https://img.alicdn.com/imgextra/i4/O1CN01Y566rd1lxNVUjXnfJ_!!6000000004885-0-tps-754-600.jpg"
12+
alt="Viter logo"
13+
/>
14+
</a>
15+
<h3>Home</h3>
16+
<span>
17+
go to <Link to={'/about'}>about</Link>.
18+
</span>
19+
</p>
920
</div>
1021
);
1122
}

0 commit comments

Comments
 (0)