Skip to content

Commit

Permalink
Merge pull request #69 from mylxsw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mylxsw authored Nov 29, 2023
2 parents 448a0f1 + f4f1e91 commit 9170559
Show file tree
Hide file tree
Showing 14 changed files with 582 additions and 29 deletions.
11 changes: 2 additions & 9 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

VERSION=1.0.6
VERSION_DATE=202310091100
VERSION=1.0.9

rm -fr build/web

Expand All @@ -10,11 +9,5 @@ cd scripts && go run main.go ../build/web/main.dart.js && cd ..
rm -fr build/web/fonts/ && mkdir build/web/fonts
cp -r scripts/s build/web/fonts/s

docker build -t mylxsw/aidea-web:$VERSION .
docker tag mylxsw/aidea-web:$VERSION mylxsw/aidea-web:$VERSION_DATE
docker tag mylxsw/aidea-web:$VERSION mylxsw/aidea-web:latest

docker push mylxsw/aidea-web:$VERSION
docker push mylxsw/aidea-web:$VERSION_DATE
docker push mylxsw/aidea-web:latest
docker buildx build --platform=linux/amd64,linux/arm64 -t mylxsw/aidea-web:$VERSION . --push

25 changes: 25 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:askaide/page/creative_island/draw/artistic_text.dart';
import 'package:askaide/page/setting/account_security.dart';
import 'package:askaide/page/app_scaffold.dart';
import 'package:askaide/page/lab/avatar_selector.dart';
import 'package:askaide/page/setting/article.dart';
import 'package:askaide/page/setting/background_selector.dart';
import 'package:askaide/page/setting/bind_phone_page.dart';
import 'package:askaide/page/setting/change_password.dart';
Expand All @@ -46,6 +47,7 @@ import 'package:askaide/page/creative_island/draw/image_edit_direct.dart';
import 'package:askaide/page/lab/draw_board.dart';
import 'package:askaide/page/creative_island/gallery/gallery.dart';
import 'package:askaide/page/creative_island/gallery/gallery_item.dart';
import 'package:askaide/page/setting/notification.dart';
import 'package:askaide/page/setting/openai_setting.dart';
import 'package:askaide/page/balance/payment.dart';
import 'package:askaide/page/lab/prompt.dart';
Expand Down Expand Up @@ -925,6 +927,29 @@ class MyApp extends StatefulWidget {
);
},
),
GoRoute(
name: 'notifications',
path: '/notifications',
parentNavigatorKey: _shellNavigatorKey,
pageBuilder: (context, state) {
return transitionResolver(
NotificationScreen(setting: settingRepo),
);
},
),
GoRoute(
name: 'articles',
path: '/article',
parentNavigatorKey: _shellNavigatorKey,
pageBuilder: (context, state) {
return transitionResolver(
ArticleScreen(
settings: settingRepo,
id: int.tryParse(state.queryParameters['id'] ?? '') ?? 0,
),
);
},
),
],
)
],
Expand Down
1 change: 1 addition & 0 deletions lib/page/chat/room_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class _RoomCreatePageState extends State<RoomCreatePage> {
const EdgeInsets.only(right: 5, left: 10),
overlayColor:
MaterialStateProperty.all(Colors.transparent),
tabAlignment: TabAlignment.center,
),
),
Expanded(
Expand Down
2 changes: 1 addition & 1 deletion lib/page/component/model_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ModelIndicator extends StatelessWidget {
Text(
model.modelName,
style: TextStyle(
fontSize: 16,
fontSize: 15,
color: selected
? Colors.white
: customColors.weakLinkColor,
Expand Down
2 changes: 2 additions & 0 deletions lib/page/component/sliver_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SliverSingleComponent extends StatelessWidget {
return CustomScrollView(
slivers: [
SliverAppBar(
automaticallyImplyLeading: false,
expandedHeight: expendedHeight,
floating: false,
pinned: true,
Expand Down Expand Up @@ -90,6 +91,7 @@ class SliverComponent extends StatelessWidget {
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverAppBar(
automaticallyImplyLeading: false,
toolbarHeight: CustomSize.toolbarHeight,
expandedHeight: expendedHeight,
floating: false,
Expand Down
53 changes: 53 additions & 0 deletions lib/page/data/notification_datasource.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:askaide/helper/logger.dart';
import 'package:askaide/repo/api/notification.dart';
import 'package:askaide/repo/api_server.dart';
import 'package:loading_more_list/loading_more_list.dart';

class NotificationDatasource extends LoadingMoreBase<NotifyMessage> {
int startId = 0;
bool _hasMore = true;
bool forceRefresh = false;

NotificationDatasource();

@override
bool get hasMore => _hasMore || forceRefresh;

@override
Future<bool> loadData([bool isloadMoreAction = false]) async {
try {
final messages =
await APIServer().notifications(startId: startId, cache: false);

if (startId == 0) {
clear();
}

for (var element in messages.data) {
add(element);
}

if (messages.data.isEmpty) {
_hasMore = false;
}

startId = messages.lastId;
return true;
} catch (e) {
Logger.instance.e(e);
return false;
}
}

@override
Future<bool> refresh([bool notifyStateChanged = false]) async {
_hasMore = true;
startId = 0;
//force to refresh list when you don't want clear list before request
//for the case, if your list already has 20 items.
forceRefresh = !notifyStateChanged;
var result = await super.refresh(notifyStateChanged);
forceRefresh = false;
return result;
}
}
126 changes: 126 additions & 0 deletions lib/page/setting/article.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import 'package:askaide/helper/ability.dart';
import 'package:askaide/page/component/background_container.dart';
import 'package:askaide/page/component/chat/markdown.dart';
import 'package:askaide/page/component/column_block.dart';
import 'package:askaide/page/component/theme/custom_size.dart';
import 'package:askaide/page/component/theme/custom_theme.dart';
import 'package:askaide/repo/api/article.dart';
import 'package:askaide/repo/api_server.dart';
import 'package:askaide/repo/settings_repo.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher_string.dart';

class ArticleScreen extends StatefulWidget {
final SettingRepository settings;
final int id;
const ArticleScreen({super.key, required this.settings, required this.id});

@override
State<ArticleScreen> createState() => _ArticleScreenState();
}

class _ArticleScreenState extends State<ArticleScreen> {
Article article = Article(
id: 0,
title: '标题',
content: '内容',
);

@override
void initState() {
APIServer().article(id: widget.id).then((value) {
setState(() {
article = value;
});
});
super.initState();
}

@override
Widget build(BuildContext context) {
final customColors = Theme.of(context).extension<CustomColors>()!;

return Scaffold(
appBar: AppBar(
title: Text(
article.title,
style: const TextStyle(fontSize: CustomSize.appBarTitleSize),
),
toolbarHeight: CustomSize.toolbarHeight,
centerTitle: true,
leading: IconButton(
icon: Icon(
Icons.close,
color: customColors.weakLinkColor,
),
onPressed: () {
if (context.canPop()) {
context.pop();
} else {
context.go(Ability().homeRoute);
}
},
),
),
backgroundColor: customColors.backgroundContainerColor,
body: BackgroundContainer(
setting: widget.settings,
child: SafeArea(
top: false,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: SingleChildScrollView(
child: ColumnBlock(
padding:
const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'作者:${article.author ?? '管理员'}',
style: TextStyle(
fontSize: 12,
color: customColors.weakTextColor,
),
),
if (article.createdAt != null)
Text(
DateFormat('yyyy/MM/dd HH:mm')
.format(article.createdAt!.toLocal()),
style: TextStyle(
fontSize: 12,
color:
customColors.weakTextColor?.withAlpha(100),
),
),
],
),
const SizedBox(height: 10),
Markdown(
data: article.content,
onUrlTap: (value) {
if (value.startsWith("aidea-app://")) {
var route = value.substring('aidea-app://'.length);
context.push(route);
} else {
launchUrlString(value);
}
},
),
],
)
],
),
),
),
),
),
);
}
}
Loading

0 comments on commit 9170559

Please sign in to comment.