Skip to content

Commit c26c5f2

Browse files
committed
feat: collection update
1 parent b89b4c0 commit c26c5f2

14 files changed

Lines changed: 117 additions & 37 deletions

lib/constants/app_constants.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ class AppConstants {
2525
static const String defaultServerAddress = 'touchfish.xin';
2626
static const int defaultApiPort = 8080;
2727
static const int defaultTcpPort = 9090;
28+
static const bool defaultUseHttps = false;
2829
}

lib/l10n/app_en.arb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@
193193
"serverErrorInvalidAddress": "Invalid address",
194194
"serverErrorInvalidPort": "Port must be an integer between 0 and 65535",
195195
"serverErrorDuplicatePort": "Ports cannot be the same",
196-
196+
"serverUseHttps": "HTTPS",
197+
"serverUseHttpsOn": "Use encrypted connection",
198+
"serverUseHttpsOff": "Use unencrypted connection",
199+
197200
"navChat": "Chat",
198201
"navAnnouncement": "Announce",
199202
"navForum": "Forum",

lib/l10n/app_localizations.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,24 @@ abstract class AppLocalizations {
10421042
/// **'Ports cannot be the same'**
10431043
String get serverErrorDuplicatePort;
10441044

1045+
/// No description provided for @serverUseHttps.
1046+
///
1047+
/// In en, this message translates to:
1048+
/// **'HTTPS'**
1049+
String get serverUseHttps;
1050+
1051+
/// No description provided for @serverUseHttpsOn.
1052+
///
1053+
/// In en, this message translates to:
1054+
/// **'Use encrypted connection'**
1055+
String get serverUseHttpsOn;
1056+
1057+
/// No description provided for @serverUseHttpsOff.
1058+
///
1059+
/// In en, this message translates to:
1060+
/// **'Use unencrypted connection'**
1061+
String get serverUseHttpsOff;
1062+
10451063
/// No description provided for @navChat.
10461064
///
10471065
/// In en, this message translates to:

lib/l10n/app_localizations_en.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ class AppLocalizationsEn extends AppLocalizations {
509509
@override
510510
String get serverErrorDuplicatePort => 'Ports cannot be the same';
511511

512+
@override
513+
String get serverUseHttps => 'HTTPS';
514+
515+
@override
516+
String get serverUseHttpsOn => 'Use encrypted connection';
517+
518+
@override
519+
String get serverUseHttpsOff => 'Use unencrypted connection';
520+
512521
@override
513522
String get navChat => 'Chat';
514523

lib/l10n/app_localizations_och.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,15 @@ class AppLocalizationsOch extends AppLocalizations {
482482
@override
483483
String get serverErrorDuplicatePort => '端口不可複';
484484

485+
@override
486+
String get serverUseHttps => 'HTTPS';
487+
488+
@override
489+
String get serverUseHttpsOn => '以加密連接';
490+
491+
@override
492+
String get serverUseHttpsOff => '以明文連接';
493+
485494
@override
486495
String get navChat => '聊天';
487496

lib/l10n/app_localizations_zh.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,15 @@ class AppLocalizationsZh extends AppLocalizations {
482482
@override
483483
String get serverErrorDuplicatePort => '端口不能重复';
484484

485+
@override
486+
String get serverUseHttps => 'HTTPS';
487+
488+
@override
489+
String get serverUseHttpsOn => '使用加密连接';
490+
491+
@override
492+
String get serverUseHttpsOff => '使用非加密连接';
493+
485494
@override
486495
String get navChat => '聊天';
487496

lib/l10n/app_och.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@
179179
"serverErrorInvalidAddress": "地址無效",
180180
"serverErrorInvalidPort": "端口須為0至65535間之整數",
181181
"serverErrorDuplicatePort": "端口不可複",
182+
"serverUseHttps": "HTTPS",
183+
"serverUseHttpsOn": "以加密連接",
184+
"serverUseHttpsOff": "以明文連接",
182185

183186
"navChat": "聊天",
184187
"navAnnouncement": "公告",

lib/l10n/app_zh.arb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@
179179
"serverErrorInvalidAddress": "地址无效",
180180
"serverErrorInvalidPort": "端口需为0到65535间的整数",
181181
"serverErrorDuplicatePort": "端口不能重复",
182-
182+
"serverUseHttps": "HTTPS",
183+
"serverUseHttpsOn": "使用加密连接",
184+
"serverUseHttpsOff": "使用非加密连接",
185+
183186
"navChat": "聊天",
184187
"navAnnouncement": "公告",
185188
"navForum": "论坛",

lib/models/forum_model.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ class ForumPost {
191191
}
192192

193193
factory ForumPost.fromServerRow(String forumId, List<dynamic> row) {
194-
final ms = ((double.tryParse(row[4].toString()) ?? 0) * 1000).toInt();
194+
final ms = ((double.tryParse(row[5].toString()) ?? 0) * 1000).toInt();
195195
return ForumPost(
196-
id: row[0].toString(),
196+
id: row[1].toString(),
197197
forumId: forumId,
198-
authorUid: row[2].toString(),
199-
title: (row[1] as String?) ?? '',
200-
content: (row[3] as String?) ?? '',
198+
authorUid: row[3].toString(),
199+
title: (row[2] as String?) ?? '',
200+
content: (row[4] as String?) ?? '',
201201
isPinned: false,
202202
createdAt: DateTime.fromMillisecondsSinceEpoch(ms),
203203
updatedAt: DateTime.fromMillisecondsSinceEpoch(ms),

lib/models/user_profile.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ class UserProfile {
66
final String createTime; // 时间戳字符串
77
final String? personalSign; // 个性签名
88
final String? introduction; // 介绍
9-
final String? avatar;
9+
final String? _avatarBase;
10+
final int avatarVersion;
11+
12+
String? get avatar => _avatarBase != null ? '$_avatarBase?v=$avatarVersion' : null;
1013

1114
UserProfile({
1215
required this.uid,
@@ -16,8 +19,9 @@ class UserProfile {
1619
required this.createTime,
1720
this.personalSign,
1821
this.introduction,
19-
this.avatar,
20-
});
22+
String? avatar,
23+
this.avatarVersion = 0,
24+
}) : _avatarBase = avatar;
2125

2226
factory UserProfile.fromJson(Map<String, dynamic> json) {
2327
return UserProfile(
@@ -33,7 +37,8 @@ class UserProfile {
3337
}
3438

3539
factory UserProfile.fromServerJson(
36-
Map<String, dynamic> json, String avatarUrl) {
40+
Map<String, dynamic> json, String avatarUrl,
41+
{int avatarVersion = 0}) {
3742
return UserProfile(
3843
uid: json['uid'].toString(),
3944
username: json['username'] as String,
@@ -43,6 +48,7 @@ class UserProfile {
4348
personalSign: json['personal_sign'] as String?,
4449
introduction: json['introduction'] as String?,
4550
avatar: avatarUrl,
51+
avatarVersion: avatarVersion,
4652
);
4753
}
4854

@@ -55,7 +61,7 @@ class UserProfile {
5561
'create_time': createTime,
5662
if (personalSign != null) 'personal_sign': personalSign,
5763
if (introduction != null) 'introduction': introduction,
58-
if (avatar != null) 'avatar': avatar,
64+
if (_avatarBase != null) 'avatar': _avatarBase,
5965
};
6066
}
6167

0 commit comments

Comments
 (0)