fix types issue

This commit is contained in:
Chen, Tai-Lin committed 2024-03-05 00:27:08 +08:00
1 parent ec63bba0fe
commit 807974d727
15 files changed
+49 -25

No files matched your search

+1
View File
@@ -33,6 +33,7 @@
"xterm-addon-fit": "^0.7.0" "xterm-addon-fit": "^0.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/validator": "^13.11.9",
"@vitejs/plugin-vue": "^4.5.2", "@vitejs/plugin-vue": "^4.5.2",
"@vue/compiler-sfc": "^3.3.13", "@vue/compiler-sfc": "^3.3.13",
"autoprefixer": "^10.4.14", "autoprefixer": "^10.4.14",
+3 -1
View File
@@ -1,6 +1,8 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
import { FileGraph, FileObject } from '@linux-odyssey/file-graph' 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 api from '../utils/api'
import Socket from '../utils/socket' import Socket from '../utils/socket'
import SocketTerminal from '../utils/terminal' import SocketTerminal from '../utils/terminal'
@@ -35,7 +37,7 @@ interface Session {
interface Store { interface Store {
session: Session session: Session
questId: string questId: string
quest: any // 这里需要根据实际情况定义 quest 属性的类型 quest: IQuest | null
} }
const store: Store = reactive({ const store: Store = reactive({
+10 -5
View File
@@ -12,7 +12,12 @@ export async function isLoggedIn() {
return loggedIn 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 if (!err.response) throw err // Not an axios error
const { status } = err.response const { status } = err.response
if (status === 429) { if (status === 429) {
@@ -41,14 +46,14 @@ function handleRequestError(err: { response: { data?: any; status?: any } }) {
throw err throw err
} }
export const login = (username: any, password: any) => { export const login = (username: string, password: string) => {
return api return api
.post('/auth/login', { username, password }) .post('/auth/login', { username, password })
.then(() => true) .then(() => true)
.catch(handleRequestError) .catch(handleRequestError)
} }
export const register = (username: any, email: any, password: any) => { export const register = (username: string, email: string, password: string) => {
return api return api
.post('/auth/register', { .post('/auth/register', {
username, username,
@@ -59,7 +64,7 @@ export const register = (username: any, email: any, password: any) => {
.catch(handleRequestError) .catch(handleRequestError)
} }
export const checkUsername = async (username: any) => { export const checkUsername = async (username: string) => {
return api return api
.get('/auth/check-username', { .get('/auth/check-username', {
params: { username }, params: { username },
@@ -68,7 +73,7 @@ export const checkUsername = async (username: any) => {
.catch(handleRequestError) .catch(handleRequestError)
} }
export const chooseUsername = async (username: any) => { export const chooseUsername = async (username: string) => {
return api return api
.post('/auth/register-from-session', { username }) .post('/auth/register-from-session', { username })
.then(() => true) .then(() => true)
+3 -2
View File
@@ -40,8 +40,9 @@ async function handleSubmit({
error, error,
}: { }: {
username: string username: string
success: any success: () => void
error: any // eslint-disable-next-line no-unused-vars
error: (msg: string) => void
}) { }) {
try { try {
await chooseUsername(username) await chooseUsername(username)
+3 -2
View File
@@ -17,8 +17,9 @@ const handleLogin = async ({
}: { }: {
username: string username: string
password: string password: string
success: any success: () => void
error: any // eslint-disable-next-line no-unused-vars
error: (msg: string) => void
}) => { }) => {
try { try {
const isSuccess = await login(username, password) const isSuccess = await login(username, password)
+5 -3
View File
@@ -22,8 +22,9 @@ function handleRegister({
username: string username: string
email: string email: string
password: string password: string
success: any success: () => void
error: any // eslint-disable-next-line no-unused-vars
error: (msg: string) => void
}) { }) {
register(username, email, password) register(username, email, password)
.then(success) .then(success)
@@ -54,7 +55,8 @@ async function check({
username: string username: string
email: string email: string
password: string password: string
error: any // eslint-disable-next-line no-unused-vars
error: (msg: string) => void
}) { }) {
if (username && !isValidUsername(username)) { if (username && !isValidUsername(username)) {
error('無效的帳號名稱') error('無效的帳號名稱')
@@ -17,7 +17,7 @@ export async function commandListController(req, res) {
nextKey: newNextKey, nextKey: newNextKey,
order: pagination.getOrder(), order: pagination.getOrder(),
}) })
} catch (error) { } catch (error: any) {
console.error(error) console.error(error)
res.status(500).send('Error fetching data') res.status(500).send('Error fetching data')
} }
@@ -15,7 +15,7 @@ export async function sessionListController(req, res) {
nextKey: newNextKey, nextKey: newNextKey,
order: pagination.getOrder(), order: pagination.getOrder(),
}) })
} catch (error) { } catch (error: any) {
console.log(error) console.log(error)
res.status(500).send('Error fetching session data') res.status(500).send('Error fetching session data')
} }
+1 -1
View File
@@ -15,7 +15,7 @@ export async function userListController(req, res) {
nextKey: newNextKey, nextKey: newNextKey,
order: pagination.getOrder(), order: pagination.getOrder(),
}) })
} catch (error) { } catch (error: any) {
console.error(error) console.error(error)
res.status(500).send('Error fetching user data') res.status(500).send('Error fetching user data')
} }
+1 -1
View File
@@ -3,7 +3,7 @@ import { Strategy as GoogleStrategy } from 'passport-google-oidc'
import config from '../config.js' import config from '../config.js'
import oauthVerify from './oauthVerify.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) oauthVerify('google', profile, { 'socialLogins.google.id': profile.id }, cb)
} }
+2 -2
View File
@@ -9,7 +9,7 @@ async function verifyPassword(
username: string, username: string,
password: string, password: string,
done: ( done: (
error: any, error: Error | null,
user?: Express.User | false, user?: Express.User | false,
options?: IVerifyOptions options?: IVerifyOptions
) => void ) => void
@@ -34,7 +34,7 @@ async function verifyPassword(
username: user.username, username: user.username,
email: user.email, email: user.email,
}) })
} catch (err) { } catch (err: any) {
return done(err) return done(err)
} }
} }
+2 -2
View File
@@ -82,7 +82,7 @@ export async function deleteContainer(id: string) {
} }
try { try {
await container.stop() await container.stop()
} catch (error) { } catch (error: any) {
logger.warn('Failed to stop container', id) logger.warn('Failed to stop container', id)
} }
await container.remove() await container.remove()
@@ -127,7 +127,7 @@ export function buildQuestImage(questPath: string, questId: string) {
.forEach((line: string) => { .forEach((line: string) => {
parseJSONOutput(line) parseJSONOutput(line)
}) })
} catch (error) { } catch (error: any) {
reject(error) reject(error)
} }
}) })
+1 -1
View File
@@ -9,7 +9,7 @@ export function asyncHandler(fn: any) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
export default function errorHandler( export default function errorHandler(
err: any, err: Error,
req: Request, req: Request,
res: Response, res: Response,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
+3 -3
View File
@@ -9,9 +9,9 @@ const questDirectory = path.join(process.cwd(), '..', 'quests')
class QuestValidationError extends Error { class QuestValidationError extends Error {
questId: string questId: string
error: any error: Error | null
constructor(message: string, questId: string, error: any) { constructor(message: string, questId: string, error: Error | null) {
super(message) super(message)
this.name = 'QuestValidationError' this.name = 'QuestValidationError'
this.questId = questId this.questId = questId
@@ -68,7 +68,7 @@ export async function loadAndUpdateQuests() {
}) })
quest.exceptions.push(...exceptions) quest.exceptions.push(...exceptions)
await quest.save() await quest.save()
} catch (error) { } catch (error: any) {
logger.error(`Error parsing quest`, { id, error }) logger.error(`Error parsing quest`, { id, error })
throw new QuestValidationError(`Error parsing quest`, id, error) throw new QuestValidationError(`Error parsing quest`, id, error)
} }
+12
View File
@@ -1043,6 +1043,13 @@
"@types/docker-modem" "*" "@types/docker-modem" "*"
"@types/node" "*" "@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": "@types/dotenv@^8.2.0":
version "8.2.0" version "8.2.0"
resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-8.2.0.tgz#5cd64710c3c98e82d9d15844375a33bf1b45d053" 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" resolved "https://registry.yarnpkg.com/@types/triple-beam/-/triple-beam-1.3.5.tgz#74fef9ffbaa198eb8b588be029f38b00299caa2c"
integrity sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw== 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": "@types/validator@^13.11.9":
version "13.11.9" version "13.11.9"
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.11.9.tgz#adfe96520b437a0eaa798a475877bf2f75ee402d" resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.11.9.tgz#adfe96520b437a0eaa798a475877bf2f75ee402d"