Re-add `?key=` support, fixes #222
This commit is contained in:
parent
e892e1a297
commit
0ce386a209
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Router, { location, replace } from 'svelte-spa-router'
|
import Router, { location, replace, querystring } from 'svelte-spa-router'
|
||||||
import { wrap } from 'svelte-spa-router/wrap'
|
import { wrap } from 'svelte-spa-router/wrap'
|
||||||
|
|
||||||
import Navbar from './lib/Navbar.svelte'
|
import Navbar from './lib/Navbar.svelte'
|
||||||
|
@ -11,6 +11,13 @@
|
||||||
import { Modals, closeModal } from 'svelte-modals'
|
import { Modals, closeModal } from 'svelte-modals'
|
||||||
import { dispatchModalEsc, checkModalEsc } from './lib/Util.svelte'
|
import { dispatchModalEsc, checkModalEsc } from './lib/Util.svelte'
|
||||||
|
|
||||||
|
// Check if the API key is passed in as a "key" query parameter - if so, save it
|
||||||
|
// Example: https://niek.github.io/chatgpt-web/#/?key=sk-...
|
||||||
|
const urlParams: URLSearchParams = new URLSearchParams($querystring)
|
||||||
|
if (urlParams.has('key')) {
|
||||||
|
apiKeyStorage.set(urlParams.get('key') as string)
|
||||||
|
}
|
||||||
|
|
||||||
// The definition of the routes with some conditions
|
// The definition of the routes with some conditions
|
||||||
const routes = {
|
const routes = {
|
||||||
'/': Home,
|
'/': Home,
|
||||||
|
|
Loading…
Reference in New Issue