Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
339b28a5
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
339b28a5
编写于
12月 08, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://gitcode.net/dcloud/hello-uni-app-x
into dev
上级
c4d8801e
95597083
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
838 addition
and
55 deletion
+838
-55
uni_modules/uni-progress-notification/changelog.md
uni_modules/uni-progress-notification/changelog.md
+11
-0
uni_modules/uni-progress-notification/package.json
uni_modules/uni-progress-notification/package.json
+111
-0
uni_modules/uni-progress-notification/readme.md
uni_modules/uni-progress-notification/readme.md
+67
-0
uni_modules/uni-progress-notification/utssdk/app-android/AndroidManifest.xml
...gress-notification/utssdk/app-android/AndroidManifest.xml
+11
-0
uni_modules/uni-progress-notification/utssdk/app-android/TransparentActivity.uts
...s-notification/utssdk/app-android/TransparentActivity.uts
+61
-0
uni_modules/uni-progress-notification/utssdk/app-android/config.json
.../uni-progress-notification/utssdk/app-android/config.json
+3
-0
uni_modules/uni-progress-notification/utssdk/app-android/constant.uts
...uni-progress-notification/utssdk/app-android/constant.uts
+2
-0
uni_modules/uni-progress-notification/utssdk/app-android/index.uts
...es/uni-progress-notification/utssdk/app-android/index.uts
+159
-0
uni_modules/uni-progress-notification/utssdk/app-android/res/values/notification_progress_styles.xml
...k/app-android/res/values/notification_progress_styles.xml
+11
-0
uni_modules/uni-progress-notification/utssdk/app-ios/config.json
...ules/uni-progress-notification/utssdk/app-ios/config.json
+3
-0
uni_modules/uni-progress-notification/utssdk/app-ios/index.uts
...odules/uni-progress-notification/utssdk/app-ios/index.uts
+85
-0
uni_modules/uni-progress-notification/utssdk/interface.uts
uni_modules/uni-progress-notification/utssdk/interface.uts
+145
-0
uni_modules/uni-progress-notification/utssdk/unierror.uts
uni_modules/uni-progress-notification/utssdk/unierror.uts
+0
-0
uni_modules/uni-upgrade-center-app/components/uni-upgrade-center-app/uni-upgrade-center-app.uvue
...onents/uni-upgrade-center-app/uni-upgrade-center-app.uvue
+73
-24
uni_modules/uni-upgrade-center-app/package.json
uni_modules/uni-upgrade-center-app/package.json
+3
-1
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
+74
-29
uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
...odules/uni-upgrade-center-app/utils/call-check-version.ts
+1
-1
uni_modules/uni-upgrade-center-app/utils/check-update.ts
uni_modules/uni-upgrade-center-app/utils/check-update.ts
+18
-0
未找到文件。
uni_modules/uni-progress-notification/changelog.md
0 → 100644
浏览文件 @
339b28a5
## 1.0.4(2023-11-30)
1.
createNotificationProgress增加
`onClick`
回调
2.
修复在小米部分系统上,通知消息会归类于不重要通知的bug
## 1.0.3(2023-11-28)
更新截图
## 1.0.2(2023-11-28)
修改资源的包名
## 1.0.1(2023-11-28)
更新文档
## 1.0.0(2023-11-28)
Android通知栏显示进度插件
uni_modules/uni-progress-notification/package.json
0 → 100644
浏览文件 @
339b28a5
{
"id"
:
"uni-progress-notification"
,
"displayName"
:
"uni-progress-notification"
,
"version"
:
"1.0.4"
,
"description"
:
"uni-progress-notification"
,
"keywords"
:
[
"uni-progress-notification"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.91"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
"无"
,
"data"
:
"插件不采集任何数据"
,
"permissions"
:
"TargetSDKVersion33以上时需配置
\n
`android.permission.POST_NOTIFICATIONS`"
},
"npmurl"
:
""
},
"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"
:
{
"tcb"
:
"y"
,
"aliyun"
:
"y"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"y"
,
"vue3"
:
"y"
},
"App"
:
{
"app-android"
:
{
"minVersion"
:
"19"
},
"app-ios"
:
"n"
},
"H5-mobile"
:
{
"Safari"
:
"n"
,
"Android Browser"
:
"n"
,
"微信浏览器(Android)"
:
"n"
,
"QQ浏览器(Android)"
:
"n"
},
"H5-pc"
:
{
"Chrome"
:
"n"
,
"IE"
:
"n"
,
"Edge"
:
"n"
,
"Firefox"
:
"n"
,
"Safari"
:
"n"
},
"小程序"
:
{
"微信"
:
"n"
,
"阿里"
:
"n"
,
"百度"
:
"n"
,
"字节跳动"
:
"n"
,
"QQ"
:
"n"
,
"钉钉"
:
"n"
,
"快手"
:
"n"
,
"飞书"
:
"n"
,
"京东"
:
"n"
},
"快应用"
:
{
"华为"
:
"n"
,
"联盟"
:
"n"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-progress-notification/readme.md
0 → 100644
浏览文件 @
339b28a5
# uni-download-notification
## 使用说明
Android平台创建显示进度的通知栏消息
**注意: 需要自定义基座,否则点击通知栏消息不会拉起应用**
### uni.createNotificationProgress(options : CreateNotificationProgressOptions) : void,
创建显示进度的通知栏消息
参数说明
```
export type CreateNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 进度
*/
progress : number,
/**
* 点击通知消息回调
* @defaultValue null
*/
onClick? : (() => void) | null
}
```
### uni.finishNotificationProgress(options: FinishNotificationProgressOptions) : void
完成时调用的API,比如下载完成后需要显示下载完成并隐藏进度时调用。
参数说明
```
export type FinishNotificationProgressOptions = {
/**
* 通知标题
* @defaultValue 应用名称
*/
title ?: string | null
/**
* 通知内容
*/
content : string,
/**
* 点击通知消息回调
*/
onClick : () => void
}
```
### cancelNotificationProgress() : void
取消通知消息显示
uni_modules/uni-progress-notification/utssdk/app-android/AndroidManifest.xml
0 → 100644
浏览文件 @
339b28a5
<?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"
>
<uses-permission
android:name=
"android.permission.POST_NOTIFICATIONS"
/>
<application>
<activity
android:name=
"uts.sdk.modules.uniProgressNotification.TransparentActivity"
android:theme=
"@style/DCNotificationProgressTranslucentTheme"
android:hardwareAccelerated=
"true"
android:screenOrientation=
"user"
android:exported=
"true"
>
</activity>
</application>
</manifest>
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-android/TransparentActivity.uts
0 → 100644
浏览文件 @
339b28a5
import Activity from "android.app.Activity";
import Bundle from 'android.os.Bundle';
import Build from 'android.os.Build';
import View from 'android.view.View';
import Color from 'android.graphics.Color';
import WindowManager from 'android.view.WindowManager';
import { globalNotificationProgressFinishCallBack, globalNotificationProgressCallBack } from './index.uts';
import { ACTION_DOWNLOAD_FINISH, ACTION_DOWNLOAD_PROGRESS } from "./constant.uts"
export class TransparentActivity extends Activity {
constructor() {
super()
}
override onCreate(savedInstanceState : Bundle | null) {
super.onCreate(savedInstanceState)
this.fullScreen(this)
const action = this.getIntent().getAction()
if (action == ACTION_DOWNLOAD_FINISH) {
setTimeout(() => {
globalNotificationProgressFinishCallBack()
globalNotificationProgressFinishCallBack = () => { }
}, 100)
this.overridePendingTransition(0, 0)
}
if (action == ACTION_DOWNLOAD_PROGRESS) {
setTimeout(() => {
globalNotificationProgressCallBack?.()
globalNotificationProgressCallBack = () => { }
}, 100)
this.overridePendingTransition(0, 0)
}
setTimeout(() => {
this.finish()
}, 20)
}
@Suppress("DEPRECATION")
private fullScreen(activity : Activity) {
if (Build.VERSION.SDK_INT >= 19) {
if (Build.VERSION.SDK_INT >= 21) {
const window = activity.getWindow();
const decorView = window.getDecorView();
const option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
} else {
const window = activity.getWindow();
const attributes = window.getAttributes();
const flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
attributes.flags |= flagTranslucentStatus;
window.setAttributes(attributes);
}
}
}
}
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-android/config.json
0 → 100644
浏览文件 @
339b28a5
{
"minSdkVersion"
:
"19"
}
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-android/constant.uts
0 → 100644
浏览文件 @
339b28a5
export const ACTION_DOWNLOAD_FINISH = "ACTION_DOWNLOAD_FINISH"
export const ACTION_DOWNLOAD_PROGRESS = "ACTION_DOWNLOAD_PROGRESS"
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
339b28a5
import Build from 'android.os.Build';
import Context from 'android.content.Context';
import NotificationManager from 'android.app.NotificationManager';
import NotificationChannel from 'android.app.NotificationChannel';
import Notification from 'android.app.Notification';
import Intent from 'android.content.Intent';
import ComponentName from 'android.content.ComponentName';
import PendingIntent from 'android.app.PendingIntent';
import { CreateNotificationProgressOptions, FinishNotificationProgressOptions } from '../interface.uts';
import { ACTION_DOWNLOAD_FINISH, ACTION_DOWNLOAD_PROGRESS } from "./constant.uts"
export { TransparentActivity } from './TransparentActivity.uts';
const DOWNLOAD_PROGRESS_NOTIFICATION_ID : Int = 7890
const DC_DOWNLOAD_CHANNEL_ID = "下载文件"
const DC_DOWNLOAD_CHANNEL_NAME = "用于显示现在进度的渠道"
let notificationBuilder : Notification.Builder | null = null
let timeId = -1
let histroyProgress = 0
let isProgress = false
export let globalNotificationProgressCallBack : (() => void) | null = () => { }
export let globalNotificationProgressFinishCallBack = () => { }
export function createNotificationProgress(options : CreateNotificationProgressOptions) : void {
const { content, progress, onClick } = options
if (progress == 100) {
clearTimeout(timeId)
const context = UTSAndroid.getAppContext() as Context
realCreateNotificationProgress(options.title ?? getAppName(context), content, progress, onClick)
reset()
return
}
histroyProgress = progress
if (timeId != -1) {
return
}
const context = UTSAndroid.getAppContext() as Context
if (!isProgress) {
realCreateNotificationProgress(options.title ?? getAppName(context), content, histroyProgress, onClick)
isProgress = true
} else {
timeId = setTimeout(() => {
realCreateNotificationProgress(options.title ?? getAppName(context), content, histroyProgress, onClick)
timeId = -1
}, 1000)
}
}
export function cancelNotificationProgress() : void {
const context = UTSAndroid.getAppContext() as Context
const notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(DOWNLOAD_PROGRESS_NOTIFICATION_ID)
reset()
}
function realCreateNotificationProgress(title : string, content : string, progress : number, cb : (() => void) | null) : void {
globalNotificationProgressCallBack = cb
const context = UTSAndroid.getAppContext() as Context
const notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
createDownloadChannel(notificationManager)
const builder = createNotificationBuilder(context)
builder.setProgress(100, progress.toInt(), false)
builder.setContentTitle(title)
builder.setContentText(content)
builder.setContentIntent(createPendingIntent(context, ACTION_DOWNLOAD_PROGRESS));
notificationManager.notify(DOWNLOAD_PROGRESS_NOTIFICATION_ID, builder.build())
}
export function finishNotificationProgress(options : FinishNotificationProgressOptions) {
globalNotificationProgressFinishCallBack = options.onClick
const context = UTSAndroid.getAppContext() as Context
const notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
createDownloadChannel(notificationManager)
const builder = createNotificationBuilder(context)
builder.setProgress(0, 0, false)
builder.setContentTitle(options.title ?? getAppName(context))
builder.setContentText(options.content)
//小米rom setOngoing未false的时候,会被通知管理器归为不重要通知
// builder.setOngoing(false)
builder.setAutoCancel(true);
builder.setContentIntent(createPendingIntent(context, ACTION_DOWNLOAD_FINISH));
notificationManager.notify(DOWNLOAD_PROGRESS_NOTIFICATION_ID, builder.build())
reset()
}
function reset() {
isProgress = false
notificationBuilder = null
histroyProgress = 0
if (timeId != -1) {
clearTimeout(timeId)
timeId = -1
}
}
function createPendingIntent(context : Context, action : string) : PendingIntent {
const i = new Intent(action);
i.setComponent(new ComponentName(context.getPackageName(), "uts.sdk.modules.uniProgressNotification.TransparentActivity"));
let flags = PendingIntent.FLAG_ONE_SHOT;
if (Build.VERSION.SDK_INT >= 23) {
flags = PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE;
}
return PendingIntent.getActivity(context, DOWNLOAD_PROGRESS_NOTIFICATION_ID, i, flags);
}
function createDownloadChannel(notificationManager : NotificationManager) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
const channel = new NotificationChannel(
DC_DOWNLOAD_CHANNEL_ID,
DC_DOWNLOAD_CHANNEL_NAME,
NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel(channel)
}
}
@Suppress("DEPRECATION")
function createNotificationBuilder(context : Context) : Notification.Builder {
if (notificationBuilder == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationBuilder = new Notification.Builder(context, DC_DOWNLOAD_CHANNEL_ID)
} else {
notificationBuilder = new Notification.Builder(context)
}
notificationBuilder!.setSmallIcon(context.getApplicationInfo().icon)
notificationBuilder!.setOngoing(true)
notificationBuilder!.setSound(null)
}
return notificationBuilder!
}
@Suppress("DEPRECATION")
function getAppName(context : Context) : string {
let appName = ""
try {
const packageManager = context.getPackageManager()
const applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0)
appName = packageManager.getApplicationLabel(applicationInfo) as string
} catch (e : Exception) {
e.printStackTrace()
}
return appName
}
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-android/res/values/notification_progress_styles.xml
0 → 100644
浏览文件 @
339b28a5
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name=
"DCNotificationProgressTranslucentTheme"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:colorBackgroundCacheHint"
>
@null
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<item
name=
"android:windowAnimationStyle"
>
@android:style/Animation
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowContentOverlay"
>
@null
</item>
</style>
</resources>
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-ios/config.json
0 → 100644
浏览文件 @
339b28a5
{
"deploymentTarget"
:
"9"
}
\ No newline at end of file
uni_modules/uni-progress-notification/utssdk/app-ios/index.uts
0 → 100644
浏览文件 @
339b28a5
/**
* 引用 iOS 系统库,示例如下:
* import { UIDevice } from "UIKit";
* [可选实现,按需引入]
*/
/* 引入 interface.uts 文件中定义的变量 */
import { MyApiOptions, MyApiResult, MyApi, MyApiSync } from '../interface.uts';
/* 引入 unierror.uts 文件中定义的变量 */
import { MyApiFailImpl } from '../unierror';
/**
* 引入三方库
* [可选实现,按需引入]
*
* 在 iOS 平台引入三方库有以下两种方式:
* 1、通过引入三方库framework 或者.a 等方式,需要将 .framework 放到 ./Frameworks 目录下,将.a 放到 ./Libs 目录下。更多信息[详见](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#ios-平台原生配置)
* 2、通过 cocoaPods 方式引入,将要引入的 pod 信息配置到 config.json 文件下的 dependencies-pods 字段下。详细配置方式[详见](https://uniapp.dcloud.net.cn/plugin/uts-ios-cocoapods.html)
*
* 在通过上述任意方式依赖三方库后,使用时需要在文件中 import:
* 示例:import { LottieLoopMode } from 'Lottie'
*/
/**
* UTSiOS 为平台内置对象,不需要 import 可直接调用其API,[详见](https://uniapp.dcloud.net.cn/uts/utsios.html)
*/
/**
* 异步方法
*
* uni-app项目中(vue/nvue)调用示例:
* 1、引入方法声明 import { myApi } from "@/uni_modules/uts-api"
* 2、方法调用
* myApi({
* paramA: false,
* complete: (res) => {
* console.log(res)
* }
* });
*
*/
export const myApi : MyApi = function (options : MyApiOptions) {
if (options.paramA == true) {
// 返回数据
const res : MyApiResult = {
fieldA: 85,
fieldB: true,
fieldC: 'some message'
};
options.success?.(res);
options.complete?.(res);
} else {
// 返回错误
let failResult = new MyApiFailImpl(9010001);
options.fail?.(failResult)
options.complete?.(failResult)
}
}
/**
* 同步方法
*
* uni-app项目中(vue/nvue)调用示例:
* 1、引入方法声明 import { myApiSync } from "@/uni_modules/uts-api"
* 2、方法调用
* myApiSync(true);
*
*/
export const myApiSync : MyApiSync = function (paramA : boolean) : MyApiResult {
// 返回数据,根据插件功能获取实际的返回值
const res : MyApiResult = {
fieldA: 85,
fieldB: paramA,
fieldC: 'some message'
};
return res;
}
/**
* 更多插件开发的信息详见:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
*/
uni_modules/uni-progress-notification/utssdk/interface.uts
0 → 100644
浏览文件 @
339b28a5
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
uni_modules/uni-progress-notification/utssdk/unierror.uts
0 → 100644
浏览文件 @
339b28a5
uni_modules/uni-upgrade-center-app/components/uni-upgrade-center-app/uni-upgrade-center-app.uvue
浏览文件 @
339b28a5
...
...
@@ -46,8 +46,8 @@
{{installing ? '正在安装……' : '下载完成,立即安装'}}
</button>
<button v-else-if="installed" class="content-button"
:disabled="tru
e">
安装
完成后,请重启应用
<button v-else-if="installed" class="content-button"
@click="installPackag
e">
安装
未完成,点击安装
</button>
</template>
</view>
...
...
@@ -67,9 +67,11 @@
const localFilePathKey = 'UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH'
const platform_iOS = 'iOS';
const platform_Android = 'Android';
const requiredKey = ['version', 'url', 'type']
let downloadTask : DownloadTask | null = null;
let openSchemePromise: Promise<boolean> | null = null;
let notificationAbortDownload: boolean = false
/**
* 对比版本号,如需要,请自行修改判断规则
...
...
@@ -115,6 +117,7 @@
}
export default {
emits: ['close'],
data() {
return {
shown: false,
...
...
@@ -141,21 +144,31 @@
contents: '',
version: '',
is_mandatory: false,
url: "",
platform: [] as string[],
store_list: null as StoreListItem[] | null,
// 可自定义属性
subTitle: '发现新版本',
downLoadBtnTextiOS: '立即跳转更新',
downLoadBtnText: '立即下载更新',
downLoadingText: '安装包下载中,请稍后',
url: "",
platform: [] as string[],
store_list: null as StoreListItem[] | null
downLoadingText: '安装包下载中,请稍后'
}
},
computed: {
isiOS() : boolean {
return this.platform.includes(platform_iOS);
},
isAndroid() : boolean {
return this.platform.includes(platform_Android);
},
needNotificationProgress(): boolean {
return this.isAndroid && !this.is_mandatory
}
},
beforeUnmount() {
if (this.needNotificationProgress) {
uni.cancelNotificationProgress()
}
},
methods: {
...
...
@@ -181,15 +194,7 @@
this.store_list = localPackageInfo.store_list
this.shown = shown
},
closeUpdate() {
if (this.downloading) {
if (this.is_mandatory) {
return uni.showToast({
title: '下载中,请稍后……',
icon: 'none',
duration: 500
})
}
askAbortDownload() {
uni.showModal({
title: '是否取消下载?',
cancelText: '否',
...
...
@@ -201,7 +206,20 @@
}
}
});
},
closeUpdate() {
if (this.downloading) {
if (this.is_mandatory) {
return uni.showToast({
title: '下载中,请稍后……',
icon: 'none',
duration: 500
})
}
if (!this.needNotificationProgress) {
this.askAbortDownload()
return;
}
}
this.closePopup()
},
...
...
@@ -222,7 +240,11 @@
this.installed = false
this.showTabbar = false
this.$emit('close')
if (this.needNotificationProgress) uni.cancelNotificationProgress()
if (!notificationAbortDownload) this.$emit('close')
notificationAbortDownload = false
},
updateApp() {
const checkStoreScheme = this.checkStoreScheme()
...
...
@@ -261,7 +283,6 @@
downloadTask = uni.downloadFile({
url: this.url,
success: res => {
console.log('downloadFile res: ', res);
if (res.statusCode == 200) {
this.tempFilePath = res.tempFilePath
this.downLoadComplete()
...
...
@@ -273,10 +294,27 @@
});
if (downloadTask !== null) {
this.downloading = true;
if (this.needNotificationProgress) {
this.closePopup()
}
downloadTask!.onProgressUpdate(res => {
this.downLoadPercent = parseFloat(res.progress.toFixed(0));
this.downloadedSize = parseFloat((res.totalBytesWritten / Math.pow(1024, 2)).toFixed(2));
this.packageFileSize = parseFloat((res.totalBytesExpectedToWrite / Math.pow(1024, 2)).toFixed(2));
if (this.needNotificationProgress) {
uni.createNotificationProgress({
title: "升级中心正在下载安装包……",
content: `${this.downLoadPercent}%`,
progress: this.downLoadPercent,
onClick: () => {
if (!this.downloadSuccess) {
this.askAbortDownload()
notificationAbortDownload = true
}
}
})
}
});
}
},
...
...
@@ -290,6 +328,17 @@
downloadTask = null;
if (this.needNotificationProgress) {
uni.finishNotificationProgress({
title: "安装升级包",
content: "下载完成",
onClick(){}
})
this.installPackage();
return
}
// 强制更新,直接安装
if (this.is_mandatory) {
this.installPackage();
...
...
@@ -306,7 +355,7 @@
this.installed = true;
},
fail: err => {
console.
log('installApk fail'
);
console.
error('installApk fail', err
);
// 安装失败需要重新下载安装包
this.installing = false;
this.installed = false;
...
...
@@ -319,7 +368,7 @@
}
});
//
非wgt包,
安装跳出覆盖安装,此处直接返回上一页
// 安装跳出覆盖安装,此处直接返回上一页
if (!this.is_mandatory) {
uni.navigateBack()
}
...
...
uni_modules/uni-upgrade-center-app/package.json
浏览文件 @
339b28a5
...
...
@@ -34,7 +34,9 @@
"type"
:
"unicloud-template-page"
},
"uni_modules"
:
{
"dependencies"
:
[],
"dependencies"
:
[
"uni-progress-notification"
],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
...
...
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
浏览文件 @
339b28a5
...
...
@@ -10,7 +10,7 @@
<view
class=
"content-body"
>
<view
class=
"title"
>
<text>
{{
subTitle
}}
</text>
<
!--
<text
style=
"padding-left:20rpx;font-size: 0.5em;color: #666;"
>
v.
{{
version
}}
</text>
--
>
<
text
class=
"content-body-version"
>
{{
version
}}
</text
>
</view>
<view
class=
"body"
>
<scroll-view
class=
"box-des-scroll"
scroll-y=
"true"
>
...
...
@@ -44,8 +44,12 @@
plain
:loading=
"installing"
:disabled=
"installing"
@
click=
"installPackage"
>
{{installing ? '正在安装……' : '下载完成,立即安装'}}
</button>
<button
v-else-if=
"installed && !isWGT"
class=
"content-button"
style=
"border: none;color: #fff;"
plain
:loading=
"installing"
:disabled=
"installing"
@
click=
"installPackage"
>
安装未完成,点击安装
</button>
<button
v-if=
"installed && isWGT"
class=
"content-button"
style=
"border: none;color: #fff;"
plain
<button
v-
else-
if=
"installed && isWGT"
class=
"content-button"
style=
"border: none;color: #fff;"
plain
@
click=
"restart"
>
安装完毕,点击重启
</button>
...
...
@@ -62,6 +66,7 @@
<
script
>
const
localFilePathKey
=
'
UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH
'
const
platform_iOS
=
'
iOS
'
;
const
platform_Android
=
'
Android
'
;
let
downloadTask
=
null
;
let
openSchemePromise
...
...
@@ -170,11 +175,8 @@
},
onBackPress
()
{
// 强制更新不允许返回
if
(
this
.
is_mandatory
)
{
return
true
}
downloadTask
&&
downloadTask
.
abort
()
if
(
this
.
is_mandatory
)
return
true
if
(
!
this
.
needNotificationProgress
)
downloadTask
&&
downloadTask
.
abort
()
},
onHide
()
{
openSchemePromise
=
null
...
...
@@ -186,8 +188,14 @@
isiOS
()
{
return
!
this
.
isWGT
?
this
.
platform
.
includes
(
platform_iOS
)
:
false
;
},
isAndroid
()
{
return
this
.
platform
.
includes
(
platform_Android
)
},
isAppStore
()
{
return
this
.
isiOS
||
(
!
this
.
isiOS
&&
!
this
.
isWGT
&&
this
.
url
.
indexOf
(
'
.apk
'
)
===
-
1
)
},
needNotificationProgress
()
{
return
this
.
isAndroid
&&
!
this
.
is_mandatory
}
},
methods
:
{
...
...
@@ -212,15 +220,7 @@
}
}
},
async
closeUpdate
()
{
if
(
this
.
downloading
)
{
if
(
this
.
is_mandatory
)
{
return
uni
.
showToast
({
title
:
'
下载中,请稍后……
'
,
icon
:
'
none
'
,
duration
:
500
})
}
askAbortDownload
()
{
uni
.
showModal
({
title
:
'
是否取消下载?
'
,
cancelText
:
'
否
'
,
...
...
@@ -232,14 +232,25 @@
}
}
});
},
async
closeUpdate
()
{
if
(
this
.
downloading
)
{
if
(
this
.
is_mandatory
)
{
return
uni
.
showToast
({
title
:
'
下载中,请稍后……
'
,
icon
:
'
none
'
,
duration
:
500
})
}
if
(
!
this
.
needNotificationProgress
)
{
this
.
askAbortDownload
()
return
;
}
}
if
(
this
.
downloadSuccess
&&
this
.
tempFilePath
)
{
if
(
!
this
.
needNotificationProgress
&&
this
.
downloadSuccess
&&
this
.
tempFilePath
)
{
// 包已经下载完毕,稍后安装,将包保存在本地
await
this
.
saveFile
(
this
.
tempFilePath
,
this
.
version
)
uni
.
navigateBack
()
return
;
}
uni
.
navigateBack
()
...
...
@@ -283,7 +294,6 @@
url
:
this
.
url
,
success
:
res
=>
{
if
(
res
.
statusCode
==
200
)
{
this
.
downloadSuccess
=
true
;
// fix: wgt 文件下载完成后后缀不是 wgt
if
(
this
.
isWGT
&&
res
.
tempFilePath
.
split
(
'
.
'
).
slice
(
-
1
)[
0
]
!==
'
wgt
'
)
{
const
failCallback
=
(
e
)
=>
{
...
...
@@ -310,9 +320,24 @@
this
.
downLoadPercent
=
res
.
progress
;
this
.
downloadedSize
=
(
res
.
totalBytesWritten
/
Math
.
pow
(
1024
,
2
)).
toFixed
(
2
);
this
.
packageFileSize
=
(
res
.
totalBytesExpectedToWrite
/
Math
.
pow
(
1024
,
2
)).
toFixed
(
2
);
if
(
this
.
needNotificationProgress
&&
!
this
.
downloadSuccess
)
{
uni
.
createNotificationProgress
({
title
:
"
升级中心正在下载安装包……
"
,
content
:
`
${
this
.
downLoadPercent
}
%`
,
progress
:
this
.
downLoadPercent
,
onClick
:
()
=>
{
this
.
askAbortDownload
()
}
})
}
});
if
(
this
.
needNotificationProgress
)
{
uni
.
navigateBack
()
}
},
downLoadComplete
()
{
this
.
downloadSuccess
=
true
;
this
.
downloading
=
false
;
this
.
downLoadPercent
=
0
...
...
@@ -321,6 +346,16 @@
downloadTask
=
null
;
if
(
this
.
needNotificationProgress
)
{
uni
.
finishNotificationProgress
({
title
:
"
安装升级包
"
,
content
:
"
下载完成
"
})
this
.
installPackage
();
return
}
// 强制更新,直接安装
if
(
this
.
is_mandatory
)
{
this
.
installPackage
();
...
...
@@ -496,6 +531,16 @@
line-height
:
38px
;
}
.content-body-version
{
padding-left
:
10px
;
color
:
#fff
;
font-size
:
10px
;
margin-left
:
5px
;
padding
:
2px
4px
;
border-radius
:
10px
;
background
:
#50aefd
;
}
.footer
{
height
:
150
rpx
;
display
:
flex
;
...
...
uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
浏览文件 @
339b28a5
...
...
@@ -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
=
systemInfo
.
appVersion
const
appVersion
=
'
1.0.15
'
//
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
)
{
...
...
uni_modules/uni-upgrade-center-app/utils/check-update.ts
浏览文件 @
339b28a5
...
...
@@ -32,6 +32,24 @@ export default function () : Promise<UniUpgradeCenterResult> {
*/
// return updateUseModal(uniUpgradeCenterResult)
// #ifndef UNI-APP-X
// 静默更新,只有wgt有
if
(
uniUpgradeCenterResult
.
is_silently
)
{
uni
.
downloadFile
({
url
,
success
:
res
=>
{
if
(
res
.
statusCode
==
200
)
{
// 下载好直接安装,下次启动生效
plus
.
runtime
.
install
(
res
.
tempFilePath
,
{
force
:
false
});
}
}
});
return
;
}
// #endif
/**
* 提示升级二
* 官方适配的升级弹窗,可自行替换资源适配UI风格
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录