Skip to content

Commit e021832

Browse files
fix(ascf): ascf资料调整 (#324)
1 parent 178ffcb commit e021832

File tree

2 files changed

+84
-40
lines changed

2 files changed

+84
-40
lines changed

docs/GETTING-STARTED.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -753,18 +753,18 @@ $ npx taro build --type harmony-hybrid
753753

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

756-
### ASCF元服务
756+
### ASCF 元服务
757757

758-
若需将 Taro 代码编译为 ASCF 元服务,需在编译命令中指定平台参数为 `ascf`,并确保满足以下条件:
759-
- 代码中需包含 ASCF 元服务编译条件:`"ascf"`(需在项目配置中声明)。
760-
- 配置文件 `project.ascf.json` 需存在于项目根目录。
758+
若需将 Taro 代码编译为 ASCF 元服务,需在编译命令中指定平台参数为 `ascf`,并确保满足以下条件:
759+
760+
- 代码中需包含 ASCF 元服务编译条件:`"ascf"`(需在项目配置中声明)。
761761

762-
示例命令:
763-
```bash
764-
taro build --type ascf
765762

766763
#### 编译命令
767764

765+
```bash
766+
taro build --type ascf
767+
768768
# pnpm
769769
$ pnpm dev:ascf
770770
$ pnpm build:ascf
@@ -789,47 +789,58 @@ $ npx taro build --type ascf
789789
$ set NODE_ENV=production && taro build --type ascf --watch # CMD
790790
$ NODE_ENV=production taro build --type ascf --watch # Bash
791791

792-
793792
```
794793

795-
开发者工具
794+
#### 开发者工具
796795

797796
工具准备:
798-
下载并安装 鸿蒙开发者工具,确保已配置ASCF元服务开发环境。
799-
导入项目:
800-
打开鸿蒙开发者工具,选择 导入项目。
801-
选择项目根目录下的 dist/ascf 目录(需确保已通过编译命令生成)。
802-
配置校验:
803-
确认项目中存在 project.ascf.json 文件(元服务专属配置)。
804-
检查配置文件字段是否符合规范(如 minPlatformVersion、permissions 等)。
805-
注意事项
806-
807-
在开发者工具中需设置:
797+
下载并安装 鸿蒙元服务 ASCF 项目[开发环境搭建指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process),确保已配置 ASCF 元服务开发环境。
808798

809-
关闭 ES6 转 ES5 功能(开启可能导致语法错误)。
810-
关闭 上传代码时样式自动补全(开启可能引发样式异常)。
811-
关闭 代码压缩上传(开启可能影响调试信息)。
799+
在 taro 项目根目录下创建 ascf-project 目录,并使用工具在该目录下创建 ASCF 元服务项目。
812800

813-
格式说明
801+
修改 taro 项目下 config/index.{js,ts}配置文件,编译 ASCF 项目情况下将 outputRoot: 'dist/ascf' 修改为 outputRoot: process.env.TARO_ENV === 'ascf' ? 'ascf-project/ascf/ascf_src' : 'dist'。
814802

815803
编译命令:
816804
使用 --type ascf 指定平台类型,与其他小程序(如 --type weapp)格式统一。
817805
支持 dev:ascf(开发模式)和 build:ascf(生产模式)。
818-
开发者工具:
819-
明确指向编译后的 dist/ascf 目录,与微信小程序的 dist 目录逻辑一致。
820-
强调 project.ascf.json 为必需配置文件(类比 project.swan.json)。
821-
注意事项:
822-
与其他小程序保持完全一致的关闭选项,避免开发者混淆。
823806

824-
效果验证
807+
调试运行:
808+
编译后文件在 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)解决。
825809

826-
执行编译命令后,检查 dist/ascf 目录是否包含以下文件:
827-
manifest.json(元服务描述文件)
828-
页面代码及资源文件
829-
在鸿蒙开发者工具中运行项目,确保:
830-
页面渲染正常,无白屏或报错。
831-
声明的权限(如定位、相机)可正常触发弹窗申请。
810+
#### 适配问题
832811

812+
- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
813+
```javascript
814+
{
815+
window: {
816+
backgroundColorTop: '@bgColorTop',
817+
backgroundColorBottom: '@bgColorBottom',
818+
backgroundTextStyle: '@bgTxtStyle',
819+
navigationBarBackgroundColor: '@navBgColor',
820+
navigationBarTitleText: 'ascf',
821+
navigationBarTextStyle: '@navTxtStyle'
822+
}
823+
}
824+
```
825+
改为:
826+
827+
```javascript
828+
const theme = require('./theme.json');
829+
const $t = (key) => process.env.TARO_ENV === 'ascf' ? theme.light[key.replace('@', '')] : key;
830+
831+
defineAppConfig({
832+
{
833+
window: {
834+
backgroundColorTop: $t('@bgColorTop'),
835+
backgroundColorBottom: $t('@bgColorBottom'),
836+
backgroundTextStyle: $t('@bgTxtStyle'),
837+
navigationBarBackgroundColor: $t('@navBgColor'),
838+
navigationBarTitleText: 'ascf',
839+
navigationBarTextStyle: $t('@navTxtStyle')
840+
}
841+
}
842+
})
843+
```
833844

834845
## 渐进式入门教程
835846

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

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,12 @@ $ npx taro build --type harmony-hybrid
713713

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

716-
示例命令:
716+
717+
#### 编译命令
717718

718719
```bash
719720
taro build --type ascf
720721

721-
#### 编译命令
722-
723722
# pnpm
724723
$ pnpm dev:ascf
725724
$ pnpm build:ascf
@@ -744,10 +743,9 @@ $ npx taro build --type ascf
744743
$ set NODE_ENV=production && taro build --type ascf --watch # CMD
745744
$ NODE_ENV=production taro build --type ascf --watch # Bash
746745

747-
748746
```
749747

750-
开发者工具
748+
#### 开发者工具
751749

752750
工具准备:
753751
下载并安装 鸿蒙元服务 ASCF 项目[开发环境搭建指南](https://developer.huawei.com/consumer/cn/doc/atomic-ascf/ascf-development-process),确保已配置 ASCF 元服务开发环境。
@@ -763,6 +761,41 @@ $ NODE_ENV=production taro build --type ascf --watch # Bash
763761
调试运行:
764762
编译后文件在 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)解决。
765763

764+
#### 适配问题
765+
766+
- ASCF的app.json配置还不支持theme变量,需要适配修改为具体的值:
767+
```javascript
768+
{
769+
window: {
770+
backgroundColorTop: '@bgColorTop',
771+
backgroundColorBottom: '@bgColorBottom',
772+
backgroundTextStyle: '@bgTxtStyle',
773+
navigationBarBackgroundColor: '@navBgColor',
774+
navigationBarTitleText: 'ascf',
775+
navigationBarTextStyle: '@navTxtStyle'
776+
}
777+
}
778+
```
779+
改为:
780+
781+
```javascript
782+
const theme = require('./theme.json');
783+
const $t = (key) => process.env.TARO_ENV === 'ascf' ? theme.light[key.replace('@', '')] : key;
784+
785+
defineAppConfig({
786+
{
787+
window: {
788+
backgroundColorTop: $t('@bgColorTop'),
789+
backgroundColorBottom: $t('@bgColorBottom'),
790+
backgroundTextStyle: $t('@bgTxtStyle'),
791+
navigationBarBackgroundColor: $t('@navBgColor'),
792+
navigationBarTitleText: 'ascf',
793+
navigationBarTextStyle: $t('@navTxtStyle')
794+
}
795+
}
796+
})
797+
```
798+
766799
## 渐进式入门教程
767800

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

0 commit comments

Comments
 (0)