Skip to content

Commit 90412c2

Browse files
author
liuchuancong
committed
fix(*)
1 parent e74b849 commit 90412c2

9 files changed

Lines changed: 160 additions & 92 deletions

File tree

assets/translations/en.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@
570570
"timeout": "Recording failed: Connection to the live server timed out. Please check your network or proxy settings.",
571571
"invalid_stream_format": "Recording failed: The input stream URL format is invalid and cannot be opened.",
572572
"unknown_error": "Recording error: An unknown exception occurred, raw log: \"{error_log}\"",
573-
"supabase_sign_in": "Sign In",
573+
"supabase_sign_in": "Sign In",
574574
"supabase_sign_up": "Sign Up",
575575
"supabase_sign_success": "Sign in successful!",
576576
"supabase_sign_failure": "Sign in failure!",
@@ -592,5 +592,22 @@
592592
"supabase_reset_password": "Send password reset email",
593593

594594
"supabase_back_sign_in": "Back to sign in",
595-
"supabase_update_password": "Update Password"
595+
"supabase_update_password": "Update Password",
596+
"supabase_account_unauthorized": "Account Unauthorized",
597+
"no_data": "No data available",
598+
"allow_user_uploads": "Allow user uploads",
599+
"download_user_configs": "Download user configs",
600+
"manage_users": "Manage users",
601+
"reset_password_email": "Please open your email to reset your password",
602+
"hint_text": "Please enter an email address",
603+
"add_btn": "Add",
604+
"user_count": "{count} users added (Click to remove)",
605+
"invalid_email": "Please enter a valid email address",
606+
"email_exists": "Email address already exists",
607+
"add_success": "Added successfully",
608+
"add_failed": "Failed to add, please try again later",
609+
"delete_success": "Deleted successfully",
610+
"delete_failed": "Failed to delete, please try again later",
611+
"download_failed": "Download failed, please try again later",
612+
"download_success": "Downloaded successfully"
596613
}

assets/translations/zh.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,22 @@
591591
"supabase_has_account": "已有帐户? 登录",
592592
"supabase_reset_password": "重置邮箱密码",
593593
"supabase_back_sign_in": "返回登录",
594-
"supabase_update_password": "更新密码"
595-
594+
"supabase_update_password": "更新密码",
595+
"supabase_account_unauthorized": "账号未授权",
596+
"no_data": "无数据",
597+
"allow_user_uploads": "允许用户上传配置文件",
598+
"download_user_configs": "下载用户配置",
599+
"manage_users": "管理用户",
600+
"reset_password_email": "请打开邮箱重置密码",
601+
"hint_text": "请输入邮箱",
602+
"add_btn": "添加",
603+
"user_count": "已添加 {count} 个用户(点击移除)",
604+
"invalid_email": "请输入正确的邮箱",
605+
"email_exists": "邮箱已存在",
606+
"add_success": "添加成功",
607+
"add_failed": "添加失败,请稍后重试",
608+
"delete_success": "删除成功",
609+
"delete_failed": "删除失败,请稍后重试",
610+
"download_failed": "下载失败,请稍后重试",
611+
"download_success": "下载成功"
596612
}

lib/common/widgets/menu_button.dart

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import 'package:get/get.dart';
22
import 'package:pure_live/common/index.dart';
3+
import 'package:pure_live/modules/auth/auth_controller.dart';
34

