update dependence

This commit is contained in:
quantulr
2023-02-10 00:07:41 +08:00
parent 2aa59649a8
commit bd259d8303
9 changed files with 58 additions and 58 deletions

View File

@ -53,8 +53,9 @@ class _GalleryState extends ConsumerState<Gallery> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("build");
return GridView.builder( return GridView.builder(
// controller: ,
itemCount: imageList.length, itemCount: imageList.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: MediaQuery.of(context).size.width > 640 ? 5 : 3), crossAxisCount: MediaQuery.of(context).size.width > 640 ? 5 : 3),

View File

@ -19,12 +19,16 @@ class _HomePageState extends ConsumerState<HomePage> {
int selectedIndex = 0; int selectedIndex = 0;
final tabList = [ final tabList = [
{"path": "/", "title": "相册"}, {"path": "/", "title": "相册"},
{"path": "/profile", "title": "用户"} {"path": "/profile", "title": "用户资料"},
{"path": "/detail", "title": "图片详情"}
]; ];
int key = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print(
widget.content.toString(),
);
print("123");
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: ["/", "/profile"].contains(GoRouterState.of(context).location) leading: ["/", "/profile"].contains(GoRouterState.of(context).location)
@ -36,7 +40,10 @@ class _HomePageState extends ConsumerState<HomePage> {
}, },
), ),
title: Text( title: Text(
tabList[selectedIndex]["title"] ?? "", tabList.firstWhere((element) =>
element["path"] ==
GoRouterState.of(context).fullpath)["title"] ??
"",
style: const TextStyle(fontWeight: FontWeight.bold), style: const TextStyle(fontWeight: FontWeight.bold),
), ),
elevation: 10, elevation: 10,
@ -60,6 +67,8 @@ class _HomePageState extends ConsumerState<HomePage> {
mimeType.split("/").last)) mimeType.split("/").last))
}); });
await dio.post("/image/upload", data: data).then((value) { await dio.post("/image/upload", data: data).then((value) {
// widget.content.key = GlobalKey();
// widget.content
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Row( content: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:momo/models/login_resp.dart'; import 'package:momo/models/login_resp.dart';
import 'package:momo/provider/token.dart'; import 'package:momo/provider/token.dart';
import 'package:momo/request/http_client.dart'; import 'package:momo/request/http_client.dart';
@ -90,6 +91,7 @@ class _LoginFormState extends ConsumerState<LoginForm> {
} }
} catch (e) { } catch (e) {
if (e is DioError) { if (e is DioError) {
print(e.response);
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(e.response?.data["msg"] ?? "请求错误"))); content: Text(e.response?.data["msg"] ?? "请求错误")));
} }

View File

@ -8,9 +8,12 @@ import 'package:momo/material/profile.dart';
class MyMaterialRouterConfig { class MyMaterialRouterConfig {
late GoRouter router; late GoRouter router;
final GlobalKey<NavigatorState> _rootNavigatorKey =
GlobalKey<NavigatorState>();
MyMaterialRouterConfig(String? token) { MyMaterialRouterConfig(String? token) {
router = GoRouter( router = GoRouter(
navigatorKey: _rootNavigatorKey,
initialLocation: "/", initialLocation: "/",
routes: <RouteBase>[ routes: <RouteBase>[
ShellRoute( ShellRoute(
@ -19,29 +22,38 @@ class MyMaterialRouterConfig {
content: child, content: child,
); );
}, },
routes: [ routes: <RouteBase>[
GoRoute( GoRoute(
path: "/", path: "/",
name: "相册",
pageBuilder: (BuildContext context, GoRouterState state) => pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: Gallery()), const NoTransitionPage(
child: Gallery(),
),
redirect: (BuildContext context, GoRouterState state) { redirect: (BuildContext context, GoRouterState state) {
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
return '/login'; return '/login';
} }
return null; return null;
}), },
routes: <RouteBase>[
GoRoute(
path: "detail",
name: "图片详情",
pageBuilder:
(BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: ImageDetail())),
]),
GoRoute( GoRoute(
path: "/profile", path: "/profile",
name: "个人资料",
pageBuilder: (BuildContext context, GoRouterState state) => pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: Profile())), const NoTransitionPage(child: Profile())),
GoRoute(
path: "/detail",
pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: ImageDetail())),
], ],
), ),
GoRoute( GoRoute(
path: "/login", path: "/login",
name: "登录",
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
return const LoginPage(); return const LoginPage();
}, },

