forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #2263 from Yidadaa/bugfix-0705
fix: #2252 polyfill composing for old safari browsers & fix #2261
This commit is contained in:
commit
1dcf2d80b4
@ -172,10 +172,29 @@ function PromptToast(props: {
|
|||||||
function useSubmitHandler() {
|
function useSubmitHandler() {
|
||||||
const config = useAppConfig();
|
const config = useAppConfig();
|
||||||
const submitKey = config.submitKey;
|
const submitKey = config.submitKey;
|
||||||
|
const isComposing = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const onCompositionStart = () => {
|
||||||
|
isComposing.current = true;
|
||||||
|
};
|
||||||
|
const onCompositionEnd = () => {
|
||||||
|
isComposing.current = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("compositionstart", onCompositionStart);
|
||||||
|
window.addEventListener("compositionend", onCompositionEnd);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("compositionstart", onCompositionStart);
|
||||||
|
window.removeEventListener("compositionend", onCompositionEnd);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const shouldSubmit = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
const shouldSubmit = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
if (e.key !== "Enter") return false;
|
if (e.key !== "Enter") return false;
|
||||||
if (e.key === "Enter" && e.nativeEvent.isComposing) return false;
|
if (e.key === "Enter" && (e.nativeEvent.isComposing || isComposing.current))
|
||||||
|
return false;
|
||||||
return (
|
return (
|
||||||
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
||||||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
||||||
|
@ -568,11 +568,11 @@ export function Settings() {
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={!config.dontAddBuiltinMasks}
|
checked={config.hideBuiltinMasks}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateConfig(
|
updateConfig(
|
||||||
(config) =>
|
(config) =>
|
||||||
(config.dontAddBuiltinMasks = !e.currentTarget.checked),
|
(config.hideBuiltinMasks = e.currentTarget.checked),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
></input>
|
></input>
|
||||||
|
@ -66,27 +66,27 @@ Current time: {{time}}`;
|
|||||||
export const DEFAULT_MODELS = [
|
export const DEFAULT_MODELS = [
|
||||||
{
|
{
|
||||||
name: "gpt-4",
|
name: "gpt-4",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-4-0314",
|
name: "gpt-4-0314",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-4-0613",
|
name: "gpt-4-0613",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-4-32k",
|
name: "gpt-4-32k",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-4-32k-0314",
|
name: "gpt-4-32k-0314",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-4-32k-0613",
|
name: "gpt-4-32k-0613",
|
||||||
available: false,
|
available: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gpt-3.5-turbo",
|
name: "gpt-3.5-turbo",
|
||||||
|
@ -134,10 +134,6 @@ const ar: PartialLocaleType = {
|
|||||||
Title: "شاشة تظهر الأقنعة",
|
Title: "شاشة تظهر الأقنعة",
|
||||||
SubTitle: "عرض شاشة تظهر الأقنعة قبل بدء الدردشة الجديدة",
|
SubTitle: "عرض شاشة تظهر الأقنعة قبل بدء الدردشة الجديدة",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -161,8 +161,8 @@ const cn = {
|
|||||||
SubTitle: "新建聊天时,展示面具启动页",
|
SubTitle: "新建聊天时,展示面具启动页",
|
||||||
},
|
},
|
||||||
Builtin: {
|
Builtin: {
|
||||||
Title: "Show Builtin Masks",
|
Title: "隐藏内置面具",
|
||||||
SubTitle: "Show builtin masks in mask list",
|
SubTitle: "在所有面具列表中隐藏内置面具",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
|
@ -91,10 +91,6 @@ const cs: PartialLocaleType = {
|
|||||||
Title: "Úvodní obrazovka Masek",
|
Title: "Úvodní obrazovka Masek",
|
||||||
SubTitle: "Před zahájením nového chatu zobrazte úvodní obrazovku Masek",
|
SubTitle: "Před zahájením nového chatu zobrazte úvodní obrazovku Masek",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const de: PartialLocaleType = {
|
|||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
SubTitle: "Show a mask splash screen before starting new chat",
|
SubTitle: "Show a mask splash screen before starting new chat",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -162,8 +162,8 @@ const en: LocaleType = {
|
|||||||
SubTitle: "Show a mask splash screen before starting new chat",
|
SubTitle: "Show a mask splash screen before starting new chat",
|
||||||
},
|
},
|
||||||
Builtin: {
|
Builtin: {
|
||||||
Title: "Show Builtin Masks",
|
Title: "Hide Builtin Masks",
|
||||||
SubTitle: "Show builtin masks in mask list",
|
SubTitle: "Hide builtin masks in mask list",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
|
@ -91,10 +91,6 @@ const es: PartialLocaleType = {
|
|||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
SubTitle: "Show a mask splash screen before starting new chat",
|
SubTitle: "Show a mask splash screen before starting new chat",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -93,10 +93,6 @@ const fr: PartialLocaleType = {
|
|||||||
SubTitle:
|
SubTitle:
|
||||||
"Afficher un écran de masque avant de démarrer une nouvelle discussion",
|
"Afficher un écran de masque avant de démarrer une nouvelle discussion",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const it: PartialLocaleType = {
|
|||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
SubTitle: "Show a mask splash screen before starting new chat",
|
SubTitle: "Show a mask splash screen before starting new chat",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -108,10 +108,6 @@ const jp: PartialLocaleType = {
|
|||||||
Title: "キャラクターページ",
|
Title: "キャラクターページ",
|
||||||
SubTitle: "新規チャット作成時にキャラクターページを表示する",
|
SubTitle: "新規チャット作成時にキャラクターページを表示する",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const ko: PartialLocaleType = {
|
|||||||
Title: "마스크 시작 화면",
|
Title: "마스크 시작 화면",
|
||||||
SubTitle: "새로운 채팅 시작 전에 마스크 시작 화면 표시",
|
SubTitle: "새로운 채팅 시작 전에 마스크 시작 화면 표시",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const ru: PartialLocaleType = {
|
|||||||
Title: "Экран заставки маски",
|
Title: "Экран заставки маски",
|
||||||
SubTitle: "Показывать экран заставки маски перед началом нового чата",
|
SubTitle: "Показывать экран заставки маски перед началом нового чата",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const tr: PartialLocaleType = {
|
|||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
SubTitle: "Show a mask splash screen before starting new chat",
|
SubTitle: "Show a mask splash screen before starting new chat",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -89,10 +89,6 @@ const tw: PartialLocaleType = {
|
|||||||
Title: "面具启动页",
|
Title: "面具启动页",
|
||||||
SubTitle: "新建聊天时,展示面具启动页",
|
SubTitle: "新建聊天时,展示面具启动页",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -91,10 +91,6 @@ const vi: PartialLocaleType = {
|
|||||||
Title: "Mask Splash Screen",
|
Title: "Mask Splash Screen",
|
||||||
SubTitle: "Chớp màn hình khi bắt đầu cuộc trò chuyện mới",
|
SubTitle: "Chớp màn hình khi bắt đầu cuộc trò chuyện mới",
|
||||||
},
|
},
|
||||||
Builtin: {
|
|
||||||
Title: "Show Builtin Masks",
|
|
||||||
SubTitle: "Show builtin masks in mask list",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Prompt: {
|
Prompt: {
|
||||||
Disable: {
|
Disable: {
|
||||||
|
@ -32,7 +32,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
disablePromptHint: false,
|
disablePromptHint: false,
|
||||||
|
|
||||||
dontShowMaskSplashScreen: false, // dont show splash screen when create chat
|
dontShowMaskSplashScreen: false, // dont show splash screen when create chat
|
||||||
dontAddBuiltinMasks: false, // dont add builtin masks
|
hideBuiltinMasks: false, // dont add builtin masks
|
||||||
|
|
||||||
models: DEFAULT_MODELS as any as LLMModel[],
|
models: DEFAULT_MODELS as any as LLMModel[],
|
||||||
|
|
||||||
@ -137,9 +137,9 @@ export const useAppConfig = create<ChatConfigStore>()(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: StoreKey.Config,
|
name: StoreKey.Config,
|
||||||
version: 3.3,
|
version: 3.4,
|
||||||
migrate(persistedState, version) {
|
migrate(persistedState, version) {
|
||||||
if (version === 3.3) return persistedState as any;
|
if (version === 3.4) return persistedState as any;
|
||||||
|
|
||||||
const state = persistedState as ChatConfig;
|
const state = persistedState as ChatConfig;
|
||||||
state.modelConfig.sendMemory = true;
|
state.modelConfig.sendMemory = true;
|
||||||
@ -149,6 +149,7 @@ export const useAppConfig = create<ChatConfigStore>()(
|
|||||||
state.modelConfig.top_p = 1;
|
state.modelConfig.top_p = 1;
|
||||||
state.modelConfig.template = DEFAULT_INPUT_TEMPLATE;
|
state.modelConfig.template = DEFAULT_INPUT_TEMPLATE;
|
||||||
state.dontShowMaskSplashScreen = false;
|
state.dontShowMaskSplashScreen = false;
|
||||||
|
state.hideBuiltinMasks = false;
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@ export const useMaskStore = create<MaskStore>()(
|
|||||||
(a, b) => b.id - a.id,
|
(a, b) => b.id - a.id,
|
||||||
);
|
);
|
||||||
const config = useAppConfig.getState();
|
const config = useAppConfig.getState();
|
||||||
if (config.dontAddBuiltinMasks) return userMasks;
|
if (config.hideBuiltinMasks) return userMasks;
|
||||||
const buildinMasks = BUILTIN_MASKS.map(
|
const buildinMasks = BUILTIN_MASKS.map(
|
||||||
(m) =>
|
(m) =>
|
||||||
({
|
({
|
||||||
|
Loading…
Reference in New Issue
Block a user