Skip to content

Commit

Permalink
docs: add README in Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
run-nan committed Jan 5, 2021
1 parent 8c0b2ea commit 806a99c
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2] - 2021-01-05
### Added
- new API: socket.existsState
- add umd bundle
## [0.2.1] - 2020-12-10
### Added
- enable to watch and set state deeply
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# obvious.js
[![Coverage Status](https://coveralls.io/repos/github/ObviousJs/obvious-core/badge.svg?branch=master)](https://coveralls.io/github/ObviousJs/obvious-core?branch=master) [![release](https://img.shields.io/github/release/ObviousJs/obvious-core.svg)](https://github.com/ObviousJs/obvious-core/releases) [![lastCommit](https://img.shields.io/github/last-commit/ObviousJs/obvious-core)](https://github.com/ObviousJs/obvious-core/commits/master)
[![Coverage Status](https://coveralls.io/repos/github/ObviousJs/obvious-core/badge.svg?branch=master)](https://coveralls.io/github/ObviousJs/obvious-core?branch=master) [![release](https://img.shields.io/github/release/ObviousJs/obvious-core.svg)](https://github.com/ObviousJs/obvious-core/releases) [![lastCommit](https://img.shields.io/github/last-commit/ObviousJs/obvious-core)](https://github.com/ObviousJs/obvious-core/commits/master) [![](https://img.shields.io/badge/document-%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87-brightgreen)](https://github.com/ObviousJs/obvious-core/blob/master/README.md)

Obvious is a progressive micro-front-end framework. In the micro-front-end architecture, Obvious focuses on solving the problem of orchestration and communication between micro frontend applications. It aims to help users quickly build a basic micro-front-end system and support deeper customization to achieve a complete and reliable micro-front-end architecture by providing easy-to-understand APIs and flexible middleware mechanisms.

## Features
- Provide flexible and convenient communication capabilities based on global status, event broadcast, and event unicast
- Provide flexible and convenient communication capabilities based on global state, event broadcast, and event unicast
- Support declaring dependencies when defining micro applications, and automatically activate dependencies when activating micro applications, allowing micro applications to be freely split and combine
- Have a flexible middleware mechanism which allows developers to freely customize the unified registration and loading rules of resources in the form of writing middleware to realize automatic registration. At the same time, allow developers to write middleware to control the code excuting, so that developers can elegantly access log, js sandbox and other functions
- Naturally supports loading multiple micro-applications in a single-screen page, based on which a high-end spa micro-front-end framework can be encapsulated, and the activation conditions of the micro-applications are completely freely set by the developer, no longer limited to routing hijacking.
- The concept is simple, the functional API is clear and easy to understand, and it can be developed without documentation

## Installation
npm:

`npm install obvious-core`

umd:

`<script src="https://unpkg.com/obvious-core@{version}/dist/index.umd.js"></script>`

## Quick Start
![](docs/_media/tutorial-target.gif)

Expand Down
103 changes: 103 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# obvious.js
[![Coverage Status](https://coveralls.io/repos/github/ObviousJs/obvious-core/badge.svg?branch=master)](https://coveralls.io/github/ObviousJs/obvious-core?branch=master) [![release](https://img.shields.io/github/release/ObviousJs/obvious-core.svg)](https://github.com/ObviousJs/obvious-core/releases) [![lastCommit](https://img.shields.io/github/last-commit/ObviousJs/obvious-core)](https://github.com/ObviousJs/obvious-core/commits/master) [![](https://img.shields.io/badge/document-english-brightgreen)](https://github.com/ObviousJs/obvious-core/blob/master/README.zh.md)

obvious是一个渐进式微前端库,在微前端架构中,obvious专注于解决前端微应用的依赖编排和应用间的通信问题,旨在通过简洁易懂,符合编程直觉的API以及灵活的中间件机制,帮助用户快速搭建好基础微前端体系,并支持进行更深层次地定制,从而实现完整可靠的微前端架构

## 特性
- 提供基于全局状态,事件广播,事件单播的通信机制
- 支持在定义微应用时声明依赖,当激活一个微应用时,其依赖将被自动激活,从而在设计前端项目时,能灵活拆分和组合各个微应用
- 提供灵活的中间件机制:用户可以通过编写资源加载中间件的方式控制微应用资源的统一加载规则,搭配后端和CI实现前端微应用自动化注册;同时,用户也可以通过编写资源运行中间件控制微应用源码的运行过程,从而优雅地接入日志,js沙箱等功能
- 不同于single-spa,本库天然支持在一个页面中加载多个微应用,微应用激活条件不再局限于路由变化,基于本库可以封装出高阶的微前端单页应用框架
- 概念简单易懂,函数式API简洁明了,学习之后完全可以脱离文档开发

## 安装
npm:

`npm install obvious-core`

umd:

`<script src="https://unpkg.com/obvious-core@{version}/dist/index.umd.js"></script>`

## 快速开始
![](docs/_media/tutorial-target.gif)

在宿主环境中创建bus,并声明微应用资源
```js
import {createBus} from 'obvious-core';

const bus = createBus('host', {
'react-app': {
js: [
'http://localhost:3000/static/js/bundle.js',
'http://localhost:3000/static/js/0.chunk.js',
'http://localhost:3000/static/js/main.chunk.js'
]
},
'vue-app': {
js: [
'http://localhost:8081/js/app.js',
'http://localhost:8081/js/chunk-vendors.js'
]
}
});
```

在微应用中可以获取到bus,并通过bus创建app和socket,通过app指定声明周期,通过socket与其他微应用通信

react-app
```js
import React from 'react';
import ReactDOM from 'react-dom';
import {getBus} from 'obvious-core';

const bus = getBus('host');
const socket = bus.createSocket();
bus.createApp('react-app')
.bootstrap(async (config) => {
socket.unicast('unicast-event');
socket.broadcast('broadcast-event');
socket.initState('some-state', true);
ReactDOM.render(<App />, document.querySelector(config.mountPoint));
});
```

vue-app
```js
import Vue from 'vue';
import App from './App.vue';
import {getBus} from 'obvious-core';

Vue.config.productionTip = false;

const bus = getBus('host');
const socket = bus.createSocket();
bus.createApp('vue-app')
.bootstrap(async (config) => {
socket.onUnicast('unicast-event', () => {
// do something
});
socket.onBroadcast('broadcast-event', () => {
// do something
});
socket.watchState('some-state', () => {
// do something
});
new Vue({
render: h => h(App),
}).$mount(config.mountPoint);
});
```

在宿主环境中,通过bus激活微应用
```js
bus.activateApp('react-app', {mountPoint: '#react-app'});
bus.activateApp('vue-app', {mountPoint: '#vue-app'});
```

## 文档

[obvious.js: 渐进式微前端库](https://obviousjs.github.io/obvious-core/#/)

## License
obvious is [MIT Licensed](https://github.com/ObviousJs/obvious-core/blob/master/LICENSE)
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 介绍
-----------
obvious是一个渐进式微前端框架,在微前端架构中,obvious专注于解决前端微应用的依赖编排和应用间的通信问题,旨在通过简洁易懂,符合编程直觉的API以及灵活的中间件机制,帮助用户快速搭建好基础微前端体系,并支持进行更深层次地定制,从而实现完整可靠的微前端架构
obvious是一个渐进式微前端库,在微前端架构中,obvious专注于解决前端微应用的依赖编排和应用间的通信问题,旨在通过简洁易懂,符合编程直觉的API以及灵活的中间件机制,帮助用户快速搭建好基础微前端体系,并支持进行更深层次地定制,从而实现完整可靠的微前端架构

## 关于微前端
前端在软件工程中是迭代更新速度比较快的一个领域,虽然前端人常以"学不动了"自嘲,但是客观地说,技术演进是问题复杂度增加,量变引起质变的结果,新的技术出现后能解决更复杂的问题,反之又驱动了问题复杂度的增加。因此前端的快速更新正说明了前端在业务中能做的事情越来越多,地位越来越重要。
Expand Down
4 changes: 2 additions & 2 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <b>obvious.js</b> <small>0.1.1</small>
# <b>obvious.js</b> <small>0.2.2</small>

> 渐进式微前端框架
> 渐进式微前端库
- 简单,轻量
- 轻松理解,快速上手
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obvious-core",
"version": "0.2.2-alpha",
"version": "0.2.2",
"description": "a progressive micro front framework",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
Expand Down

0 comments on commit 806a99c

Please sign in to comment.