17
lib/provider/gallery.dart Normal file
View File

@ -0,0 +1,17 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class GalleryUpdateKeyNotifier extends Notifier<GlobalKey> {
@override
GlobalKey build() {
return GlobalKey();
}
void updateGallery() {
state = GlobalKey();
}
}
final galleryUpdateKeyProvider =
NotifierProvider<GalleryUpdateKeyNotifier, GlobalKey>(
() => GalleryUpdateKeyNotifier());

View File

@ -26,27 +26,3 @@ class TokenNotifier extends Notifier<String?> {
final tokenProvider = final tokenProvider =
NotifierProvider<TokenNotifier, String?>(() => TokenNotifier()); NotifierProvider<TokenNotifier, String?>(() => TokenNotifier());
// import 'package:fluent_ui/fluent_ui.dart';
// import 'package:fluent_ui/fluent_ui.dart';
// import 'package:shared_preferences/shared_preferences.dart';
//
// class Secret extends ChangeNotifier {
// String? token;
//
// void setToken(String? data) {
// token = data;
// SharedPreferences.getInstance().then((prefs) {
// prefs.setString("token", data ?? "");
// });
// // notifyListeners();
// // notifyListeners();
// }
//
// void removeToken() {
// token = "";
// SharedPreferences.getInstance().then((prefs) {
// prefs.setString("token", "");
// });
// }
// }

View File

@ -1,5 +1,5 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
var dio = Dio(BaseOptions( var dio = Dio(BaseOptions(
baseUrl: "http://localhost:8080", baseUrl: "http://192.168.0.110:8080",
)); ));

View File

@ -261,10 +261,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: fluent_ui name: fluent_ui
sha256: f9d443f9181900cfab9f38793195c7c4221cf05eb86918ac3517e67c024da867 sha256: ff172e78492faad2c9eca01b24ea8341f2bd6e1ce6986b15d4886fd2e7c3fb09
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.2.0" version: "4.3.0"
fluentui_system_icons: fluentui_system_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -353,10 +353,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: go_router name: go_router
sha256: "9e8cee9969a9f33821a5594e5822d9a7ef3ae8528e5258f5178436e3deb0e095" sha256: "313e5899851b43de7e779c4a054e8d489fb61caf95fe786bc301b13120557f03"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "6.0.3" version: "6.0.5"
graphs: graphs:
dependency: transitive dependency: transitive
description: description:
@ -501,14 +501,6 @@ packages:
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.7.0" version: "3.7.0"
nested:
dependency: transitive
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "1.0.0"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@ -597,14 +589,6 @@ packages:
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
provider:
dependency: "direct main"
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "6.0.5"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
@ -972,4 +956,4 @@ packages:
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.19.0 <3.0.0" dart: ">=2.19.0 <3.0.0"
flutter: ">=3.3.0" flutter: ">=3.7.0"

View File

@ -46,7 +46,6 @@ dependencies:
flutter_riverpod: ^2.1.3 flutter_riverpod: ^2.1.3
window_manager: ^0.3.0 window_manager: ^0.3.0
tray_manager: ^0.2.0 tray_manager: ^0.2.0
provider: ^6.0.5
file_picker: ^5.2.5 file_picker: ^5.2.5
dio: ^4.0.6 dio: ^4.0.6
http_parser: ^4.0.2 http_parser: ^4.0.2