docs(webrtc_controller_flutter): 更新项目文档以反映重构后的架构
AGENTS.md 与 README.md 同步更新:根据实际代码结构重写目录树、技术栈、架构分层及编码规范,移除旧版内联示例并补充新的开发约定与代码生成命令。
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/// 账号体系与自助接口抽象(对应服务端 /api/auth/* 与 /api/client/*)。
|
||||
abstract interface class AuthRepository {
|
||||
/// 内存中的 accessToken(掉线即失)。
|
||||
String? get accessToken;
|
||||
|
||||
/// 从安全存储恢复令牌(应用启动时调用)。
|
||||
Future<void> restore();
|
||||
|
||||
Future<bool> hasRefreshToken();
|
||||
|
||||
Future<String?> getUsername();
|
||||
|
||||
Future<Map<String, dynamic>> login(String username, String password);
|
||||
|
||||
Future<Map<String, dynamic>> register(String username, String password);
|
||||
|
||||
/// 刷新令牌:带单飞锁,并发调用共享同一次刷新结果。可能轮换 refreshToken。
|
||||
Future<Map<String, dynamic>> refresh();
|
||||
|
||||
Future<Map<String, dynamic>> verify();
|
||||
|
||||
Future<Map<String, dynamic>> bindings();
|
||||
|
||||
/// 拉取 TURN 短期凭证(服务端开启时返回 iceServers);关闭时返回 null。
|
||||
Future<Map<String, dynamic>?> turnCredentials();
|
||||
|
||||
Future<void> clear();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_state.freezed.dart';
|
||||
|
||||
/// 登录状态。
|
||||
@freezed
|
||||
class AuthState with _$AuthState {
|
||||
const factory AuthState({
|
||||
@Default(false) bool loggedIn,
|
||||
@Default(false) bool restoring,
|
||||
String? username,
|
||||
String? error,
|
||||
}) = _AuthState;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'auth_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthState {
|
||||
bool get loggedIn => throw _privateConstructorUsedError;
|
||||
bool get restoring => throw _privateConstructorUsedError;
|
||||
String? get username => throw _privateConstructorUsedError;
|
||||
String? get error => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthStateCopyWith<AuthState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthStateCopyWith<$Res> {
|
||||
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) =
|
||||
_$AuthStateCopyWithImpl<$Res, AuthState>;
|
||||
@useResult
|
||||
$Res call({bool loggedIn, bool restoring, String? username, String? error});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState>
|
||||
implements $AuthStateCopyWith<$Res> {
|
||||
_$AuthStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? loggedIn = null,
|
||||
Object? restoring = null,
|
||||
Object? username = freezed,
|
||||
Object? error = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
loggedIn: null == loggedIn
|
||||
? _value.loggedIn
|
||||
: loggedIn // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
restoring: null == restoring
|
||||
? _value.restoring
|
||||
: restoring // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
username: freezed == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
error: freezed == error
|
||||
? _value.error
|
||||
: error // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateImplCopyWith<$Res>
|
||||
implements $AuthStateCopyWith<$Res> {
|
||||
factory _$$AuthStateImplCopyWith(
|
||||
_$AuthStateImpl value,
|
||||
$Res Function(_$AuthStateImpl) then,
|
||||
) = __$$AuthStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({bool loggedIn, bool restoring, String? username, String? error});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateImpl>
|
||||
implements _$$AuthStateImplCopyWith<$Res> {
|
||||
__$$AuthStateImplCopyWithImpl(
|
||||
_$AuthStateImpl _value,
|
||||
$Res Function(_$AuthStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? loggedIn = null,
|
||||
Object? restoring = null,
|
||||
Object? username = freezed,
|
||||
Object? error = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$AuthStateImpl(
|
||||
loggedIn: null == loggedIn
|
||||
? _value.loggedIn
|
||||
: loggedIn // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
restoring: null == restoring
|
||||
? _value.restoring
|
||||
: restoring // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
username: freezed == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
error: freezed == error
|
||||
? _value.error
|
||||
: error // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateImpl implements _AuthState {
|
||||
const _$AuthStateImpl({
|
||||
this.loggedIn = false,
|
||||
this.restoring = false,
|
||||
this.username,
|
||||
this.error,
|
||||
});
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool loggedIn;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool restoring;
|
||||
@override
|
||||
final String? username;
|
||||
@override
|
||||
final String? error;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState(loggedIn: $loggedIn, restoring: $restoring, username: $username, error: $error)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthStateImpl &&
|
||||
(identical(other.loggedIn, loggedIn) ||
|
||||
other.loggedIn == loggedIn) &&
|
||||
(identical(other.restoring, restoring) ||
|
||||
other.restoring == restoring) &&
|
||||
(identical(other.username, username) ||
|
||||
other.username == username) &&
|
||||
(identical(other.error, error) || other.error == error));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, loggedIn, restoring, username, error);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith =>
|
||||
__$$AuthStateImplCopyWithImpl<_$AuthStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _AuthState implements AuthState {
|
||||
const factory _AuthState({
|
||||
final bool loggedIn,
|
||||
final bool restoring,
|
||||
final String? username,
|
||||
final String? error,
|
||||
}) = _$AuthStateImpl;
|
||||
|
||||
@override
|
||||
bool get loggedIn;
|
||||
@override
|
||||
bool get restoring;
|
||||
@override
|
||||
String? get username;
|
||||
@override
|
||||
String? get error;
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
Reference in New Issue
Block a user