Skip to content

Commit 178ffcb

Browse files
Merge pull request #322 from 2extliuweijian32/feat/ascf
docs:更新ascf资料
1 parent e37f153 commit 178ffcb

File tree

9 files changed

+117
-24
lines changed

9 files changed

+117
-24
lines changed

docs/README.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import News from './news'
1111

1212
## 简介
1313

14-
**Taro** 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发 [微信](https://mp.weixin.qq.com/) / [京东](https://mp.jd.com/?entrance=taro) / [百度](https://smartprogram.baidu.com/) / [支付宝](https://mini.open.alipay.com/) / [字节跳动](https://developer.open-douyin.com/) / [QQ](https://q.qq.com/) / [飞书](https://open.feishu.cn/document/uYjL24iN/ucDOzYjL3gzM24yN4MjN) / [快手](https://mp.kuaishou.com/) 小程序 / H5 / RN 等应用。
14+
**Taro** 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发 [微信](https://mp.weixin.qq.com/) / [京东](https://mp.jd.com/?entrance=taro) / [百度](https://smartprogram.baidu.com/) / [支付宝](https://mini.open.alipay.com/) / [字节跳动](https://developer.open-douyin.com/) / [QQ](https://q.qq.com/) / [飞书](https://open.feishu.cn/document/uYjL24iN/ucDOzYjL3gzM24yN4MjN) / [快手](https://mp.kuaishou.com/) 小程序 / H5 / RN / [ASCF元服务](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-overview) 等应用。
1515

1616
现如今市面上端的形态多种多样,Web、React Native、微信小程序等各种端大行其道。当业务要求同时在不同的端都要求有所表现的时候,针对不同的端去编写多套代码的成本显然非常高,这时候只编写一套代码就能够适配到多端的能力就显得极为需要。
1717

@@ -36,6 +36,7 @@ Taro 3 可以支持转换到 H5、ReactNative 以及任意小程序平台。
3636
- [<img title="支付宝 IOT 小程序" src={require('@site/static/img/platform/alipay.png').default} className="icon_platform" width="25px" /> 支付宝 IOT 小程序](https://opendocs.alipay.com/iot/multi-platform/vcs0fv?from=taro)
3737
- [<img title="飞书小程序" src={require('@site/static/img/platform/lark.png').default} className="icon_platform" width="25px" /> 飞书小程序](https://open.feishu.cn/document/uYjL24iN/uMjNzUjLzYzM14yM2MTN?from=taro)
3838
- [<img title="快手小程序" src={require('@site/static/img/platform/kuaishou.png').default} className="icon_platform" width="25px" /> 快手小程序](https://mp.kuaishou.com/docs/develop/frame/config/conf_appjson.html?from=taro)
39+
- [<img title="ASCF元服务" src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px" /> ASCF元服务](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-overview)
3940

4041
### 框架支持
4142

docs/project-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: 项目配置
1111
- 支付宝小程序,[mini.project.json](https://opendocs.alipay.com/mini/framework/project)
1212
- 京东小程序,暂无发现
1313
- 飞书小程序,[project.config.json](https://open.feishu.cn/document/uYjL24iN/uEzMzUjLxMzM14SMzMTN/gadget-project-configuration?from=taro)
14-
- ASCF元服务,[project.config.json](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/project-json-config)
14+
- ASCF元服务,[ascf.config.json](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/project-json-config)
1515

1616
为了能够适配不同小程序平台的配置文件不同的情况,Taro 支持为各个小程序平台添加各自的项目配置文件。
1717

static/img/platform/ascf.png

26.3 KB
Loading

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,64 @@ $ npx taro build --type harmony-hybrid
705705

706706
- 把 Taro 项目目录下的 `dist` 目录的编译产物复制到鸿蒙应用的 `src/main/resources/rawfile` 目录下,编译运行鸿蒙应用进行开发调试。
707707

708+
### ASCF 元服务
709+
710+
> Taro v3.6.38+ 开始支持
711+
712+
若需将 Taro 代码编译为 ASCF 元服务,需在编译命令中指定平台参数为 `ascf`,并确保满足以下条件:
713+
714+
- 代码中需包含 ASCF 元服务编译条件:`"ascf"`(需在项目配置中声明)。
715+
716+
示例命令:
717+
718+
```bash
719+
taro build --type ascf
720+
721+
#### 编译命令
722+
723+
# pnpm
724+
$ pnpm dev:ascf
725+
$ pnpm build:ascf
726+
727+
# yarn
728+
$ yarn dev:ascf
729+
$ yarn build:ascf
730+
731+
# npm script
732+
$ npm run dev:ascf
733+
$ npm run build:ascf
734+
735+
# 仅限全局安装
736+
$ taro build --type ascf --watch
737+
$ taro build --type ascf
738+
739+
# npx 用户也可以使用
740+
$ npx taro build --type ascf --watch
741+
$ npx taro build --type ascf
742+
743+
# watch 同时开启压缩
744+
$ set NODE_ENV=production && taro build --type ascf --watch # CMD
745+
$ NODE_ENV=production taro build --type ascf --watch # Bash
746+
747+
748+
```
749+
750+
开发者工具
751+
752+
工具准备:
753+
下载并安装 鸿蒙元服务 ASCF 项目[开发环境搭建指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process),确保已配置 ASCF 元服务开发环境。
754+
755+
在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。
756+
757+
修改 taro 项目下 config/index.{js,ts}配置文件,编译 ASCF 项目情况下将 outputRoot: 'dist/ascf' 修改为 outputRoot: process.env.TARO_ENV === 'ascf' ? 'ascf-project/ascf/ascf_src' : 'dist'。
758+
759+
编译命令:
760+
使用 --type ascf 指定平台类型,与其他小程序(如 --type weapp)格式统一。
761+
支持 dev:ascf(开发模式)和 build:ascf(生产模式)。
762+
763+
调试运行:
764+
编译后文件在 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)解决。
765+
708766
## 渐进式入门教程
709767

710768
我们提供了一个由浅入深的实战教程,请参考[《教程》](./guide)

versioned_docs/version-3.x/README.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import News from './news'
1111

1212
## 简介
1313

14-
**Taro** 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发 [微信](https://mp.weixin.qq.com/) / [京东](https://mp.jd.com/?entrance=taro) / [百度](https://smartprogram.baidu.com/) / [支付宝](https://mini.open.alipay.com/) / [字节跳动](https://developer.open-douyin.com/) / [QQ](https://q.qq.com/) / [飞书](https://open.feishu.cn/document/uYjL24iN/ucDOzYjL3gzM24yN4MjN) / [快手](https://mp.kuaishou.com/) 小程序 / H5 / RN 等应用。
14+
**Taro** 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发 [微信](https://mp.weixin.qq.com/) / [京东](https://mp.jd.com/?entrance=taro) / [百度](https://smartprogram.baidu.com/) / [支付宝](https://mini.open.alipay.com/) / [字节跳动](https://developer.open-douyin.com/) / [QQ](https://q.qq.com/) / [飞书](https://open.feishu.cn/document/uYjL24iN/ucDOzYjL3gzM24yN4MjN) / [快手](https://mp.kuaishou.com/) 小程序 / H5 / RN / [ASCF元服务](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-overview) 等应用。
1515

1616
现如今市面上端的形态多种多样,Web、React Native、微信小程序等各种端大行其道。当业务要求同时在不同的端都要求有所表现的时候,针对不同的端去编写多套代码的成本显然非常高,这时候只编写一套代码就能够适配到多端的能力就显得极为需要。
1717

@@ -36,6 +36,7 @@ Taro 3 可以支持转换到 H5、ReactNative 以及任意小程序平台。
3636
- [<img title="支付宝 IOT 小程序" src={require('@site/static/img/platform/alipay.png').default} className="icon_platform" width="25px" /> 支付宝 IOT 小程序](https://opendocs.alipay.com/iot/multi-platform/vcs0fv?from=taro)
3737
- [<img title="飞书小程序" src={require('@site/static/img/platform/lark.png').default} className="icon_platform" width="25px" /> 飞书小程序](https://open.feishu.cn/document/uYjL24iN/uMjNzUjLzYzM14yM2MTN?from=taro)
3838
- [<img title="快手小程序" src={require('@site/static/img/platform/kuaishou.png').default} className="icon_platform" width="25px" /> 快手小程序](https://mp.kuaishou.com/docs/develop/frame/config/conf_appjson.html?from=taro)
39+
- [<img title="ASCF元服务" src={require('@site/static/img/platform/ascf.png').default} className="icon_platform" width="25px" /> ASCF元服务](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-overview)
3940

4041
### 框架支持
4142

versioned_docs/version-3.x/app-config.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,34 @@ export default {
658658
animation: false,
659659
}
660660
```
661+
662+
## ASCF 元服务支持的属性
663+
664+
### ASCF 支持的全局参数
665+
666+
这些配置需在项目的入口配置文件(如 app.config.js)中声明,以实现对 ASCF 元服务的适配。
667+
668+
| 属性 | 类型 | 必填 | 默认值 | 说明 |
669+
| :---------- | :------ | :--- | :----- | :---------------------------------------------------------------------------- |
670+
| ascfAppId | String ||| ASCF 元服务的唯一应用标识,需在 ASCF 开发者平台申请后填写。 |
671+
| serviceType | String ||| 元服务类型,可选值:miniprogram(小程序式元服务)、webapp(轻应用式元服务)。 |
672+
| enableAuth | Boolean || false | 是否开启 ASCF 的全局用户鉴权功能,需配合 ASCF 的 API 使用。 |
673+
| apiBaseUrl | String ||| ASCF 后端 API 的统一请求地址,用于元服务与服务器的通信。 |
674+
675+
#### 代码示例
676+
677+
```js title="app.config.js"
678+
export default {
679+
pages: ['pages/index/index'],
680+
window: {
681+
navigationBarTitleText: 'Taro Demo',
682+
},
683+
684+
ascf: {
685+
ascfAppId: 'ASCF_123456',
686+
serviceType: 'miniprogram',
687+
enableAuth: true,
688+
apiBaseUrl: 'https://api.ascf.com',
689+
},
690+
}
691+
```

versioned_docs/version-3.x/envs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Taro 在编译时提供了一些内置的环境变量来帮助用户做一些特
1212

1313
用于判断当前的编译平台类型。
1414

15-
取值:`weapp` / `swan` / `alipay` / `tt` / `qq` / `jd` / `h5` / `rn`
15+
取值:`weapp` / `swan` / `alipay` / `tt` / `qq` / `jd` / `h5` / `rn` / `ascf`
1616

1717
可以通过这个变量来区分不同环境,从而使用不同的逻辑。在编译阶段,**会移除不属于当前编译类型的代码,只保留当前编译类型下的代码**,例如:
1818

versioned_docs/version-3.x/page-config.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,23 @@ export default function Index() {}
103103

104104
### 各端支持程度
105105

106-
| 属性 | 微信小程序 | 百度小程序 | 抖音小程序 | 支付宝小程序 | H5 | RN |
107-
| ---------------------------- | ---------------------------------- | -------------------------- | -------------- | ------------ | --- | --- |
108-
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
109-
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ |
110-
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
111-
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ ||| ✔️ |
112-
| transparentTitle | - | - | - | ✔️ | - | - |
113-
| backgroundColor | ✔️ | ✔️ | ✔️ ||| ✔️ |
114-
| backgroundTextStyle | ✔️ | ✔️ | ✔️ ||| ✔️ |
115-
| backgroundColorTop | ✔️(微信客户端 6.5.16) || ✔️ ||||
116-
| backgroundColorBottom | ✔️(微信客户端 6.5.16) || ✔️ ||||
117-
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ |||
118-
| onReachBottomDistance | ✔️ | ✔️ | ✔️ ||||
119-
| pageOrientation | ✔️2.4.0 (auto) / 2.5.0 (landscape) ||||||
120-
| disableScroll | ✔️ ||||| ✔️ |
121-
| disableSwipeBack | ✔️ ||||||
122-
| enableShareAppMessage | ✔️ |||| ✔️ ||
123-
| enableShareTimeline | ✔️ |||| ✔️ ||
124-
| usingComponents | ✔️ | ✔️ | ✔️ | ✔️ |||
125-
| renderer | ✔️ ||||||
106+
| 属性 | 微信小程序 | 百度小程序 | 抖音小程序 | 支付宝小程序 | H5 | RN | ASCF |
107+
| ---------------------------- | ---------------------------------- | -------------------------- | -------------- | ------------ | --- | --- | --- |
108+
| navigationBarBackgroundColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
109+
| navigationBarTextStyle | ✔️ | ✔️ | ✔️ || ✔️ | ✔️ | ✔️ |
110+
| navigationBarTitleText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
111+
| navigationStyle | ✔️(微信客户端 6.6.0) | ✔️(百度 App 版本 11.1.0) | ✔️ ||| ✔️ | ✔️ |
112+
| transparentTitle | - | - | - | ✔️ | - | - ||
113+
| backgroundColor | ✔️ | ✔️ | ✔️ ||| ✔️ | ✔️ |
114+
| backgroundTextStyle | ✔️ | ✔️ | ✔️ ||| ✔️ ||
115+
| backgroundColorTop | ✔️(微信客户端 6.5.16) || ✔️ |||||
116+
| backgroundColorBottom | ✔️(微信客户端 6.5.16) || ✔️ |||||
117+
| enablePullDownRefresh | ✔️ | ✔️ | ✔️ | ✔️ ||| ✔️ |
118+
| onReachBottomDistance | ✔️ | ✔️ | ✔️ |||||
119+
| pageOrientation | ✔️2.4.0 (auto) / 2.5.0 (landscape) |||||||
120+
| disableScroll | ✔️ ||||| ✔️ ||
121+
| disableSwipeBack | ✔️ |||||||
122+
| enableShareAppMessage | ✔️ |||| ✔️ |||
123+
| enableShareTimeline | ✔️ |||| ✔️ |||
124+
| usingComponents | ✔️ | ✔️ | ✔️ | ✔️ ||| ✔️ |
125+
| renderer | ✔️ |||||||

versioned_docs/version-3.x/project-config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ title: 项目配置
1111
- 支付宝小程序,[mini.project.json](https://opendocs.alipay.com/mini/framework/project)
1212
- 京东小程序,暂无发现
1313
- 飞书小程序,[project.config.json](https://open.feishu.cn/document/uYjL24iN/uEzMzUjLxMzM14SMzMTN/gadget-project-configuration?from=taro)
14+
- ASCF元服务,[ascf.config.json](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/project-json-config)
1415

1516
为了能够适配不同小程序平台的配置文件不同的情况,Taro 支持为各个小程序平台添加各自的项目配置文件。
1617

@@ -24,6 +25,7 @@ title: 项目配置
2425
| QQ 小程序 | project.qq.json |
2526
| 支付宝小程序 | project.alipay.json |
2627
| 飞书小程序 | project.lark.json |
28+
| ASCF元服务 | ascf.config.json |
2729

2830
:::caution 注意
2931
飞书小程序从[插件](https://www.npmjs.com/package/@tarojs/plugin-platform-lark)1.0.2 版本开始,配置文件修改为`project.lark.json`,之前版本为`project.tt.json`

0 commit comments

Comments
 (0)