提交 192130da 编写于 作者: D DCloud_LXH

feat: 升级中心使用 uts-progressNotification 插件

上级 2055b54e
export type uni = {
/**
* createNotificationProgress()
* @description
* 创建通知栏下载进度消息
* @param {CreateNotificationProgressOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.9+",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.createNotificationProgress({
title: "正在下载升级包",
content: "进度 50%",
progress: 50,
onClick:()=>{
console.log("正在下载");
}
}
```
*/
createNotificationProgress : (options : CreateNotificationProgressOptions) => void,
/**
* finishNotificationProgress()
* @description
* 通知栏显示下载完成,并且传入点击通知栏消息的回调。
* @param {FinishNotificationProgressOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.9+",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.finishNotificationProgress({
title: "安装升级包",
content: "下载完成。",
onClick: () => {
uni.installApk({
filePath: e.tempFilePath,
complete(res) {
console.log(res);
}
})
}
}
```
*/
finishNotificationProgress : (options: FinishNotificationProgressOptions) => void,
/**
* cancelNotificationProgress()
* @description
* 取消通知消息显示
* @param {void}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.9+",
* "unixVer": "3.9+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.cancelNotificationProgress()
```
*/
cancelNotificationProgress : () => void
}
export type CreateNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 进度
*/
progress : number,
/**
* 点击通知消息回调
* @defaultValue null
*/
onClick? : (() => void) | null
}
export type FinishNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 点击通知消息回调
*/
onClick : () => void
}
export type CreateNotificationProgress = (options : CreateNotificationProgressOptions) => void;
export type CancelNotificationProgress = () => void;
export type FinishNotificationProgress = (options: FinishNotificationProgressOptions) => void
\ No newline at end of file
## 0.7.5(2023-12-12)
- 新增 通知栏进度条使用 uts-progressNotification 插件
- 新增 依赖 uni-installApk、uts-progressNotification。使用前要安装插件三方依赖
## 0.7.4(2023-11-29)
- 修复 uni-app-x 项目中由上版引发的无法升级的Bug
## 0.7.3(2023-11-27)
......
......@@ -62,6 +62,8 @@
</template>
<script>
import { createNotificationProgress, cancelNotificationProgress, finishNotificationProgress } from '@/uni_modules/uts-progressNotification'
import { type CreateNotificationProgressOptions, type FinishNotificationProgressOptions } from '@/uni_modules/uts-progressNotification/utssdk/interface.uts'
import { UniUpgradeCenterResult, StoreListItem } from '../../utils/call-check-version'
import { openSchema } from '../../utils/utils.uts'
......@@ -168,7 +170,7 @@
},
beforeUnmount() {
if (this.needNotificationProgress) {
uni.cancelNotificationProgress()
cancelNotificationProgress()
}
},
methods: {
......@@ -240,7 +242,7 @@
this.installed = false
this.showTabbar = false
if (this.needNotificationProgress) uni.cancelNotificationProgress()
if (this.needNotificationProgress) cancelNotificationProgress()
if (!notificationAbortDownload) this.$emit('close')
......@@ -303,7 +305,7 @@
this.packageFileSize = parseFloat((res.totalBytesExpectedToWrite / Math.pow(1024, 2)).toFixed(2));
if (this.needNotificationProgress) {
uni.createNotificationProgress({
createNotificationProgress({
title: "升级中心正在下载安装包……",
content: `${this.downLoadPercent}%`,
progress: this.downLoadPercent,
......@@ -313,7 +315,7 @@
notificationAbortDownload = true
}
}
})
} as CreateNotificationProgressOptions)
}
});
}
......@@ -329,11 +331,11 @@
downloadTask = null;
if (this.needNotificationProgress) {
uni.finishNotificationProgress({
finishNotificationProgress({
title: "安装升级包",
content: "下载完成",
onClick(){}
})
} as FinishNotificationProgressOptions)
this.installPackage();
return
......
{
"id": "uni-upgrade-center-app",
"displayName": "升级中心 uni-upgrade-center - App",
"version": "0.7.4",
"version": "0.7.5",
"description": "uni升级中心 - 客户端检查更新",
"keywords": [
"uniCloud",
......@@ -35,7 +35,8 @@
},
"uni_modules": {
"dependencies": [
"uni-progress-notification"
"uni-installApk",
"uts-progressNotification"
],
"encrypt": [],
"platforms": {
......
......@@ -64,6 +64,7 @@
</template>
<script>
import { createNotificationProgress, cancelNotificationProgress, finishNotificationProgress } from '@/uni_modules/uts-progressNotification'
const localFilePathKey = 'UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH'
const platform_iOS = 'iOS';
const platform_Android = 'Android';
......@@ -228,6 +229,7 @@
success: res => {
if (res.confirm) {
downloadTask && downloadTask.abort()
cancelNotificationProgress()
uni.navigateBack()
}
}
......@@ -322,7 +324,7 @@
this.packageFileSize = (res.totalBytesExpectedToWrite / Math.pow(1024, 2)).toFixed(2);
if (this.needNotificationProgress && !this.downloadSuccess) {
uni.createNotificationProgress({
createNotificationProgress({
title: "升级中心正在下载安装包……",
content: `${this.downLoadPercent}%`,
progress: this.downLoadPercent,
......@@ -347,7 +349,7 @@
downloadTask = null;
if (this.needNotificationProgress) {
uni.finishNotificationProgress({
finishNotificationProgress({
title: "安装升级包",
content: "下载完成"
})
......
......@@ -34,7 +34,7 @@ export default function () : Promise<UniUpgradeCenterResult> {
return new Promise<UniUpgradeCenterResult>((resolve, reject) => {
const systemInfo = uni.getSystemInfoSync()
const appId = systemInfo.appId
const appVersion = '1.0.15' //systemInfo.appVersion
const appVersion = systemInfo.appVersion //systemInfo.appVersion
// #ifndef UNI-APP-X
if (typeof appId === 'string' && typeof appVersion === 'string' && appId.length > 0 && appVersion.length > 0) {
plus.runtime.getProperty(appId, function (widgetInfo) {
......
## 1.0.7(2023-12-11)
去除无用代码
## 1.0.6(2023-12-11)
修改文档
## 1.0.5(2023-12-11)
1.修改插件名称
2.修改插件引入方式为import导入
## 1.0.4(2023-11-30)
1. createNotificationProgress增加`onClick`回调
2.修复在小米部分系统上,通知消息会归类于不重要通知的bug
......
{
"id": "uni-progress-notification",
"displayName": "uni-progress-notification",
"version": "1.0.4",
"description": "uni-progress-notification",
"id": "uts-progressNotification",
"displayName": "uts-progressNotification",
"version": "1.0.7",
"description": "uts-progressNotification",
"keywords": [
"uni-progress-notification"
"uts-progressNotification"
],
"repository": "",
"engines": {
......@@ -32,34 +32,6 @@
},
"uni_modules": {
"dependencies": [],
"uni-ext-api": {
"uni": {
"createNotificationProgress": {
"name": "createNotificationProgress",
"app": {
"js": true,
"kotlin": true,
"swift": false
}
},
"finishNotificationProgress": {
"name": "finishNotificationProgress",
"app": {
"js": true,
"kotlin": true,
"swift": false
}
},
"cancelNotificationProgress": {
"name": "cancelNotificationProgress",
"app": {
"js": true,
"kotlin": true,
"swift": false
}
}
}
},
"encrypt": [],
"platforms": {
"cloud": {
......
# uni-download-notification
# uts-progressNotification
## 使用说明
......@@ -6,7 +6,11 @@ Android平台创建显示进度的通知栏消息
**注意: 需要自定义基座,否则点击通知栏消息不会拉起应用**
### uni.createNotificationProgress(options : CreateNotificationProgressOptions) : void,
### 导入
需要import导入插件
### createNotificationProgress(options : CreateNotificationProgressOptions) : void,
创建显示进度的通知栏消息
......@@ -35,7 +39,7 @@ export type CreateNotificationProgressOptions = {
}
```
### uni.finishNotificationProgress(options: FinishNotificationProgressOptions) : void
### finishNotificationProgress(options: FinishNotificationProgressOptions) : void
完成时调用的API,比如下载完成后需要显示下载完成并隐藏进度时调用。
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="uts.sdk.modules.uniPush">
package="uts.sdk.modules.utsProgressNotification">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application>
<activity android:name="uts.sdk.modules.uniProgressNotification.TransparentActivity"
<activity android:name="uts.sdk.modules.utsProgressNotification.TransparentActivity"
android:theme="@style/DCNotificationProgressTranslucentTheme" android:hardwareAccelerated="true"
android:screenOrientation="user" android:exported="true">
</activity>
......
......@@ -111,7 +111,7 @@ function reset() {
function createPendingIntent(context : Context, action : string) : PendingIntent {
const i = new Intent(action);
i.setComponent(new ComponentName(context.getPackageName(), "uts.sdk.modules.uniProgressNotification.TransparentActivity"));
i.setComponent(new ComponentName(context.getPackageName(), "uts.sdk.modules.utsProgressNotification.TransparentActivity"));
let flags = PendingIntent.FLAG_ONE_SHOT;
if (Build.VERSION.SDK_INT >= 23) {
flags = PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE;
......
export type CreateNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 进度
*/
progress : number,
/**
* 点击通知消息回调
* @defaultValue null
*/
onClick? : (() => void) | null
}
export type FinishNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 点击通知消息回调
*/
onClick : () => void
}
export type CreateNotificationProgress = (options : CreateNotificationProgressOptions) => void;
export type CancelNotificationProgress = () => void;
export type FinishNotificationProgress = (options: FinishNotificationProgressOptions) => void
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册