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() {
|
||||
const config = useAppConfig();
|
||||
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>) => {
|
||||
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 (
|
||||
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
||||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
||||
|
@ -568,11 +568,11 @@ export function Settings() {
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={!config.dontAddBuiltinMasks}
|
||||
checked={config.hideBuiltinMasks}
|
||||
onChange={(e) =>
|
||||
updateConfig(
|
||||
(config) =>
|
||||
(config.dontAddBuiltinMasks = !e.currentTarget.checked),
|
||||
(config.hideBuiltinMasks = e.currentTarget.checked),
|
||||
)
|
||||
}
|
||||
></input>
|
||||
|
@ -66,27 +66,27 @@ Current time: {{time}}`;
|
||||
export const DEFAULT_MODELS = [
|
||||
{
|
||||
name: "gpt-4",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-4-0314",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-4-0613",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-4-32k",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-4-32k-0314",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-4-32k-0613",
|
||||
available: false,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
name: "gpt-3.5-turbo",
|
||||
|
@ -134,10 +134,6 @@ const ar: PartialLocaleType = {
|
||||
Title: "شاشة تظهر الأقنعة",
|
||||
SubTitle: "عرض شاشة تظهر الأقنعة قبل بدء الدردشة الجديدة",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -161,8 +161,8 @@ const cn = {
|
||||
SubTitle: "新建聊天时,展示面具启动页",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
Title: "隐藏内置面具",
|
||||
SubTitle: "在所有面具列表中隐藏内置面具",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
|
@ -91,10 +91,6 @@ const cs: PartialLocaleType = {
|
||||
Title: "Úvodní obrazovka 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: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const de: PartialLocaleType = {
|
||||
Title: "Mask Splash Screen",
|
||||
SubTitle: "Show a mask splash screen before starting new chat",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -162,8 +162,8 @@ const en: LocaleType = {
|
||||
SubTitle: "Show a mask splash screen before starting new chat",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
Title: "Hide Builtin Masks",
|
||||
SubTitle: "Hide builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
|
@ -91,10 +91,6 @@ const es: PartialLocaleType = {
|
||||
Title: "Mask Splash Screen",
|
||||
SubTitle: "Show a mask splash screen before starting new chat",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -93,10 +93,6 @@ const fr: PartialLocaleType = {
|
||||
SubTitle:
|
||||
"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: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const it: PartialLocaleType = {
|
||||
Title: "Mask Splash Screen",
|
||||
SubTitle: "Show a mask splash screen before starting new chat",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -108,10 +108,6 @@ const jp: PartialLocaleType = {
|
||||
Title: "キャラクターページ",
|
||||
SubTitle: "新規チャット作成時にキャラクターページを表示する",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const ko: PartialLocaleType = {
|
||||
Title: "마스크 시작 화면",
|
||||
SubTitle: "새로운 채팅 시작 전에 마스크 시작 화면 표시",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const ru: PartialLocaleType = {
|
||||
Title: "Экран заставки маски",
|
||||
SubTitle: "Показывать экран заставки маски перед началом нового чата",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const tr: PartialLocaleType = {
|
||||
Title: "Mask Splash Screen",
|
||||
SubTitle: "Show a mask splash screen before starting new chat",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -89,10 +89,6 @@ const tw: PartialLocaleType = {
|
||||
Title: "面具启动页",
|
||||
SubTitle: "新建聊天时,展示面具启动页",
|
||||
},
|
||||
Builtin: {
|
||||
Title: "Show Builtin Masks",
|
||||
SubTitle: "Show builtin masks in mask list",
|
||||
},
|
||||
},
|
||||
Prompt: {
|
||||
Disable: {
|
||||
|
@ -91,10 +91,6 @@ const vi: PartialLocaleType = {
|
||||
Title: "Mask Splash Screen",
|
||||
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: {
|
||||
Disable: {
|
||||
|
@ -32,7 +32,7 @@ export const DEFAULT_CONFIG = {
|
||||
disablePromptHint: false,
|
||||
|
||||
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[],
|
||||
|
||||
@ -137,9 +137,9 @@ export const useAppConfig = create<ChatConfigStore>()(
|
||||
}),
|
||||
{
|
||||
name: StoreKey.Config,
|
||||
version: 3.3,
|
||||
version: 3.4,
|
||||
migrate(persistedState, version) {
|
||||
if (version === 3.3) return persistedState as any;
|
||||
if (version === 3.4) return persistedState as any;
|
||||
|
||||
const state = persistedState as ChatConfig;
|
||||
state.modelConfig.sendMemory = true;
|
||||
@ -149,6 +149,7 @@ export const useAppConfig = create<ChatConfigStore>()(
|
||||
state.modelConfig.top_p = 1;
|
||||
state.modelConfig.template = DEFAULT_INPUT_TEMPLATE;
|
||||
state.dontShowMaskSplashScreen = false;
|
||||
state.hideBuiltinMasks = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ export const useMaskStore = create<MaskStore>()(
|
||||
(a, b) => b.id - a.id,
|
||||
);
|
||||
const config = useAppConfig.getState();
|
||||
if (config.dontAddBuiltinMasks) return userMasks;
|
||||
if (config.hideBuiltinMasks) return userMasks;
|
||||
const buildinMasks = BUILTIN_MASKS.map(
|
||||
(m) =>
|
||||
({
|
||||
|
Loading…
Reference in New Issue
Block a user