-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Nauxscript/feature/progress-limit
Feature/progress limit
- Loading branch information
Showing
10 changed files
with
132 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<dialog className="modal" :open="authRequireModalState"> | ||
<div className="modal-box"> | ||
<h3 className="font-bold text-lg mb-4">✨</h3> | ||
<p class="text-xl px-4">注册以进行下一课</p> | ||
<div className="modal-action"> | ||
<button class="btn" @click="hideAuthRequireModal">取消</button> | ||
<button class="btn" @click="navigateTo('/auth/signup')">去注册</button> | ||
</div> | ||
</div> | ||
</dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useAuthRequire } from "~/composables/main/authRequire"; | ||
const { authRequireModalState, hideAuthRequireModal } = useAuthRequire() | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const authRequireModalState = ref() | ||
|
||
export function useAuthRequire() { | ||
function showAuthRequireModal() { | ||
authRequireModalState.value = true; | ||
} | ||
|
||
function hideAuthRequireModal() { | ||
authRequireModalState.value = false; | ||
} | ||
|
||
return { | ||
showAuthRequireModal, | ||
hideAuthRequireModal, | ||
authRequireModalState | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { fetchUpdateProgress, fetchUserProgress } from "~/api/userProgress" | ||
|
||
export const ACTIVE_COURSE_ID = 'activeCourseId' | ||
export function useUserProgress() { | ||
|
||
const activeCourseId = ref(1) | ||
|
||
const initing = ref(false) | ||
const initProgress = async () => { | ||
initing.value = true | ||
const { courseId } = await fetchUserProgress() | ||
activeCourseId.value = +courseId | ||
updateProgressLocal(+courseId) | ||
initing.value = false | ||
} | ||
|
||
const updateProgress = async (courseId: number) => { | ||
const { courseId: updatedCourseId } = await fetchUpdateProgress({courseId}) | ||
updateProgressLocal(updatedCourseId) | ||
} | ||
|
||
const updateProgressLocal = async (courseId: number) => { | ||
localStorage.setItem(ACTIVE_COURSE_ID, `${courseId}`) | ||
} | ||
|
||
return { | ||
activeCourseId, | ||
initing, | ||
updateProgressLocal, | ||
updateProgress, | ||
initProgress | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useUserStore } from "~/store/user" | ||
|
||
export default defineNuxtRouteMiddleware((to, from) => { | ||
const userStore = useUserStore() | ||
if (!userStore.user && +to.params.id !== 1) { | ||
return navigateTo("/auth/login"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters