refactor: migrate session management to TRPC and remove legacy API endpoints

This commit is contained in:
Justin Lin committed 2025-04-23 16:37:12 +08:00
1 parent b4b8f8baee
commit 92173bb7e9
7 files changed
+71 -191

No files matched your search

+3 -2
View File
@@ -1,7 +1,6 @@
import { defineStore } from 'pinia'
import { FileGraph, FileObject } from '@linux-odyssey/file-graph'
import { IResponse, ITask } from '@linux-odyssey/game'
import { createSession, getActiveSession } from '../utils/api'
import Socket from '../utils/socket'
import SocketTerminal from '../utils/terminal'
import { Session } from '../types'
@@ -50,7 +49,9 @@ const useSession = defineStore('session', {
term.focus()
},
async createSession() {
const session = await createSession(this.questId)
const session = await trpc.session.createSession.mutate({
questId: this.questId,
})
await this.setSession(session)
socket.emit('terminal', 'echo start\n')
},
-14
View File
@@ -9,17 +9,3 @@ const api = axios.create({
withCredentials: true,
})
export default api
export async function createSession(questId: string): Promise<Session> {
const res = await api.post<Session>('/sessions', { questId })
return res.data
}
export async function getActiveSession(
questId: string
): Promise<Session | null> {
const res = await api.get<Session | null>('/sessions/active', {
params: { questId },
})
return res.data
}