Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/GETTING-STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ $ npx taro build --type harmony-hybrid

- 代码中需包含 ASCF 元服务编译条件:`"ascf"`(需在项目配置中声明)。


#### 编译命令

```bash
Expand Down Expand Up @@ -796,6 +795,8 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
工具准备:
下载并安装 鸿蒙元服务 ASCF 项目[开发环境搭建指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process),确保已配置 ASCF 元服务开发环境。

#### 现有项目

在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。

修改 taro 项目下 config/index.{js,ts}配置文件,编译 ASCF 项目情况下将 outputRoot: 'dist/ascf' 修改为 outputRoot: process.env.TARO_ENV === 'ascf' ? 'ascf-project/ascf/ascf_src' : 'dist'。
Expand All @@ -804,12 +805,18 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
使用 --type ascf 指定平台类型,与其他小程序(如 --type weapp)格式统一。
支持 dev:ascf(开发模式)和 build:ascf(生产模式)。

调试运行:
#### 新建项目

使用 taro init 进行项目初始化时,模板源选择`Gitee或者Github` -> `ascf`。项目初始化完成后,后续操作可查看[README.md](https://gitee.com/o2team/taro-project-templates/blob/v4.0/ascf/README.md)。

#### 调试运行

编译后文件在 ascf-project/ascf/ascf_src 目录下。参考鸿蒙元服务 ASCF 项目[开发流程](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process) 调试运行 ascf-project 项目。如果运行有异常,可以参考[调试指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/debug-ascf-code)解决。

#### 适配问题

- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
- ASCF 的 app.json 配置还不支持 theme 变量,需要适配修改为具体的值:

```javascript
{
window: {
Expand All @@ -822,6 +829,7 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
}
}
```

改为:

```javascript
Expand Down Expand Up @@ -891,4 +899,3 @@ $ pnpm add -g @tarojs/cli@1.3.9
# OR 安装了 cnpm,使用 cnpm 安装 CLI
$ cnpm install -g @tarojs/cli@1.3.9
```

99 changes: 54 additions & 45 deletions docs/app-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ export default {

#### 各端支持程度如下

| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN |
| ---------------------------- | ----------------------------------- | -------------------------- | -------- | ------ | --- | --- |
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ | ✘ | ✔️ | ✔️ |
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ | ✘ | ✘ | ✘ |
| backgroundColor | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ |
| backgroundTextStyle | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ |
| backgroundColorTop | ✔️(微信客户端 6.5.16) | ✘ | ✔️ | ✘ | ✘ | ✘ |
| backgroundColorBottom | ✔️(微信客户端 6.5.16) | ✘ | ✔️ | ✘ | ✘ | ✘ |
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ | ✘ | ✘ |
| onReachBottomDistance | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ |
| pageOrientation | ✔️ 2.4.0 (auto) / 2.5.0 (landscape) | ✘ | ✘ | ✘ | ✘ | ✘ |
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN | ASCF 元服务 |
| ---------------------------- | ----------------------------------- | -------------------------- | -------- | ------ | --- | --- | ----------- |
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ | ✘ | ✔️ | ✔️ | ✔️ |
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ | ✘ | ✘ | ✘ | ✔️ |
| backgroundColor | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ | ✔️ |
| backgroundTextStyle | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ | ✘ |
| backgroundColorTop | ✔️(微信客户端 6.5.16) | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ |
| backgroundColorBottom | ✔️(微信客户端 6.5.16) | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ |
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✔️ |
| onReachBottomDistance | ✔️ | ✔️ | ✔️ | ✘ | ✘ | ✘ | ✘ |
| pageOrientation | ✔️ 2.4.0 (auto) / 2.5.0 (landscape) | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ |

#### 代码示例

Expand Down Expand Up @@ -147,15 +147,15 @@ export default {

#### 各端支持程度如下

| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN |
| --------------- | ----------------------- | ---- | -------- | ------ | --- | --- |
| color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| selectedColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| backgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| borderStyle | ✔️ | ✔️ | ✔️ | ✘ | ✔️ | ✔️ |
| list | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| position | ✔️ | ✘ | ✔️ | ✘ | ✘ | ✘ |
| custom | ✔️(基础库 2.5.0 以上) | ✘ | ✘ | ✘ | ✘ | ✘ |
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN | ASCF 元服务 |
| --------------- | ----------------------- | ---- | -------- | ------ | --- | --- | ----------- |
| color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| selectedColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| backgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| borderStyle | ✔️ | ✔️ | ✔️ | ✘ | ✔️ | ✔️ | ✔️ |
| list | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| position | ✔️ | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ |
| custom | ✔️(基础库 2.5.0 以上) | ✘ | ✘ | ✘ | ✘ | ✘ | ✔️ |

### subPackages

Expand Down Expand Up @@ -199,7 +199,7 @@ export default {

### permission

支持情况: <img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/qq.png').default} className="icon_platform" width="25px"/>
支持情况: <img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/qq.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px"/>

小程序[接口权限](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)相关设置。字段类型为 `Object`,结构为:

Expand Down Expand Up @@ -230,7 +230,7 @@ export default {

### requiredBackgroundModes

支持情况:<img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/qq.png').default} className="icon_platform" width="25px"/>
支持情况:<img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/qq.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px"/>

申明需要后台运行的能力,类型为数组。目前支持以下项目:

Expand Down Expand Up @@ -260,7 +260,7 @@ export default {

### entryPagePath

支持情况:<img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/>
支持情况:<img src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px"/>

指定小程序的默认启动路径(首页),常见情景是从微信聊天列表页下拉启动、小程序列表启动等。如果不填,将默认为 `pages` 列表的第一项。不支持带页面路径参数。

Expand Down Expand Up @@ -661,31 +661,40 @@ export default {

## ASCF 元服务支持的属性

### ASCF支持的全局参数
只在 ASCF 元服务中支持的属性。<img src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px"/>

这些配置需在项目的入口配置文件(如 app.config.js)中声明,以实现对ASCF元服务的适配。
| 属性 | 类型 | 描述 |
| :------------------------------------ | :----- | :------------------------- |
| [usingComponents](#usingcomponents-1) | Object | 全局自定义组件配置 |
| [resolveAlias](#resolveAlias) | Object | 微信消息用小程序打开 |
| [lazyCodeLoading](#lazycodeloading-1) | String | 配置自定义组件代码按需注入 |

| 属性 | 类型 | 必填 | 默认值 | 说明 |
| :------------ | :------ | :--- | :----- | :--------------------------------- |
| ascfAppId | String | 是 | 无 | ASCF元服务的唯一应用标识,需在ASCF开发者平台申请后填写。 |
| serviceType | String | 是 | 无 | 元服务类型,可选值:miniprogram(小程序式元服务)、webapp(轻应用式元服务)。 |
| enableAuth | Boolean | 否 | false | 是否开启ASCF的全局用户鉴权功能,需配合ASCF的API使用。 |
| apiBaseUrl | String | 否 | 无 | ASCF后端API的统一请求地址,用于元服务与服务器的通信。 |
### usingComponents

在此处声明的自定义组件视为全局自定义组件,在 ASCF 元服务内的页面或自定义组件中可以直接使用而无需再声明。

### lazyCodeLoading

> 配置自定义组件代码按需注入,目前仅支持"requiredComponents"。起始版本:1.0.13。依赖关系:ASCF Toolkit 版本 ≥1.0.6

在元服务启动的过程中,代码注入是一个主要的耗时环节。注入代码量的大小与内存占用与注入耗时正相关。

利用“按需注入”和“用时注入”的特性,可以优化代码注入环节的耗时和内存占用。

更多详见[按需注入和用时注入](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/on-demand-render-time-injection)。

#### 代码示例

```js title="app.config.js"
export default {
pages: ['pages/index/index'],
window: {
navigationBarTitleText: 'Taro Demo',
},
lazyCodeLoading: 'requiredComponents',
}
```

ascf: {
ascfAppId: 'ASCF_123456',
serviceType: 'miniprogram',
enableAuth: true,
apiBaseUrl: 'https://api.ascf.com',
},
};
```
### resolveAlias

