mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix types issue
This commit is contained in:
1 parent
ec63bba0fe
commit
807974d727
15 files changed
+49
-25
No files matched your search
@@ -33,6 +33,7 @@
|
||||
"xterm-addon-fit": "^0.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/validator": "^13.11.9",
|
||||
"@vitejs/plugin-vue": "^4.5.2",
|
||||
"@vue/compiler-sfc": "^3.3.13",
|
||||
"autoprefixer": "^10.4.14",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { reactive } from 'vue'
|
||||
import { useToast } from 'vue-toastification'
|
||||
import { FileGraph, FileObject } from '@linux-odyssey/file-graph'
|
||||
// eslint-disable-next-line import/no-relative-packages
|
||||
import { IQuest } from '../../../packages/models/src/quest'
|
||||
import api from '../utils/api'
|
||||
import Socket from '../utils/socket'
|
||||
import SocketTerminal from '../utils/terminal'
|
||||
@@ -35,7 +37,7 @@ interface Session {
|
||||
interface Store {
|
||||
session: Session
|
||||
questId: string
|
||||
quest: any // 这里需要根据实际情况定义 quest 属性的类型
|
||||
quest: IQuest | null
|
||||
}
|
||||
|
||||
const store: Store = reactive({
|
||||
|
||||
+10
-5
@@ -12,7 +12,12 @@ export async function isLoggedIn() {
|
||||
return loggedIn
|
||||
}
|
||||
|
||||
function handleRequestError(err: { response: { data?: any; status?: any } }) {
|
||||
function handleRequestError(err: {
|
||||
response: {
|
||||
data?: any
|
||||
status?: number
|
||||
}
|
||||
}) {
|
||||
if (!err.response) throw err // Not an axios error
|
||||
const { status } = err.response
|
||||
if (status === 429) {
|
||||
@@ -41,14 +46,14 @@ function handleRequestError(err: { response: { data?: any; status?: any } }) {
|
||||
throw err
|
||||
}
|
||||
|
||||
export const login = (username: any, password: any) => {
|
||||
export const login = (username: string, password: string) => {
|
||||
return api
|
||||
.post('/auth/login', { username, password })
|
||||
.then(() => true)
|
||||
.catch(handleRequestError)
|
||||
}
|
||||
|
||||
export const register = (username: any, email: any, password: any) => {
|
||||
export const register = (username: string, email: string, password: string) => {
|
||||
return api
|
||||
.post('/auth/register', {
|
||||
username,
|
||||
@@ -59,7 +64,7 @@ export const register = (username: any, email: any, password: any) => {
|
||||
.catch(handleRequestError)
|
||||
}
|
||||
|
||||
export const checkUsername = async (username: any) => {
|
||||
export const checkUsername = async (username: string) => {
|
||||
return api
|
||||
.get('/auth/check-username', {
|
||||
params: { username },
|
||||
@@ -68,7 +73,7 @@ export const checkUsername = async (username: any) => {
|
||||
.catch(handleRequestError)
|
||||
}
|
||||
|
||||
export const chooseUsername = async (username: any) => {
|
||||
export const chooseUsername = async (username: string) => {
|
||||
return api
|
||||
.post('/auth/register-from-session', { username })
|
||||
.then(() => true)
|
||||
|
||||
@@ -40,8 +40,9 @@ async function handleSubmit({
|
||||
error,
|
||||
}: {
|
||||
username: string
|
||||
success: any
|
||||
error: any
|
||||
success: () => void
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
error: (msg: string) => void
|
||||
}) {
|
||||
try {
|
||||
await chooseUsername(username)
|
||||
|
||||
@@ -17,8 +17,9 @@ const handleLogin = async ({
|
||||
}: {
|
||||
username: string
|
||||
password: string
|
||||
success: any
|
||||
error: any
|
||||
success: () => void
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
error: (msg: string) => void
|
||||
}) => {
|
||||
try {
|
||||
const isSuccess = await login(username, password)
|
||||
|
||||
@@ -22,8 +22,9 @@ function handleRegister({
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
success: any
|
||||
error: any
|
||||
success: () => void
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
error: (msg: string) => void
|
||||
}) {
|
||||
register(username, email, password)
|
||||
.then(success)
|
||||
@@ -54,7 +55,8 @@ async function check({
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
error: any
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
error: (msg: string) => void
|
||||
}) {
|
||||
if (username && !isValidUsername(username)) {
|
||||
error('無效的帳號名稱')
|
||||
|
||||
Reference in new issue
Block a user