初始提交
This commit is contained in:
0
uni_modules/jnpf-exitApp/changelog.md
Normal file
0
uni_modules/jnpf-exitApp/changelog.md
Normal file
95
uni_modules/jnpf-exitApp/package.json
Normal file
95
uni_modules/jnpf-exitApp/package.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"id": "jnpf-exitApp",
|
||||
"displayName": "jnpf-exitApp",
|
||||
"version": "1.0.0",
|
||||
"description": "jnpf-exitApp",
|
||||
"keywords": [
|
||||
"jnpf-exitApp"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.6.8"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "uts",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "",
|
||||
"data": "",
|
||||
"permissions": ""
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"uni-ext-api": {
|
||||
"uni": {
|
||||
"exitApp": {
|
||||
"name": "exitApp",
|
||||
"app": {
|
||||
"js": false,
|
||||
"kotlin": false,
|
||||
"swift": false,
|
||||
"arkts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "u",
|
||||
"aliyun": "u",
|
||||
"alipay": "u"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "u",
|
||||
"vue3": "u"
|
||||
},
|
||||
"App": {
|
||||
"app-android": "u",
|
||||
"app-ios": "u"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "u",
|
||||
"Android Browser": "u",
|
||||
"微信浏览器(Android)": "u",
|
||||
"QQ浏览器(Android)": "u"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "u",
|
||||
"IE": "u",
|
||||
"Edge": "u",
|
||||
"Firefox": "u",
|
||||
"Safari": "u"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "u",
|
||||
"阿里": "u",
|
||||
"百度": "u",
|
||||
"字节跳动": "u",
|
||||
"QQ": "u",
|
||||
"钉钉": "u",
|
||||
"快手": "u",
|
||||
"飞书": "u",
|
||||
"京东": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
uni_modules/jnpf-exitApp/readme.md
Normal file
6
uni_modules/jnpf-exitApp/readme.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# jnpf-exitApp
|
||||
### 开发文档
|
||||
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
|
||||
[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
|
||||
[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
|
||||
[Hello UTS](https://gitcode.net/dcloud/hello-uts)
|
||||
24
uni_modules/jnpf-exitApp/utssdk/app-harmony/index.uts
Normal file
24
uni_modules/jnpf-exitApp/utssdk/app-harmony/index.uts
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
import type { RestartApp, ExitApp } from "../interface.uts";
|
||||
import type { common, Want } from '@kit.Abilitykit';
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
import { process } from '@kit.ArkTS';
|
||||
|
||||
// export const reStartApp : RestartApp = () => {
|
||||
// const context = UTSHarmony.getUIAbilityContext() as common.UIAbilityContext
|
||||
// let applicationContext = context.getApplicationContext();
|
||||
// let request : Want = {
|
||||
// bundleName: bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).name // 加载当前包名
|
||||
// }
|
||||
// try {
|
||||
// applicationContext.restartApp(request);
|
||||
// } catch (error) {
|
||||
// console.error(`restartApp fail, error: ${JSON.stringify(error)}`);
|
||||
// }
|
||||
// }
|
||||
//退出应用
|
||||
|
||||
export const exitApp : ExitApp = () => {
|
||||
let pro = new process.ProcessManager();
|
||||
pro.exit(0);
|
||||
}
|
||||
2
uni_modules/jnpf-exitApp/utssdk/interface.uts
Normal file
2
uni_modules/jnpf-exitApp/utssdk/interface.uts
Normal file
@@ -0,0 +1,2 @@
|
||||
// export type RestartApp = () => void
|
||||
export type ExitApp = () => void
|
||||
39
uni_modules/jnpf-exitApp/utssdk/unierror.uts
Normal file
39
uni_modules/jnpf-exitApp/utssdk/unierror.uts
Normal file
@@ -0,0 +1,39 @@
|
||||
/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */
|
||||
import { MyApiErrorCode, MyApiFail } from "./interface.uts"
|
||||
/**
|
||||
* 错误主题
|
||||
* 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。
|
||||
* [可选实现]
|
||||
*/
|
||||
export const UniErrorSubject = 'uts-api';
|
||||
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
* @UniError
|
||||
* [可选实现]
|
||||
*/
|
||||
export const MyAPIErrors : Map<MyApiErrorCode, string> = new Map([
|
||||
/**
|
||||
* 错误码及对应的错误信息
|
||||
*/
|
||||
[9010001, 'custom error mseeage1'],
|
||||
[9010002, 'custom error mseeage2'],
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* 错误对象实现
|
||||
*/
|
||||
export class MyApiFailImpl extends UniError implements MyApiFail {
|
||||
|
||||
/**
|
||||
* 错误对象构造函数
|
||||
*/
|
||||
constructor(errCode : MyApiErrorCode) {
|
||||
super();
|
||||
this.errSubject = UniErrorSubject;
|
||||
this.errCode = errCode;
|
||||
this.errMsg = MyAPIErrors.get(errCode) ?? "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user