feat(server): config file editor — read/edit/save a host config file per instance
The Server page's config-honesty note now leads somewhere real: a Configuration file panel that loads a config file from the instance (prefilled with the game's primaryConfigFile hint — server.cfg, ServerSettings.ini, GameXishu.json), edits it in a mono textarea, and saves it straight to the host through the jailed agent file bridge. Not-found is handled gracefully (empty editor to create). Works across games; gameProfiles gains primaryConfigFile per game. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,23 @@ export const useInstancesStore = defineStore('instances', () => {
|
||||
return api.post<Record<string, unknown>>(`/instances/${id}/rcon`, { command })
|
||||
}
|
||||
|
||||
/** Read a config/text file from the current instance (jailed to its root). */
|
||||
async function readFile(path: string): Promise<string> {
|
||||
const id = currentId.value
|
||||
if (!id) throw new Error('No instance selected')
|
||||
const res = await api.get<{ content?: string }>(
|
||||
`/instances/${id}/file?path=${encodeURIComponent(path)}`,
|
||||
)
|
||||
return res?.content ?? ''
|
||||
}
|
||||
|
||||
/** Write a config/text file to the current instance. */
|
||||
async function writeFile(path: string, content: string): Promise<void> {
|
||||
const id = currentId.value
|
||||
if (!id) throw new Error('No instance selected')
|
||||
await api.put(`/instances/${id}/file`, { path, content })
|
||||
}
|
||||
|
||||
return {
|
||||
instances,
|
||||
currentId,
|
||||
@@ -117,5 +134,7 @@ export const useInstancesStore = defineStore('instances', () => {
|
||||
select,
|
||||
lifecycle,
|
||||
rcon,
|
||||
readFile,
|
||||
writeFile,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user