diff --git a/.changes/splash.md b/.changes/splash.md new file mode 100644 index 0000000..6c58ed2 --- /dev/null +++ b/.changes/splash.md @@ -0,0 +1,5 @@ +--- +"algohub": patch:feat +--- + +Add splash screen before loading index page. diff --git a/src/components/MonacoEditor.vue b/src/components/MonacoEditor.vue index 7a633c0..fc494a2 100644 --- a/src/components/MonacoEditor.vue +++ b/src/components/MonacoEditor.vue @@ -104,7 +104,7 @@ const onSubmit = () => { emit( 'submit', rawEditor.value.getValue(), - language, + language.value, (text: string, severity: Severity) => { submitting.value = false message.value = { text, severity } diff --git a/src/components/SplashScreen.vue b/src/components/SplashScreen.vue new file mode 100644 index 0000000..e823da2 --- /dev/null +++ b/src/components/SplashScreen.vue @@ -0,0 +1,88 @@ + + + + + + + + AlgoHub + + + + {{ texts[index] }} + + {{ status }} + + + + Copyright © 2006-present ACM-SWPU. All rights reserved. + + + \ No newline at end of file diff --git a/src/scripts/api.ts b/src/scripts/api.ts index babf472..ff07f29 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -8,6 +8,8 @@ import type { Profile, UserContent, CreateProblem, + Language, + RecordId, } from "./types"; export interface Response { @@ -79,6 +81,15 @@ export const login = async (form: Login) => { } }; +export const verifyToken = async (auth?: Credentials) => { + try { + const response = await axios.post("/account/verify", auth); + return response.data as Response; + } catch (error) { + return handleAxiosError(AxiosError.from(error)); + } +}; + export const fetchProfile = async (id: string) => { try { const response = await axios.get(`/account/profile/${id}`); @@ -131,10 +142,34 @@ interface SubmitCodeForm { lang: string; } +interface Id { + id: string; +} + export const submitCode = async (problem_id: string, form: SubmitCodeForm) => { try { const response = await axios.post(`/code/submit/${problem_id}`, form); - return response.data as Response; + return response.data as Response; + } catch (error) { + return handleAxiosError(AxiosError.from(error)); + } +}; + +interface Submission { + id: string; + lang: Language; + problem: RecordId; + code: string; + status: 'in_queue' | 'judging' | 'ready'; + judge_details: { status: any, timeUsed: number, memoryUsed: number }[], + judge_result: { status: any, timeUsed: number, memoryUsed: number }, + // contest +} + +export const fetchSubmission = async (id: string, form?: Credentials) => { + try { + const response = await axios.post(`/code/get/${id}`, form); + return response.data as Response; } catch (error) { return handleAxiosError(AxiosError.from(error)); } diff --git a/src/views/index.vue b/src/views/index.vue index b7d2a58..3d205cb 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -1,20 +1,18 @@ - + - AlgoHub is on nightly build now! Want to try it out? + AlgoHub is on alpha now! Want to try it out? See the latest updates! @@ -24,7 +22,7 @@ if (accountStore.isLoggedIn) { Releases - + -import { onMounted, ref } from 'vue'; +import { onMounted, onUnmounted, ref } from 'vue'; import { useRoute } from 'vue-router'; import * as api from '@/scripts/api'; import { useAccountStore, useThemeStore } from '@/scripts/store'; @@ -33,7 +33,7 @@ const formatProblem = (problem: UserProblem) => { } hint && (formattedText += `## Hint\n\n${hint}\n\n`); - return formattedText; + return formattedText.repeat(10); } const code = ref(''); @@ -53,7 +53,12 @@ const onSubmit = async (code: string, lang: Language, finish: (text: string, sev if (!res.success) { return finish(res.message, 'error'); } - finish('Code submitted', 'success'); + await new Promise(resolve => setTimeout(resolve, 2000)); + const submission = await api.fetchSubmission(res.data!.id, accountStore.auth!); + if (!submission.success) { + return finish(submission.message, 'error'); + } + finish(submission.data!.judge_result.status, 'success'); } const path = ref<{ label?: string, link?: string }[]>([]); @@ -74,24 +79,49 @@ onMounted(async () => { ] loading.value = false; }) + +const windowWidth = ref(window.innerWidth); +window.onresize = () => { + windowWidth.value = window.innerWidth; +} + +onUnmounted(() => { + window.onresize = null; +}) - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + @@ -100,3 +130,9 @@ onMounted(async () => { + + \ No newline at end of file
- AlgoHub is on nightly build now! Want to try it out? + AlgoHub is on alpha now! Want to try it out? See the latest updates!