mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
Re-add ?key= support, fixes #222
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user