Explorar el Código

fix: #1976 Adding a cover image via upload doesn't work

Lucas.Xu hace 2 años
padre
commit
dcf48ceb50

+ 3 - 2
frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/change_cover_popover.dart

@@ -16,6 +16,7 @@ import 'package:flowy_infra_ui/style_widget/icon_button.dart';
 import 'package:flowy_infra_ui/style_widget/text.dart';
 import 'package:flutter/material.dart';
 import 'package:shared_preferences/shared_preferences.dart';
+import 'package:path/path.dart' as Path;
 
 const String kLocalImagesKey = 'local_images';
 
@@ -263,7 +264,7 @@ class _ChangeCoverPopoverState extends State<ChangeCoverPopover> {
       if (path != null) {
         final directory = await _coverPath();
         final newPath = await File(path).copy(
-          '$directory/${path.split('/').last}',
+          '$directory/${Path.split(path).last}}',
         );
         imageNames.add(newPath.path);
       }
@@ -274,7 +275,7 @@ class _ChangeCoverPopoverState extends State<ChangeCoverPopover> {
 
   Future<String> _coverPath() async {
     final directory = await getIt<SettingsLocationCubit>().fetchLocation();
-    return Directory('$directory/covers')
+    return Directory(Path.join(directory, 'covers'))
         .create(recursive: true)
         .then((value) => value.path);
   }

+ 4 - 3
frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart

@@ -2,6 +2,7 @@ import 'dart:io';
 
 import 'package:appflowy_backend/appflowy_backend.dart';
 import 'package:path_provider/path_provider.dart';
+import 'package:path/path.dart' as Path;
 
 import '../startup.dart';
 
@@ -35,11 +36,11 @@ Future<Directory> appFlowyDocumentDirectory() async {
   switch (integrationEnv()) {
     case IntegrationMode.develop:
       Directory documentsDir = await getApplicationDocumentsDirectory();
-      return Directory('${documentsDir.path}/flowy_dev').create();
+      return Directory(Path.join(documentsDir.path, 'flowy_dev')).create();
     case IntegrationMode.release:
       Directory documentsDir = await getApplicationDocumentsDirectory();
-      return Directory('${documentsDir.path}/flowy').create();
+      return Directory(Path.join(documentsDir.path, 'flowy')).create();
     case IntegrationMode.test:
-      return Directory("${Directory.current.path}/.sandbox");
+      return Directory(Path.join(Directory.current.path, '.sandbox'));
   }
 }

+ 1 - 1
frontend/appflowy_flutter/pubspec.lock

@@ -830,7 +830,7 @@ packages:
     source: hosted
     version: "1.0.5"
   path:
-    dependency: transitive
+    dependency: "direct main"
     description:
       name: path
       url: "https://pub.dartlang.org"

+ 1 - 0
frontend/appflowy_flutter/pubspec.yaml

@@ -95,6 +95,7 @@ dependencies:
   window_manager: ^0.3.0
   http: ^0.13.5
   json_annotation: ^4.7.0
+  path: ^1.8.2
 
 dev_dependencies:
   flutter_lints: ^2.0.1