diff --git a/lib/client/science.ts b/lib/client/science.ts new file mode 100644 index 0000000..e630dba --- /dev/null +++ b/lib/client/science.ts @@ -0,0 +1,3 @@ +export const recordView = async (sid: number) => { + await useApiFetch(`/story/${sid}/set-viewed`); +}; diff --git a/pages/story/[id]/[cidx]/index.vue b/pages/story/[id]/[cidx]/index.vue index 14c5650..1a2bcc9 100644 --- a/pages/story/[id]/[cidx]/index.vue +++ b/pages/story/[id]/[cidx]/index.vue @@ -6,6 +6,7 @@ import storyInfo from "~/components/story/view/storyInfo.vue"; import chapterPicker from "~/components/story/view/chapterPicker.vue"; import { IUser } from "@models/user"; + import { recordView } from "@client/science"; const { useToken } = theme; const { token } = useToken(); @@ -24,6 +25,7 @@ useHead({ title: `"${story.value.title}" by ${story.value.author.username}${and.value}`, }); + await recordView(story.value._id!);