mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
update views
This commit is contained in:
1 parent
63a57aa2cf
commit
4739849549
6 files changed
+54
-14
No files matched your search
@@ -1,11 +1,11 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { isValidUsername } from '@linux-odyssey/utils'
|
import { isValidUsername } from '@linux-odyssey/utils'
|
||||||
import AuthForm from '../components/AuthForm.vue'
|
import AuthForm from '../components/AuthForm.vue'
|
||||||
import Background from '../components/DynamicBackground.vue'
|
import Background from '../components/DynamicBackground.vue'
|
||||||
import { TooManyRequestsError, ValidationError } from '../utils/errors'
|
import { TooManyRequestsError, ValidationError } from '../utils/errors'
|
||||||
import { checkUsername, chooseUsername } from '../utils/auth'
|
import { checkUsername, chooseUsername } from '../utils/auth'
|
||||||
|
|
||||||
async function check({ username, error }) {
|
async function check({ username, error }: { username: string; error: any }) {
|
||||||
if (username) {
|
if (username) {
|
||||||
if (!isValidUsername(username)) {
|
if (!isValidUsername(username)) {
|
||||||
// error('Invalid username.')
|
// error('Invalid username.')
|
||||||
@@ -30,11 +30,19 @@ async function check({ username, error }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit({ username, success, error }) {
|
async function handleSubmit({
|
||||||
|
username,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
username: string
|
||||||
|
success: any
|
||||||
|
error: any
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
await chooseUsername(username)
|
await chooseUsername(username)
|
||||||
success()
|
success()
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
if (err instanceof TooManyRequestsError) {
|
if (err instanceof TooManyRequestsError) {
|
||||||
// error('Too many requests. Try again in 2 minutes.')
|
// error('Too many requests. Try again in 2 minutes.')
|
||||||
error('太多請求,兩分鐘後再試一次。')
|
error('太多請求,兩分鐘後再試一次。')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed, onMounted } from 'vue'
|
import { computed, onMounted } from 'vue'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import sessionStore, { init } from '../store/session'
|
import sessionStore, { init } from '../store/session'
|
||||||
@@ -28,7 +28,7 @@ const toast = useToast()
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
await init(props.questId)
|
await init(props.questId)
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
if (err instanceof LoadQuestError) {
|
if (err instanceof LoadQuestError) {
|
||||||
// toast.error(`Failed to load quest: ${err.questId}. Please check the URL.`)
|
// toast.error(`Failed to load quest: ${err.questId}. Please check the URL.`)
|
||||||
toast.error(`無法讀取關卡: ${err.questId},請確認網頁連結。`)
|
toast.error(`無法讀取關卡: ${err.questId},請確認網頁連結。`)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import DynamicBackground from '../components/DynamicBackground.vue'
|
import DynamicBackground from '../components/DynamicBackground.vue'
|
||||||
@@ -12,7 +12,7 @@ async function getLeaderboard() {
|
|||||||
try {
|
try {
|
||||||
const res = await api.get('/leaderboard')
|
const res = await api.get('/leaderboard')
|
||||||
leaderboard.value = res.data
|
leaderboard.value = res.data
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
toast.error('讀取排行榜失敗')
|
toast.error('讀取排行榜失敗')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import AuthForm from '../components/AuthForm.vue'
|
import AuthForm from '../components/AuthForm.vue'
|
||||||
import Background from '../components/DynamicBackground.vue'
|
import Background from '../components/DynamicBackground.vue'
|
||||||
|
|
||||||
@@ -9,7 +9,17 @@ import {
|
|||||||
} from '../utils/errors'
|
} from '../utils/errors'
|
||||||
import { login } from '../utils/auth'
|
import { login } from '../utils/auth'
|
||||||
|
|
||||||
const handleLogin = async ({ username, password, success, error }) => {
|
const handleLogin = async ({
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
success: any
|
||||||
|
error: any
|
||||||
|
}) => {
|
||||||
try {
|
try {
|
||||||
const isSuccess = await login(username, password)
|
const isSuccess = await login(username, password)
|
||||||
if (isSuccess) success()
|
if (isSuccess) success()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import QuestMap from '../components/QuestMap.vue'
|
import QuestMap from '../components/QuestMap.vue'
|
||||||
import GameHeaderPart from '../components/GameHeaderPart.vue'
|
import GameHeaderPart from '../components/GameHeaderPart.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
import { isValidUsername } from '@linux-odyssey/utils'
|
import { isValidUsername } from '@linux-odyssey/utils'
|
||||||
import { passwordPolicy } from '@linux-odyssey/constants'
|
import { passwordPolicy } from '@linux-odyssey/constants'
|
||||||
@@ -12,7 +12,19 @@ import {
|
|||||||
ValidationError,
|
ValidationError,
|
||||||
} from '../utils/errors'
|
} from '../utils/errors'
|
||||||
|
|
||||||
function handleRegister({ username, email, password, success, error }) {
|
function handleRegister({
|
||||||
|
username,
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
password: string
|
||||||
|
success: any
|
||||||
|
error: any
|
||||||
|
}) {
|
||||||
register(username, email, password)
|
register(username, email, password)
|
||||||
.then(success)
|
.then(success)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -36,7 +48,17 @@ function handleRegister({ username, email, password, success, error }) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function check({ username, email, password, error }) {
|
async function check({
|
||||||
|
username,
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
username: string
|
||||||
|
email: string
|
||||||
|
password: string
|
||||||
|
error: any
|
||||||
|
}) {
|
||||||
if (username && !isValidUsername(username)) {
|
if (username && !isValidUsername(username)) {
|
||||||
// error('Invalid username.')
|
// error('Invalid username.')
|
||||||
error('無效的帳號名稱')
|
error('無效的帳號名稱')
|
||||||
|
|||||||
Reference in new issue
Block a user