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 54b39c5d
authored
2026-04-27 17:26:18 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
showAppMenu, getDeviceInfo
1 parent
7a995230
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
9 deletions
lib/config/locator.dart
lib/data/repositories/message/app_menu_handler.dart
lib/data/repositories/message/device_info_handler.dart
lib/config/locator.dart
View file @
54b39c5
...
@@ -2,6 +2,7 @@ import 'dart:io' show Platform;
...
@@ -2,6 +2,7 @@ import 'dart:io' show Platform;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/data/repositories/message/app_info_handler.dart'
;
import
'package:appframe/data/repositories/message/app_info_handler.dart'
;
import
'package:appframe/data/repositories/message/app_menu_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_player_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_player_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_recorder_handler.dart'
;
import
'package:appframe/data/repositories/message/audio_recorder_handler.dart'
;
import
'package:appframe/data/repositories/message/choose_file_handler.dart'
;
import
'package:appframe/data/repositories/message/choose_file_handler.dart'
;
...
@@ -104,6 +105,9 @@ Future<void> setupLocator() async {
...
@@ -104,6 +105,9 @@ Future<void> setupLocator() async {
/// 窗口信息
/// 窗口信息
getIt
.
registerLazySingleton
<
MessageHandler
>(()
=>
WindowInfoHandler
(),
instanceName:
'getWindowInfo'
);
getIt
.
registerLazySingleton
<
MessageHandler
>(()
=>
WindowInfoHandler
(),
instanceName:
'getWindowInfo'
);
/// 显示应用菜单
getIt
.
registerLazySingleton
<
MessageHandler
>(()
=>
AppMenuHandler
(),
instanceName:
'showAppMenu'
);
/// 本地缓存
/// 本地缓存
// Android已测试通过
// Android已测试通过
getIt
.
registerLazySingleton
<
MessageHandler
>(()
=>
GetStorageHandler
(),
instanceName:
'getStorage'
);
getIt
.
registerLazySingleton
<
MessageHandler
>(()
=>
GetStorageHandler
(),
instanceName:
'getStorage'
);
...
...
lib/data/repositories/message/app_menu_handler.dart
0 → 100644
View file @
54b39c5
import
'package:appframe/config/routes.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
class
AppMenuHandler
extends
MessageHandler
{
@override
Future
<
dynamic
>
handleMessage
(
params
)
async
{
router
.
push
(
'/setting'
);
return
true
;
}
}
lib/data/repositories/message/device_info_handler.dart
View file @
54b39c5
import
'dart:io'
;
import
'dart:io'
;
import
'dart:ui'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:device_info_plus/device_info_plus.dart'
;
import
'package:device_info_plus/device_info_plus.dart'
;
...
@@ -6,9 +7,11 @@ import 'package:device_info_plus/device_info_plus.dart';
...
@@ -6,9 +7,11 @@ import 'package:device_info_plus/device_info_plus.dart';
class
DeviceInfoHandler
extends
MessageHandler
{
class
DeviceInfoHandler
extends
MessageHandler
{
@override
@override
Future
<
Map
<
String
,
dynamic
>>
handleMessage
(
dynamic
params
)
async
{
Future
<
Map
<
String
,
dynamic
>>
handleMessage
(
dynamic
params
)
async
{
var
deviceInfoPlugin
=
DeviceInfoPlugin
();
var
viewPadding
=
PlatformDispatcher
.
instance
.
views
.
first
.
viewPadding
;
var
devicePixelRatio
=
PlatformDispatcher
.
instance
.
views
.
first
.
devicePixelRatio
;
var
statusBarHeight
=
viewPadding
.
top
/
devicePixelRatio
;
// 测试效果,先随便响应一些数据
var
deviceInfoPlugin
=
DeviceInfoPlugin
();
if
(
Platform
.
isAndroid
)
{
if
(
Platform
.
isAndroid
)
{
AndroidDeviceInfo
androidInfo
=
await
deviceInfoPlugin
.
androidInfo
;
AndroidDeviceInfo
androidInfo
=
await
deviceInfoPlugin
.
androidInfo
;
return
{
return
{
...
@@ -18,21 +21,48 @@ class DeviceInfoHandler extends MessageHandler {
...
@@ -18,21 +21,48 @@ class DeviceInfoHandler extends MessageHandler {
'brand'
:
androidInfo
.
brand
,
'brand'
:
androidInfo
.
brand
,
'model'
:
androidInfo
.
model
,
'model'
:
androidInfo
.
model
,
'system'
:
androidInfo
.
version
.
release
,
'system'
:
androidInfo
.
version
.
release
,
'platform'
:
"Android"
,
'platform'
:
'Android'
,
'cpuType'
:
androidInfo
.
hardware
,
'cpuType'
:
androidInfo
.
hardware
,
"memorySize"
:
androidInfo
.
physicalRamSize
,
'memorySize'
:
_getAndroidMemorySize
(
androidInfo
),
'statusBarHeight'
:
statusBarHeight
,
};
};
}
else
if
(
Platform
.
isIOS
)
{
}
else
if
(
Platform
.
isIOS
)
{
IosDeviceInfo
iosInfo
=
await
deviceInfoPlugin
.
iosInfo
;
IosDeviceInfo
iosInfo
=
await
deviceInfoPlugin
.
iosInfo
;
return
{
return
{
"brand"
:
"Apple"
,
'abi'
:
''
,
"model"
:
iosInfo
.
model
,
'deviceAbi'
:
''
,
"system"
:
iosInfo
.
systemVersion
,
'benchmarkLevel'
:
-
1
,
"platform"
:
"iOS"
,
'brand'
:
'Apple'
,
"memorySize"
:
(
iosInfo
.
physicalRamSize
~/
(
1024
*
1024
)).
toString
(),
'model'
:
iosInfo
.
model
,
'system'
:
iosInfo
.
systemVersion
,
'platform'
:
'iOS'
,
'cpuType'
:
''
,
'memorySize'
:
(
iosInfo
.
physicalRamSize
~/
(
1024
*
1024
)).
toString
(),
'statusBarHeight'
:
statusBarHeight
,
};
};
}
else
{
}
else
{
return
{};
return
{};
}
}
}
}
String
_getAndroidMemorySize
(
AndroidDeviceInfo
info
)
{
try
{
final
file
=
File
(
'/proc/meminfo'
);
final
lines
=
file
.
readAsLinesSync
();
for
(
final
line
in
lines
)
{
if
(
line
.
startsWith
(
'MemTotal:'
))
{
final
parts
=
line
.
trim
().
split
(
RegExp
(
r'\s+'
));
if
(
parts
.
length
>=
2
)
{
final
kb
=
int
.
tryParse
(
parts
[
1
]);
if
(
kb
!=
null
)
{
return
(
kb
~/
1024
).
toString
();
}
}
}
}
}
catch
(
_
)
{}
final
raw
=
info
.
physicalRamSize
;
return
raw
.
toString
();
}
}
}
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