docs(mobile-app): 完善认种密码校验相关代码注释

- PasswordVerifyDialog: 补充类级文档、onVerify 字段说明、_handleConfirm 流程注释
- account_service.verifyLoginPassword: 补充参数、响应格式、行为说明
- planting_location_page._verifyPasswordThenSubmit: 说明在认种流程中的插入位置与作用

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-05 05:55:07 -08:00
parent 3a84315b64
commit d91ff7b83a
3 changed files with 42 additions and 4 deletions

View File

@ -2097,7 +2097,14 @@ class AccountService {
/// (POST /user/verify-password)
///
/// true false /
///
///
/// [password]
///
/// { "valid": true/false }
/// - true
/// - falsevalid=false
/// - /ApiException
Future<bool> verifyLoginPassword(String password) async {
debugPrint('$_tag verifyLoginPassword() - 开始验证登录密码');
try {

View File

@ -243,7 +243,11 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
}
}
///
///
///
/// [PlantingConfirmDialog] [_submitPlanting]
/// [PasswordVerifyDialog] [_submitPlanting]
///
Future<void> _verifyPasswordThenSubmit() async {
final verified = await PasswordVerifyDialog.show(
context: context,

View File

@ -1,12 +1,29 @@
import 'package:flutter/material.dart';
///
/// true false /
///
/// [password]
/// true false valid=false
/// /
typedef PasswordVerifyCallback = Future<bool> Function(String password);
///
///
///
/// [PlantingConfirmDialog] "确认认种"
///
///
///
/// ```dart
/// final verified = await PasswordVerifyDialog.show(
/// context: context,
/// onVerify: (password) => accountService.verifyLoginPassword(password),
/// );
/// if (verified == true) _submitPlanting();
/// ```
///
/// POST /user/verify-password { valid: bool }
class PasswordVerifyDialog extends StatefulWidget {
/// accountService.verifyLoginPassword
final PasswordVerifyCallback onVerify;
const PasswordVerifyDialog({
@ -46,6 +63,13 @@ class _PasswordVerifyDialogState extends State<PasswordVerifyDialog> {
}
///
///
///
/// 1.
/// 2. [onVerify]
/// 3. valid=true true
/// 4. valid=false "密码错误"
/// 5.
Future<void> _handleConfirm() async {
final password = _passwordController.text.trim();
if (password.isEmpty) {
@ -62,14 +86,17 @@ class _PasswordVerifyDialogState extends State<PasswordVerifyDialog> {
final success = await widget.onVerify(password);
if (!mounted) return;
if (success) {
// true
Navigator.pop(context, true);
} else {
// valid=false
setState(() {
_isVerifying = false;
_errorMessage = '密码错误,请重试';
});
}
} catch (e) {
// /
if (!mounted) return;
setState(() {
_isVerifying = false;