-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from mylxsw/develop
Develop
- Loading branch information
Showing
47 changed files
with
2,744 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:askaide/repo/api/keys.dart'; | ||
import 'package:askaide/repo/api_server.dart'; | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'user_api_keys_event.dart'; | ||
part 'user_api_keys_state.dart'; | ||
|
||
class UserApiKeysBloc extends Bloc<UserApiKeysEvent, UserApiKeysState> { | ||
UserApiKeysBloc() : super(UserApiKeysInitial()) { | ||
// 加载用户 API Key 列表 | ||
on<UserApiKeysLoad>((event, emit) async { | ||
final keys = await APIServer().userAPIKeys(); | ||
emit(UserApiKeysLoaded(keys: keys)); | ||
}); | ||
|
||
// 加载用户 API Key | ||
on<UserApiKeyLoad>((event, emit) async { | ||
final key = await APIServer().userAPIKeyDetail(id: event.id); | ||
emit(UserApiKeyLoaded(key: key)); | ||
}); | ||
|
||
// 创建用户 API Key | ||
on<UserApiKeyCreate>((event, emit) async { | ||
final key = await APIServer().createAPIKey(name: event.name); | ||
emit(UserApiKeyCreated(key: key)); | ||
|
||
final keys = await APIServer().userAPIKeys(); | ||
emit(UserApiKeysLoaded(keys: keys)); | ||
}); | ||
|
||
// 删除用户 API Key | ||
on<UserApiKeyDelete>((event, emit) async { | ||
await APIServer().deleteAPIKey(id: event.id); | ||
final keys = await APIServer().userAPIKeys(); | ||
emit(UserApiKeysLoaded(keys: keys)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
part of 'user_api_keys_bloc.dart'; | ||
|
||
@immutable | ||
sealed class UserApiKeysEvent {} | ||
|
||
class UserApiKeysLoad extends UserApiKeysEvent {} | ||
|
||
class UserApiKeyLoad extends UserApiKeysEvent { | ||
final int id; | ||
|
||
UserApiKeyLoad(this.id); | ||
} | ||
|
||
class UserApiKeyCreate extends UserApiKeysEvent { | ||
final String name; | ||
|
||
UserApiKeyCreate(this.name); | ||
} | ||
|
||
class UserApiKeyDelete extends UserApiKeysEvent { | ||
final int id; | ||
|
||
UserApiKeyDelete(this.id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
part of 'user_api_keys_bloc.dart'; | ||
|
||
@immutable | ||
sealed class UserApiKeysState {} | ||
|
||
final class UserApiKeysInitial extends UserApiKeysState {} | ||
|
||
class UserApiKeysLoaded extends UserApiKeysState { | ||
final List<UserAPIKey> keys; | ||
|
||
UserApiKeysLoaded({required this.keys}); | ||
} | ||
|
||
class UserApiKeyLoaded extends UserApiKeysState { | ||
final UserAPIKey key; | ||
|
||
UserApiKeyLoaded({required this.key}); | ||
} | ||
|
||
class UserApiKeyCreated extends UserApiKeysState { | ||
final String key; | ||
|
||
UserApiKeyCreated({required this.key}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:askaide/page/component/chat/file_upload.dart'; | ||
|
||
class GlobalStore { | ||
static final GlobalStore _instance = GlobalStore._internal(); | ||
GlobalStore._internal(); | ||
|
||
factory GlobalStore() { | ||
return _instance; | ||
} | ||
|
||
List<FileUpload> uploadedFiles = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.