重构目录树

This commit is contained in:
Developer
2026-04-13 07:51:51 +08:00
parent 5150501643
commit a59f54567f
282 changed files with 7213 additions and 28292 deletions

23
scripts/test_qr_api.dart Normal file
View File

@@ -0,0 +1,23 @@
/*
* 测试 qr 包 API
*/
import 'package:qr/qr.dart';
void main() {
final qrCode = QrCode.fromData(
data: 'https://example.com',
errorCorrectLevel: QrErrorCorrectLevel.M,
);
print('Module count: ${qrCode.moduleCount}');
print('QR Code type: ${qrCode.runtimeType}');
// 检查可用的方法和属性
final mirror = reflect(qrCode);
final instance = mirror.type;
print('Available methods:');
for (final method in instance.declarations.keys) {
print(' - $method');
}
}

View File

@@ -0,0 +1,152 @@
/*
* 文件: test_recipe_code.dart
* 作用: 测试菜谱code字段验证二维码海报功能所需数据
* 创建: 2026-04-13
*/
import 'dart:convert';
import 'dart:io';
const String baseUrl = 'http://eat.wktyl.com/api';
Future<void> main() async {
final client = HttpClient();
print('=== 菜谱 Code 字段测试 ===\n');
// 测试1: detail接口是否返回code字段
print('📋 测试1: detail接口 code字段');
try {
final url = Uri.parse('$baseUrl/api.php?act=detail&id=32892');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final recipe = data['data'];
print(' ✅ 菜谱标题: ${recipe['title']}');
print(' ✅ Code字段: ${recipe['code']}');
print(' ✅ Pic_id: ${recipe['pic_id']}');
print(' ✅ Statistics: ${recipe['statistics']}');
} else {
print(' ❌ 接口返回错误: ${data['message']}');
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试2: full接口是否返回code字段
print('📋 测试2: full接口 code字段');
try {
final url = Uri.parse('$baseUrl/api.php?act=full&id=32892');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final recipe = data['data'];
print(' ✅ 菜谱标题: ${recipe['title']}');
print(' ✅ Code字段: ${recipe['code']}');
print(' ✅ Category: ${recipe['category']}');
print(' ✅ Allergens: ${recipe['allergens']}');
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试3: what_to_eat detail接口通过code查询
print('📋 测试3: what_to_eat detail接口 code查询');
try {
final url =
Uri.parse('$baseUrl/api_what_to_eat.php?act=detail&code=CP032892');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final recipe = data['data'];
print(' ✅ 通过code查询成功: ${recipe['title']}');
} else {
print(' ❌ code查询失败: ${data['message']}');
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试4: mini接口是否返回code字段
print('📋 测试4: mini接口 code字段');
try {
final url = Uri.parse('$baseUrl/api.php?act=mini&id=32892');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final recipe = data['data'];
print(' ✅ 菜谱标题: ${recipe['title']}');
print(' ✅ Code字段: ${recipe['code']}');
print(' ✅ 返回字段: ${recipe.keys.toList()}');
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试5: feed recommend接口
print('📋 测试5: feed recommend接口');
try {
final url = Uri.parse('$baseUrl/api_feed.php?act=recommend&page=1&limit=3');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final items = data['data'] as List;
print(' ✅ 推荐数量: ${items.length}');
for (final item in items) {
print(
' - ${item['title']} (code: ${item['code']}, views: ${item['statistics']?['view_count']})');
}
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试6: filter_apply接口每日菜单规划用
print('📋 测试6: filter_apply接口 三餐推荐');
for (final meal in ['早餐', '中餐', '晚餐']) {
try {
final url = Uri.parse(
'$baseUrl/api_what_to_eat.php?act=filter_apply&count=2&meal_time=$meal');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body);
if (data['code'] == 200) {
final items = data['data'] as List;
final titles = items.map((e) => e['title']).join(', ');
print('$meal: $titles');
}
} catch (e) {
print('$meal 请求失败: $e');
}
}
print('\n=== 测试完成 ===');
client.close();
}

View File

@@ -0,0 +1,153 @@
/*
* 文件: test_recipe_code_v2.dart
* 作用: 测试feed recommend和filter_apply接口的真实数据结构
* 创建: 2026-04-13
*/
import 'dart:convert';
import 'dart:io';
const String baseUrl = 'http://eat.wktyl.com/api';
Future<void> main() async {
final client = HttpClient();
// 测试1: feed recommend接口真实结构
print('📋 测试1: feed recommend接口');
try {
final url = Uri.parse('$baseUrl/api_feed.php?act=recommend&page=1&limit=3');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body) as Map<String, dynamic>;
if (data['code'] == 200) {
final d = data['data'];
if (d is List) {
print(' data是List, 长度: ${d.length}');
for (final item in d) {
print(' - ${(item as Map)['title']}');
}
} else if (d is Map) {
print(' data是Map, keys: ${d.keys.toList()}');
final items = d['items'] ?? d['list'] ?? d['recipes'];
if (items is List) {
print(' 列表字段长度: ${items.length}');
for (final item in items) {
print(' - ${(item as Map)['title']}');
}
} else {
print(' data内容: ${d.toString().substring(0, 200)}...');
}
}
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试2: filter_apply接口真实结构
print('📋 测试2: filter_apply接口');
try {
final url = Uri.parse(
'$baseUrl/api_what_to_eat.php?act=filter_apply&count=2&meal_time=早餐');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body) as Map<String, dynamic>;
if (data['code'] == 200) {
final d = data['data'];
if (d is List) {
print(' data是List, 长度: ${d.length}');
for (final item in d) {
print(' - ${(item as Map)['title']}');
}
} else if (d is Map) {
print(' data是Map, keys: ${d.keys.toList()}');
final items = d['items'] ?? d['list'] ?? d['recipes'];
if (items is List) {
print(' 列表字段长度: ${items.length}');
for (final item in items) {
print(' - ${(item as Map)['title']}');
}
} else {
print(' data内容: ${d.toString().substring(0, 300)}...');
}
}
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试3: filter_apply无meal_time参数
print('📋 测试3: filter_apply无meal_time');
try {
final url =
Uri.parse('$baseUrl/api_what_to_eat.php?act=filter_apply&count=3');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body) as Map<String, dynamic>;
if (data['code'] == 200) {
final d = data['data'];
if (d is List) {
print(' data是List, 长度: ${d.length}');
for (final item in d) {
print(' - ${(item as Map)['title']}');
}
} else if (d is Map) {
print(' data是Map, keys: ${d.keys.toList()}');
final items = d['items'] ?? d['list'] ?? d['recipes'];
if (items is List) {
print(' 列表字段长度: ${items.length}');
for (final item in items) {
print(' - ${(item as Map)['title']}');
}
} else {
print(' data内容: ${d.toString().substring(0, 300)}...');
}
}
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('');
// 测试4: filter_recipes接口 meal_time参数
print('📋 测试4: filter_recipes接口 meal_time参数');
try {
final url = Uri.parse(
'$baseUrl/api_filter.php?act=filter_recipes&meal_time=早餐&limit=3');
final request = await client.getUrl(url);
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
final data = json.decode(body) as Map<String, dynamic>;
if (data['code'] == 200) {
final d = data['data'];
if (d is Map) {
print(' data是Map, keys: ${d.keys.toList()}');
final items = d['items'] ?? d['list'];
if (items is List) {
print(' 列表长度: ${items.length}');
for (final item in items) {
print(' - ${(item as Map)['title']}');
}
}
} else if (d is List) {
print(' data是List, 长度: ${d.length}');
}
}
} catch (e) {
print(' ❌ 请求失败: $e');
}
print('\n=== 测试完成 ===');
client.close();
}