mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
登录页支持切换账号
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## v1.0.6
|
||||
* 支持切换账号功能
|
||||
* 登录页青龙图标颜色随颜色主题变换
|
||||
|
||||
## v1.0.5
|
||||
* 优化配置文件编辑功能
|
||||
* 优化文本选择样式
|
||||
@@ -18,6 +22,7 @@
|
||||
|
||||
* 解决2.10.12及以下版本无法登录的问题
|
||||
* 适配最新版qinglong 相关接口字段
|
||||
* 其他页面排版优化
|
||||
|
||||
## 1.0.2
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:qinglong_app/module/env/env_detail_page.dart';
|
||||
import 'package:qinglong_app/module/home/home_page.dart';
|
||||
import 'package:qinglong_app/module/login/login_page.dart';
|
||||
import 'package:qinglong_app/module/others/about_page.dart';
|
||||
import 'package:qinglong_app/module/others/change_account.dart';
|
||||
import 'package:qinglong_app/module/others/change_account_page.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
|
||||
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
|
||||
|
||||
@@ -208,6 +208,7 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
|
||||
abstract class ThemeColors {
|
||||
Color settingBgColor();
|
||||
Color settingBordorColor();
|
||||
|
||||
Color titleColor();
|
||||
|
||||
@@ -250,6 +251,11 @@ class LightThemeColors extends ThemeColors {
|
||||
Color buttonBgColor() {
|
||||
return _primaryColor;
|
||||
}
|
||||
|
||||
@override
|
||||
Color settingBordorColor() {
|
||||
return Colors.white;
|
||||
}
|
||||
}
|
||||
|
||||
class DartThemeColors extends ThemeColors {
|
||||
@@ -282,4 +288,9 @@ class DartThemeColors extends ThemeColors {
|
||||
Color buttonBgColor() {
|
||||
return const Color(0xff333333);
|
||||
}
|
||||
|
||||
@override
|
||||
Color settingBordorColor() {
|
||||
return Color(0xff333333);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
IndexBean(
|
||||
CupertinoIcons.cube,
|
||||
CupertinoIcons.cube_fill,
|
||||
"其他",
|
||||
"其他功能",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
if (!widget.doNotLoadLocalData) {
|
||||
_hostController.text = getIt<UserInfoViewModel>().host ?? "";
|
||||
useSecretLogin = getIt<UserInfoViewModel>().useSecretLogined;
|
||||
if (getIt<UserInfoViewModel>().userName != null &&
|
||||
getIt<UserInfoViewModel>().userName!.isNotEmpty) {
|
||||
if (getIt<UserInfoViewModel>().userName != null && getIt<UserInfoViewModel>().userName!.isNotEmpty) {
|
||||
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
||||
_cIdController.text = getIt<UserInfoViewModel>().userName!;
|
||||
} else {
|
||||
@@ -56,8 +55,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
} else {
|
||||
rememberPassword = false;
|
||||
}
|
||||
if (getIt<UserInfoViewModel>().passWord != null &&
|
||||
getIt<UserInfoViewModel>().passWord!.isNotEmpty) {
|
||||
if (getIt<UserInfoViewModel>().passWord != null && getIt<UserInfoViewModel>().passWord!.isNotEmpty) {
|
||||
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
||||
_cSecretController.text = getIt<UserInfoViewModel>().passWord!;
|
||||
} else {
|
||||
@@ -76,313 +74,335 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ColoredBox(
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
child: Image.asset(
|
||||
"assets/images/login_bg.png",
|
||||
width: MediaQuery.of(context).size.width,
|
||||
return SafeArea(
|
||||
child: ColoredBox(
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
child: Image.asset(
|
||||
"assets/images/login_bg.png",
|
||||
width: MediaQuery.of(context).size.width,
|
||||
),
|
||||
),
|
||||
),
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 8,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Image.asset(
|
||||
"assets/images/login_tip.png",
|
||||
height: 45,
|
||||
Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 10,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Image.asset(
|
||||
"assets/images/login_tip.png",
|
||||
height: 45,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onDoubleTap: () {
|
||||
if (debugBtnIsShow()) {
|
||||
dismissDebugBtn();
|
||||
} else {
|
||||
showDebugBtn(context,
|
||||
btnColor: ref
|
||||
.watch(themeProvider)
|
||||
.primaryColor);
|
||||
}
|
||||
WidgetsBinding.instance?.endOfFrame;
|
||||
},
|
||||
child: ColorFiltered(
|
||||
colorFilter: ColorFilter.mode(
|
||||
ref.watch(themeProvider).primaryColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/images/ql.png",
|
||||
height: 45,
|
||||
GestureDetector(
|
||||
onDoubleTap: () {
|
||||
if (debugBtnIsShow()) {
|
||||
dismissDebugBtn();
|
||||
} else {
|
||||
showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor);
|
||||
}
|
||||
WidgetsBinding.instance?.endOfFrame;
|
||||
},
|
||||
child: ColorFiltered(
|
||||
colorFilter: ColorFilter.mode(
|
||||
ref.watch(themeProvider).primaryColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/images/ql.png",
|
||||
height: 45,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 15,
|
||||
),
|
||||
const Text(
|
||||
"域名:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
],
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _hostController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "http://1.1.1.1:5700",
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 15,
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
FlipCard(
|
||||
key: cardKey,
|
||||
flipOnTouch: false,
|
||||
onFlipDone: (back) {
|
||||
useSecretLogin = back;
|
||||
setState(() {});
|
||||
},
|
||||
direction: FlipDirection.HORIZONTAL,
|
||||
front: SizedBox(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"用户名:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _userNameController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入用户名",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"密码:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入密码",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
const Text(
|
||||
"域名:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
back: SizedBox(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"client_id:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _cIdController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入client_id",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"client_secret:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _cSecretController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入client_secret",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: rememberPassword,
|
||||
onChanged: (checked) {
|
||||
rememberPassword = checked ?? false;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
const Text(
|
||||
"记住密码/client",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
cardKey.currentState?.toggleCard();
|
||||
WidgetsBinding.instance
|
||||
?.addPostFrameCallback((timeStamp) {
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
loginByUserName() ? "client_id登录" : "账号登录",
|
||||
style: const TextStyle(
|
||||
},
|
||||
controller: _hostController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "http://1.1.1.1:5700",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
FlipCard(
|
||||
key: cardKey,
|
||||
flipOnTouch: false,
|
||||
onFlipDone: (back) {
|
||||
useSecretLogin = back;
|
||||
setState(() {});
|
||||
},
|
||||
direction: FlipDirection.HORIZONTAL,
|
||||
front: SizedBox(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"用户名:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _userNameController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入用户名",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"密码:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入密码",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
back: SizedBox(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"client_id:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _cIdController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入client_id",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"client_secret:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _cSecretController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入client_secret",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: rememberPassword,
|
||||
onChanged: (checked) {
|
||||
rememberPassword = checked ?? false;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
const Text(
|
||||
"记住密码/client",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 80,
|
||||
child: IgnorePointer(
|
||||
ignoring: !canClickLoginBtn(),
|
||||
child: CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
cardKey.currentState?.toggleCard();
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
setState(() {});
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
loginByUserName() ? "client_id登录" : "账号登录",
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
color: canClickLoginBtn()
|
||||
? ref.watch(themeProvider).primaryColor
|
||||
: ref
|
||||
.watch(themeProvider)
|
||||
.primaryColor
|
||||
.withOpacity(0.4),
|
||||
child: isLoading
|
||||
? const CupertinoActivityIndicator()
|
||||
: const Text(
|
||||
"登 录",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 80,
|
||||
child: IgnorePointer(
|
||||
ignoring: !canClickLoginBtn(),
|
||||
child: CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
),
|
||||
color: canClickLoginBtn() ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).primaryColor.withOpacity(0.4),
|
||||
child: isLoading
|
||||
? const CupertinoActivityIndicator()
|
||||
: const Text(
|
||||
"登 录",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Http.pushedLoginPage = false;
|
||||
Utils.hideKeyBoard(context);
|
||||
if (loginByUserName()) {
|
||||
login(_userNameController.text,
|
||||
_passwordController.text);
|
||||
} else {
|
||||
login(_cIdController.text,
|
||||
_cSecretController.text);
|
||||
}
|
||||
},
|
||||
onPressed: () {
|
||||
Http.pushedLoginPage = false;
|
||||
Utils.hideKeyBoard(context);
|
||||
if (loginByUserName()) {
|
||||
login(_userNameController.text, _passwordController.text);
|
||||
} else {
|
||||
login(_cIdController.text, _cSecretController.text);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: PopupMenuButton<UserInfoBean>(
|
||||
onSelected: (UserInfoBean result) {
|
||||
selected(result);
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<UserInfoBean>>[
|
||||
...getIt<UserInfoViewModel>()
|
||||
.historyAccounts
|
||||
.map((e) => PopupMenuItem<UserInfoBean>(
|
||||
value: e,
|
||||
child: buildCell(e),
|
||||
))
|
||||
.toList(),
|
||||
],
|
||||
child: Text(
|
||||
"切换账号",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -400,8 +420,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
isLoading = true;
|
||||
setState(() {});
|
||||
|
||||
helper = LoginHelper(useSecretLogin, _hostController.text, userName,
|
||||
password, rememberPassword);
|
||||
helper = LoginHelper(useSecretLogin, _hostController.text, userName, password, rememberPassword);
|
||||
var response = await helper!.login();
|
||||
dealLoginResponse(response);
|
||||
}
|
||||
@@ -426,11 +445,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
|
||||
if (_hostController.text.isEmpty) return false;
|
||||
if (!loginByUserName()) {
|
||||
return _cIdController.text.isNotEmpty &&
|
||||
_cSecretController.text.isNotEmpty;
|
||||
return _cIdController.text.isNotEmpty && _cSecretController.text.isNotEmpty;
|
||||
} else {
|
||||
return _userNameController.text.isNotEmpty &&
|
||||
_passwordController.text.isNotEmpty;
|
||||
return _userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,11 +518,49 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
void update() async {
|
||||
String? result = await UpdateUtils().checkUpdate();
|
||||
if (result != null && result.isNotEmpty) {
|
||||
UpdateDialog updateDialog = UpdateDialog(context,
|
||||
title: "发现新版本", updateContent: "版本号:v${result}", onUpdate: () {
|
||||
UpdateDialog updateDialog = UpdateDialog(context, title: "发现新版本", updateContent: "版本号:v${result}", onUpdate: () {
|
||||
UpdateUtils.launchURL(result);
|
||||
});
|
||||
updateDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildCell(UserInfoBean bean) {
|
||||
return ListTile(
|
||||
title: Text(
|
||||
bean.host ?? "",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
child: Text(
|
||||
bean.userName ?? "",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void selected(UserInfoBean result) {
|
||||
_hostController.text = result.host ?? "";
|
||||
if (result.useSecretLogined) {
|
||||
_cIdController.text = result.userName ?? "";
|
||||
_cSecretController.text = result.password ?? "";
|
||||
if (cardKey.currentState?.isFront ?? false) {
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
cardKey.currentState?.toggleCard();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_userNameController.text = result.userName ?? "";
|
||||
_passwordController.text = result.password ?? "";
|
||||
if (!(cardKey.currentState?.isFront ?? false)) {
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
cardKey.currentState?.toggleCard();
|
||||
});
|
||||
}
|
||||
}
|
||||
rememberPassword = true;
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
"轻触账号以切换登录",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 25,
|
||||
fontSize: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@@ -64,14 +64,13 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
getIt<UserInfoViewModel>().historyAccounts.length) {
|
||||
if (index == getIt<UserInfoViewModel>().historyAccounts.length) {
|
||||
return addAccount();
|
||||
}
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||
child: buildCell(index),
|
||||
),
|
||||
);
|
||||
@@ -81,8 +80,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
height: 10,
|
||||
);
|
||||
},
|
||||
itemCount:
|
||||
getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
||||
itemCount: getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -115,13 +113,11 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: ref.watch(themeProvider).primaryColor, width: 1),
|
||||
border: Border.all(color: ref.watch(themeProvider).primaryColor, width: 1),
|
||||
),
|
||||
child: Text(
|
||||
"已登录",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
||||
style: TextStyle(color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
||||
),
|
||||
)
|
||||
: (isLoginingHost.isNotEmpty
|
||||
@@ -136,8 +132,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
: const SizedBox.shrink()),
|
||||
);
|
||||
|
||||
if (getIt<UserInfoViewModel>().historyAccounts[index].host ==
|
||||
getIt<UserInfoViewModel>().host) {
|
||||
if (getIt<UserInfoViewModel>().historyAccounts[index].host == getIt<UserInfoViewModel>().host) {
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -151,8 +146,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
backgroundColor: Colors.red,
|
||||
flex: 1,
|
||||
onPressed: (_) {
|
||||
getIt<UserInfoViewModel>().removeHistoryAccount(
|
||||
getIt<UserInfoViewModel>().historyAccounts[index].host);
|
||||
getIt<UserInfoViewModel>().removeHistoryAccount(getIt<UserInfoViewModel>().historyAccounts[index].host);
|
||||
setState(() {});
|
||||
},
|
||||
foregroundColor: Colors.white,
|
||||
@@ -187,8 +181,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
|
||||
void dealLoginResponse(int response) {
|
||||
if (response == LoginHelper.success) {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
||||
} else if (response == LoginHelper.failed) {
|
||||
loginFailed();
|
||||
} else {
|
||||
@@ -284,7 +277,10 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
vertical: 15,
|
||||
horizontal: 15,
|
||||
),
|
||||
color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -308,7 +304,7 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
"添加账号",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 18,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -27,10 +27,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 30,
|
||||
vertical: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(15),
|
||||
),
|
||||
@@ -48,8 +48,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 12,
|
||||
bottom: 8,
|
||||
top: 10,
|
||||
bottom: 5,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
@@ -58,10 +58,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"脚本管理",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -86,7 +83,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
vertical: 5,
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Row(
|
||||
@@ -94,10 +91,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"依赖管理",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -122,8 +116,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 8,
|
||||
bottom: 15,
|
||||
top: 5,
|
||||
bottom: 5,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
@@ -132,10 +126,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"任务日志",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -148,24 +139,9 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(15),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Divider(
|
||||
indent: 15,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
@@ -178,9 +154,11 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 15,
|
||||
padding: const EdgeInsets.only(
|
||||
top: 5,
|
||||
bottom: 5,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
@@ -188,10 +166,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"登录日志",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -220,8 +195,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 8,
|
||||
bottom: 15,
|
||||
top: 5,
|
||||
bottom: 10,
|
||||
left: 15,
|
||||
right: 15,
|
||||
),
|
||||
@@ -232,10 +207,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"修改密码",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -257,7 +229,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
vertical: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(15),
|
||||
),
|
||||
@@ -279,8 +251,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"夜间模式",
|
||||
style: TextStyle(
|
||||
color:
|
||||
ref.watch(themeProvider).themeColor.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -294,6 +265,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(
|
||||
indent: 15,
|
||||
),
|
||||
@@ -316,10 +288,42 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"主题设置",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
const Icon(
|
||||
CupertinoIcons.right_chevron,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
indent: 15,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.routeChangeAccount);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15,
|
||||
right: 15,
|
||||
top: 5,
|
||||
bottom: 5,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"切换账号",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -347,7 +351,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
left: 15,
|
||||
right: 15,
|
||||
top: 5,
|
||||
bottom: 15,
|
||||
bottom: 10,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -356,10 +360,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
Text(
|
||||
"关于",
|
||||
style: TextStyle(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -378,29 +379,6 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
// Center(
|
||||
// child: SizedBox(
|
||||
// width: MediaQuery.of(context).size.width - 40,
|
||||
// child: CupertinoButton(
|
||||
// padding: const EdgeInsets.symmetric(
|
||||
// vertical: 5,
|
||||
// ),
|
||||
// color: ref.watch(themeProvider).themeColor.buttonBgColor(),
|
||||
// child: const Text(
|
||||
// "切换账号",
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// ),
|
||||
// ),
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(Routes.routeChangeAccount);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// height: 30,
|
||||
// ),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 40,
|
||||
@@ -441,8 +419,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
||||
),
|
||||
onPressed: () {
|
||||
getIt<UserInfoViewModel>().updateToken("");
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.routeLogin);
|
||||
Navigator.of(context).pushReplacementNamed(Routes.routeLogin);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user