Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit 30d8cf8

Browse files
committed
docs: intro & cli
1 parent ae23448 commit 30d8cf8

File tree

13 files changed

+299
-66
lines changed

13 files changed

+299
-66
lines changed

README.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1-
# Vize: 现代化的 Web 可视化搭建引擎
1+
# Vize:代化的 Web 可视化编排引擎
22

3-
文档: [https://vize-team.github.io/](https://vize-team.github.io/)
3+
Github: [https://github.com/vize-team/vize](https://github.com/vize-team/vize)
44

55
![stars] ![forks] ![issues] ![pr] ![closed-pr]
66

7-
## ⚠️ 警告 Warning
8-
9-
此项目仍处于开发状态,某些功能可能不稳定,部分 API 也可能会有变动。
10-
11-
This is an **experimental** project and is still in development. BUGs may exist. APIs and features may change.
12-
13-
## ✨ 特性 Features
7+
## ✨ 特性
148

9+
- 丰富的物料抽象粒度
10+
- 强大的可配置事件系统
1511
- 友好、便捷的可视化编辑体验
12+
- 支持物料间联动
13+
- 友好、一致的物料 API
1614
- 完全所见即所得
17-
- 丰富的物料抽象粒度
18-
- 支持物料间联动,强大的可配置事件系统
15+
- 丰富的拓展接口
1916
- 物料与系统完全解耦
2017
- 完备的开发工具链支持
21-
- 便捷的接入方式
18+
- 开箱即用的接入方式
19+
- ...
20+
21+
## 🤟 体验
22+
23+
体验站点:[vize.cool](https://vize.cool)
24+
25+
## 🛠 部署
26+
27+
参考:[部署服务](/deploy/intro.html)
28+
29+
## 👨‍💻 开发者
30+
31+
核心架构 & 开发:**[Aedron@github](https://github.com/Aedron)**
32+
33+
贡献者:
34+
35+
- [Copyes@github](https://github.com/Copyes)
36+
37+
## 🙌 帮助和交流
38+
39+
<img src="./packages/doc/src/welcome/wechat.jpg" class="zoom" alt="Preview" style="width:128px;height:auto;border-radius:3px;margin-top:14px;"/>
2240

2341
## 📦 核心包 Core Packages
2442

@@ -61,3 +79,9 @@ This is an **experimental** project and is still in development. BUGs may exist.
6179
[issues]: https://img.shields.io/github/issues/vize-team/vize?style=social&label=Issues&style=plastic
6280
[pr]: https://img.shields.io/github/issues-pr/vize-team/vize?style=social&label=PullRequests&style=plastic
6381
[closed-pr]: https://img.shields.io/github/issues-pr-closed/vize-team/vize?style=social&label=PullRequests&style=plastic
82+
83+
## ⚠️ 警告 Warning
84+
85+
此项目仍处于开发状态,某些功能可能不稳定,部分 API 也可能会有变动。
86+
87+
This is an **experimental** project and is still in development. BUGs may exist. APIs and features may change.

packages/doc/src/.vuepress/config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { sidebar } = require('./sidebar');
22

33
module.exports = {
44
title: 'Vize',
5-
description: 'Vize: 现代化的可视化搭建引擎',
5+
description: 'Vize: 现代化的可视化编排引擎',
66
repo: 'https://github.com/vize-team/vize',
77
serviceWorker: true,
88
displayAllHeaders: true,
@@ -28,10 +28,18 @@ module.exports = {
2828
text: '文档',
2929
link: '/welcome/intro',
3030
},
31+
{
32+
text: 'Types',
33+
link: 'https://vize-team.github.io/types/modules.html',
34+
},
3135
{
3236
text: 'Github',
3337
link: 'https://github.com/vize-team/vize',
3438
},
39+
{
40+
text: 'Discussions',
41+
link: 'https://github.com/vize-team/vize/discussions',
42+
},
3543
],
3644
sidebarDepth: 2,
3745
sidebar,

packages/doc/src/.vuepress/sidebar.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
const sidebar = [
22
{
3-
title: '欢迎',
3+
title: '👏 欢迎',
44
collapsable: true,
55
children: ['/welcome/intro', '/welcome/packages'],
66
},
77
{
8-
title: '快速上手',
8+
title: '⚡️ 快速上手',
99
collapsable: true,
1010
children: ['/start/ready', '/start/component', '/start/plugin', '/start/action', '/start/container'],
1111
},
1212
{
13-
title: '物料开发',
13+
title: '🌟 物料开发',
1414
collapsable: true,
1515
children: ['/dev/materials', '/dev/component', '/dev/plugin', '/dev/action', '/dev/container'],
1616
},
1717
{
18-
title: '事件系统',
18+
title: '⚛️ 事件系统',
1919
collapsable: true,
2020
children: [
2121
'/events/intro',
@@ -27,28 +27,28 @@ const sidebar = [
2727
],
2828
},
2929
{
30-
title: '表单',
30+
title: '✉️ 表单',
3131
collapsable: true,
3232
children: ['/form/intro', '/form/jsonSchema', '/form/registryField', '/form/dynamicForm'],
3333
},
3434
{
35-
title: '样式',
35+
title: '💅 样式',
3636
collapsable: true,
3737
children: ['/style/styleGroup', '/style/styleInject', '/style/fixed'],
3838
},
3939
{
40-
title: '进阶',
40+
title: '⚙️ 进阶',
4141
collapsable: true,
4242
children: [
4343
'/advanced/meta',
4444
'/advanced/containerComponent',
4545
'/advanced/routerController.md',
46-
'/advanced/hot-area-component.md',
46+
'/advanced/hotAreaComponent.md',
4747
'/advanced/dsl.md',
4848
],
4949
},
5050
{
51-
title: '部署',
51+
title: '🛠 部署',
5252
collapsable: true,
5353
children: [
5454
'/deploy/intro',
@@ -60,8 +60,9 @@ const sidebar = [
6060
],
6161
},
6262
{
63-
title: 'CLI',
63+
title: '🪄 CLI',
6464
collapsable: true,
65+
children: ['/cli/config', '/cli/commands'],
6566
},
6667
];
6768

packages/doc/src/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ actionText: 上手 →
55
actionLink: /welcome/intro
66

77
features:
8-
- title: 丰富完备的物料抽象
9-
details: 组件、插件、动作、页面容器等多种粒度的物料抽象,具备无限的拓展能力
10-
- title: 易用的可视化编辑
8+
- title: 🌟 丰富完备的物料抽象
9+
details: 组件、插件、事件、动作、页面容器等多种粒度的物料抽象,具备无限的拓展能力
10+
- title: 🤟 易用的可视化编辑
1111
details: 拖拽式编排、流式/自由布局能力、可视化热区、容器组件嵌套等能力,让复杂的编排功能也变得友好且易用
12-
- title: 强大的逻辑配置能力
13-
details: 强大的事件配置系统,让物料具备真正的联动能力,即使复杂地逻辑与交互也不在话下
14-
- title: 真 · 所见即所得
15-
details: 高性能地实时预览渲染引擎,带来真正所见即做的编辑体验
16-
- title: 便捷的接入方式
17-
details: 为所有的单元能力提供 NPM Packages,超低成本接入
18-
- title: 完善的工具链支持
19-
details: CLI 提供完善的模板创建、开发、调试、发布等功能
12+
- title: ⚛️ 强大的逻辑编排能力
13+
details: 强大的可视化事件配置系统,让物料具备真正的联动能力,即使复杂的逻辑与交互也不在话下
14+
- title: 👁 真 · 所见即所得
15+
details: 高性能的实时预览渲染引擎,带来真正所见即做的编辑体验
16+
- title: 🛠 强大的拓展能力
17+
details: 为所有的单元能力提供独立 Packages,开箱即用,超低成本接入,同时提供丰富的拓展接口
18+
- title: 🪄 完善的工具链支持
19+
details: CLI 提供完善的模板创建、开发、调试、构建、发布等功能
2020

2121
footer: Developing with ❤️ by Aedron@github
2222
meta:
2323
- name: description
24-
content: 现代化的 Web 可视化搭建引擎
24+
content: 现代化的 Web 可视化编排引擎
2525
- name: keywords
2626
content: home homepage homepages
2727
---
File renamed without changes.

packages/doc/src/advanced/routerController.md

Lines changed: 109 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,134 @@ meta:
1212

1313
Vize 支持注册自定义路由,来控制子页面的加载和渲染方式。
1414

15-
## 1. 实现路由
15+
## 1. 实现 RouterController
1616

17-
在页面容器目录下新建 `Router.tsx`
17+
在页面容器目录下新建 `Router.tsx``PageLoader.tsx`
1818

19-
```tsx {8,9,13-17,26-29}
19+
<CodeSwitcher :languages="{r:'Router.tsx',p:'PageLoader.tsx'}">
20+
21+
<template v-slot:r>
22+
23+
```tsx
2024
import * as React from 'react';
21-
import { useState, ComponentType, useEffect } from 'react';
22-
import { RouterProps, PageRouter } from '@vize/types';
25+
import { useEffect, useMemo, useState } from 'react';
26+
import { Maybe, PageInstance, PageRouter, RouterProps } from '@vize/types';
27+
import { PageLoader } from './pagerLoader';
2328

24-
export function MyRouter({ pages, dynamicPageImports, SharedComponentInstances }: RouterProps) {
25-
const [Page, setPageRender] = useState<ComponentType | null>(null);
29+
export function Router({
30+
setCurrentPageInstance,
31+
setRouter,
32+
pages,
33+
pageImports,
34+
sharedComponentInstances,
35+
ComponentsRender,
36+
PageRender,
37+
}: RouterProps) {
38+
// 当前页面的 key
2639
const [currentPage, setCurrentPage] = useState(pages[0].key);
27-
// 声明 router
40+
// 当前页面的实例(动态引入)
41+
const [pageInstance, setPageInstance] = useState<Maybe<PageInstance>>(null);
42+
43+
// 页面路由状态
2844
const router = useMemo<PageRouter>(() => ({ pages, currentPage, setCurrentPage }), [currentPage]);
2945

46+
// 当路由变更时,执行 set 回调,同步 router 状态
3047
useEffect(() => {
31-
setPageRender(null);
32-
// 动态引入页面
33-
const dynamicPageImport = dynamicPageImports[currentPage];
34-
dynamicPageImport()
35-
.then(setPageRender)
36-
.catch(console.error);
37-
}, [currentPage]);
38-
39-
if (!Page) {
40-
return <div>loading...</div>;
41-
}
48+
setRouter(router);
49+
setCurrentPageInstance(pageInstance);
50+
}, [pageInstance, router]);
4251

4352
return (
4453
<>
45-
{/* 跨页面共享的组件 */}
46-
<SharedComponentInstances router={router} />
47-
{/* 当前页面 */}
48-
<Page router={router} />
54+
{/* 渲染跨页面共享的组件 */}
55+
{sharedComponentInstances && <ComponentsRender componentInstances={sharedComponentInstances} />}
56+
<PageLoader
57+
pageImports={pageImports}
58+
currentPage={currentPage}
59+
currentPageInstance={pageInstance}
60+
setCurrentPageInstance={setPageInstance}
61+
PageRender={PageRender}
62+
/>
4963
</>
5064
);
5165
}
5266
```
5367

68+
</template>
69+
70+
<template v-slot:p>
71+
72+
```tsx
73+
import * as React from 'react';
74+
import { useState, useEffect } from 'react';
75+
import { PageInstance, Maybe, RouterProps } from '@vize/types';
76+
77+
interface Props extends Pick<RouterProps, 'PageRender' | 'pageImports' | 'setCurrentPageInstance'> {
78+
currentPage: number;
79+
currentPageInstance: Maybe<PageInstance>;
80+
}
81+
82+
export function PageLoader({
83+
currentPage,
84+
pageImports,
85+
currentPageInstance,
86+
setCurrentPageInstance,
87+
PageRender,
88+
}: Props) {
89+
const [[loading, error], setStatus] = useState([true, false]);
90+
91+
useEffect(() => {
92+
setStatus([true, false]);
93+
// 当页面为多页模式时,所有子页面独立存在
94+
// 这时 pageImports 为空,直接跳转到对应的地址
95+
const pageImport = pageImports[currentPage];
96+
if (!pageImport) {
97+
window.location.href = `/${currentPage}`;
98+
return;
99+
}
100+
101+
// 动态 import 页面实例
102+
pageImport()
103+
.then(({ pageInstance }) => {
104+
setCurrentPageInstance(pageInstance);
105+
setStatus([false, false]);
106+
})
107+
.catch(e => {
108+
console.error('Load page error:\n', e);
109+
setStatus([false, true]);
110+
});
111+
}, [currentPage]);
112+
113+
if (loading) {
114+
return <Loading />;
115+
}
116+
117+
if (error) {
118+
return <LoadError />;
119+
}
120+
121+
// 渲染页面实例
122+
return <PageRender pageInstance={currentPageInstance} />;
123+
}
124+
125+
function Loading() {
126+
return <div>loading...</div>;
127+
}
128+
129+
function LoadError() {
130+
return <div>Error occurred</div>;
131+
}
132+
```
133+
134+
</template>
135+
136+
</CodeSwitcher>
137+
54138
## 2. 注册路由
55139

56-
在页面容器目录下编辑 `index.ts`
140+
在页面容器目录下编辑 `index.ts`,引入并注册 RouterController
57141

58-
```ts {5,6}
142+
```ts {2,5,6}
59143
import { ContainerProps } from '@vize/types';
60144
import { MyRouter } from './Router';
61145

0 commit comments

Comments
 (0)