resolveAlias 配置项可用于自定义模块路径的映射规则。

配置完成后,它会对 require 中的模块路径按照所设定的映射规则进行匹配,进而转换为对应的配置路径。

更多详见[resolveAlias](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/appjson-global-config#section13041254111110)。
1 change: 1 addition & 0 deletions docs/folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ title: 目录结构
├── project.tt.json 抖音小程序项目配置 project.tt.json
├── project.swan.json 百度小程序项目配置 project.swan.json
├── project.qq.json QQ 小程序项目配置 project.qq.json
├── ascf.config.json ASCF元服务项目配置 ascf.config.json
|
├── babel.config.js Babel 配置
├── tsconfig.json TypeScript 配置
Expand Down
14 changes: 11 additions & 3 deletions versioned_docs/version-3.x/GETTING-STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,6 @@ $ npx taro build --type harmony-hybrid

- 代码中需包含 ASCF 元服务编译条件:`"ascf"`(需在项目配置中声明)。


#### 编译命令

```bash
Expand Down Expand Up @@ -750,6 +749,8 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
工具准备:
下载并安装 鸿蒙元服务 ASCF 项目[开发环境搭建指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process),确保已配置 ASCF 元服务开发环境。

#### 现有项目

在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。

修改 taro 项目下 config/index.{js,ts}配置文件,编译 ASCF 项目情况下将 outputRoot: 'dist/ascf' 修改为 outputRoot: process.env.TARO_ENV === 'ascf' ? 'ascf-project/ascf/ascf_src' : 'dist'。
Expand All @@ -758,12 +759,18 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
使用 --type ascf 指定平台类型,与其他小程序(如 --type weapp)格式统一。
支持 dev:ascf(开发模式)和 build:ascf(生产模式)。

调试运行:
#### 新建项目

使用 taro init 进行项目初始化时,模板源选择`Gitee或者Github` -> `ascf`。项目初始化完成后,后续操作可查看[README.md](https://gitee.com/o2team/taro-project-templates/blob/v4.0/ascf/README.md)。

#### 调试运行

编译后文件在 ascf-project/ascf/ascf_src 目录下。参考鸿蒙元服务 ASCF 项目[开发流程](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process) 调试运行 ascf-project 项目。如果运行有异常,可以参考[调试指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/debug-ascf-code)解决。

#### 适配问题

- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
- ASCF 的 app.json 配置还不支持 theme 变量,需要适配修改为具体的值:

```javascript
{
window: {
Expand All @@ -776,6 +783,7 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
}
}
```

改为:

```javascript
Expand Down
Loading