Skip to content

Commit 9114028

Browse files
committed
feat: 接入 TouchFish API
1 parent 9f74be0 commit 9114028

25 files changed

Lines changed: 1628 additions & 218 deletions

lib/l10n/app_en.arb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@
5252
"registerErrorPasswordMismatch": "Passwords do not match",
5353
"registerErrorVerificationCodeRequired": "Please enter verification code",
5454
"registerErrorVerificationCodeInvalid": "Verification code must be 6 digits",
55+
"loginErrorEmptyFields": "Please enter username and password",
56+
"loginErrorUserNotFound": "User not found",
57+
"loginErrorInvalidCredentials": "Incorrect password",
58+
"loginErrorNetwork": "Network error, please try again",
59+
"registerErrorCaptchaRequired": "Please enter the captcha",
60+
"registerCaptchaLoad": "Loading captcha...",
61+
"registerCaptchaCode": "Captcha",
62+
"registerCaptchaRefresh": "Refresh",
63+
"registerErrorFailed": "Registration failed, please try again",
64+
"registerConfirmInfo": "Confirm your registration details",
65+
"registerActivateFailed": "Activation failed, please check the code",
66+
"forumLoadFailed": "Failed to load forums",
67+
"forumPostLoadFailed": "Failed to load posts",
68+
"forumCommentFailed": "Failed to post comment",
69+
"forumPostFailed": "Failed to publish post",
70+
"userProfileNotFound": "User not found",
71+
"retry": "Retry",
5572

5673
"settingsTitle": "Settings",
5774
"settingsTooltip": "Settings",
@@ -213,6 +230,7 @@
213230
"profileEditChangeAvatar": "Change Avatar",
214231
"profileEditRemoveAvatar": "Remove Avatar",
215232
"profileEditUpdated": "Profile updated",
233+
"profileEditSaveFailed": "Failed to save some changes",
216234
"profileEditUsernameCannotChange": "Username cannot be changed",
217235

218236
"chatTabMessages": "Messages",

