update dependence
This commit is contained in:
@ -53,8 +53,9 @@ class _GalleryState extends ConsumerState<Gallery> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("build");
|
||||
|
||||
return GridView.builder(
|
||||
// controller: ,
|
||||
itemCount: imageList.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: MediaQuery.of(context).size.width > 640 ? 5 : 3),
|
||||
|
@ -19,12 +19,16 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
int selectedIndex = 0;
|
||||
final tabList = [
|
||||
{"path": "/", "title": "相册"},
|
||||
{"path": "/profile", "title": "用户"}
|
||||
{"path": "/profile", "title": "用户资料"},
|
||||
{"path": "/detail", "title": "图片详情"}
|
||||
];
|
||||
int key = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(
|
||||
widget.content.toString(),
|
||||
);
|
||||
print("123");
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: ["/", "/profile"].contains(GoRouterState.of(context).location)
|
||||
@ -36,7 +40,10 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
tabList[selectedIndex]["title"] ?? "",
|
||||
tabList.firstWhere((element) =>
|
||||
element["path"] ==
|
||||
GoRouterState.of(context).fullpath)["title"] ??
|
||||
"",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
elevation: 10,
|
||||
@ -60,6 +67,8 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
mimeType.split("/").last))
|
||||
});
|
||||
await dio.post("/image/upload", data: data).then((value) {
|
||||
// widget.content.key = GlobalKey();
|
||||
// widget.content
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.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/provider/token.dart';
|
||||
import 'package:momo/request/http_client.dart';
|
||||
@ -90,6 +91,7 @@ class _LoginFormState extends ConsumerState<LoginForm> {
|
||||
}
|
||||
} catch (e) {
|
||||
if (e is DioError) {
|
||||
print(e.response);
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(e.response?.data["msg"] ?? "请求错误")));
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ import 'package:momo/material/profile.dart';
|
||||
|
||||
class MyMaterialRouterConfig {
|
||||
late GoRouter router;
|
||||
final GlobalKey<NavigatorState> _rootNavigatorKey =
|
||||
GlobalKey<NavigatorState>();
|
||||
|
||||
MyMaterialRouterConfig(String? token) {
|
||||
router = GoRouter(
|
||||
navigatorKey: _rootNavigatorKey,
|
||||
initialLocation: "/",
|
||||
routes: <RouteBase>[
|
||||
ShellRoute(
|
||||
@ -19,29 +22,38 @@ class MyMaterialRouterConfig {
|
||||
content: child,
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: "/",
|
||||
name: "相册",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: Gallery()),
|
||||
const NoTransitionPage(
|
||||
child: Gallery(),
|
||||
),
|
||||
redirect: (BuildContext context, GoRouterState state) {
|
||||
if (token == null || token.isEmpty) {
|
||||
return '/login';
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
},
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: "detail",
|
||||
name: "图片详情",
|
||||
pageBuilder:
|
||||
(BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: ImageDetail())),
|
||||
]),
|
||||
GoRoute(
|
||||
path: "/profile",
|
||||
name: "个人资料",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: Profile())),
|
||||
GoRoute(
|
||||
path: "/detail",
|
||||
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||
const NoTransitionPage(child: ImageDetail())),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: "/login",
|
||||
name: "登录",
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const LoginPage();
|
||||
},
|
||||
|
17
lib/provider/gallery.dart
Normal file
17
lib/provider/gallery.dart
Normal 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());
|
@ -26,27 +26,3 @@ class TokenNotifier extends Notifier<String?> {
|
||||
|
||||
final tokenProvider =
|
||||
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", "");
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
var dio = Dio(BaseOptions(
|
||||
baseUrl: "http://localhost:8080",
|
||||
baseUrl: "http://192.168.0.110:8080",
|
||||
));
|
||||
|
26
pubspec.lock
26
pubspec.lock
@ -261,10 +261,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluent_ui
|
||||
sha256: f9d443f9181900cfab9f38793195c7c4221cf05eb86918ac3517e67c024da867
|
||||
sha256: ff172e78492faad2c9eca01b24ea8341f2bd6e1ce6986b15d4886fd2e7c3fb09
|
||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||
source: hosted
|
||||
version: "4.2.0"
|
||||
version: "4.3.0"
|
||||
fluentui_system_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -353,10 +353,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: "9e8cee9969a9f33821a5594e5822d9a7ef3ae8528e5258f5178436e3deb0e095"
|
||||
sha256: "313e5899851b43de7e779c4a054e8d489fb61caf95fe786bc301b13120557f03"
|
||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
version: "6.0.5"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -501,14 +501,6 @@ packages:
|
||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -597,14 +589,6 @@ packages:
|
||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -972,4 +956,4 @@ packages:
|
||||
version: "3.1.1"
|
||||
sdks:
|
||||
dart: ">=2.19.0 <3.0.0"
|
||||
flutter: ">=3.3.0"
|
||||
flutter: ">=3.7.0"
|
||||
|
@ -46,7 +46,6 @@ dependencies:
|
||||
flutter_riverpod: ^2.1.3
|
||||
window_manager: ^0.3.0
|
||||
tray_manager: ^0.2.0
|
||||
provider: ^6.0.5
|
||||
file_picker: ^5.2.5
|
||||
dio: ^4.0.6
|
||||
http_parser: ^4.0.2
|
||||
|
Reference in New Issue
Block a user