mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
refactor: migrate session management to TRPC and remove legacy API endpoints
This commit is contained in:
1 parent
b4b8f8baee
commit
92173bb7e9
7 files changed
+71
-191
No files matched your search
@@ -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')
|
||||
},
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user