From 77dffa82497f2e1eefb2e98526bc7218226cd8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=BA=B7?= Date: Mon, 4 Jul 2022 19:05:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=87=E6=A1=A3=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E5=AE=98=E3=80=913.1=E5=88=86=E6=94=AF=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=86=97=E4=BD=99API=EF=BC=9Ajs-apis-applicationContext?= =?UTF-8?q?=E5=92=8Cjs-apis-application-context=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20js-apis-applicationContext=20=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E6=96=87=E6=A1=A3=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡康 --- .../apis/js-apis-application-context.md | 78 +++++++++--- .../apis/js-apis-applicationContext.md | 116 ------------------ 2 files changed, 58 insertions(+), 136 deletions(-) delete mode 100644 zh-cn/application-dev/reference/apis/js-apis-applicationContext.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index ff20db878e..7e8c5f94af 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -18,18 +18,18 @@ **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - | 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 | -| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 | -| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 | -| tempDir | string | 是 | 否 | 应用的临时文件路径。 | -| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 | -| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 | -| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 | -| bundleCodeDir | string | 是 | 否 | 应用安装路径。 | -| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | -| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。| +| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 | +| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 | +| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 | +| tempDir | string | 是 | 否 | 应用的临时文件路径。 | +| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 | +| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 | +| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 | +| bundleCodeDir | string | 是 | 否 | 应用安装路径。 | +| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | +| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。| ## Context.createBundleContext @@ -42,15 +42,15 @@ createBundleContext(bundleName: string): Context; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 应用bundle名。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| bundleName | string | 是 | 应用bundle名。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Context | 对应创建应用的上下文context。 | +| 类型 | 说明 | +| -------- | -------- | +| Context | 对应创建应用的上下文context。 | **示例:** @@ -70,13 +70,51 @@ getApplicationContext(): Context; **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Context | 当前Context 信息。 | +| 类型 | 说明 | +| -------- | -------- | +| Context | 当前Context 信息。 | **示例:** + ```js // 必选项。 let context = this.context.getApplicationContext(); ``` + + + +> **说明:** +> 当SDK :API 9版本为Canary版本时; + +## Context.switchArea + +switchArea(mode: AreaMode): void + +开启文件范围 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------------------- | ---- | -------------- | +| mode | [AreaMode](#AreaMode) | 是 | 应用bundle名。 | + +**示例**: + +```js +var areaMode = 0 +this.context.switchArea(areaMode); +``` + +## AreaMode + +文件范围模式 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +| 名称 | 参数类型 | 值 | +| ---- | -------- | ---- | +| EL1 | number | 0 | +| EL2 | number | 1 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md deleted file mode 100644 index fe2add752f..0000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md +++ /dev/null @@ -1,116 +0,0 @@ -# Context - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明** -> -> 本模块首批接口从API version 9开始支持。API 9当前为Canary版本,仅供使用,不保证接口可稳定调用。 - - -提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 - - -## 使用说明 - - -通过AbilityContext等继承实现。 - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 | -| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 | -| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 | -| tempDir | string | 是 | 否 | 应用的临时文件路径。 | -| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 | -| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 | -| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 | -| bundleCodeDir | string | 是 | 否 | 应用安装路径。 | -| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | -| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。| - - -## Context.createBundleContext - -createBundleContext(bundleName: string): Context; - -创建指定应用上下文。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 应用bundle名。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Context | 对应创建应用的上下文context。 | - -**示例:** - -```js -let test = "com.example.test"; -let context = this.context.createBundleContext(test); -``` - - -## Context.getApplicationContext - -getApplicationContext(): Context; - -获取当前context。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Context | 当前Context 信息。 | - -**示例:** - -```js -// 必选项。 -let context = this.context.getApplicationContext(); -``` - - -## Context.switchArea - -switchArea(mode: AreaMode): void - -开启文件范围 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mode | [AreaMode](#AreaMode) | 是 | 应用bundle名。 | - -**示例**: - -```js -var areaMode = 0 -this.context.switchArea(areaMode); -``` - - -## AreaMode - -文件范围模式 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 值 | -| -------- | -------- | -------- | -| EL1 | number | 0 | -| EL2 | number | 1 | \ No newline at end of file -- GitLab