mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
Set new chat settings via URI
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { querystring } from 'svelte-spa-router'
|
import { querystring } from 'svelte-spa-router'
|
||||||
import { addChat } from './Storage.svelte'
|
import { addChat, setChatSettingValueByKey } from './Storage.svelte'
|
||||||
import { replace } from 'svelte-spa-router'
|
import { replace } from 'svelte-spa-router'
|
||||||
import { getProfile } from './Profiles.svelte'
|
import { getProfile } from './Profiles.svelte'
|
||||||
|
import { getChatDefaults } from './Settings.svelte'
|
||||||
|
|
||||||
// Create the new chat instance then redirect to it
|
// Create the new chat instance then redirect to it
|
||||||
|
|
||||||
const urlParams: URLSearchParams = new URLSearchParams($querystring)
|
const urlParams: URLSearchParams = new URLSearchParams($querystring)
|
||||||
const chatId = urlParams.has('p') ? addChat(getProfile(urlParams.get('p') || '')) : addChat()
|
const chatId = urlParams.has('p') ? addChat(getProfile(urlParams.get('p') || '')) : addChat()
|
||||||
|
Object.keys(getChatDefaults()).forEach(k => {
|
||||||
|
if (urlParams.has(k)) {
|
||||||
|
setChatSettingValueByKey(chatId, k as any, urlParams.get(k))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
replace(`/chat/${chatId}`)
|
replace(`/chat/${chatId}`)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user