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('無效的帳號名稱')
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function commandListController(req, res) {
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
res.status(500).send('Error fetching data')
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function sessionListController(req, res) {
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error)
|
||||
res.status(500).send('Error fetching session data')
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function userListController(req, res) {
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
res.status(500).send('Error fetching user data')
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Strategy as GoogleStrategy } from 'passport-google-oidc'
|
||||
import config from '../config.js'
|
||||
import oauthVerify from './oauthVerify.js'
|
||||
|
||||
function verify(issuer: string, profile: any, cb: any) {
|
||||
function verify(profile: any, cb: any) {
|
||||
oauthVerify('google', profile, { 'socialLogins.google.id': profile.id }, cb)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ async function verifyPassword(
|
||||
username: string,
|
||||
password: string,
|
||||
done: (
|
||||
error: any,
|
||||
error: Error | null,
|
||||
user?: Express.User | false,
|
||||
options?: IVerifyOptions
|
||||
) => void
|
||||
@@ -34,7 +34,7 @@ async function verifyPassword(
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
})
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
return done(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export async function deleteContainer(id: string) {
|
||||
}
|
||||
try {
|
||||
await container.stop()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.warn('Failed to stop container', id)
|
||||
}
|
||||
await container.remove()
|
||||
@@ -127,7 +127,7 @@ export function buildQuestImage(questPath: string, questId: string) {
|
||||
.forEach((line: string) => {
|
||||
parseJSONOutput(line)
|
||||
})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ export function asyncHandler(fn: any) {
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export default function errorHandler(
|
||||
err: any,
|
||||
err: Error,
|
||||
req: Request,
|
||||
res: Response,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
@@ -9,9 +9,9 @@ const questDirectory = path.join(process.cwd(), '..', 'quests')
|
||||
|
||||
class QuestValidationError extends Error {
|
||||
questId: string
|
||||
error: any
|
||||
error: Error | null
|
||||
|
||||
constructor(message: string, questId: string, error: any) {
|
||||
constructor(message: string, questId: string, error: Error | null) {
|
||||
super(message)
|
||||
this.name = 'QuestValidationError'
|
||||
this.questId = questId
|
||||
@@ -68,7 +68,7 @@ export async function loadAndUpdateQuests() {
|
||||
})
|
||||
quest.exceptions.push(...exceptions)
|
||||
await quest.save()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.error(`Error parsing quest`, { id, error })
|
||||
throw new QuestValidationError(`Error parsing quest`, id, error)
|
||||
}
|
||||
|
||||
@@ -1043,6 +1043,13 @@
|
||||
"@types/docker-modem" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/dompurify@^3.0.5":
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/dompurify/-/dompurify-3.0.5.tgz#02069a2fcb89a163bacf1a788f73cb415dd75cb7"
|
||||
integrity sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==
|
||||
dependencies:
|
||||
"@types/trusted-types" "*"
|
||||
|
||||
"@types/dotenv@^8.2.0":
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-8.2.0.tgz#5cd64710c3c98e82d9d15844375a33bf1b45d053"
|
||||
@@ -1307,6 +1314,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/triple-beam/-/triple-beam-1.3.5.tgz#74fef9ffbaa198eb8b588be029f38b00299caa2c"
|
||||
integrity sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==
|
||||
|
||||
"@types/trusted-types@*":
|
||||
version "2.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.7.tgz#baccb07a970b91707df3a3e8ba6896c57ead2d11"
|
||||
integrity sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==
|
||||
|
||||
"@types/validator@^13.11.9":
|
||||
version "13.11.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.11.9.tgz#adfe96520b437a0eaa798a475877bf2f75ee402d"
|
||||
|
||||
Reference in new issue
Block a user