Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 1658cb3d
authored
2026-06-30 14:39:23 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化打开相机和相册功能
1 parent
4c8cf445
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
lib/data/repositories/message/sys_album_handler.dart
lib/data/repositories/message/sys_camera_handler.dart
lib/data/repositories/message/sys_album_handler.dart
View file @
1658cb3
...
@@ -14,9 +14,14 @@ class SysAlbumHandler extends MessageHandler {
...
@@ -14,9 +14,14 @@ class SysAlbumHandler extends MessageHandler {
return
false
;
return
false
;
}
}
// 使用 ACTION_MAIN + CATEGORY_APP_GALLERY 打开系统图库应用
// 等同于点击桌面图库图标
// FLAG_ACTIVITY_NEW_TASK (0x10000000) 让图库在独立任务栈中打开,
// Flutter APP 保留在自己的任务栈,用户通过最近任务键可切回
const
intent
=
AndroidIntent
(
const
intent
=
AndroidIntent
(
action:
'android.intent.action.VIEW'
,
action:
'android.intent.action.MAIN'
,
data:
'content://media/external/images/media'
,
category:
'android.intent.category.APP_GALLERY'
,
flags:
<
int
>[
0x10000000
],
);
);
await
intent
.
launch
();
await
intent
.
launch
();
return
true
;
return
true
;
...
...
lib/data/repositories/message/sys_camera_handler.dart
View file @
1658cb3
...
@@ -5,8 +5,8 @@ import 'package:appframe/services/dispatcher.dart';
...
@@ -5,8 +5,8 @@ import 'package:appframe/services/dispatcher.dart';
/// sysCamera 指令处理类
/// sysCamera 指令处理类
///
///
/// 打开系统相机
进行拍照或录像
,仅 Android 平台生效。
/// 打开系统相机
应用(等同于点击桌面相机图标)
,仅 Android 平台生效。
/// 可选参数 type:'photo'(默认,拍照
)或 'video'(录像
)。
/// 可选参数 type:'photo'(默认,拍照
模式)或 'video'(录像模式
)。
/// H5 调用示例:{ "cmd": "sysCamera" } 或 { "cmd": "sysCamera", "params": { "type": "video" } }
/// H5 调用示例:{ "cmd": "sysCamera" } 或 { "cmd": "sysCamera", "params": { "type": "video" } }
class
SysCameraHandler
extends
MessageHandler
{
class
SysCameraHandler
extends
MessageHandler
{
@override
@override
...
@@ -20,9 +20,11 @@ class SysCameraHandler extends MessageHandler {
...
@@ -20,9 +20,11 @@ class SysCameraHandler extends MessageHandler {
type
=
params
[
'type'
]
as
String
?
??
'photo'
;
type
=
params
[
'type'
]
as
String
?
??
'photo'
;
}
}
// 使用 STILL_IMAGE_CAMERA / VIDEO_CAMERA 打开系统相机应用
// 而非 IMAGE_CAPTURE / VIDEO_CAPTURE 的捕获模式
final
String
action
=
type
==
'video'
final
String
action
=
type
==
'video'
?
'android.media.action.VIDEO_CA
PTURE
'
?
'android.media.action.VIDEO_CA
MERA
'
:
'android.media.action.
IMAGE_CAPTURE
'
;
:
'android.media.action.
STILL_IMAGE_CAMERA
'
;
final
intent
=
AndroidIntent
(
action:
action
);
final
intent
=
AndroidIntent
(
action:
action
);
await
intent
.
launch
();
await
intent
.
launch
();
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment