Skip to content

Commit ea91671

Browse files
committed
Add to ext.to()
1 parent b2a8d81 commit ea91671

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llms/ui/ctx.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class ExtensionScope {
77
constructor(ctx, id) {
88
/**@type {AppContext} */
99
this.ctx = ctx
10+
this.router = ctx.router
1011
this.id = id
1112
this.baseUrl = `${ctx.ai.base}/ext/${this.id}`
1213
this.storageKey = `llms.${this.id}`
@@ -97,6 +98,22 @@ export class ExtensionScope {
9798
toast(msg) {
9899
this.ctx.toast(msg)
99100
}
101+
to(route) {
102+
if (typeof route == 'string') {
103+
route = route.startsWith(this.baseUrl)
104+
? route
105+
: combinePaths(this.baseUrl, route)
106+
const path = { path: route }
107+
console.log(`to/${this.id}`, path)
108+
this.router.push(path)
109+
} else {
110+
route.path = route.path.startsWith(this.baseUrl)
111+
? route.path
112+
: combinePaths(this.baseUrl, route.path)
113+
console.log(`to/${this.id}`, route)
114+
this.router.push(route)
115+
}
116+
}
100117
}
101118

102119
export class AppContext {

0 commit comments

Comments
 (0)