From 67eead570d15378b8b5ae937f2265c6d4f3cbe6d Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Thu, 12 Feb 2026 11:31:26 +0800
Subject: [PATCH] feat: app语音

---
 uniapps/work-app/src/uni_modules/lgh-dialog/utssdk/app-android/index.uts |   75 ++++++++++++++++++++++++++++---------
 1 files changed, 56 insertions(+), 19 deletions(-)

diff --git a/uniapps/work-app/src/uni_modules/lgh-dialog/utssdk/app-android/index.uts b/uniapps/work-app/src/uni_modules/lgh-dialog/utssdk/app-android/index.uts
index f1af48a..bacf33a 100644
--- a/uniapps/work-app/src/uni_modules/lgh-dialog/utssdk/app-android/index.uts
+++ b/uniapps/work-app/src/uni_modules/lgh-dialog/utssdk/app-android/index.uts
@@ -3,7 +3,7 @@
 import Intent from 'android.content.Intent'
 import Settings from 'android.provider.Settings'
 import { UTSAndroid } from 'io.dcloud.uts'
-import BatteryManager from "android.os.BatteryManager";
+import BatteryManager from 'android.os.BatteryManager'
 
 // 拉起应用
 export function openDialog(): void {
@@ -26,17 +26,58 @@
 	const context = UTSAndroid.getAppContext()
 	if (context == null) return
 	// 1. 检查悬浮窗权限 (Android 6.0+)
-	if (Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(context)) {
-		try {
-			// 无权限,跳转到权限设置页面
-			const intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
+	const noneFloat = Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(context)
+	if (noneFloat) {
+		uni.showToast({ title: '请允许应用悬浮在屏幕上', icon: 'none' })
+	} else {
+		setTimeout(() => {
+			try {
+				// 无权限,跳转到权限设置页面
+				const intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
+				intent.setData(android.net.Uri.parse('package:' + context.getPackageName()))
+				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+				context.startActivity(intent)
+			} catch (e) {
+				console.error(e)
+			}
+		}, 2000)
+	}
+}
+
+// 跳到后台弹出界面权限页面(应用详情设置)
+export function allowBackgroundPopup() {
+	const context = UTSAndroid.getAppContext()
+	if (context == null) return
+	try {
+		const intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
+		intent.setData(android.net.Uri.parse('package:' + context.getPackageName()))
+		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+		context.startActivity(intent)
+	} catch (e) {
+		console.error(e)
+	}
+}
+
+// 跳到锁屏显示权限页面(通知设置)
+export function allowLockScreen() {
+	const context = UTSAndroid.getAppContext()
+	if (context == null) return
+	try {
+		if (Build.VERSION.SDK_INT >= 26) {
+			// Android 8.0+ 跳转到应用通知设置
+			const intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
+			intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
+			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+			context.startActivity(intent)
+		} else {
+			// 低版本跳转到应用详情
+			const intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
 			intent.setData(android.net.Uri.parse('package:' + context.getPackageName()))
 			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
 			context.startActivity(intent)
-		} catch (e) {
-			console.error(e)
 		}
-		return
+	} catch (e) {
+		console.error(e)
 	}
 }
 
@@ -50,16 +91,12 @@
  */
 export function getBatteryCapacity(): string {
 	// 获取android系统 application上下文
-    const context = UTSAndroid.getAppContext();
-    if (context != null) {
-        const manager = context.getSystemService(
-            Context.BATTERY_SERVICE
-        ) as BatteryManager;
-        const currentLevel: number = manager.getIntProperty(
-            BatteryManager.BATTERY_PROPERTY_CAPACITY
-        );
-        return '' + currentLevel + '%';
-    }
-    return "0%";
+	const context = UTSAndroid.getAppContext()
+	if (context != null) {
+		const manager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
+		const currentLevel: number = manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
+		return '' + currentLevel + '%'
+	}
+	return '0%'
 }
 

--
Gitblit v1.9.3