Skip to content

Commit

Permalink
Merge pull request #94 from mylxsw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mylxsw authored Feb 13, 2024
2 parents 58cbc62 + 0939354 commit 714ef64
Show file tree
Hide file tree
Showing 22 changed files with 1,024 additions and 282 deletions.
2 changes: 1 addition & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION=1.0.11
VERSION=1.0.12

rm -fr build/web

Expand Down
7 changes: 5 additions & 2 deletions lib/bloc/free_count_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ class FreeCountBloc extends Bloc<FreeCountEvent, FreeCountState> {
return;
}

final freeCount = await APIServer()
.userFreeStatisticsForModel(model: event.model.split(':').last);
final freeCount = await APIServer().userFreeStatisticsForModel(
model: event.model.startsWith('v2@')
? event.model
: event.model.split(':').last,
);
if (freeCount.maxCount > 0) {
var matched = false;
for (var i = 0; i < counts.length; i++) {
Expand Down
38 changes: 29 additions & 9 deletions lib/bloc/room_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
lastActiveTime: room.lastActiveTime,
systemPrompt: room.systemPrompt,
priority: room.priority ?? 0,
model: '${room.vendor}:${room.model}',
model: room.model.startsWith('v2@')
? room.model
: '${room.vendor}:${room.model}',
initMessage: room.initMessage,
maxContext: room.maxContext,
avatarId: room.avatarId,
Expand All @@ -81,15 +83,21 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
lastActiveTime: room.lastActiveTime,
systemPrompt: room.systemPrompt,
priority: room.priority ?? 0,
model: '${room.vendor}:${room.model}',
model: room.model.startsWith('v2@')
? room.model
: '${room.vendor}:${room.model}',
initMessage: room.initMessage,
maxContext: room.maxContext,
avatarId: room.avatarId,
avatarUrl: room.avatarUrl,
roomType: room.roomType,
),
states,
examples: await APIServer().example('${room.vendor}:${room.model}'),
examples: await APIServer().example(
room.model.startsWith('v2@')
? room.model
: '${room.vendor}:${room.model}',
),
cascading: event.cascading,
));
return;
Expand Down Expand Up @@ -131,8 +139,12 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
if (Ability().isUserLogon()) {
await APIServer().createRoom(
name: event.name,
vendor: event.model.split(':').first,
model: event.model.split(':').last,
vendor: event.model.startsWith('v2@')
? ''
: event.model.split(':').first,
model: event.model.startsWith('v2@')
? event.model
: event.model.split(':').last,
systemPrompt: event.prompt,
avatarId: event.avatarId,
avatarUrl: event.avatarUrl,
Expand Down Expand Up @@ -184,8 +196,12 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
final room = await APIServer().updateRoom(
roomId: event.roomId,
name: event.name!,
model: event.model!.split(':').last,
vendor: event.model!.split(':').first,
model: event.model!.startsWith('v2@')
? event.model!
: event.model!.split(':').last,
vendor: event.model!.startsWith('v2@')
? ''
: event.model!.split(':').first,
systemPrompt: event.prompt!,
avatarId: event.avatarId,
avatarUrl: event.avatarUrl,
Expand All @@ -206,7 +222,9 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
lastActiveTime: room.lastActiveTime,
systemPrompt: room.systemPrompt,
priority: room.priority ?? 0,
model: '${room.vendor}:${room.model}',
model: room.model.startsWith('v2@')
? room.model
: '${room.vendor}:${room.model}',
avatarId: room.avatarId,
avatarUrl: room.avatarUrl,
initMessage: room.initMessage,
Expand Down Expand Up @@ -325,7 +343,9 @@ class RoomBloc extends BlocExt<RoomEvent, RoomState> {
lastActiveTime: room.lastActiveTime,
systemPrompt: room.systemPrompt,
priority: room.priority ?? 0,
model: '${room.vendor}:${room.model}',
model: room.model.startsWith('v2@')
? room.model
: '${room.vendor}:${room.model}',
avatarId: room.avatarId,
avatarUrl: room.avatarUrl,
roomType: room.roomType,
Expand Down
17 changes: 16 additions & 1 deletion lib/helper/ability.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:askaide/helper/constant.dart';
import 'package:askaide/helper/platform.dart';
import 'package:askaide/repo/api/info.dart';
import 'package:askaide/repo/api/model.dart';
import 'package:askaide/repo/settings_repo.dart';

class Ability {
Expand Down Expand Up @@ -46,7 +47,7 @@ class Ability {
}

/// 首页支持的模型列表
List<HomeModel> get homeModels {
List<HomeModelV2> get homeModels {
return capabilities.homeModels;
}

Expand Down Expand Up @@ -96,6 +97,20 @@ class Ability {
return capabilities.applePayEnabled;
}

/// 是否显示 Apple 登录
bool get enableAppleSignin {
return enableApplePay &&
(PlatformTool.isIOS() ||
PlatformTool.isAndroid() ||
PlatformTool.isMacOS());
}

/// 是否支持微信登录
bool get enableWechatSignin {
return capabilities.wechatSigninEnabled &&
(PlatformTool.isIOS() || PlatformTool.isAndroid());
}

/// 是否支持支付功能
bool get enablePayment {
if (!enableApplePay && !enableOtherPay) {
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/constant.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

// 客户端应用版本号
const clientVersion = '1.0.12';
const clientVersion = '1.0.13';
// 本地数据库版本号
const databaseVersion = 26;

Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ class MyApp extends StatefulWidget {
username: state.queryParameters['username']!,
isSignup: state.queryParameters['is_signup'] == 'true',
signInMethod: state.queryParameters['sign_in_method']!,
wechatBindToken: state.queryParameters['wechat_bind_token'],
),
),
),
Expand Down
9 changes: 8 additions & 1 deletion lib/page/auth/signin_or_signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class SigninOrSignupScreen extends StatefulWidget {
final String username;
final String signInMethod;
final bool isSignup;
final String? wechatBindToken;

const SigninOrSignupScreen({
super.key,
required this.settings,
required this.username,
required this.isSignup,
required this.signInMethod,
this.wechatBindToken,
});

@override
Expand Down Expand Up @@ -159,7 +161,11 @@ class _SigninOrSignupScreenState extends State<SigninOrSignupScreen> {
}

APIServer()
.signInWithPassword(widget.username, password)
.signInWithPassword(
widget.username,
password,
wechatBindToken: widget.wechatBindToken,
)
.then((value) async {
await widget.settings.set(settingAPIServerToken, value.token);
await widget.settings.set(settingUserInfo, jsonEncode(value));
Expand Down Expand Up @@ -387,6 +393,7 @@ class _SigninOrSignupScreenState extends State<SigninOrSignupScreen> {
inviteCode: inviteCode,
verifyCodeId: verifyCodeId,
verifyCode: verificationCode,
wechatBindToken: widget.wechatBindToken,
)
.then((value) async {
await widget.settings.set(settingAPIServerToken, value.token);
Expand Down
Loading

0 comments on commit 714ef64

Please sign in to comment.