From 1fbd4ee87b13018d09be60d9b90635a89c999dbf Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Tue, 15 Oct 2024 15:01:51 +0800 Subject: [PATCH] refac: export getDefaultParam --- src/app.tsx | 2 +- src/chatbox.tsx | 2 +- src/settings.tsx | 2 +- src/types/chatstore.ts | 2 -- src/types/newChatstore.ts | 2 +- src/utils/getDefaultParam.ts | 10 ++++------ 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 17fbc31..b515c3d 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "preact/hooks"; import "@/global.css"; import { calculate_token_length } from "@/chatgpt"; -import getDefaultParams from "@/utils/getDefaultParam"; +import { getDefaultParams } from "@/utils/getDefaultParam"; import ChatBOX from "@/chatbox"; import { DefaultModel } from "@/const"; import { Tr, langCodeContext, LANG_OPTIONS } from "@/translate"; diff --git a/src/chatbox.tsx b/src/chatbox.tsx index 683a966..8eb07e3 100644 --- a/src/chatbox.tsx +++ b/src/chatbox.tsx @@ -43,7 +43,7 @@ import { import Message from "@/message"; import { models } from "@/types/models"; import Settings from "@/settings"; -import getDefaultParams from "@/utils/getDefaultParam"; +import { getDefaultParams } from "@/utils/getDefaultParam"; import { AddImage } from "@/addImage"; import { ListAPIs } from "@/listAPIs"; import { ListToolsTempaltes } from "@/listToolsTemplates"; diff --git a/src/settings.tsx b/src/settings.tsx index 0a36503..c63b893 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -33,7 +33,7 @@ import { tr, Tr, langCodeContext, LANG_OPTIONS } from "@/translate"; import { isVailedJSON } from "@/message"; import { SetAPIsTemplate } from "@/setAPIsTemplate"; import { autoHeight } from "@/textarea"; -import getDefaultParams from "@/utils/getDefaultParam"; +import { getDefaultParams } from "@/utils/getDefaultParam"; const TTS_VOICES: string[] = [ "alloy", diff --git a/src/types/chatstore.ts b/src/types/chatstore.ts index 88dc539..06567fd 100644 --- a/src/types/chatstore.ts +++ b/src/types/chatstore.ts @@ -1,6 +1,4 @@ import { Logprobs, Message } from "@/chatgpt"; -import { DefaultModel, CHATGPT_API_WEB_VERSION } from "@/const"; -import getDefaultParams from "@/utils/getDefaultParam"; /** * ChatStore is the main object of the chatgpt-api-web, diff --git a/src/types/newChatstore.ts b/src/types/newChatstore.ts index 2528cc0..dd5a598 100644 --- a/src/types/newChatstore.ts +++ b/src/types/newChatstore.ts @@ -3,7 +3,7 @@ import { DefaultModel, CHATGPT_API_WEB_VERSION, } from "@/const"; -import getDefaultParams from "@/utils/getDefaultParam"; +import { getDefaultParams } from "@/utils/getDefaultParam"; import { ChatStore } from "@/types/chatstore"; import { models } from "@/types/models"; diff --git a/src/utils/getDefaultParam.ts b/src/utils/getDefaultParam.ts index 519a242..c9be9fe 100644 --- a/src/utils/getDefaultParam.ts +++ b/src/utils/getDefaultParam.ts @@ -1,8 +1,8 @@ -function getDefaultParams(param: string, val: string): string; -function getDefaultParams(param: string, val: number): number; -function getDefaultParams(param: string, val: boolean): boolean; +export function getDefaultParams(param: string, val: string): string; +export function getDefaultParams(param: string, val: number): number; +export function getDefaultParams(param: string, val: boolean): boolean; -function getDefaultParams(param: any, val: any) { +export function getDefaultParams(param: any, val: any) { const queryParameters = new URLSearchParams(window.location.search); const get = queryParameters.get(param); if (typeof val === "string") { @@ -17,5 +17,3 @@ function getDefaultParams(param: any, val: any) { return val; } } - -export default getDefaultParams;