From 969761a11b2a7ce522eea40f4f4ae394be4bb042 Mon Sep 17 00:00:00 2001 From: gongshun <2440606146@qq.com> Date: Mon, 21 Sep 2020 18:13:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20supplement=20and=20improve=20api?= =?UTF-8?q?=20documentation=20(#942)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/README.md | 11 ++++++----- docs/api/README.zh.md | 13 +++++++------ package.json | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/api/README.md b/docs/api/README.md index 6cb9524..3dfd7ff 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -25,8 +25,9 @@ By linking the micro-application to some url rules, the function of automaticall - name - `string` - required, the name of the child application and must be unique between the child applications. - - entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - required, The entry url of the child application. - + - entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - required, The entry of the micro application. + - If configured as `string`, it represents the access address of the micro application. If the micro application is deployed in a secondary directory, the last `/` cannot be omitted. For example, the access address of the micro application is: `https://qiankun.umijs.org/guide`, then the `entry` should be `https://qiankun.umijs.org/guide/`. + - If configured as `object`, the value of `html` is the html content string of the micro application, not the access address of the micro application. The `publicPath` of the micro application will be set to `/`. - container - `string | HTMLElement` - required,A selector or Element instance of the container node of a micro application. Such as `container: '#root'` or `container: document.querySelector('#root')`. - activeRule - - `string | (location: Location) => boolean | Array boolean> ` - required,activation rules for micro-apps. @@ -158,7 +159,7 @@ By linking the micro-application to some url rules, the function of automaticall - fetch - `Function` - optional - - getPublicPath - `(url: string) => string` - optional + - getPublicPath - `(enrty: Entry) => string` - optional,The parameter is the entry value of the micro application. - getTemplate - `(tpl: string) => string` - optional @@ -227,7 +228,7 @@ A criterion for judging whether the business is closely related: Look at * Parameters * app - `LoadableApp` - Required, basic information of micro application * name - `string` - Required, the name of the micro application must be unique among the micro applications. - * entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - Required, the entry address of the micro application. + * entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - Required, The entry of the micro application(The detailed description is the same as above). * container - `string | HTMLElement` - Required, selector or Element instance of the container node of the micro application. Such as `container: '#root'` or `container: document.querySelector('#root')`. * props - `object` - Optional, the data that needs to be passed to the micro-application during initialization. @@ -241,7 +242,7 @@ A criterion for judging whether the business is closely related: Look at * fetch - `Function` - Optional, custom fetch method. - * getPublicPath - `(url: string) => string` - Optional + * getPublicPath - `(url: string) => string` - Optional,The parameter is the entry value of the micro application. * getTemplate - `(tpl: string) => string` - Optional diff --git a/docs/api/README.zh.md b/docs/api/README.zh.md index beb7ddc..3e90679 100644 --- a/docs/api/README.zh.md +++ b/docs/api/README.zh.md @@ -25,8 +25,9 @@ toc: menu - name - `string` - 必选,微应用的名称,微应用之间必须确保唯一。 - - entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - 必选,微应用的 entry 地址。 - + - entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - 必选,微应用的入口。 + - 配置为字符串时,表示微应用的访问地址。如果微应用部署在二级目录,则最后面的 `/` 不可省略。例如,微应用的访问地址是:`https://qiankun.umijs.org/guide`,那么 `entry` 应该是 `https://qiankun.umijs.org/guide/`。 + - 配置为对象时,`html` 的值是微应用的 html 内容字符串,而不是微应用的访问地址。微应用的 `publicPath` 将会被设置为 `/`。 - container - `string | HTMLElement` - 必选,微应用的容器节点的选择器或者 Element 实例。如`container: '#root'` 或 `container: document.querySelector('#root')`。 - activeRule - `string | (location: Location) => boolean | Array boolean> ` - 必选,微应用的激活规则。 @@ -158,11 +159,11 @@ toc: menu - fetch - `Function` - 可选,自定义的 fetch 方法。 - - getPublicPath - `(url: string) => string` - 可选 + - getPublicPath - `(enrty: Entry) => string` - 可选,参数是微应用的 entry 值。 - getTemplate - `(tpl: string) => string` - 可选 - - excludeAssetFilter - `(assetUrl: string) => boolean` - 可选,指定部分特殊的动态加载的微应用资源(css/js) 不被qiankun 劫持处理 + - excludeAssetFilter - `(assetUrl: string) => boolean` - 可选,指定部分特殊的动态加载的微应用资源(css/js) 不被 qiankun 劫持处理 - 用法 @@ -227,7 +228,7 @@ toc: menu * 参数 * app - `LoadableApp` - 必选,微应用的基础信息 * name - `string` - 必选,微应用的名称,微应用之间必须确保唯一。 - * entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - 必选,微应用的 entry 地址。 + * entry - `string | { scripts?: string[]; styles?: string[]; html?: string }` - 必选,微应用的入口(详细说明同上)。 * container - `string | HTMLElement` - 必选,微应用的容器节点的选择器或者 Element 实例。如`container: '#root'` 或 `container: document.querySelector('#root')`。 * props - `object` - 可选,初始化时需要传递给微应用的数据。 @@ -263,7 +264,7 @@ toc: menu * fetch - `Function` - 可选,自定义的 fetch 方法。 - * getPublicPath - `(url: string) => string` - 可选 + * getPublicPath - `(entry: Entry) => string` - 可选,参数是微应用的 entry 值。 * getTemplate - `(tpl: string) => string` - 可选 diff --git a/package.json b/package.json index 5cfcdcf..59bf89c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "docs:dev": "dumi dev", "docs:build": "dumi build", "ci": "yarn lint && yarn test", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", @@ -73,6 +73,7 @@ "@umijs/fabric": "^2.0.7", "babel-plugin-import": "^1.12.1", "check-prettier": "^1.0.3", + "cross-env": "^7.0.2", "dumi": "^1.0.24", "father-build": "^1.7.0", "husky": "^2.3.0",