lib/l10n/app_localizations.dart

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,108 @@ abstract class AppLocalizations {
332332
/// **'Verification code must be 6 digits'**
333333
String get registerErrorVerificationCodeInvalid;
334334

335+
/// No description provided for @loginErrorEmptyFields.
336+
///
337+
/// In en, this message translates to:
338+
/// **'Please enter username and password'**
339+
String get loginErrorEmptyFields;
340+
341+
/// No description provided for @loginErrorUserNotFound.
342+
///
343+
/// In en, this message translates to:
344+
/// **'User not found'**
345+
String get loginErrorUserNotFound;
346+
347+
/// No description provided for @loginErrorInvalidCredentials.
348+
///
349+
/// In en, this message translates to:
350+
/// **'Incorrect password'**
351+
String get loginErrorInvalidCredentials;
352+
353+
/// No description provided for @loginErrorNetwork.
354+
///
355+
/// In en, this message translates to:
356+
/// **'Network error, please try again'**
357+
String get loginErrorNetwork;
358+
359+
/// No description provided for @registerErrorCaptchaRequired.
360+
///
361+
/// In en, this message translates to:
362+
/// **'Please enter the captcha'**
363+
String get registerErrorCaptchaRequired;
364+
365+
/// No description provided for @registerCaptchaLoad.
366+
///
367+
/// In en, this message translates to:
368+
/// **'Loading captcha...'**
369+
String get registerCaptchaLoad;
370+
371+
/// No description provided for @registerCaptchaCode.
372+
///
373+
/// In en, this message translates to:
374+
/// **'Captcha'**
375+
String get registerCaptchaCode;
376+
377+
/// No description provided for @registerCaptchaRefresh.
378+
///
379+
/// In en, this message translates to:
380+
/// **'Refresh'**
381+
String get registerCaptchaRefresh;
382+
383+
/// No description provided for @registerErrorFailed.
384+
///
385+
/// In en, this message translates to:
386+
/// **'Registration failed, please try again'**
387+
String get registerErrorFailed;
388+
389+
/// No description provided for @registerConfirmInfo.
390+
///
391+
/// In en, this message translates to:
392+
/// **'Confirm your registration details'**
393+
String get registerConfirmInfo;
394+
395+
/// No description provided for @registerActivateFailed.
396+
///
397+
/// In en, this message translates to:
398+
/// **'Activation failed, please check the code'**
399+
String get registerActivateFailed;
400+
401+
/// No description provided for @forumLoadFailed.
402+
///
403+
/// In en, this message translates to:
404+
/// **'Failed to load forums'**
405+
String get forumLoadFailed;
406+
407+
/// No description provided for @forumPostLoadFailed.
408+
///
409+
/// In en, this message translates to:
410+
/// **'Failed to load posts'**
411+
String get forumPostLoadFailed;
412+
413+
/// No description provided for @forumCommentFailed.
414+
///
415+
/// In en, this message translates to:
416+
/// **'Failed to post comment'**
417+
String get forumCommentFailed;
418+
419+
/// No description provided for @forumPostFailed.
420+
///
421+
/// In en, this message translates to:
422+
/// **'Failed to publish post'**
423+
String get forumPostFailed;
424+
425+
/// No description provided for @userProfileNotFound.
426+
///
427+
/// In en, this message translates to:
428+
/// **'User not found'**
429+
String get userProfileNotFound;
430+
431+
/// No description provided for @retry.
432+
///
433+
/// In en, this message translates to:
434+
/// **'Retry'**
435+
String get retry;
436+
335437
/// No description provided for @settingsTitle.
336438
///
337439
/// In en, this message translates to:
@@ -1142,6 +1244,12 @@ abstract class AppLocalizations {
11421244
/// **'Profile updated'**
11431245
String get profileEditUpdated;
11441246

1247+
/// No description provided for @profileEditSaveFailed.
1248+
///
1249+
/// In en, this message translates to:
1250+
/// **'Failed to save some changes'**
1251+
String get profileEditSaveFailed;
1252+
11451253
/// No description provided for @profileEditUsernameCannotChange.
11461254
///
11471255
/// In en, this message translates to:

lib/l10n/app_localizations_en.dart

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,58 @@ class AppLocalizationsEn extends AppLocalizations {
133133
String get registerErrorVerificationCodeInvalid =>
134134
'Verification code must be 6 digits';
135135

136+
@override
137+
String get loginErrorEmptyFields => 'Please enter username and password';
138+
139+
@override
140+
String get loginErrorUserNotFound => 'User not found';
141+
142+
@override
143+
String get loginErrorInvalidCredentials => 'Incorrect password';
144+
145+
@override
146+
String get loginErrorNetwork => 'Network error, please try again';
147+
148+
@override
149+
String get registerErrorCaptchaRequired => 'Please enter the captcha';
150+
151+
@override
152+
String get registerCaptchaLoad => 'Loading captcha...';
153+
154+
@override
155+
String get registerCaptchaCode => 'Captcha';
156+
157+
@override
158+
String get registerCaptchaRefresh => 'Refresh';
159+
160+
@override
161+
String get registerErrorFailed => 'Registration failed, please try again';
162+
163+
@override
164+
String get registerConfirmInfo => 'Confirm your registration details';
165+
166+
@override
167+
String get registerActivateFailed =>
168+
'Activation failed, please check the code';
169+
170+
@override
171+
String get forumLoadFailed => 'Failed to load forums';
172+
173+
@override
174+
String get forumPostLoadFailed => 'Failed to load posts';
175+
176+
@override
177+
String get forumCommentFailed => 'Failed to post comment';
178+
179+
@override
180+
String get forumPostFailed => 'Failed to publish post';
181+
182+
@override
183+
String get userProfileNotFound => 'User not found';
184+
185+
@override
186+
String get retry => 'Retry';
187+
136188
@override
137189
String get settingsTitle => 'Settings';
138190

@@ -558,6 +610,9 @@ class AppLocalizationsEn extends AppLocalizations {
558610
@override
559611
String get profileEditUpdated => 'Profile updated';
560612

613+
@override
614+
String get profileEditSaveFailed => 'Failed to save some changes';
615+
561616
@override
562617
String get profileEditUsernameCannotChange => 'Username cannot be changed';
563618

lib/l10n/app_localizations_zh.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,57 @@ class AppLocalizationsZh extends AppLocalizations {
126126
@override
127127
String get registerErrorVerificationCodeInvalid => '验证码必须是6位数字';
128128

129+
@override
130+
String get loginErrorEmptyFields => '请输入用户名和密码';
131+
132+
@override
133+
String get loginErrorUserNotFound => '用户不存在';
134+
135+
@override
136+
String get loginErrorInvalidCredentials => '密码错误';
137+
138+
@override
139+
String get loginErrorNetwork => '网络错误,请重试';
140+
141+
@override
142+
String get registerErrorCaptchaRequired => '请输入验证码';
143+
144+
@override
145+
String get registerCaptchaLoad => '正在加载验证码...';
146+
147+
@override
148+
String get registerCaptchaCode => '验证码';
149+
150+
@override
151+
String get registerCaptchaRefresh => '刷新';
152+
153+
@override
154+
String get registerErrorFailed => '注册失败,请重试';
155+
156+
@override
157+
String get registerConfirmInfo => '确认注册信息';
158+
159+
@override
160+
String get registerActivateFailed => '激活失败,请检查激活码';
161+
162+
@override
163+
String get forumLoadFailed => '加载论坛失败';
164+
165+
@override
166+
String get forumPostLoadFailed => '加载帖子失败';
167+
168+
@override
169+
String get forumCommentFailed => '评论发送失败';
170+
171+
@override
172+
String get forumPostFailed => '发布帖子失败';
173+
174+
@override
175+
String get userProfileNotFound => '用户不存在';
176+
177+
@override
178+
String get retry => '重试';
179+
129180
@override
130181
String get settingsTitle => '设置';
131182

@@ -533,6 +584,9 @@ class AppLocalizationsZh extends AppLocalizations {
533584
@override
534585
String get profileEditUpdated => '资料已更新';
535586

587+
@override
588+
String get profileEditSaveFailed => '部分修改保存失败';
589+
536590
@override
537591
String get profileEditUsernameCannotChange => '用户名不可更改';
538592

lib/l10n/app_zh.arb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@
4343
"registerErrorPasswordMismatch": "两次输入的密码不一致",
4444
"registerErrorVerificationCodeRequired": "请输入验证码",
4545
"registerErrorVerificationCodeInvalid": "验证码必须是6位数字",
46+
"loginErrorEmptyFields": "请输入用户名和密码",
47+
"loginErrorUserNotFound": "用户不存在",
48+
"loginErrorInvalidCredentials": "密码错误",
49+
"loginErrorNetwork": "网络错误,请重试",
50+
"registerErrorCaptchaRequired": "请输入验证码",
51+
"registerCaptchaLoad": "正在加载验证码...",
52+
"registerCaptchaCode": "验证码",
53+
"registerCaptchaRefresh": "刷新",
54+
"registerErrorFailed": "注册失败,请重试",
55+
"registerConfirmInfo": "确认注册信息",
56+
"registerActivateFailed": "激活失败,请检查激活码",
57+
"forumLoadFailed": "加载论坛失败",
58+
"forumPostLoadFailed": "加载帖子失败",
59+
"forumCommentFailed": "评论发送失败",
60+
"forumPostFailed": "发布帖子失败",
61+
"userProfileNotFound": "用户不存在",
62+
"retry": "重试",
4663

4764
"settingsTitle": "设置",
4865
"settingsTooltip": "设置",
@@ -199,6 +216,7 @@
199216
"profileEditChangeAvatar": "更改头像",
200217
"profileEditRemoveAvatar": "移除头像",
201218
"profileEditUpdated": "资料已更新",
219+
"profileEditSaveFailed": "部分修改保存失败",
202220
"profileEditUsernameCannotChange": "用户名不可更改",
203221

204222
"chatTabMessages": "聊天",

lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'l10n/app_localizations.dart';
99
import 'models/app_state.dart';
1010
import 'models/settings_service.dart';
1111
import 'routes/app_routes.dart';
12+
import 'services/auth_state.dart';
1213
import 'utils/talker.dart';
1314

1415
void main() async {
@@ -67,6 +68,9 @@ void main() async {
6768
final isFirstLaunch = prefs.getBool('isFirstLaunch') ?? true;
6869

6970
talker.info('TouchFish Client started!');
71+
AuthState.instance.init().catchError((e) {
72+
talker.error('AuthState.init error', e);
73+
});
7074

7175
runApp(TouchFishApp(isFirstLaunch: isFirstLaunch));
7276
}

lib/models/forum_model.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ class Forum {
3434
);
3535
}
3636

37+
factory Forum.fromServerRow(List<dynamic> row) {
38+
final ms = ((row[3] as num).toDouble() * 1000).toInt();
39+
return Forum(
40+
id: row[0].toString(),
41+
name: row[1] as String,
42+
description: (row[4] as String?) ?? '',
43+
isPublic: true,
44+
isCommunity: true,
45+
createdByUid: row[2].toString(),
46+
createdAt: DateTime.fromMillisecondsSinceEpoch(ms),
47+
updatedAt: DateTime.fromMillisecondsSinceEpoch(ms),
48+
);
49+
}
50+
3751
Map<String, dynamic> toJson() {
3852
return {
3953
'id': id,
@@ -124,6 +138,20 @@ class ForumPost {
124138
);
125139
}
126140

141+
factory ForumPost.fromServerRow(String forumId, List<dynamic> row) {
142+
final ms = ((row[4] as num).toDouble() * 1000).toInt();
143+
return ForumPost(
144+
id: row[0].toString(),
145+
forumId: forumId,
146+
authorUid: row[2].toString(),
147+
title: (row[1] as String?) ?? '',
148+
content: (row[3] as String?) ?? '',
149+
isPinned: false,
150+
createdAt: DateTime.fromMillisecondsSinceEpoch(ms),
151+
updatedAt: DateTime.fromMillisecondsSinceEpoch(ms),
152+
);
153+
}
154+
127155
Map<String, dynamic> toJson() {
128156
return {
129157
'id': id,

0 commit comments

Comments
 (0)