基本完成

This commit is contained in:
zhutao
2025-08-28 16:27:56 +08:00
commit 5d7d233d2e
132 changed files with 6390 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
class Storage {
//存储数据
static Future<void> set(String key, dynamic value) async {
SharedPreferences sp = await SharedPreferences.getInstance();
if (value is String) {
sp.setString(key, value);
} else if (value is int) {
sp.setInt(key, value);
} else if (value is bool) {
sp.setBool(key, value);
} else if (value is double) {
sp.setDouble(key, value);
} else if (value is Map) {
String jsonStr = jsonEncode(value);
sp.setString(key, jsonStr);
}
}
//获取数据
static Future<dynamic> get(String key) async {
SharedPreferences sp = await SharedPreferences.getInstance();
var value = sp.get(key);
if (value is String) {
try {
return jsonDecode(value);
} catch (e) {
return value;
}
}
return value;
}
//删除数据
static Future<void> remove(key) async {
SharedPreferences sp = await SharedPreferences.getInstance();
sp.remove(key);
}
//判断键是否存在
static Future<bool> hasKey(String key) async {
SharedPreferences sp = await SharedPreferences.getInstance();
return sp.containsKey(key);
}
}

View File

@@ -0,0 +1,8 @@
enum OtherLoginType {
google('google'),
apple('apple');
const OtherLoginType(this.value);
final String value;
}

View File

@@ -0,0 +1,22 @@
enum SkinCheckStatus {
/// 正常
normal(1),
/// 警告
warning(2),
/// 危险
danger(3),
/// 未知
unknown(0);
final int value;
const SkinCheckStatus(this.value);
/// 根据 int 值返回对应的枚举,默认返回 online
static SkinCheckStatus fromValue(int value) {
return SkinCheckStatus.values.firstWhere((e) => e.value == value, orElse: () => SkinCheckStatus.unknown);
}
}