From 9d1ba5a837679ac5841c36879a6c94eacf65bccf Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Sat, 21 Sep 2024 11:02:51 +0800 Subject: [PATCH 1/2] move nav to home --- api/Notepad.fsproj | 3 +- api/Program.fs | 1 + api/Word.fs | 13 ++++++ web/src/components/DiaryEditor.vue | 37 ++++------------- web/src/router.js | 2 +- web/src/util.js | 2 +- web/src/views/Home.vue | 67 +++++++++++++++++++++++++++--- 7 files changed, 87 insertions(+), 38 deletions(-) create mode 100644 api/Word.fs diff --git a/api/Notepad.fsproj b/api/Notepad.fsproj index 3c9b38c..2bbf20a 100644 --- a/api/Notepad.fsproj +++ b/api/Notepad.fsproj @@ -1,4 +1,4 @@ - + Exe net8.0 @@ -16,6 +16,7 @@ + diff --git a/api/Program.fs b/api/Program.fs index 9a5a5ad..45e7a08 100644 --- a/api/Program.fs +++ b/api/Program.fs @@ -153,6 +153,7 @@ webHost [||] { get "/api/diary/{id}" Note.noteByIdPartDebug put "/api/diary/{id}" Note.addNotePart get "/api/todo" Note.todoListsHandler + get "/api/random-word" Word.getRandomWord ] use_middleware serveVueFiles diff --git a/api/Word.fs b/api/Word.fs new file mode 100644 index 0000000..e840eaa --- /dev/null +++ b/api/Word.fs @@ -0,0 +1,13 @@ +module Word + +open System + +let randomWords = + [ ] // Add more words as needed + +let getRandomWord = + fun ctx -> + let random = Random() + let word = randomWords.[random.Next(randomWords.Length)] + // refresh note summary + Falco.Request.mapRoute (ignore) (fun _ -> {| word = word |} |> Json.Response.ofJson) ctx diff --git a/web/src/components/DiaryEditor.vue b/web/src/components/DiaryEditor.vue index 47d53db..74dd861 100644 --- a/web/src/components/DiaryEditor.vue +++ b/web/src/components/DiaryEditor.vue @@ -1,15 +1,5 @@