Skip to content

Commit 1f4526b

Browse files
committed
feat:适配harmony平台
1 parent b11ba88 commit 1f4526b

File tree

12 files changed

+132
-5
lines changed

12 files changed

+132
-5
lines changed

harmony/exit_app.har

1.39 KB
Binary file not shown.

harmony/exit_app/Index.ets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./ts";

harmony/exit_app/build-profile.json5

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"apiType": "stageMode",
3+
"buildOption": {
4+
},
5+
"buildOptionSet": [
6+
{
7+
"name": "release",
8+
"arkOptions": {
9+
"obfuscation": {
10+
"ruleOptions": {
11+
"enable": true,
12+
"files": [
13+
"./obfuscation-rules.txt"
14+
]
15+
},
16+
},
17+
},
18+
},
19+
],
20+
"targets": [
21+
{
22+
"name": "default"
23+
},
24+
{
25+
"name": "ohosTest"
26+
}
27+
]
28+
}

harmony/exit_app/hvigorfile.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { harTasks } from '@ohos/hvigor-ohos-plugin';
2+
3+
export default {
4+
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5+
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Define project specific obfuscation rules here.
2+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
3+
#
4+
# For more details, see
5+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6+
7+
# Obfuscation options:
8+
# -disable-obfuscation: disable all obfuscations
9+
# -enable-property-obfuscation: obfuscate the property names
10+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
11+
# -compact: remove unnecessary blank spaces and all line feeds
12+
# -remove-log: remove all console.* statements
13+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
14+
# -apply-namecache: reuse the given cache file
15+
16+
# Keep options:
17+
# -keep-property-name: specifies property names that you want to keep
18+
# -keep-global-name: specifies names that you want to keep in the global scope

harmony/exit_app/oh-package.json5

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@react-native-oh-tpl/react-native-exit-app",
3+
"version": "2.0.0-0.0.1",
4+
"description": "",
5+
"main": "Index.ets",
6+
"author": "",
7+
"license": "Apache-2.0",
8+
"dependencies": {
9+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
2+
import { TM } from "@rnoh/react-native-openharmony/generated/ts"
3+
import { process } from '@kit.ArkTS'
4+
export class ExitAppModule extends TurboModule implements TM.RNExitApp.Spec {
5+
public exitApp(): void {
6+
let pro = new process.ProcessManager()
7+
pro.exit(0);
8+
}
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
RNPackage,
3+
TurboModulesFactory,
4+
} from "@rnoh/react-native-openharmony/ts";
5+
import type {
6+
TurboModule,
7+
TurboModuleContext,
8+
} from "@rnoh/react-native-openharmony/ts";
9+
import { TM } from "@rnoh/react-native-openharmony/generated/ts";
10+
import { ExitAppModule } from './ExitAppModule';
11+
12+
class ExitAppModulesFactory extends TurboModulesFactory {
13+
createTurboModule(name: string): TurboModule | null {
14+
if (name === TM.RNExitApp.NAME) {
15+
return new ExitAppModule(this.ctx);
16+
}
17+
return null;
18+
}
19+
20+
hasTurboModule(name: string): boolean {
21+
return name === TM.RNExitApp.NAME;
22+
}
23+
}
24+
25+
export class ExitAppPackage extends RNPackage {
26+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
27+
return new ExitAppModulesFactory(ctx);
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"module": {
3+
"name": 'exit_app',
4+
"type": 'har',
5+
"deviceTypes": ['default'],
6+
},
7+
}

harmony/exit_app/ts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./src/main/ets/ExitAppPackage";
2+
export * from "./src/main/ets/ExitAppModule";

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
{
2-
"name": "react-native-exit-app",
3-
"version": "2.0.0",
4-
"description": "Exit,close,kill,shutdown app completely for React Native on iOS and Android.",
2+
"name": "@react-native-oh-tpl/react-native-exit-app",
3+
"version": "2.0.0-0.0.1",
4+
"description": "Exit,close,kill,shutdown app completely for React Native on iOS Android and harmony.",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/wumke/react-native-exit-app"
11+
"url": "https://github.com/react-native-oh-library/react-native-exit-app.git"
12+
},
13+
"harmony": {
14+
"alias": "react-native-exit-app",
15+
"codegenConfig": {
16+
"specPaths": [
17+
"./src"
18+
]
19+
}
1220
},
1321
"types": "index.d.ts",
1422
"keywords": [
@@ -19,7 +27,8 @@
1927
"shutdown",
2028
"kill",
2129
"android",
22-
"ios"
30+
"ios",
31+
"harmony"
2332
],
2433
"author": "Wumke",
2534
"license": "MIT",

src/NativeExitApp.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2+
import { TurboModuleRegistry } from 'react-native';
3+
export interface Spec extends TurboModule {
4+
exitApp: () => void;
5+
}
6+
7+
export default TurboModuleRegistry.get<Spec>('RNExitApp') as Spec | null;

0 commit comments

Comments
 (0)