此提交包含多项变更: 1. 新增鸿蒙平台支持,完善设备检测与数据库适配 2. 替换旧版分享插件API为SharePlus 3. 批量迁移StateNotifier到Notifier以适配新版Riverpod 4. 修复zip编码判断、图表API参数等bug 5. 更新应用图标、启动页资源与多尺寸适配图标 6. 调整Android最小SDK版本与应用名称 7. 优化日志打印与正则表达式使用 8. 修正编辑器画布样式初始化与配置逻辑 9. 更新依赖与CI插件配置
52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
/// ============================================================
|
||
/// 闲言APP — 鸿蒙剪贴板桥接工具
|
||
/// 创建时间: 2026-05-17
|
||
/// 更新时间: 2026-05-17
|
||
/// 作用: 在鸿蒙平台上通过原生MethodChannel读取剪贴板,
|
||
/// 替代Flutter Clipboard.getData以避免READ_PASTEBOARD受限ACL权限
|
||
/// 上次更新: 修复_isOhos检测逻辑,使用platform_utils.isOhos
|
||
/// ============================================================
|
||
|
||
import 'package:flutter/services.dart';
|
||
import 'package:xianyan/core/utils/platform_utils.dart' as pu;
|
||
|
||
class ClipboardBridge {
|
||
ClipboardBridge._();
|
||
|
||
static const _channel = MethodChannel('plugins.flutter.io/clipboard_ohos');
|
||
|
||
static bool get _isOhos => pu.isOhos;
|
||
|
||
static Future<String?> getData() async {
|
||
if (_isOhos) {
|
||
try {
|
||
final result = await _channel.invokeMethod<String>('Clipboard.getData');
|
||
return result;
|
||
} on MissingPluginException {
|
||
// ohos channel not available, fallback
|
||
} on PlatformException {
|
||
// permission or other error, fallback
|
||
}
|
||
}
|
||
final data = await Clipboard.getData(Clipboard.kTextPlain);
|
||
return data?.text;
|
||
}
|
||
|
||
static Future<bool> hasStrings() async {
|
||
if (_isOhos) {
|
||
try {
|
||
final result = await _channel.invokeMethod<bool>(
|
||
'Clipboard.hasStrings',
|
||
);
|
||
return result ?? false;
|
||
} on MissingPluginException {
|
||
// fallback
|
||
} on PlatformException {
|
||
// fallback
|
||
}
|
||
}
|
||
final data = await Clipboard.getData(Clipboard.kTextPlain);
|
||
return data?.text?.isNotEmpty ?? false;
|
||
}
|
||
}
|