todo:send upsertuserall packet
This commit is contained in:
1 parent
2ad6781049
commit
2bf8030c37
6 files changed
+1660
-5
No files matched your search
+27
-2
@@ -4,6 +4,7 @@ class AppStrings {
|
||||
// Tab
|
||||
static const tabHome = '主页';
|
||||
static const tabTickets = '票据';
|
||||
static const tabTransfer = '传包';
|
||||
static const tabSettings = '设置';
|
||||
static const tabAbout = '关于';
|
||||
|
||||
@@ -116,6 +117,8 @@ class AppStrings {
|
||||
'冷却中,剩余 $remaining 秒';
|
||||
static String ticketCooldownNotice(int remaining) =>
|
||||
'登录后需冷却 $ticketCooldownSeconds 秒,剩余 $remaining 秒后可使用功能票。';
|
||||
static String packetCooldownNotice(int remaining) =>
|
||||
'登录后需冷却 $ticketCooldownSeconds 秒,剩余 $remaining 秒后可使用传包。';
|
||||
|
||||
// Settings
|
||||
static const titleServerSettings = 'Title Server 设置';
|
||||
@@ -124,7 +127,7 @@ class AppStrings {
|
||||
static const machineSettings = '机器信息';
|
||||
static const save = '保存';
|
||||
static const labelTitleServerUrl = 'Title Server URL';
|
||||
static const hintTitleServerUrl = 'https://maimai-gm.wahlap.com:42081/Maimai2Servlet/';
|
||||
static const hintTitleServerUrl = '';
|
||||
static const labelAesKey = 'AES Key';
|
||||
static const hintAesKey = 'your aes key string';
|
||||
static const labelAesIv = 'AES IV';
|
||||
@@ -146,7 +149,7 @@ class AppStrings {
|
||||
static const labelKeychipId = 'Keychip ID';
|
||||
static const hintKeychipId = 'ID';
|
||||
static const labelAimeUrl = 'Aime URL';
|
||||
static const hintAimeUrl = 'http://ai.sys-allnet.cn/wc_aime/api/get_data';
|
||||
static const hintAimeUrl = '';
|
||||
static const labelAimeSalt = 'Aime Salt';
|
||||
static const hintAimeSalt = 'API Key 派生用 Salt';
|
||||
static String fieldRequired(String label) => '$label 不能为空';
|
||||
@@ -160,6 +163,28 @@ class AppStrings {
|
||||
static const importFailed = '导入失败:剪贴板内容无效';
|
||||
static const noConfigToExport = '没有可导出的配置';
|
||||
|
||||
// Transfer Package (传包)
|
||||
static const transferTitle = '传包 (UpsertUserAll)';
|
||||
static const transferDesc = '拉取用户数据后,可修改角色槽位、锁定槽位和角色等级,然后传包回服务器。';
|
||||
static const transferFetchData = '拉取数据';
|
||||
static const transferFetching = '拉取中...';
|
||||
static const transferNotLoggedIn = '尚未登录游戏服务器,无法传包。';
|
||||
static const transferCharaSlot = '角色槽位 (charaSlot)';
|
||||
static const transferCharaLockSlot = '锁定槽位 (charaLockSlot)';
|
||||
static const transferCharacterLevels = '角色等级 (userCharacterList)';
|
||||
static const transferAddCharacter = '添加角色';
|
||||
static const transferCharacterId = '角色ID';
|
||||
static const transferLevel = '等级';
|
||||
static const transferAwakening = '觉醒';
|
||||
static const transferSend = '发送传包';
|
||||
static const transferSending = '发送中...';
|
||||
static const transferSuccess = '传包完成';
|
||||
static const transferFailed = '传包失败';
|
||||
static const transferSlotLabel = '槽位';
|
||||
static const transferNoData = '⚠️ 未拉取到用户数据,请先点「拉取数据」按钮获取。';
|
||||
static const transferDataLoaded = '数据已就绪,可在下方编辑后发送。';
|
||||
static const transferRemove = '移除';
|
||||
|
||||
// About
|
||||
static const aboutTitle = 'Project Ichino';
|
||||
static const aboutDesc = '基于 QR Code 的 maimai DX 街机网络登录客户端。';
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
class UserCharacter {
|
||||
int characterId;
|
||||
int level;
|
||||
int awakening;
|
||||
int useCount;
|
||||
|
||||
UserCharacter({
|
||||
required this.characterId,
|
||||
this.level = 1,
|
||||
this.awakening = 0,
|
||||
this.useCount = 0,
|
||||
});
|
||||
|
||||
factory UserCharacter.fromJson(Map<String, dynamic> json) {
|
||||
return UserCharacter(
|
||||
characterId: (json['characterId'] as num).toInt(),
|
||||
level: (json['level'] as num?)?.toInt() ?? 1,
|
||||
awakening: (json['awakening'] as num?)?.toInt() ?? 0,
|
||||
useCount: (json['useCount'] as num?)?.toInt() ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'characterId': characterId,
|
||||
'level': level,
|
||||
'awakening': awakening,
|
||||
'useCount': useCount,
|
||||
};
|
||||
}
|
||||
|
||||
/// The full UpsertUserAll API payload, constructed from fetched user data
|
||||
/// and editable fields (charaSlot, charaLockSlot, character levels).
|
||||
class UpsertUserAllPayload {
|
||||
final int userId;
|
||||
final int playlogId;
|
||||
final bool isEventMode;
|
||||
final bool isFreePlay;
|
||||
final int loginDateTime;
|
||||
|
||||
/// The entire [upsertUserAll] sub-object from the JSON.
|
||||
final Map<String, dynamic> upsertUserAll;
|
||||
|
||||
/// Editable character slots (5 elements).
|
||||
final List<int> charaSlot;
|
||||
|
||||
/// Editable locked character slots (5 elements).
|
||||
final List<int> charaLockSlot;
|
||||
|
||||
/// Editable character list.
|
||||
final List<UserCharacter> userCharacterList;
|
||||
|
||||
/// Minimal playlog entry (required — server rejects empty playlogList).
|
||||
final Map<String, dynamic>? userPlaylog;
|
||||
|
||||
const UpsertUserAllPayload({
|
||||
required this.userId,
|
||||
required this.playlogId,
|
||||
this.isEventMode = false,
|
||||
this.isFreePlay = false,
|
||||
required this.loginDateTime,
|
||||
required this.upsertUserAll,
|
||||
required this.charaSlot,
|
||||
required this.charaLockSlot,
|
||||
required this.userCharacterList,
|
||||
this.userPlaylog,
|
||||
});
|
||||
|
||||
/// Serialize to the JSON packet expected by UpsertUserAllApi.
|
||||
Map<String, dynamic> toJson() {
|
||||
final copy = Map<String, dynamic>.from(upsertUserAll);
|
||||
final userData = List<Map<String, dynamic>>.from(
|
||||
(copy['userData'] as List<dynamic>)
|
||||
.map((e) => Map<String, dynamic>.from(e as Map)),
|
||||
);
|
||||
userData[0]['charaSlot'] = charaSlot;
|
||||
userData[0]['charaLockSlot'] = charaLockSlot;
|
||||
copy['userData'] = userData;
|
||||
copy['userCharacterList'] =
|
||||
userCharacterList.map((c) => c.toJson()).toList();
|
||||
|
||||
return {
|
||||
'userId': userId,
|
||||
'playlogId': playlogId,
|
||||
'isEventMode': isEventMode,
|
||||
'isFreePlay': isFreePlay,
|
||||
'loginDateTime': loginDateTime,
|
||||
'userPlaylogList': userPlaylog != null ? [userPlaylog] : <dynamic>[],
|
||||
'upsertUserAll': copy,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../services/title_api_service.dart';
|
||||
import 'about_page.dart';
|
||||
import 'settings_page.dart';
|
||||
import 'ticket_page.dart';
|
||||
import 'transfer_package_page.dart';
|
||||
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@@ -42,6 +43,7 @@ class _HomePageState extends State<HomePage> {
|
||||
static const _tabTitles = [
|
||||
AppStrings.tabHome,
|
||||
AppStrings.tabTickets,
|
||||
AppStrings.tabTransfer,
|
||||
AppStrings.tabSettings,
|
||||
AppStrings.tabAbout,
|
||||
];
|
||||
@@ -184,8 +186,10 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
Future<void> _performLogoutAndExit() async {
|
||||
setState(() => _loggingOut = true);
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
await _logoutSession();
|
||||
if (_login != null) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
await _logoutSession();
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
@@ -227,6 +231,13 @@ class _HomePageState extends State<HomePage> {
|
||||
playerRating: _userData?.playerRating ?? _preview?.playerRating ?? 0,
|
||||
onLogoutRequested: _login != null ? _logoutSession : null,
|
||||
),
|
||||
TransferPackagePage(
|
||||
userId: widget.userId,
|
||||
cookies: _sessionCookies ?? widget.cookies,
|
||||
loginDateTime: _login?.loginDateTime,
|
||||
playlogId: _login?.loginId,
|
||||
lastLoginDate: _login?.lastLoginDate,
|
||||
),
|
||||
SettingsPage(showAppBar: false),
|
||||
const AboutPage(),
|
||||
],
|
||||
@@ -237,6 +248,7 @@ class _HomePageState extends State<HomePage> {
|
||||
destinations: const [
|
||||
NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home), label: AppStrings.tabHome),
|
||||
NavigationDestination(icon: Icon(Icons.confirmation_number_outlined), selectedIcon: Icon(Icons.confirmation_number), label: AppStrings.tabTickets),
|
||||
NavigationDestination(icon: Icon(Icons.inventory_2_outlined), selectedIcon: Icon(Icons.inventory_2), label: AppStrings.tabTransfer),
|
||||
NavigationDestination(icon: Icon(Icons.settings_outlined), selectedIcon: Icon(Icons.settings), label: AppStrings.tabSettings),
|
||||
NavigationDestination(icon: Icon(Icons.info_outlined), selectedIcon: Icon(Icons.info), label: AppStrings.tabAbout),
|
||||
],
|
||||
@@ -268,7 +280,7 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FilledButton.icon(
|
||||
onPressed: () => setState(() => _currentTab = 2),
|
||||
onPressed: () => setState(() => _currentTab = 3),
|
||||
icon: const Icon(Icons.settings, size: 20),
|
||||
label: const Text(AppStrings.openSettings),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Editable JSON fields that feed into the UpsertUserAll payload.
|
||||
/// Defaults match the Python script at E:\eaquira\sdgb\payload.py.
|
||||
class AdvancedFields {
|
||||
String userItemList;
|
||||
String userMapList;
|
||||
String userLoginBonusList;
|
||||
String userGetPointList;
|
||||
String userTradeItemList;
|
||||
|
||||
AdvancedFields({
|
||||
this.userItemList = '[]',
|
||||
this.userMapList = '[]',
|
||||
this.userLoginBonusList = '[]',
|
||||
this.userGetPointList = '[]',
|
||||
this.userTradeItemList = '[]',
|
||||
});
|
||||
|
||||
List<dynamic>? _parse(String src) {
|
||||
try {
|
||||
final decoded = jsonDecode(src);
|
||||
return decoded is List ? decoded : null;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> parsedUserItemList(String fb) => _parse(userItemList) ?? const [];
|
||||
List<dynamic> parsedUserMapList(String fb) => _parse(userMapList) ?? const [];
|
||||
List<dynamic> parsedUserLoginBonusList(String fb) => _parse(userLoginBonusList) ?? const [];
|
||||
List<dynamic> parsedUserGetPointList(String fb) => _parse(userGetPointList) ?? const [];
|
||||
List<dynamic> parsedUserTradeItemList(String fb) => _parse(userTradeItemList) ?? const [];
|
||||
|
||||
Map<String, String> toJson() => {
|
||||
'userItemList': userItemList,
|
||||
'userMapList': userMapList,
|
||||
'userLoginBonusList': userLoginBonusList,
|
||||
'userGetPointList': userGetPointList,
|
||||
'userTradeItemList': userTradeItemList,
|
||||
};
|
||||
|
||||
factory AdvancedFields.fromJson(Map<String, String> json) {
|
||||
return AdvancedFields(
|
||||
userItemList: json['userItemList'] ?? '[]',
|
||||
userMapList: json['userMapList'] ?? '[]',
|
||||
userLoginBonusList: json['userLoginBonusList'] ?? '[]',
|
||||
userGetPointList: json['userGetPointList'] ?? '[]',
|
||||
userTradeItemList: json['userTradeItemList'] ?? '[]',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Page that lets users paste raw JSON for advanced UpsertUserAll fields.
|
||||
class TransferAdvancedPage extends StatefulWidget {
|
||||
final AdvancedFields initial;
|
||||
|
||||
const TransferAdvancedPage({
|
||||
super.key,
|
||||
required this.initial,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TransferAdvancedPage> createState() => _TransferAdvancedPageState();
|
||||
}
|
||||
|
||||
class _TransferAdvancedPageState extends State<TransferAdvancedPage> {
|
||||
late final List<_FieldMeta> _fields;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fields = [
|
||||
_FieldMeta('userItemList', '物品列表', widget.initial.userItemList),
|
||||
_FieldMeta('userMapList', '地图列表', widget.initial.userMapList),
|
||||
_FieldMeta('userLoginBonusList', '登录奖励', widget.initial.userLoginBonusList),
|
||||
_FieldMeta('userGetPointList', '获取点数', widget.initial.userGetPointList),
|
||||
_FieldMeta('userTradeItemList', '交易物品', widget.initial.userTradeItemList),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final f in _fields) {
|
||||
f.ctrl.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
AdvancedFields get values => AdvancedFields(
|
||||
userItemList: _fields[0].ctrl.text,
|
||||
userMapList: _fields[1].ctrl.text,
|
||||
userLoginBonusList: _fields[2].ctrl.text,
|
||||
userGetPointList: _fields[3].ctrl.text,
|
||||
userTradeItemList: _fields[4].ctrl.text,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('高级字段'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.check),
|
||||
tooltip: '保存并返回',
|
||||
onPressed: () => Navigator.of(context).pop(values),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
'以下字段默认来自 Python 脚本 (空数组 [] )。如需覆盖,请粘贴完整 JSON 数组。错误格式将回退为 []。',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: Colors.orange.shade800,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
for (final field in _fields) _buildFieldCard(theme, field),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFieldCard(ThemeData theme, _FieldMeta field) {
|
||||
return Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(
|
||||
color: theme.colorScheme.outline.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
field.label,
|
||||
style: theme.textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
field.ctrl.text = '[]';
|
||||
},
|
||||
child: Text('重置', style: theme.textTheme.labelSmall),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
controller: field.ctrl,
|
||||
maxLines: 6,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 12,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
contentPadding: const EdgeInsets.all(10),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FieldMeta {
|
||||
final String key;
|
||||
final String label;
|
||||
final TextEditingController ctrl;
|
||||
|
||||
_FieldMeta(this.key, this.label, String initial)
|
||||
: ctrl = TextEditingController(text: initial);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -510,6 +510,56 @@ class TitleApiService {
|
||||
return '${dt.year}-${dt.month.toString().padLeft(2, '0')}-${dt.day.toString().padLeft(2, '0')} '
|
||||
'${dt.hour.toString().padLeft(2, '0')}:${dt.minute.toString().padLeft(2, '0')}:${dt.second.toString().padLeft(2, '0')}.0';
|
||||
}
|
||||
|
||||
// ---- UpsertUserAll (传包) ----
|
||||
|
||||
/// Fetch all user data needed to build an UpsertUserAll payload.
|
||||
/// Returns a map keyed by the raw API names (e.g. 'GetUserDataApi').
|
||||
Future<Map<String, Map<String, dynamic>>> fetchUserAllData(int userId) async {
|
||||
final results = await Future.wait([
|
||||
getUserData(userId),
|
||||
getUserExtend(userId),
|
||||
getUserOption(userId),
|
||||
getUserRating(userId),
|
||||
getUserCharge(userId),
|
||||
getUserActivity(userId),
|
||||
getUserMissionData(userId),
|
||||
]);
|
||||
|
||||
return {
|
||||
'GetUserDataApi': results[0],
|
||||
'GetUserExtendApi': results[1],
|
||||
'GetUserOptionApi': results[2],
|
||||
'GetUserRatingApi': results[3],
|
||||
'GetUserChargeApi': results[4],
|
||||
'GetUserActivityApi': results[5],
|
||||
'GetUserMissionDataApi': results[6],
|
||||
};
|
||||
}
|
||||
|
||||
/// Send an UpsertUserAll payload to the server.
|
||||
Future<void> upsertUserAll(
|
||||
Map<String, dynamic> packet,
|
||||
int userId,
|
||||
) async {
|
||||
const apiName = 'UpsertUserAllApi';
|
||||
final json = await _callApi(apiName, packet, userId);
|
||||
final returnCode = json['returnCode'] as int? ?? -1;
|
||||
if (returnCode != 1) {
|
||||
throw TitleApiException('UpsertUserAllApi returnCode=$returnCode');
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetch user character list.
|
||||
Future<List<Map<String, dynamic>>> getUserCharacter(int userId) async {
|
||||
final json = await _callApi(
|
||||
'GetUserCharacterApi',
|
||||
{'userId': userId},
|
||||
userId,
|
||||
);
|
||||
final list = json['userCharacterList'] as List<dynamic>? ?? [];
|
||||
return list.map((e) => e as Map<String, dynamic>).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class _RandomHelper {
|
||||
|
||||
Reference in new issue
Block a user