chore: 清理项目中多余的示例、依赖和资源文件

本次提交删除了大量冗余的平台配置文件、示例项目构建产物、测试资源文件以及第三方插件的无关代码,包括:
1. 移除了fluttertoast、liquid_glass_easy等插件的全量示例项目文件
2. 删除了本地依赖的ohos模块缓存和构建配置
3. 清理了各种平台的图标、资源文件和gitignore配置
4. 调整了主项目安卓最小SDK版本配置
5. 添加了macos运行需要的权限配置
This commit is contained in:
Developer
2026-05-21 20:50:22 +08:00
parent fed86c0375
commit 1b1a3ef450
419 changed files with 3394 additions and 24439 deletions

View File

@@ -1,10 +1,10 @@
/// ============================================================
/// 闲言APP — Hive KV 存储封装
/// 创建时间: 2026-04-28
/// 更新时间: 2026-05-02
/// 作用: 基于 Hive 的高性能 KV 存储,替代部分 SharedPreferences
/// 上次更新: 修复init()内_migrateFromSharedPreferences自锁问题
/// ============================================================
// ============================================================
// 闲言APP — Hive KV 存储封装
// 创建时间: 2026-04-28
// 更新时间: 2026-05-21
// 作用: 基于 Hive 的高性能 KV 存储,替代部分 SharedPreferences
// 上次更新: 未初始化时读返回null写静默跳过防止鸿蒙端崩溃
// ============================================================
import 'dart:convert';
@@ -84,9 +84,10 @@ class AppKVStore {
}
}
static Box<dynamic> _box(String boxName) {
static Box<dynamic>? _box(String boxName) {
if (!_initialized) {
throw StateError('AppKVStore 未初始化,请先调用 AppKVStore.init()');
Log.w('AppKVStore 未初始化,跳过访问 $boxName');
return null;
}
return Hive.box<dynamic>(boxName);
}
@@ -98,29 +99,41 @@ class AppKVStore {
// ============================================================
static String? getString(String key) =>
_box(HiveBoxNames.app).get(key) as String?;
_box(HiveBoxNames.app)?.get(key) as String?;
static Future<void> setString(String key, String value) =>
_box(HiveBoxNames.app).put(key, value);
static Future<void> setString(String key, String value) {
final box = _box(HiveBoxNames.app);
if (box == null) return Future.value();
return box.put(key, value);
}
static int? getInt(String key) => _box(HiveBoxNames.app).get(key) as int?;
static int? getInt(String key) => _box(HiveBoxNames.app)?.get(key) as int?;
static Future<void> setInt(String key, int value) =>
_box(HiveBoxNames.app).put(key, value);
static Future<void> setInt(String key, int value) {
final box = _box(HiveBoxNames.app);
if (box == null) return Future.value();
return box.put(key, value);
}
static bool? getBool(String key) => _box(HiveBoxNames.app).get(key) as bool?;
static bool? getBool(String key) => _box(HiveBoxNames.app)?.get(key) as bool?;
static Future<void> setBool(String key, bool value) =>
_box(HiveBoxNames.app).put(key, value);
static Future<void> setBool(String key, bool value) {
final box = _box(HiveBoxNames.app);
if (box == null) return Future.value();
return box.put(key, value);
}
static double? getDouble(String key) =>
_box(HiveBoxNames.app).get(key) as double?;
_box(HiveBoxNames.app)?.get(key) as double?;
static Future<void> setDouble(String key, double value) =>
_box(HiveBoxNames.app).put(key, value);
static Future<void> setDouble(String key, double value) {
final box = _box(HiveBoxNames.app);
if (box == null) return Future.value();
return box.put(key, value);
}
static List<String>? getStringList(String key) {
final raw = _box(HiveBoxNames.app).get(key) as String?;
final raw = _box(HiveBoxNames.app)?.get(key) as String?;
if (raw == null || raw.isEmpty) return null;
try {
return List<String>.from(jsonDecode(raw) as List);
@@ -129,21 +142,27 @@ class AppKVStore {
}
}
static Future<void> setStringList(String key, List<String> value) =>
_box(HiveBoxNames.app).put(key, jsonEncode(value));
static Future<void> setStringList(String key, List<String> value) {
final box = _box(HiveBoxNames.app);
if (box == null) return Future.value();
return box.put(key, jsonEncode(value));
}
static Future<void> remove(String key, {String boxName = HiveBoxNames.app}) =>
_box(boxName).delete(key);
static Future<void> remove(String key, {String boxName = HiveBoxNames.app}) {
final box = _box(boxName);
if (box == null) return Future.value();
return box.delete(key);
}
static bool containsKey(String key, {String boxName = HiveBoxNames.app}) =>
_box(boxName).containsKey(key);
_box(boxName)?.containsKey(key) ?? false;
// ============================================================
// 搜索历史
// ============================================================
static List<String> getSearchHistory() {
final raw = _box(HiveBoxNames.searchHistory).get('list') as String?;
final raw = _box(HiveBoxNames.searchHistory)?.get('list') as String?;
if (raw == null || raw.isEmpty) return [];
try {
return List<String>.from(jsonDecode(raw) as List);
@@ -152,8 +171,11 @@ class AppKVStore {
}
}
static Future<void> setSearchHistory(List<String> history) =>
_box(HiveBoxNames.searchHistory).put('list', jsonEncode(history));
static Future<void> setSearchHistory(List<String> history) {
final box = _box(HiveBoxNames.searchHistory);
if (box == null) return Future.value();
return box.put('list', jsonEncode(history));
}
static Future<void> addSearchHistory(String keyword, {int maxCount = 30}) {
final list = getSearchHistory();
@@ -169,15 +191,18 @@ class AppKVStore {
return setSearchHistory(list);
}
static Future<void> clearSearchHistory() =>
_box(HiveBoxNames.searchHistory).clear();
static Future<void> clearSearchHistory() {
final box = _box(HiveBoxNames.searchHistory);
if (box == null) return Future.value();
return box.clear();
}
// ============================================================
// 工具使用统计
// ============================================================
static Map<String, dynamic> getToolUsageStats() {
final raw = _box(HiveBoxNames.toolUsage).get('stats') as String?;
final raw = _box(HiveBoxNames.toolUsage)?.get('stats') as String?;
if (raw == null || raw.isEmpty) return {};
try {
return Map<String, dynamic>.from(jsonDecode(raw) as Map);
@@ -186,8 +211,11 @@ class AppKVStore {
}
}
static Future<void> setToolUsageStats(Map<String, dynamic> stats) =>
_box(HiveBoxNames.toolUsage).put('stats', jsonEncode(stats));
static Future<void> setToolUsageStats(Map<String, dynamic> stats) {
final box = _box(HiveBoxNames.toolUsage);
if (box == null) return Future.value();
return box.put('stats', jsonEncode(stats));
}
static Future<void> incrementToolUsage(String toolId, String toolName) {
final stats = getToolUsageStats();
@@ -207,33 +235,50 @@ class AppKVStore {
return setToolUsageStats(stats);
}
static Future<void> clearToolUsageStats() =>
_box(HiveBoxNames.toolUsage).clear();
static Future<void> clearToolUsageStats() {
final box = _box(HiveBoxNames.toolUsage);
if (box == null) return Future.value();
return box.clear();
}
// ============================================================
// 用户偏好
// ============================================================
static String? getUserPref(String key) =>
_box(HiveBoxNames.userPrefs).get(key) as String?;
_box(HiveBoxNames.userPrefs)?.get(key) as String?;
static Future<void> setUserPref(String key, String value) =>
_box(HiveBoxNames.userPrefs).put(key, value);
static Future<void> setUserPref(String key, String value) {
final box = _box(HiveBoxNames.userPrefs);
if (box == null) return Future.value();
return box.put(key, value);
}
static Future<void> removeUserPref(String key) =>
_box(HiveBoxNames.userPrefs).delete(key);
static Future<void> removeUserPref(String key) {
final box = _box(HiveBoxNames.userPrefs);
if (box == null) return Future.value();
return box.delete(key);
}
static Future<void> clearUserPrefs() => _box(HiveBoxNames.userPrefs).clear();
static Future<void> clearUserPrefs() {
final box = _box(HiveBoxNames.userPrefs);
if (box == null) return Future.value();
return box.clear();
}
// ============================================================
// 全局清理
// ============================================================
static Future<void> clearAll() async {
await _box(HiveBoxNames.app).clear();
await _box(HiveBoxNames.searchHistory).clear();
await _box(HiveBoxNames.toolUsage).clear();
await _box(HiveBoxNames.userPrefs).clear();
final appBox = _box(HiveBoxNames.app);
final searchBox = _box(HiveBoxNames.searchHistory);
final toolBox = _box(HiveBoxNames.toolUsage);
final prefsBox = _box(HiveBoxNames.userPrefs);
if (appBox != null) await appBox.clear();
if (searchBox != null) await searchBox.clear();
if (toolBox != null) await toolBox.clear();
if (prefsBox != null) await prefsBox.clear();
Log.i('AppKVStore 全部数据已清理');
}
}