4-
class MenuButton extends StatelessWidget {
5+
class MenuButton extends GetView<AuthController> {
56
const MenuButton({super.key});
67

7-
final menuRoutes = const [RoutePath.kSettingsAccount, RoutePath.kSettings, RoutePath.kAbout, RoutePath.kHistory];
8+
final menuRoutes = const [
9+
RoutePath.kSignIn,
10+
RoutePath.kSettingsAccount,
11+
RoutePath.kSettings,
12+
RoutePath.kAbout,
13+
RoutePath.kHistory,
14+
];
815

916
@override
1017
Widget build(BuildContext context) {
@@ -15,27 +22,43 @@ class MenuButton extends StatelessWidget {
1522
position: PopupMenuPosition.under,
1623
icon: const Icon(Icons.menu_rounded),
1724
onSelected: (int index) {
18-
Get.toNamed(menuRoutes[index]);
25+
if (index == 0) {
26+
if (controller.isLogin) {
27+
Get.toNamed(RoutePath.kMine);
28+
} else {
29+
Get.toNamed(RoutePath.kSignIn);
30+
}
31+
} else {
32+
Get.toNamed(menuRoutes[index]);
33+
}
1934
},
2035
itemBuilder: (context) => [
2136
PopupMenuItem(
2237
value: 0,
2338
padding: const EdgeInsets.symmetric(horizontal: 12),
24-
child: MenuListTile(leading: const Icon(Icons.assignment_ind_sharp), text: i18n('third_party_auth')),
39+
child: MenuListTile(
40+
leading: const Icon(Icons.account_circle),
41+
text: controller.isLogin ? i18n('supabase_mine') : i18n('supabase_sign_in'),
42+
),
2543
),
2644
PopupMenuItem(
2745
value: 1,
2846
padding: const EdgeInsets.symmetric(horizontal: 12),
29-
child: MenuListTile(leading: const Icon(Icons.settings_rounded), text: i18n("settings_title")),
47+
child: MenuListTile(leading: const Icon(Icons.assignment_ind_sharp), text: i18n('third_party_auth')),
3048
),
3149
PopupMenuItem(
3250
value: 2,
3351
padding: const EdgeInsets.symmetric(horizontal: 12),
52+
child: MenuListTile(leading: const Icon(Icons.settings_rounded), text: i18n("settings_title")),
53+
),
54+
PopupMenuItem(
55+
value: 3,
56+
padding: const EdgeInsets.symmetric(horizontal: 12),
3457
child: MenuListTile(leading: const Icon(Icons.info_rounded), text: i18n("about")),
3558
),
3659

3760
PopupMenuItem(
38-
value: 3,
61+
value: 4,
3962
padding: const EdgeInsets.symmetric(horizontal: 12),
4063
child: MenuListTile(leading: const Icon(Icons.history), text: i18n("history")),
4164
),

lib/modules/auth/components/update_password.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class UpdatePassword extends StatelessWidget {
1111
@override
1212
Widget build(BuildContext context) {
1313
return Scaffold(
14-
appBar: appBar('更新密码'),
14+
appBar: appBar(i18n('supabase_update_password')),
1515
body: Padding(
1616
padding: const EdgeInsets.all(24.0),
1717
child: Column(

lib/modules/auth/mine_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class _MinePageState extends State<MinePage> {
4343
if (isManager())
4444
ListTile(
4545
leading: const Icon(Icons.verified_user_outlined, size: 32),
46-
subtitle: const Text("允许用户是否可以上传"),
47-
title: const Text("用户管理"),
46+
subtitle: Text(i18n('allow_user_uploads')),
47+
title: Text(i18n('manage_users')),
4848
onTap: () => Get.toNamed(RoutePath.kUserManage),
4949
),
5050
ListTile(
5151
leading: const Icon(Icons.sim_card_download_outlined, size: 32),
5252
subtitle: Text(i18n('supabase_mine_streams')),
53-
title: const Text('下载用户配置'),
53+
title: Text(i18n('download_user_configs')),
5454
onTap: downloadUserConifg,
5555
),
5656
ListTile(

lib/modules/auth/sign_in_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class _SignInPageState extends State<SignInPage> {
2828
onPasswordResetEmailSent: () {
2929
final AuthController authController = Get.find<AuthController>();
3030
authController.shouldGoReset = true;
31-
ToastUtil.show('请打开邮箱重置密码');
31+
ToastUtil.show(i18n('reset_password_email'));
3232
},
3333
onSignInComplete: (AuthResponse response) {
3434
ToastUtil.show(i18n('supabase_sign_success'));

lib/modules/auth/user_manage_page.dart

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ class _UserManagerState extends State<UserManager> {
1616
Color get themeColor => HexColor(settingsController.themeColorSwitch.value);
1717
final refreshController = EasyRefreshController(controlFinishRefresh: true, controlFinishLoad: true);
1818

19-
Future onRefresh() async {
20-
getCurrentUsers();
21-
refreshController.finishRefresh(IndicatorResult.success);
22-
}
19+
final users = <String>[].obs;
2320

24-
final users = [].obs;
2521
@override
2622
void initState() {
2723
getCurrentUsers();
2824
super.initState();
2925
}
3026

27+
Future onRefresh() async {
28+
await getCurrentUsers();
29+
refreshController.finishRefresh(IndicatorResult.success);
30+
}
31+
3132
Future<void> getCurrentUsers() async {
3233
List<dynamic> data = await SupaBaseManager().client.from(SupaBaseManager.supabasePolicy.checkTable).select();
3334
if (data.isNotEmpty) {
@@ -36,24 +37,26 @@ class _UserManagerState extends State<UserManager> {
3637
}
3738

3839
void addUser() {
39-
if (textEditingController.text.isEmpty || !EmailValidator.validate(textEditingController.text)) {
40-
ToastUtil.show('请输入正确的邮箱');
40+
final text = textEditingController.text.trim();
41+
if (text.isEmpty || !EmailValidator.validate(text)) {
42+
ToastUtil.show(i18n('invalid_email'));
4143
return;
4244
}
43-
if (users.contains(textEditingController.text.trim())) {
44-
ToastUtil.show('邮箱已存在');
45+
if (users.contains(text)) {
46+
ToastUtil.show(i18n('email_exists'));
4547
return;
4648
}
4749
SupaBaseManager().client
4850
.from(SupaBaseManager.supabasePolicy.checkTable)
49-
.insert({SupaBaseManager.supabasePolicy.email: textEditingController.text.trim()})
51+
.insert({SupaBaseManager.supabasePolicy.email: text})
5052
.then(
5153
(value) {
52-
ToastUtil.show('添加成功');
53-
users.add(textEditingController.text.trim());
54+
ToastUtil.show(i18n('add_success'));
55+
users.add(text);
56+
textEditingController.clear();
5457
},
5558
onError: (err) {
56-
ToastUtil.show('添加失败,请稍后重试');
59+
ToastUtil.show(i18n('add_failed'));
5760
},
5861
);
5962
}
@@ -65,73 +68,74 @@ class _UserManagerState extends State<UserManager> {
6568
.eq(SupaBaseManager.supabasePolicy.email, email)
6669
.then(
6770
(value) {
68-
ToastUtil.show('删除成功');
71+
ToastUtil.show(i18n('delete_success'));
6972
users.removeAt(index);
7073
},
7174
onError: (err) {
72-
ToastUtil.show('删除失败,请稍后重试');
75+
ToastUtil.show(i18n('delete_failed'));
7376
},
7477
);
7578
}
7679

7780
@override
7881
Widget build(BuildContext context) {
7982
return Scaffold(
80-
appBar: AppBar(title: const Text('用户管理')),
81-
body: Obx(
82-
() => EasyRefresh(
83-
controller: refreshController,
84-
onRefresh: onRefresh,
85-
onLoad: () {
86-
refreshController.finishLoad(IndicatorResult.success);
87-
},
88-
child: ListView(
89-
padding: const EdgeInsets.all(24.0),
90-
children: [
91-
TextField(
92-
keyboardType: TextInputType.emailAddress,
93-
controller: textEditingController,
94-
decoration: InputDecoration(
95-
prefixIcon: const Icon(Icons.email),
96-
contentPadding: const EdgeInsets.all(12.0),
97-
border: OutlineInputBorder(borderSide: BorderSide(color: themeColor)),
98-
hintText: "请输入邮箱",
99-
suffixIcon: TextButton.icon(onPressed: addUser, icon: const Icon(Icons.add), label: const Text("添加")),
83+
appBar: AppBar(title: Text(i18n('manage_users'))),
84+
body: EasyRefresh(
85+
controller: refreshController,
86+
onRefresh: onRefresh,
87+
onLoad: () {
88+
refreshController.finishLoad(IndicatorResult.success);
89+
},
90+
child: ListView(
91+
padding: const EdgeInsets.all(24.0),
92+
children: [
93+
TextField(
94+
keyboardType: TextInputType.emailAddress,
95+
controller: textEditingController,
96+
decoration: InputDecoration(
97+
prefixIcon: const Icon(Icons.email),
98+
contentPadding: const EdgeInsets.all(12.0),
99+
border: OutlineInputBorder(borderSide: BorderSide(color: themeColor)),
100+
hintText: i18n('hint_text'),
101+
suffixIcon: TextButton.icon(
102+
onPressed: addUser,
103+
icon: const Icon(Icons.add),
104+
label: Text(i18n('add_btn')),
100105
),
101-
onSubmitted: (e) {
102-
addUser();
103-
},
104106
),
105-
spacer(12.0),
106-
Obx(() => Text("已添加${users.length}个用户(点击移除)", style: Get.textTheme.titleMedium)),
107-
spacer(12.0),
108-
Obx(
109-
() => Wrap(
110-
runSpacing: 12,
111-
spacing: 12,
112-
children: users
113-
.map(
114-
(email) => InkWell(
115-
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
116-
onTap: () {
117-
var index = users.indexWhere((element) => element == email);
118-
removeUser(email, index);
119-
},
120-
child: Container(
121-
decoration: BoxDecoration(
122-
border: Border.all(color: Theme.of(context).primaryColor),
123-
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
124-
),
125-
padding: const EdgeInsets.only(top: 10, bottom: 10, left: 8, right: 8),
126-
child: Text(email, style: Get.textTheme.bodyMedium),
127-
),
128-
),
129-
)
130-
.toList(),
131-
),
107+
onSubmitted: (e) => addUser(),
108+
),
109+
spacer(12.0),
110+
// Using your custom helper with named parameters here
111+
Obx(
112+
() =>
113+
Text(i18n('user_count', args: {'count': users.length.toString()}), style: Get.textTheme.titleMedium),
114+
),
115+
spacer(12.0),
116+
Obx(
117+
() => Wrap(
118+
runSpacing: 12,
119+
spacing: 12,
120+
children: users.asMap().entries.map((entry) {
121+
int index = entry.key;
122+
String email = entry.value;
123+
return InkWell(
124+
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
125+
onTap: () => removeUser(email, index),
126+
child: Container(
127+
decoration: BoxDecoration(
128+
border: Border.all(color: Theme.of(context).primaryColor),
129+
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
130+
),
131+
padding: const EdgeInsets.only(top: 10, bottom: 10, left: 8, right: 8),
132+
child: Text(email, style: Get.textTheme.bodyMedium),
133+
),
134+
);
135+
}).toList(),
132136
),
133-
],
134-
),
137+
),
138+
],
135139
),
136140
),
137141
);

0 commit comments

Comments
 (0)