mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: add pwd handling to session and update related components
This commit is contained in:
1 parent
fba92dad46
commit
26e79690f8
7 files changed
+16
-4
No files matched your search
@@ -23,7 +23,7 @@ function nodeClass() {
|
|||||||
<a href="#" :class="nodeClass()">
|
<a href="#" :class="nodeClass()">
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
v-if="node.type === 'directory'"
|
v-if="node.type === 'directory'"
|
||||||
:icon="['far', 'directory']"
|
:icon="['far', 'folder']"
|
||||||
class="text-text-primary size-8"
|
class="text-text-primary size-8"
|
||||||
/>
|
/>
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const sessionStore = useSession()
|
|||||||
<FileNode
|
<FileNode
|
||||||
v-if="sessionStore.session"
|
v-if="sessionStore.session"
|
||||||
:node="sessionStore.session.graph"
|
:node="sessionStore.session.graph"
|
||||||
pwd="/home/commander"
|
:pwd="sessionStore.session.pwd"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const useSession = defineStore('session', {
|
|||||||
this.session = {
|
this.session = {
|
||||||
...session,
|
...session,
|
||||||
graph: new FileGraph(session.graph),
|
graph: new FileGraph(session.graph),
|
||||||
|
pwd: '/home/commander',
|
||||||
}
|
}
|
||||||
term.reset()
|
term.reset()
|
||||||
await socket.connect(this.session)
|
await socket.connect(this.session)
|
||||||
@@ -105,6 +106,9 @@ const useSession = defineStore('session', {
|
|||||||
socket.on('graph', (event: FileGraphUpdateEvent) => {
|
socket.on('graph', (event: FileGraphUpdateEvent) => {
|
||||||
if (!this.session) return
|
if (!this.session) return
|
||||||
this.session.graph.handleEvent(event)
|
this.session.graph.handleEvent(event)
|
||||||
|
if (event.pwd) {
|
||||||
|
this.session.pwd = event.pwd
|
||||||
|
}
|
||||||
})
|
})
|
||||||
socket.on('update', (update: SessionUpdate) => {
|
socket.on('update', (update: SessionUpdate) => {
|
||||||
this.newUpdate(update)
|
this.newUpdate(update)
|
||||||
|
|||||||
+1
-2
@@ -18,8 +18,7 @@ export interface Session {
|
|||||||
_id: string
|
_id: string
|
||||||
status: string
|
status: string
|
||||||
graph: FileGraph
|
graph: FileGraph
|
||||||
// pwd: string
|
pwd: string
|
||||||
// hints: string[][]
|
|
||||||
tasks: ITask[]
|
tasks: ITask[]
|
||||||
responses: IResponse[]
|
responses: IResponse[]
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,13 @@ async function readOrNone(file) {
|
|||||||
|
|
||||||
const commandListeners = {
|
const commandListeners = {
|
||||||
ls: [discoverFiles],
|
ls: [discoverFiles],
|
||||||
|
cd: [changeDirectory],
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeDirectory() {
|
||||||
|
return {
|
||||||
|
pwd: process.cwd(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCommand(command) {
|
async function handleCommand(command) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export interface FileGraphUpdateEvent {
|
|||||||
add?: FileObject[]
|
add?: FileObject[]
|
||||||
remove?: FileObject[]
|
remove?: FileObject[]
|
||||||
discover?: FileObject[]
|
discover?: FileObject[]
|
||||||
|
pwd?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FileGraph extends FileNode {
|
export default class FileGraph extends FileNode {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const fileSchema = z.object({
|
|||||||
|
|
||||||
export const commandParamsSchema = z.object({
|
export const commandParamsSchema = z.object({
|
||||||
discover: fileSchema.array().optional(),
|
discover: fileSchema.array().optional(),
|
||||||
|
pwd: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type ICommandParams = z.infer<typeof commandParamsSchema>
|
export type ICommandParams = z.infer<typeof commandParamsSchema>
|
||||||
|
|||||||
Reference in new issue
Block a user