diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml deleted file mode 100644 index 6906d0f4..00000000 --- a/.github/workflows/mirror.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# This is a basic workflow to help you get started with Actions -name: host_mirror-gitee - -# Controls when the workflow will run -on: [push, delete] - -# update -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v1 - - uses: pixta-dev/repository-mirroring-action@v1 - with: - target_repo_url: - git@gitee.com:younpc/note.git - ssh_private_key: # <-- use 'secrets' to pass credential information. - ${{ secrets.ID_ED25519_GITEE_YOUNPC }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 27f5c32a..e724aa05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR ./you RUN ./bake install RUN if [[ "$test" = "on" ]]; then ./bake test ; fi -RUN ./bake flutter build --base-href "/you/flutter_web/" +RUN ./bake flutter_web build RUN pwd RUN ls -l @@ -24,7 +24,7 @@ FROM nginx:1.23.4 as nginx # ref: # https://github.com/nginxinc/docker-nginx/blob/master/mainline -COPY --from=ci /home/flutter/you/notes/flutter_web/build/web /usr/share/nginx/html/you/flutter_web +COPY --from=ci /home/flutter/you/notes/flutter_web/build/web /usr/share/nginx/html/ # The port that your application listens to. EXPOSE 443 diff --git a/bake b/bake index 16094181..ac9568e7 100755 --- a/bake +++ b/bake @@ -116,7 +116,7 @@ flutter_web.install() ( flutter_web.run flutter pub get) flutter_web.clean() ( flutter_web.run flutter clean; rm -rf build;) flutter_web.upgrade() ( flutter_web.run flutter pub upgrade ;) flutter_web.build_macos() { flutter_web.run flutter build macos -v --release --tree-shake-icons "$@"; } -flutter_web.build() { flutter_web.run flutter build web -v --release --tree-shake-icons --web-renderer html "$@" ;} +flutter_web.build() { flutter_web.run flutter build web -v --release --tree-shake-icons --web-renderer html --output build/web/you/flutter_web --base-href "/you/flutter_web/" "$@" ;} flutter_web.build_web_skwasm() { flutter_web.run flutter build web -v --release --tree-shake-icons --web-renderer skwasm "$@" ; } flutter_web.build_web_canvaskit() { flutter_web.run flutter build web -v --release --tree-shake-icons --web-renderer canvaskit "$@" ; } flutter_web.dev() { flutter_web.run flutter run --device-id macos "$@"; } diff --git a/notes/flutter_web/lib/main.dart b/notes/flutter_web/lib/main.dart index 95c57eb6..997fb0d7 100644 --- a/notes/flutter_web/lib/main.dart +++ b/notes/flutter_web/lib/main.dart @@ -3,13 +3,15 @@ import 'package:flutter_web/notes.g.dart'; import 'package:you_note_dart/note.dart'; import 'package:flutter_web/note_app.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_web_plugins/url_strategy.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + usePathUrlStrategy(); NoteSystem noteSystem = await NoteSystem.load( root: BaseNotes.rootroot, ); SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - runApp(NoteApp(noteSystem: noteSystem,sharedPreferences:sharedPreferences)); + runApp(NoteApp(noteSystem: noteSystem, sharedPreferences: sharedPreferences)); } diff --git a/packages/you_note_dart/lib/src/conventions.dart b/packages/you_note_dart/lib/src/conventions.dart index 05093915..3a26716c 100644 --- a/packages/you_note_dart/lib/src/conventions.dart +++ b/packages/you_note_dart/lib/src/conventions.dart @@ -5,14 +5,15 @@ import 'package:path/path.dart' as path; Conventions conventions = Conventions._(); +/// 惯用规则 class Conventions { Conventions._(); String noteDartAssetPath(String notePath) { - return path.join("lib/notes", notePath, "note.dart"); + return path.join("lib/notes", path.relative(notePath, from: "/"), "note.dart"); } String noteConfAssetPath(String notePath) { - return path.join("lib/notes", notePath, "note.json"); + return path.join("lib/notes", path.relative(notePath, from: "/"), "note.json"); } } diff --git a/packages/you_note_dart/lib/src/note_core.dart b/packages/you_note_dart/lib/src/note_core.dart index fd0e28f0..9a7f6ffb 100644 --- a/packages/you_note_dart/lib/src/note_core.dart +++ b/packages/you_note_dart/lib/src/note_core.dart @@ -140,9 +140,9 @@ class NoteRoute { String get displayName => conf != null ? conf!.displayName : basename; String get path { - if (isRoot) return ""; + if (isRoot) return "/"; var parentPath = parent!.path; - return parentPath == "" ? basename : "$parentPath/$basename"; + return parentPath == "/" ? "/$basename" : "$parentPath/$basename"; } List toList({ @@ -224,11 +224,7 @@ class NoteRoute { String get confAssetPath => conventions.noteConfAssetPath(path); Future lazyInit({required NotePageBuilder builder}) async { - return NotePage( - noteRoute: this, - pageBuilder: builder, - conf: conf == null ? null : NoteConf.decode(await rootBundle.loadString(confAssetPath)), - content: await rootBundle.loadString(dartAssetPath)); + return NotePage(noteRoute: this, pageBuilder: builder, conf: conf == null ? null : NoteConf.decode(await rootBundle.loadString(confAssetPath)), content: await rootBundle.loadString(dartAssetPath)); } } // TODO 这个类设计的比较突兀, @@ -386,10 +382,10 @@ class NoteCell extends ChangeNotifier { cell: this, specialSources: codeCell.specialNodes .map((e) => SpecialSource( - codeType: e.nodeType, - codeEntity: CodeEntity(offset: e.offset, end: e.end), - cell: this, - )) + codeType: e.nodeType, + codeEntity: CodeEntity(offset: e.offset, end: e.end), + cell: this, + )) .toList(), ); } diff --git a/packages/you_note_dart/pubspec.yaml b/packages/you_note_dart/pubspec.yaml index b0256dbb..b9dfe960 100644 --- a/packages/you_note_dart/pubspec.yaml +++ b/packages/you_note_dart/pubspec.yaml @@ -38,6 +38,7 @@ dev_dependencies: # for NoteDevTool stack_trace: ^1.11.0 + checks: ^0.3.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/you_note_dart/test/note_route_test.dart b/packages/you_note_dart/test/note_route_test.dart new file mode 100644 index 00000000..1e33156c --- /dev/null +++ b/packages/you_note_dart/test/note_route_test.dart @@ -0,0 +1,17 @@ +import 'package:collection/collection.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:checks/checks.dart'; +import 'package:path/path.dart' as path; +void main() { + group("Note path", () { + test("study", () async { + check(path.dirname("/")).equals("/"); + check(path.dirname("/a/b")).equals("/a"); + check(path.relative("/a/b",from: "/")).equals("a/b"); + check(path.dirname("")).equals("."); + check(path.basename("/")).equals("/"); + check(path.basename("")).equals(""); + + }); + }); +}