diff --git a/_auto_push.ps1 b/_auto_push.ps1
new file mode 100644
index 0000000..5129bb3
--- /dev/null
+++ b/_auto_push.ps1
@@ -0,0 +1,26 @@
+# 大商道扫书入库 - 快速提交脚本
+# 运行后自动 add -> commit -> push
+
+$repoDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$message = $args[0]
+if (-not $message) {
+ $message = "自动提交 " + (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
+}
+
+Write-Host "=== 提交变更到服务器 ===" -ForegroundColor Cyan
+Set-Location $repoDir
+
+git add -A
+$status = git status --porcelain
+if (-not $status) {
+ Write-Host "没有需要提交的变更" -ForegroundColor Yellow
+ exit 0
+}
+
+Write-Host "变更文件:" -ForegroundColor Yellow
+git status --short
+
+git commit -m $message
+git push
+
+Write-Host "=== 提交完成 ===" -ForegroundColor Green
diff --git a/manifest.json b/manifest.json
index 4591a6f..f1695ea 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,8 +1,8 @@
{
- "name" : "scanBook",
- "appid" : "",
+ "name" : "书海寻源-上书",
+ "appid" : "__UNI__40357CF",
"description" : "",
- "versionName" : "1.0.0",
+ "versionName" : "1.1.0.3",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
@@ -17,7 +17,10 @@
"delay" : 0
},
/* 模块配置 */
- "modules" : {},
+ "modules" : {
+ "Camera" : {},
+ "Barcode" : {}
+ },
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
@@ -41,9 +44,43 @@
]
},
/* ios打包配置 */
- "ios" : {},
+ "ios" : {
+ "dSYMs" : false
+ },
/* SDK配置 */
- "sdkConfigs" : {}
+ "sdkConfigs" : {},
+ "icons" : {
+ "android" : {
+ "hdpi" : "unpackage/res/icons/72x72.png",
+ "xhdpi" : "unpackage/res/icons/96x96.png",
+ "xxhdpi" : "unpackage/res/icons/144x144.png",
+ "xxxhdpi" : "unpackage/res/icons/192x192.png"
+ },
+ "ios" : {
+ "appstore" : "unpackage/res/icons/1024x1024.png",
+ "ipad" : {
+ "app" : "unpackage/res/icons/76x76.png",
+ "app@2x" : "unpackage/res/icons/152x152.png",
+ "notification" : "unpackage/res/icons/20x20.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "proapp@2x" : "unpackage/res/icons/167x167.png",
+ "settings" : "unpackage/res/icons/29x29.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "spotlight" : "unpackage/res/icons/40x40.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png"
+ },
+ "iphone" : {
+ "app@2x" : "unpackage/res/icons/120x120.png",
+ "app@3x" : "unpackage/res/icons/180x180.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "notification@3x" : "unpackage/res/icons/60x60.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "settings@3x" : "unpackage/res/icons/87x87.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png",
+ "spotlight@3x" : "unpackage/res/icons/120x120.png"
+ }
+ }
+ }
}
},
/* 快应用特有相关 */
diff --git a/package.json b/package.json
index 8fd3395..8eba4af 100644
--- a/package.json
+++ b/package.json
@@ -3,4 +3,4 @@
"blueimp-md5": "^2.19.0",
"js-sha256": "^0.11.1"
}
-}
+}
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 2031cf0..273d5a8 100644
--- a/pages.json
+++ b/pages.json
@@ -59,6 +59,22 @@
"style": {
"navigationBarTitleText": "连拍"
}
+ },
+
+ {
+ "path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
+ "style": {
+ "disableScroll": true,
+ "app-plus": {
+ "backgroundColorTop": "transparent",
+ "background": "transparent",
+ "titleNView": false,
+ "scrollIndicator": false,
+ "popGesture": "none",
+ "animationType": "fade-in",
+ "animationDuration": 200
+ }
+ }
}
],
"globalStyle": {
diff --git a/pages/home/home.vue b/pages/home/home.vue
index c6baeb2..0556246 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -131,7 +131,7 @@
+
+
diff --git a/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue b/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
new file mode 100644
index 0000000..e9769d6
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
@@ -0,0 +1,679 @@
+
+
+
+
+ {{ title }}
+
+
+
+
+
+ {{ subTitle }}
+ {{ version }}
+
+
+
+
+ {{ contents }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-upgrade-center-app/readme.md b/uni_modules/uni-upgrade-center-app/readme.md
new file mode 100644
index 0000000..53ff781
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/readme.md
@@ -0,0 +1 @@
+文档已移至 [uni-upgrade-center](https://uniapp.dcloud.net.cn/uniCloud/upgrade-center.html)
\ No newline at end of file
diff --git a/uni_modules/uni-upgrade-center-app/static/app/app_update_close.png b/uni_modules/uni-upgrade-center-app/static/app/app_update_close.png
new file mode 100644
index 0000000..8b2ffe6
Binary files /dev/null and b/uni_modules/uni-upgrade-center-app/static/app/app_update_close.png differ
diff --git a/uni_modules/uni-upgrade-center-app/static/app/bg_top.png b/uni_modules/uni-upgrade-center-app/static/app/bg_top.png
new file mode 100644
index 0000000..015f698
Binary files /dev/null and b/uni_modules/uni-upgrade-center-app/static/app/bg_top.png differ
diff --git a/uni_modules/uni-upgrade-center-app/uniCloud/database/db_init.json b/uni_modules/uni-upgrade-center-app/uniCloud/database/db_init.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/uniCloud/database/db_init.json
@@ -0,0 +1 @@
+{}
diff --git a/uni_modules/uni-upgrade-center-app/utils/call-check-version.1ts b/uni_modules/uni-upgrade-center-app/utils/call-check-version.1ts
new file mode 100644
index 0000000..82b4de1
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/call-check-version.1ts
@@ -0,0 +1,120 @@
+export type StoreListItem = {
+ enable : boolean
+ id : string
+ name : string
+ scheme : string
+ priority : number // 优先级
+}
+
+export type UniUpgradeCenterResult = {
+ _id : string
+ appid : string
+ name : string
+ title : string
+ contents : string
+ url : string // 安装包下载地址
+ platform : Array // Array<'Android' | 'iOS' | 'Harmony'>
+ version : string // 版本号 1.0.0
+ uni_platform : string // "android" | "ios" | 'harmony'
+ stable_publish : boolean // 是否是稳定版
+ is_mandatory : boolean // 是否强制更新
+ is_silently : boolean | null // 是否静默更新
+ create_env : string // "upgrade-center"
+ create_date : number
+ message : string
+ code : number
+
+ type : string // "native_app" | "wgt"
+ store_list : StoreListItem[] | null
+ min_uni_version : string | null // 升级 wgt 的最低 uni-app 版本
+}
+
+export default function () : Promise {
+ // #ifdef APP
+ return new Promise((resolve, reject) => {
+ const systemInfo = uni.getSystemInfoSync()
+ const appId = systemInfo.appId
+ 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) {
+ if (widgetInfo.version) {
+ let data = {
+ action: 'checkVersion',
+ appid: appId,
+ appVersion: appVersion,
+ wgtVersion: widgetInfo.version
+ }
+ uniCloud.callFunction({
+ name: 'uni-upgrade-center',
+ data,
+ success: (e) => {
+ resolve(e.result as UniUpgradeCenterResult)
+ },
+ fail: (error) => {
+ reject(error)
+ }
+ })
+ } else {
+ reject('widgetInfo.version is EMPTY')
+ }
+ })
+ } else {
+ reject('plus.runtime.appid is EMPTY')
+ }
+ // #endif
+ // #ifdef UNI-APP-X
+ if (typeof appId === 'string' && typeof appVersion === 'string' && appId.length > 0 && appVersion.length > 0) {
+ let data = {
+ action: 'checkVersion',
+ appid: appId,
+ appVersion: appVersion,
+ is_uniapp_x: true,
+ wgtVersion: '0.0.0.0.0.1'
+ }
+ try {
+ uniCloud.callFunction({
+ name: 'uni-upgrade-center',
+ data: data
+ }).then(res => {
+ const code = res.result['code']
+ const codeIsNumber = ['Int', 'Long', 'number'].includes(typeof code)
+ if (codeIsNumber) {
+ if ((code as number) == 0) {
+ reject({
+ code: res.result['code'],
+ message: res.result['message']
+ })
+ } else if ((code as number) < 0) {
+ reject({
+ code: res.result['code'],
+ message: res.result['message']
+ })
+ } else {
+ const result = JSON.parse(JSON.stringify(res.result)) as UniUpgradeCenterResult
+ resolve(result)
+ }
+ }
+ }).catch((err : any | null) => {
+ const error = err as UniCloudError
+ if (error.errMsg == '未匹配到云函数[uni-upgrade-center]')
+ error.errMsg = '【uni-upgrade-center-app】未配置uni-upgrade-center,无法升级。参考: https://uniapp.dcloud.net.cn/uniCloud/upgrade-center.html'
+ reject(error.errMsg)
+ })
+ } catch (e) {
+ reject(e.message)
+ }
+ } else {
+ reject('invalid appid or appVersion')
+ }
+ // #endif
+ })
+ // #endif
+ // #ifndef APP
+ return new Promise((resolve, reject) => {
+ reject({
+ message: '请在App中使用'
+ })
+ })
+ // #endif
+}
diff --git a/uni_modules/uni-upgrade-center-app/utils/call-check-version.ts b/uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
new file mode 100644
index 0000000..5be5ee5
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
@@ -0,0 +1,122 @@
+export type StoreListItem = {
+ enable : boolean
+ id : string
+ name : string
+ scheme : string
+ priority : number // 优先级
+}
+
+export type UniUpgradeCenterResult = {
+ _id : string
+ appid : string
+ name : string
+ title : string
+ contents : string
+ url : string // 安装包下载地址
+ platform : Array // Array<'Android' | 'iOS' | 'Harmony'>
+ version : string // 版本号 1.0.0
+ uni_platform : string // "android" | "ios" | 'harmony'
+ stable_publish : boolean // 是否是稳定版
+ is_mandatory : boolean // 是否强制更新
+ is_silently : boolean | null // 是否静默更新
+ create_env : string // "upgrade-center"
+ create_date : number
+ message : string
+ code : number
+
+ type : string // "native_app" | "wgt"
+ store_list : StoreListItem[] | null
+ min_uni_version : string | null // 升级 wgt 的最低 uni-app 版本
+}
+
+export default function () : Promise {
+ // #ifdef APP
+ return new Promise((resolve, reject) => {
+ const systemInfo = uni.getSystemInfoSync()
+ const appId = systemInfo.appId
+ const appVersion = systemInfo.appWgtVersion //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) {
+ // 使用降级:widgetInfo.version 或 appVersion(appWgtVersion)
+ const wgtVersion = (widgetInfo.version && widgetInfo.version !== "")
+ ? widgetInfo.version
+ : appVersion
+
+ console.log("版本检查手动日志:"+wgtVersion)
+ if (wgtVersion) {
+ let data = {
+ action: 'checkVersion',
+ appid: appId,
+ appVersion: wgtVersion,
+ wgtVersion: wgtVersion
+ }
+ uniCloud.callFunction({
+ name: 'uni-upgrade-center',
+ data,
+ success: (e) => resolve(e.result as UniUpgradeCenterResult),
+ fail: (error) => reject(error)
+ })
+ } else {
+ reject('widgetInfo.version is EMPTY')
+ }
+ })
+ } else {
+ reject('plus.runtime.appid is EMPTY')
+ }
+ // #endif
+ // #ifdef UNI-APP-X
+ if (typeof appId === 'string' && typeof appVersion === 'string' && appId.length > 0 && appVersion.length > 0) {
+ let data = {
+ action: 'checkVersion',
+ appid: appId,
+ appVersion: appVersion,
+ is_uniapp_x: true,
+ wgtVersion: '0.0.0.0.0.1'
+ }
+ try {
+ uniCloud.callFunction({
+ name: 'uni-upgrade-center',
+ data: data
+ }).then(res => {
+ const code = res.result['code']
+ const codeIsNumber = ['Int', 'Long', 'number'].includes(typeof code)
+ if (codeIsNumber) {
+ if ((code as number) == 0) {
+ reject({
+ code: res.result['code'],
+ message: res.result['message']
+ })
+ } else if ((code as number) < 0) {
+ reject({
+ code: res.result['code'],
+ message: res.result['message']
+ })
+ } else {
+ const result = JSON.parse(JSON.stringify(res.result)) as UniUpgradeCenterResult
+ resolve(result)
+ }
+ }
+ }).catch((err : any | null) => {
+ const error = err as UniCloudError
+ if (error.errMsg == '未匹配到云函数[uni-upgrade-center]')
+ error.errMsg = '【uni-upgrade-center-app】未配置uni-upgrade-center,无法升级。参考: https://uniapp.dcloud.net.cn/uniCloud/upgrade-center.html'
+ reject(error.errMsg)
+ })
+ } catch (e) {
+ reject(e.message)
+ }
+ } else {
+ reject('invalid appid or appVersion')
+ }
+ // #endif
+ })
+ // #endif
+ // #ifndef APP
+ return new Promise((resolve, reject) => {
+ reject({
+ message: '请在App中使用'
+ })
+ })
+ // #endif
+}
diff --git a/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js b/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js
new file mode 100644
index 0000000..6c0d4bc
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js
@@ -0,0 +1,184 @@
+function callCheckVersion() {
+ // #ifdef APP-PLUS
+ return new Promise((resolve, reject) => {
+ plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
+ let data = {
+ action: 'checkVersion',
+ appid: plus.runtime.appid,
+ appVersion: plus.runtime.version,
+ wgtVersion: widgetInfo.version
+ }
+ uniCloud.callFunction({
+ name: 'uni-upgrade-center',
+ data,
+ success: (e) => {
+ resolve(e)
+ },
+ fail: (error) => {
+ reject(error)
+ }
+ })
+ })
+ })
+ // #endif
+ // #ifndef APP-PLUS
+ return new Promise((resolve, reject) => {})
+ // #endif
+}
+
+// 推荐再App.vue中使用
+const PACKAGE_INFO_KEY = '__package_info__'
+
+export default function() {
+ // #ifdef APP-PLUS
+ return new Promise((resolve, reject) => {
+ callCheckVersion().then(async (e) => {
+ if (!e.result) return;
+ const {
+ code,
+ message,
+ is_silently, // 是否静默更新
+ url, // 安装包下载地址
+ platform, // 安装包平台
+ type // 安装包类型
+ } = e.result;
+
+ // 此处逻辑仅为实例,可自行编写
+ if (code > 0) {
+ // 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回
+ const {
+ fileList
+ } = await uniCloud.getTempFileURL({
+ fileList: [url]
+ });
+ if (fileList[0].tempFileURL)
+ e.result.url = fileList[0].tempFileURL;
+
+ resolve(e)
+
+ // 静默更新,只有wgt有
+ if (is_silently) {
+ uni.downloadFile({
+ url: e.result.url,
+ success: res => {
+ if (res.statusCode == 200) {
+ // 下载好直接安装,下次启动生效
+ plus.runtime.install(res.tempFilePath, {
+ force: false
+ });
+ }
+ }
+ });
+ return;
+ }
+
+ /**
+ * 提示升级一
+ * 使用 uni.showModal
+ */
+ // return updateUseModal(e.result)
+
+ /**
+ * 提示升级二
+ * 官方适配的升级弹窗,可自行替换资源适配UI风格
+ */
+ uni.setStorageSync(PACKAGE_INFO_KEY, e.result)
+ uni.navigateTo({
+ url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
+ fail: (err) => {
+ console.error('更新弹框跳转失败', err)
+ uni.removeStorageSync(PACKAGE_INFO_KEY)
+ }
+ })
+
+ return
+ } else if (code < 0) {
+ // TODO 云函数报错处理
+ console.error(message)
+ return reject(e)
+ }
+ return resolve(e)
+ }).catch(err => {
+ // TODO 云函数报错处理
+ console.error(err.message)
+ reject(err)
+ })
+ });
+ // #endif
+}
+
+/**
+ * 使用 uni.showModal 升级
+ */
+function updateUseModal(packageInfo) {
+ const {
+ title, // 标题
+ contents, // 升级内容
+ is_mandatory, // 是否强制更新
+ url, // 安装包下载地址
+ platform, // 安装包平台
+ type // 安装包类型
+ } = packageInfo;
+
+ let isWGT = type === 'wgt'
+ let isiOS = !isWGT ? platform.includes('iOS') : false;
+ let confirmText = isiOS ? '立即跳转更新' : '立即下载更新'
+
+ return uni.showModal({
+ title,
+ content: contents,
+ showCancel: !is_mandatory,
+ confirmText,
+ success: res => {
+ if (res.cancel) return;
+
+ // 安装包下载
+ if (isiOS) {
+ plus.runtime.openURL(url);
+ return;
+ }
+
+ uni.showToast({
+ title: '后台下载中……',
+ duration: 1000
+ });
+
+ // wgt 和 安卓下载更新
+ downloadTask = uni.downloadFile({
+ url,
+ success: res => {
+ if (res.statusCode !== 200) {
+ console.error('下载安装包失败', err);
+ return;
+ }
+ // 下载好直接安装,下次启动生效
+ plus.runtime.install(res.tempFilePath, {
+ force: false
+ }, () => {
+ if (is_mandatory) {
+ //更新完重启app
+ plus.runtime.restart();
+ return;
+ }
+ uni.showModal({
+ title: '安装成功是否重启?',
+ success: res => {
+ if (res.confirm) {
+ //更新完重启app
+ plus.runtime.restart();
+ }
+ }
+ });
+ }, err => {
+ uni.showModal({
+ title: '更新失败',
+ content: err
+ .message,
+ showCancel: false
+ });
+ });
+ }
+ });
+ }
+ });
+}
diff --git a/uni_modules/uni-upgrade-center-app/utils/check-update.ts b/uni_modules/uni-upgrade-center-app/utils/check-update.ts
new file mode 100644
index 0000000..8c27d17
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/check-update.ts
@@ -0,0 +1,228 @@
+import callCheckVersion, { UniUpgradeCenterResult } from "./call-check-version"
+import { platform_iOS } from './utils'
+// #ifdef UNI-APP-X
+import { openSchema } from '@/uni_modules/uts-openSchema'
+// #endif
+
+// 推荐再App.vue中使用
+const PACKAGE_INFO_KEY = '__package_info__'
+// #ifdef APP-HARMONY
+export default function (component?: any) : Promise {
+// #endif
+// #ifndef APP-HARMONY
+export default function () : Promise {
+// #endif
+ return new Promise((resolve, reject) => {
+ callCheckVersion().then(async (uniUpgradeCenterResult) => {
+ // NOTE uni-app x 3.96 解构有问题
+ const code = uniUpgradeCenterResult.code
+ const message = uniUpgradeCenterResult.message
+ const url = uniUpgradeCenterResult.url // 安装包下载地址
+ // 此处逻辑仅为示例,可自行编写
+ if (code > 0) {
+ // 腾讯云获取下载链接
+ if (/^cloud:\/\//.test(url)) {
+ const tcbRes = await uniCloud.getTempFileURL({ fileList: [url] });
+ if (typeof tcbRes.fileList[0].tempFileURL !== 'undefined') uniUpgradeCenterResult.url = tcbRes.fileList[0].tempFileURL;
+ }
+
+ /**
+ * 提示升级一
+ * 使用 uni.showModal
+ */
+ // return updateUseModal(uniUpgradeCenterResult)
+
+ // #ifndef UNI-APP-X
+ // 静默更新,只有wgt有
+ if (uniUpgradeCenterResult.is_silently) {
+ uni.downloadFile({
+ url: uniUpgradeCenterResult.url,
+ success: res => {
+ if (res.statusCode == 200) {
+ // 下载好直接安装,下次启动生效
+ plus.runtime.install(res.tempFilePath, {
+ force: false
+ });
+ }
+ }
+ });
+ return;
+ }
+ // #endif
+
+ /**
+ * 提示升级二
+ * 官方适配的升级弹窗,可自行替换资源适配UI风格
+ */
+ // #ifndef UNI-APP-X
+ // #ifdef APP-PLUS
+ uni.setStorageSync(PACKAGE_INFO_KEY, uniUpgradeCenterResult)
+ uni.navigateTo({
+ url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
+ fail: (err) => {
+ console.error('更新弹框跳转失败', err)
+ uni.removeStorageSync(PACKAGE_INFO_KEY)
+ }
+ })
+ // #endif
+ // #ifdef APP-HARMONY
+ if (component) {
+ component.show(true, uniUpgradeCenterResult)
+ } else {
+ reject({
+ code: -1,
+ message: '在 HarmonyOS Next 平台请传递组件使用'
+ })
+ }
+ // #endif
+ // #endif
+ // #ifdef UNI-APP-X
+ uni.setStorageSync(PACKAGE_INFO_KEY, uniUpgradeCenterResult)
+ uni.openDialogPage({
+ url: `/uni_modules/uni-upgrade-center-app/pages/uni-app-x/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
+ disableEscBack: true,
+ fail: (err) => {
+ console.error('更新弹框跳转失败', err)
+ uni.removeStorageSync(PACKAGE_INFO_KEY)
+ }
+ })
+ // #endif
+
+ return resolve(uniUpgradeCenterResult)
+ } else if (code < 0) {
+ console.error(message)
+ return reject(uniUpgradeCenterResult)
+ }
+ return resolve(uniUpgradeCenterResult)
+ }).catch((err) => {
+ reject(err)
+ })
+ });
+ }
+
+/**
+ * 使用 uni.showModal 升级
+ */
+function updateUseModal(packageInfo : UniUpgradeCenterResult) : void {
+ // #ifdef APP
+ const {
+ title, // 标题
+ contents, // 升级内容
+ is_mandatory, // 是否强制更新
+ url, // 安装包下载地址
+ type,
+ platform
+ } = packageInfo;
+
+ let isWGT = type === 'wgt'
+ let isiOS = !isWGT ? platform.includes(platform_iOS) : false;
+
+ // #ifndef UNI-APP-X
+ let confirmText = isiOS ? '立即跳转更新' : '立即下载更新'
+ // #endif
+ // #ifdef UNI-APP-X
+ let confirmText = '立即下载更新'
+ // #endif
+
+ uni.showModal({
+ title,
+ content: contents,
+ showCancel: !is_mandatory,
+ confirmText,
+ success: res => {
+ if (res.cancel) return;
+
+ if (isiOS) {
+ // iOS 平台跳转 AppStore
+ // #ifndef UNI-APP-X
+ plus.runtime.openURL(url);
+ // #endif
+ // #ifdef UNI-APP-X
+ openSchema(url)
+ // #endif
+ return;
+ }
+
+ uni.showToast({
+ title: '后台下载中……',
+ duration: 1000
+ });
+
+ // wgt 和 安卓下载更新
+ uni.downloadFile({
+ url,
+ success: res => {
+ if (res.statusCode !== 200) {
+ console.error('下载安装包失败');
+ return;
+ }
+ // 下载好直接安装,下次启动生效
+ // uni-app x 项目没有 plus5+ 故使用条件编译
+ // #ifndef UNI-APP-X
+ plus.runtime.install(res.tempFilePath, {
+ force: false
+ }, () => {
+ if (is_mandatory) {
+ //更新完重启app
+ // #ifdef APP-PLUS
+ plus.runtime.restart();
+ // #endif
+ // #ifdef APP-HARMONY
+ uni.showModal({
+ title: '安装成功',
+ content: '请手动重启应用',
+ showCancel: false,
+ success: res => {
+ plus.runtime.quit();
+ }
+ });
+ // #endif
+ return;
+ }
+ uni.showModal({
+ title: '安装成功是否重启?',
+ success: res => {
+ if (res.confirm) {
+ //更新完重启app
+ // #ifdef APP-PLUS
+ plus.runtime.restart();
+ // #endif
+ // #ifdef APP-HARMONY
+ plus.runtime.quit();
+ // #endif
+ }
+ }
+ });
+ }, err => {
+ uni.showModal({
+ title: '更新失败',
+ content: err
+ .message,
+ showCancel: false
+ });
+ });
+ // #endif
+
+ // #ifdef UNI-APP-X
+ uni.installApk({
+ filePath: res.tempFilePath,
+ success: () => {
+ uni.showModal({
+ title: '安装成功请手动重启'
+ });
+ },
+ fail: err => {
+ uni.showModal({
+ title: '更新失败',
+ content: err.errMsg,
+ showCancel: false
+ });
+ }
+ });
+ // #endif
+ }
+ });
+ }
+ });
+ // #endif
+}
diff --git a/uni_modules/uni-upgrade-center-app/utils/utils.ts b/uni_modules/uni-upgrade-center-app/utils/utils.ts
new file mode 100644
index 0000000..414e096
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/utils.ts
@@ -0,0 +1,46 @@
+export const platform_iOS: string = 'iOS';
+export const platform_Android: string = 'Android';
+export const platform_Harmony: string = 'Harmony';
+
+/**
+ * 对比版本号,如需要,请自行修改判断规则
+ * 支持比对 ("3.0.0.0.0.1.0.1", "3.0.0.0.0.1") ("3.0.0.1", "3.0") ("3.1.1", "3.1.1.1") 之类的
+ * @param {Object} v1
+ * @param {Object} v2
+ * v1 > v2 return 1
+ * v1 < v2 return -1
+ * v1 == v2 return 0
+ */
+export function compare(v_1: string = '0', v_2: string = '0') {
+ const v1: string[] = String(v_1).split('.');
+ const v2: string[] = String(v_2).split('.');
+ const minVersionLens = Math.min(v1.length, v2.length);
+
+ let result = 0;
+ for (let i = 0; i < minVersionLens; i++) {
+ const curV1 = Number(v1[i]);
+ const curV2 = Number(v2[i]);
+
+ if (curV1 > curV2) {
+ result = 1;
+ break;
+ } else if (curV1 < curV2) {
+ result = -1;
+ break;
+ }
+ }
+
+ if (result === 0 && v1.length !== v2.length) {
+ const v1BiggerThenv2 = v1.length > v2.length;
+ const maxLensVersion = v1BiggerThenv2 ? v1 : v2;
+ for (let i = minVersionLens; i < maxLensVersion.length; i++) {
+ const curVersion = Number(maxLensVersion[i]);
+ if (curVersion > 0) {
+ v1BiggerThenv2 ? (result = 1) : (result = -1);
+ break;
+ }
+ }
+ }
+
+ return result;
+}
\ No newline at end of file
diff --git a/uni_modules/uts-openSchema/changelog.md b/uni_modules/uts-openSchema/changelog.md
new file mode 100644
index 0000000..de1703b
--- /dev/null
+++ b/uni_modules/uts-openSchema/changelog.md
@@ -0,0 +1,13 @@
+## 1.1.3(2025-09-12)
+- 鸿蒙平台 新增 打开 url 错误时输出
+- iOS平台 修复 语法报黄问题
+## 1.1.2(2025-03-20)
+- 更新 支持鸿蒙
+## 1.1.1(2024-12-16)
+- 修复 canOpenURL 在安卓端可能会报类型错误的问题
+## 1.1.0(2024-12-06)
+- 新增 canOpenURL UTS API,可用此API判断url是否可以跳转
+## 1.0.1(2024-11-13)
+- 修复 Android 打开部分 schema 时没有跳转到目标应用的 Bug
+## 1.0.0(2024-04-25)
+- 更新 在 Android 和 iOS 上打开链接的 UTS API
diff --git a/uni_modules/uts-openSchema/package.json b/uni_modules/uts-openSchema/package.json
new file mode 100644
index 0000000..2225c04
--- /dev/null
+++ b/uni_modules/uts-openSchema/package.json
@@ -0,0 +1,124 @@
+{
+ "id": "uts-openSchema",
+ "displayName": "uts-openSchema",
+ "version": "1.1.3",
+ "description": "在 Android、iOS、HarmonyOS 上打开链接的 UTS API",
+ "keywords": [
+ "uts-openSchema"
+],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^4.0",
+ "uni-app": "^4.75",
+ "uni-app-x": "^4.75"
+ },
+ "dcloudext": {
+ "type": "uts",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "",
+ "darkmode": "x",
+ "i18n": "x",
+ "widescreen": "x"
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "√",
+ "aliyun": "√",
+ "alipay": "√"
+ },
+ "client": {
+ "uni-app": {
+ "vue": {
+ "vue2": {
+ "extVersion": "1.0.0",
+ "minVersion": ""
+ },
+ "vue3": {
+ "extVersion": "1.0.0",
+ "minVersion": ""
+ }
+ },
+ "web": {
+ "safari": "x",
+ "chrome": "x"
+ },
+ "app": {
+ "vue": {
+ "extVersion": "1.0.0",
+ "minVersion": ""
+ },
+ "nvue": "-",
+ "android": {
+ "extVersion": "1.0.0",
+ "minVersion": "21"
+ },
+ "ios": {
+ "extVersion": "1.0.0",
+ "minVersion": "12"
+ },
+ "harmony": {
+ "extVersion": "1.1.2",
+ "minVersion": "5.0.0"
+ }
+ },
+ "mp": {
+ "weixin": "x",
+ "alipay": "x",
+ "toutiao": "x",
+ "baidu": "x",
+ "kuaishou": "x",
+ "jd": "x",
+ "harmony": "x",
+ "qq": "x",
+ "lark": "x"
+ },
+ "quickapp": {
+ "huawei": "x",
+ "union": "x"
+ }
+ },
+ "uni-app-x": {
+ "web": {
+ "safari": "x",
+ "chrome": "x"
+ },
+ "app": {
+ "android": {
+ "extVersion": "1.0.0",
+ "minVersion": "21"
+ },
+ "ios": {
+ "extVersion": "1.0.0",
+ "minVersion": "12"
+ },
+ "harmony": {
+ "extVersion": "1.1.2",
+ "minVersion": "5.0.0"
+ }
+ },
+ "mp": {
+ "weixin": "x"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uts-openSchema/readme.md b/uni_modules/uts-openSchema/readme.md
new file mode 100644
index 0000000..e03fdf7
--- /dev/null
+++ b/uni_modules/uts-openSchema/readme.md
@@ -0,0 +1,59 @@
+# uts-openSchema
+
+打开链接,支持:
+
+1. 打开外部 App
+2. 使用浏览器打开链接
+3. 打开地图到指定地点
+4. ...
+
+## 使用
+
+1. 安装此插件
+2. 在要使用的地方 `import` 导入
+ ```ts
+ import { openSchema, canOpenURL } from '@/uni_modules/uts-openSchema'
+ ```
+3. 直接调用 `openSchema` 方法:
+ ```ts
+ // #ifdef UNI-APP-X
+ // 使用外部浏览器打开指定URL
+ openSchema('https://uniapp.dcloud.io/uni-app-x')
+
+ // #ifdef APP-ANDROID
+ // Android 使用应用商店打开指定App
+ openSchema('market://details?id=com.tencent.mm')
+
+ // Android 打开地图坐标
+ // 可以先用canOpenURL判断是否安装了地图软件
+ if (canOpenURL('androidamap://')) {
+ openSchema('androidamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0')
+ } else {
+ console.log('未安装高德地图')
+ }
+ // #endif -->
+
+ // #ifdef APP-IOS
+ // 打开 AppStore 到搜索页
+ openSchema('itms-apps://search.itunes.apple.com//WebObjects//MZSearch.woa/wa/search?media=software<erm=')
+
+ // 打开 iOS 地图坐标
+ openSchema('http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s')
+ // #endif -->
+
+ // #endif -->
+ ```
+
+### 参数
+
+- openSchema(url: string) // `url`:要打开的链接 `必填` `不为空字符串`
+
+## 相关开发文档
+
+[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)
diff --git a/uni_modules/uts-openSchema/utssdk/app-android/config.json b/uni_modules/uts-openSchema/utssdk/app-android/config.json
new file mode 100644
index 0000000..bf95925
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "21"
+}
\ No newline at end of file
diff --git a/uni_modules/uts-openSchema/utssdk/app-android/index.uts b/uni_modules/uts-openSchema/utssdk/app-android/index.uts
new file mode 100644
index 0000000..ae2f7de
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/app-android/index.uts
@@ -0,0 +1,27 @@
+import Intent from 'android.content.Intent'
+import Uri from 'android.net.Uri'
+import { OpenSchema, CanOpenURL } from '../interface.uts'
+
+export const openSchema : OpenSchema = function (url : string) {
+ if (canOpenURL(url)) {
+ const context = UTSAndroid.getUniActivity()!
+ const uri = Uri.parse(url)
+ const intent = new Intent(Intent.ACTION_VIEW, uri)
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ intent.setData(uri)
+ context.startActivity(intent)
+ } else {
+ console.error('[uts-openSchema] url param Error:', JSON.stringify(url))
+ }
+}
+
+export const canOpenURL : CanOpenURL = function (url : string) : boolean {
+ if (typeof url === 'string' && url.length > 0) {
+ const context = UTSAndroid.getUniActivity()!
+ const uri = Uri.parse(url)
+ const intent = new Intent(Intent.ACTION_VIEW, uri)
+ return intent.resolveActivity(context.packageManager) != null ? true : false
+ } else {
+ return false
+ }
+}
diff --git a/uni_modules/uts-openSchema/utssdk/app-harmony/index.uts b/uni_modules/uts-openSchema/utssdk/app-harmony/index.uts
new file mode 100644
index 0000000..21af83b
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/app-harmony/index.uts
@@ -0,0 +1,21 @@
+import { bundleManager, common } from '@kit.AbilityKit';
+import OpenLinkOptions from '@ohos.app.ability.OpenLinkOptions'
+import { getAbilityContext } from '@dcloudio/uni-runtime'
+import { OpenSchema, CanOpenURL } from '../interface.uts'
+
+
+export const openSchema : OpenSchema = function (url : string) : void {
+ (getAbilityContext() as common.UIAbilityContext)?.openLink(url, {
+ appLinkingOnly: false
+ } as OpenLinkOptions)
+}
+
+
+export const canOpenURL : CanOpenURL = function (url : string) : boolean {
+ try {
+ return bundleManager.canOpenLink(url)
+ } catch (error) {
+ console.error('[uts-openSchema] url param Error:', JSON.stringify(url))
+ return false
+ }
+}
diff --git a/uni_modules/uts-openSchema/utssdk/app-ios/config.json b/uni_modules/uts-openSchema/utssdk/app-ios/config.json
new file mode 100644
index 0000000..f272043
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "12.0"
+}
\ No newline at end of file
diff --git a/uni_modules/uts-openSchema/utssdk/app-ios/index.uts b/uni_modules/uts-openSchema/utssdk/app-ios/index.uts
new file mode 100644
index 0000000..9adaf48
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/app-ios/index.uts
@@ -0,0 +1,22 @@
+import { UIApplication } from 'UIKit'
+import { URL } from 'Foundation'
+import { OpenSchema, CanOpenURL } from '../interface.uts'
+
+export const openSchema : OpenSchema = function (url : string) : void {
+ if (canOpenURL(url)) {
+ let uri = new URL(string = url)
+ UIApplication.shared.open(uri!)
+ } else {
+ console.error('[uts-openSchema] url param Error: ', url)
+ }
+}
+
+export const canOpenURL : CanOpenURL = function (url : string) : boolean {
+ if (typeof url == 'string' && url.length > 0) {
+ let uri = new URL(string = url)
+ if (uri != null && UIApplication.shared.canOpenURL(uri!)) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/uni_modules/uts-openSchema/utssdk/interface.uts b/uni_modules/uts-openSchema/utssdk/interface.uts
new file mode 100644
index 0000000..2b599ac
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/interface.uts
@@ -0,0 +1,2 @@
+export type OpenSchema = (url : string) => void
+export type CanOpenURL = (url : string) => boolean
diff --git a/uni_modules/uts-openSchema/utssdk/web/index.uts b/uni_modules/uts-openSchema/utssdk/web/index.uts
new file mode 100644
index 0000000..4a20902
--- /dev/null
+++ b/uni_modules/uts-openSchema/utssdk/web/index.uts
@@ -0,0 +1,12 @@
+import { OpenSchema, CanOpenURL } from '../interface.uts'
+
+export const openSchema : OpenSchema = function (url : string) : void {
+ location.href = url;
+}
+
+export const canOpenURL : CanOpenURL = function (url : string) : boolean {
+ if (url != "") {
+ return true;
+ }
+ return false;
+}
diff --git a/uni_modules/uts-progressNotification/changelog.md b/uni_modules/uts-progressNotification/changelog.md
new file mode 100644
index 0000000..b7caf4e
--- /dev/null
+++ b/uni_modules/uts-progressNotification/changelog.md
@@ -0,0 +1,28 @@
+## 1.1.2(2025-02-10)
+修复某些情况通过点击通知消息无法拉起App的bug
+## 1.1.1(2024-09-03)
+去除TypeScript警告
+## 1.1.0(2024-03-08)
+修复uniapp打包报错问题
+## 1.0.9(2024-02-29)
+去除代码过时警告
+## 1.0.8(2023-12-21)
+去除app-ios目录
+## 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
+## 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通知栏显示进度插件
diff --git a/uni_modules/uts-progressNotification/package.json b/uni_modules/uts-progressNotification/package.json
new file mode 100644
index 0000000..9f2adb1
--- /dev/null
+++ b/uni_modules/uts-progressNotification/package.json
@@ -0,0 +1,85 @@
+{
+ "id": "uts-progressNotification",
+ "displayName": "uts-progressNotification",
+ "version": "1.1.2",
+ "description": "uts-progressNotification",
+ "keywords": [
+ "progressNotification"
+],
+ "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": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y",
+ "alipay": "n"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ },
+ "App": {
+ "app-android": {
+ "minVersion": "19"
+ },
+ "app-ios": "n",
+ "app-harmony": "u"
+ },
+ "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"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/uts-progressNotification/readme.md b/uni_modules/uts-progressNotification/readme.md
new file mode 100644
index 0000000..70e8d79
--- /dev/null
+++ b/uni_modules/uts-progressNotification/readme.md
@@ -0,0 +1,71 @@
+# uts-progressNotification
+
+## 使用说明
+
+Android平台创建显示进度的通知栏消息
+
+**注意: 需要自定义基座,否则点击通知栏消息不会拉起应用**
+
+### 导入
+
+需要import导入插件
+
+### createNotificationProgress(options : CreateNotificationProgressOptions) : void,
+
+创建显示进度的通知栏消息
+
+参数说明
+
+```
+export type CreateNotificationProgressOptions = {
+ /**
+ * 通知标题
+ * @defaultValue 应用名称
+ */
+ title ?: string | null
+ /**
+ * 通知内容
+ */
+ content : string,
+ /**
+ * 进度
+ */
+ progress : number,
+ /**
+ * 点击通知消息回调
+ * @defaultValue null
+ */
+ onClick? : (() => void) | null
+}
+```
+
+### finishNotificationProgress(options: FinishNotificationProgressOptions) : void
+
+完成时调用的API,比如下载完成后需要显示下载完成并隐藏进度时调用。
+
+参数说明
+
+
+```
+export type FinishNotificationProgressOptions = {
+ /**
+ * 通知标题
+ * @defaultValue 应用名称
+ */
+ title ?: string | null
+ /**
+ * 通知内容
+ */
+ content : string,
+ /**
+ * 点击通知消息回调
+ */
+ onClick : () => void
+}
+```
+
+
+### cancelNotificationProgress() : void
+
+取消通知消息显示
+
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/AndroidManifest.xml b/uni_modules/uts-progressNotification/utssdk/app-android/AndroidManifest.xml
new file mode 100644
index 0000000..bcc33ab
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/AndroidManifest.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/TransparentActivity.uts b/uni_modules/uts-progressNotification/utssdk/app-android/TransparentActivity.uts
new file mode 100644
index 0000000..06fe1bc
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/TransparentActivity.uts
@@ -0,0 +1,62 @@
+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 { getGlobalNotificationProgressCallBack, getGlobalNotificationProgressFinishCallBack, setGlobalNotificationProgressCallBack, setGlobalNotificationProgressFinishCallBack} from './callbacks.uts';
+import { ACTION_DOWNLOAD_FINISH, ACTION_DOWNLOAD_PROGRESS } from "./constant.uts"
+
+
+export class TransparentActivity extends Activity {
+ constructor() {
+ super()
+ }
+
+ @Suppress("DEPRECATION")
+ override onCreate(savedInstanceState : Bundle | null) {
+ super.onCreate(savedInstanceState)
+ this.fullScreen(this)
+ const action = this.getIntent().getAction()
+ if (action == ACTION_DOWNLOAD_FINISH) {
+ setTimeout(() => {
+ getGlobalNotificationProgressFinishCallBack()?.()
+ setGlobalNotificationProgressFinishCallBack(() => { })
+ }, 100)
+ this.overridePendingTransition(0, 0)
+ }
+
+ if (action == ACTION_DOWNLOAD_PROGRESS) {
+ setTimeout(() => {
+ getGlobalNotificationProgressCallBack()?.()
+ setGlobalNotificationProgressCallBack(() => { })
+ }, 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);
+ }
+ }
+ }
+}
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/callbacks.uts b/uni_modules/uts-progressNotification/utssdk/app-android/callbacks.uts
new file mode 100644
index 0000000..5dacea6
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/callbacks.uts
@@ -0,0 +1,19 @@
+let globalNotificationProgressCallBack : (() => void) | null = () => { }
+let globalNotificationProgressFinishCallBack : (() => void) | null = () => { }
+
+export function setGlobalNotificationProgressCallBack(callBack : (() => void) | null) : void {
+ globalNotificationProgressCallBack = callBack
+}
+
+export function getGlobalNotificationProgressCallBack() : (() => void) | null {
+ return globalNotificationProgressCallBack
+}
+
+
+export function setGlobalNotificationProgressFinishCallBack(callBack : (() => void) | null) : void {
+ globalNotificationProgressFinishCallBack = callBack
+}
+
+export function getGlobalNotificationProgressFinishCallBack() : (() => void) | null {
+ return globalNotificationProgressFinishCallBack
+}
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/config.json b/uni_modules/uts-progressNotification/utssdk/app-android/config.json
new file mode 100644
index 0000000..7ed4299
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "19"
+}
\ No newline at end of file
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/constant.uts b/uni_modules/uts-progressNotification/utssdk/app-android/constant.uts
new file mode 100644
index 0000000..e89c210
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/constant.uts
@@ -0,0 +1,2 @@
+export const ACTION_DOWNLOAD_FINISH = "ACTION_DOWNLOAD_FINISH"
+export const ACTION_DOWNLOAD_PROGRESS = "ACTION_DOWNLOAD_PROGRESS"
\ No newline at end of file
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/index.uts b/uni_modules/uts-progressNotification/utssdk/app-android/index.uts
new file mode 100644
index 0000000..76957c3
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/index.uts
@@ -0,0 +1,156 @@
+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"
+
+import { setGlobalNotificationProgressCallBack, setGlobalNotificationProgressFinishCallBack } from './callbacks.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 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 {
+ setGlobalNotificationProgressCallBack(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) {
+ setGlobalNotificationProgressFinishCallBack(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 intent = new Intent(action);
+ intent.setComponent(new ComponentName(context.getPackageName(), "uts.sdk.modules.utsProgressNotification.TransparentActivity"));
+ let flags = PendingIntent.FLAG_UPDATE_CURRENT;
+ if (Build.VERSION.SDK_INT >= 23) {
+ flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
+ }
+ return PendingIntent.getActivity(context, DOWNLOAD_PROGRESS_NOTIFICATION_ID, intent, 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
+}
diff --git a/uni_modules/uts-progressNotification/utssdk/app-android/res/values/notification_progress_styles.xml b/uni_modules/uts-progressNotification/utssdk/app-android/res/values/notification_progress_styles.xml
new file mode 100644
index 0000000..cc01105
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/app-android/res/values/notification_progress_styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
\ No newline at end of file
diff --git a/uni_modules/uts-progressNotification/utssdk/interface.uts b/uni_modules/uts-progressNotification/utssdk/interface.uts
new file mode 100644
index 0000000..7d68ffe
--- /dev/null
+++ b/uni_modules/uts-progressNotification/utssdk/interface.uts
@@ -0,0 +1,46 @@
+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
diff --git a/uni_modules/uts-progressNotification/utssdk/unierror.uts b/uni_modules/uts-progressNotification/utssdk/unierror.uts
new file mode 100644
index 0000000..e69de29
diff --git a/utils/kongfz.js b/utils/kongfz.js
index b28cb28..152ebeb 100644
--- a/utils/kongfz.js
+++ b/utils/kongfz.js
@@ -114,6 +114,9 @@ export function searchFacet(keyword, options = {}) {
})
const totalFound = parseInt(res.data.data.totalFoundText || res.data.data.matchInfo?.totalFound || 0, 10)
resolve({ newCount, oldCount, totalFound })
+ } else if (res.statusCode === 200 && res.data && res.data.status === 0 && res.data.errType === '102') {
+ console.warn('孔夫子统计-会话过期,需要重新登录')
+ reject(new Error('KONGZ_SESSION_EXPIRED'))
} else {
resolve({ newCount: 0, oldCount: 0, totalFound: 0 })
}
@@ -236,6 +239,9 @@ export function searchProducts(keyword, options = {}) {
} else {
resolve({ total: 0, list: [] })
}
+ } else if (res.statusCode === 200 && res.data && res.data.status === 0 && res.data.errType === '102') {
+ console.warn('孔夫子搜索-会话过期,需要重新登录')
+ reject(new Error('KONGZ_SESSION_EXPIRED'))
} else {
resolve({ total: 0, list: [] })
}