Skip to content

Commit 85572b3

Browse files
fix(ascf): 补充&调整ascf相关说明 (#328)
1 parent e021832 commit 85572b3

File tree

6 files changed

+131
-96
lines changed

6 files changed

+131
-96
lines changed

docs/GETTING-STARTED.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ $ npx taro build --type harmony-hybrid
759759

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

762-
763762
#### 编译命令
764763

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

798+
#### 现有项目
799+
799800
在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。
800801

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

807-
调试运行:
808+
#### 新建项目
809+
810+
使用 taro init 进行项目初始化时,模板源选择`Gitee或者Github` -> `ascf`。项目初始化完成后,后续操作可查看[README.md](https://gitee.com/o2team/taro-project-templates/blob/v4.0/ascf/README.md)
811+
812+
#### 调试运行
813+
808814
编译后文件在 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)解决。
809815

810816
#### 适配问题
811817

812-
- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
818+
- ASCF 的 app.json 配置还不支持 theme 变量,需要适配修改为具体的值:
819+
813820
```javascript
814821
{
815822
window: {
@@ -822,6 +829,7 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
822829
}
823830
}
824831
```
832+
825833
改为:
826834

827835
```javascript
@@ -891,4 +899,3 @@ $ pnpm add -g @tarojs/cli@1.3.9
891899
# OR 安装了 cnpm,使用 cnpm 安装 CLI
892900
$ cnpm install -g @tarojs/cli@1.3.9
893901
```
894-

docs/app-config.md

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,19 @@ export default {
9191

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

94-
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN |
95-
| ---------------------------- | ----------------------------------- | -------------------------- | -------- | ------ | --- | --- |
96-
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
97-
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ |
98-
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
99-
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ ||||
100-
| backgroundColor | ✔️ | ✔️ | ✔️ ||||
101-
| backgroundTextStyle | ✔️ | ✔️ | ✔️ ||||
102-
| backgroundColorTop | ✔️(微信客户端 6.5.16) || ✔️ ||||
103-
| backgroundColorBottom | ✔️(微信客户端 6.5.16) || ✔️ ||||
104-
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ |||
105-
| onReachBottomDistance | ✔️ | ✔️ | ✔️ ||||
106-
| pageOrientation | ✔️ 2.4.0 (auto) / 2.5.0 (landscape) ||||||
94+
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN | ASCF 元服务 |
95+
| ---------------------------- | ----------------------------------- | -------------------------- | -------- | ------ | --- | --- | ----------- |
96+
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
97+
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ | ✔️ |
98+
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
99+
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ |||| ✔️ |
100+
| backgroundColor | ✔️ | ✔️ | ✔️ |||| ✔️ |
101+
| backgroundTextStyle | ✔️ | ✔️ | ✔️ |||||
102+
| backgroundColorTop | ✔️(微信客户端 6.5.16) || ✔️ |||||
103+
| backgroundColorBottom | ✔️(微信客户端 6.5.16) || ✔️ |||||
104+
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ ||| ✔️ |
105+
| onReachBottomDistance | ✔️ | ✔️ | ✔️ |||||
106+
| pageOrientation | ✔️ 2.4.0 (auto) / 2.5.0 (landscape) |||||||
107107

108108
#### 代码示例
109109

@@ -147,15 +147,15 @@ export default {
147147

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

150-
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN |
151-
| --------------- | ----------------------- | ---- | -------- | ------ | --- | --- |
152-
| color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
153-
| selectedColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
154-
| backgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
155-
| borderStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ |
156-
| list | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
157-
| position | ✔️ || ✔️ ||||
158-
| custom | ✔️(基础库 2.5.0 以上) ||||||
150+
| 属性 | 微信 | 百度 | 字节跳动 | 支付宝 | H5 | RN | ASCF 元服务 |
151+
| --------------- | ----------------------- | ---- | -------- | ------ | --- | --- | ----------- |
152+
| color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
153+
| selectedColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
154+
| backgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
155+
| borderStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ | ✔️ |
156+
| list | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
157+
| position | ✔️ || ✔️ |||||
158+
| custom | ✔️(基础库 2.5.0 以上) |||||| ✔️ |
159159

160160
### subPackages
161161

@@ -199,7 +199,7 @@ export default {
199199

200200
### permission
201201

202-
支持情况: <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"/>
202+
支持情况: <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"/>
203203

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

@@ -230,7 +230,7 @@ export default {
230230

231231
### requiredBackgroundModes
232232

233-
支持情况:<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"/>
233+
支持情况:<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"/>
234234

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

@@ -260,7 +260,7 @@ export default {
260260

261261
### entryPagePath
262262

263-
支持情况:<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"/>
263+
支持情况:<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"/>
264264

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

@@ -661,31 +661,40 @@ export default {
661661

662662
## ASCF 元服务支持的属性
663663

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

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

668-
| 属性 | 类型 | 必填 | 默认值 | 说明 |
669-
| :------------ | :------ | :--- | :----- | :--------------------------------- |
670-
| ascfAppId | String ||| ASCF元服务的唯一应用标识,需在ASCF开发者平台申请后填写。 |
671-
| serviceType | String ||| 元服务类型,可选值:miniprogram(小程序式元服务)、webapp(轻应用式元服务)。 |
672-
| enableAuth | Boolean || false | 是否开启ASCF的全局用户鉴权功能,需配合ASCF的API使用。 |
673-
| apiBaseUrl | String ||| ASCF后端API的统一请求地址,用于元服务与服务器的通信。 |
672+
### usingComponents
673+
674+
在此处声明的自定义组件视为全局自定义组件,在 ASCF 元服务内的页面或自定义组件中可以直接使用而无需再声明。
675+
676+
### lazyCodeLoading
677+
678+
> 配置自定义组件代码按需注入,目前仅支持"requiredComponents"。起始版本:1.0.13。依赖关系:ASCF Toolkit 版本 ≥1.0.6
679+
680+
在元服务启动的过程中,代码注入是一个主要的耗时环节。注入代码量的大小与内存占用与注入耗时正相关。
681+
682+
利用“按需注入”和“用时注入”的特性,可以优化代码注入环节的耗时和内存占用。
683+
684+
更多详见[按需注入和用时注入](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/on-demand-render-time-injection)
674685

675686
#### 代码示例
676687

677688
```js title="app.config.js"
678689
export default {
679-
pages: ['pages/index/index'],
680-
window: {
681-
navigationBarTitleText: 'Taro Demo',
682-
},
690+
lazyCodeLoading: 'requiredComponents',
691+
}
692+
```
683693

684-
ascf: {
685-
ascfAppId: 'ASCF_123456',
686-
serviceType: 'miniprogram',
687-
enableAuth: true,
688-
apiBaseUrl: 'https://api.ascf.com',
689-
},
690-
};
691-
```
694+
### resolveAlias
695+
696+
resolveAlias 配置项可用于自定义模块路径的映射规则。
697+
698+
配置完成后,它会对 require 中的模块路径按照所设定的映射规则进行匹配,进而转换为对应的配置路径。
699+
700+
更多详见[resolveAlias](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/appjson-global-config#section13041254111110)

docs/folder.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ title: 目录结构
2626
├── project.tt.json 抖音小程序项目配置 project.tt.json
2727
├── project.swan.json 百度小程序项目配置 project.swan.json
2828
├── project.qq.json QQ 小程序项目配置 project.qq.json
29+
├── ascf.config.json ASCF元服务项目配置 ascf.config.json
2930
|
3031
├── babel.config.js Babel 配置
3132
├── tsconfig.json TypeScript 配置

versioned_docs/version-3.x/GETTING-STARTED.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ $ npx taro build --type harmony-hybrid
713713

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

716-
717716
#### 编译命令
718717

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

752+
#### 现有项目
753+
753754
在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。
754755

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

761-
调试运行:
762+
#### 新建项目
763+
764+
使用 taro init 进行项目初始化时,模板源选择`Gitee或者Github` -> `ascf`。项目初始化完成后,后续操作可查看[README.md](https://gitee.com/o2team/taro-project-templates/blob/v4.0/ascf/README.md)
765+
766+
#### 调试运行
767+
762768
编译后文件在 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)解决。
763769

764770
#### 适配问题
765771

766-
- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
772+
- ASCF 的 app.json 配置还不支持 theme 变量,需要适配修改为具体的值:
773+
767774
```javascript
768775
{
769776
window: {
@@ -776,6 +783,7 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
776783
}
777784
}
778785
```
786+
779787
改为:
780788

781789
```javascript

0 commit comments

Comments
 (0)