wip(desktop): new layout work
This commit is contained in:
parent
5ba9b47b3c
commit
4069999b78
18 changed files with 257 additions and 140 deletions
|
|
@ -5,7 +5,7 @@ import { createClient } from "./gen/client/client.gen.js"
|
|||
import { type Config } from "./gen/client/types.gen.js"
|
||||
import { OpencodeClient } from "./gen/sdk.gen.js"
|
||||
|
||||
export function createOpencodeClient(config?: Config) {
|
||||
export function createOpencodeClient(config?: Config, options?: { directory?: string }) {
|
||||
if (!config?.fetch) {
|
||||
config = {
|
||||
...config,
|
||||
|
|
@ -18,5 +18,15 @@ export function createOpencodeClient(config?: Config) {
|
|||
}
|
||||
|
||||
const client = createClient(config)
|
||||
|
||||
if (options?.directory) {
|
||||
async function middleware(request: Request) {
|
||||
const url = new URL(request.url)
|
||||
url.searchParams.set("directory", options!.directory!)
|
||||
return new Request(url.toString(), request)
|
||||
}
|
||||
client.interceptors.request.use(middleware)
|
||||
}
|
||||
|
||||
return new OpencodeClient({ client })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue