Skip to content

发送 Prompt 时,在中文输入法下表现异常 #127

@j10ccc

Description

@j10ccc

What operating system are you using?

Mac

What browser are you using?

Safari

Describe the bug

发送 Prompt 时,在中文输入法下表现异常。Safari 浏览器,在中文输入法下按回车的时候,会触发发送 Prompt。源码里通过 isComposing 解决,但是 Safari 对这个 api 表现有所差异。

目标就是在输出回车的时候判断是否在中文输入法下。

我看了下其他项目的实现

https://github.com/labring/FastGPT/blob/006ad17c6a34cd6144ee871a2d9f1a9577ffaf21/projects/app/src/components/ChatBox/MessageInput.tsx#L335-L340

他用的是键盘事件的 keyCode。对于回车键,在中文输入法(Mac 微信输入法)下 keyCode 输出的值是 229,而默认英文输入下,是 13。通过这个 API 可以达到目标。而 anse 现在使用的是 key,两种输入状态下的输出都是 "Enter",无法判断中文输入法,并且 isComposing 也无法在全平台下正确判断

keyCode 这个属性被标记为 Deprecated,目前应该没有什么好方法处理这个问题了吧?

What provider are you using?

None

What prompt did you enter?

No response

Console Logs

No response

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    useissue when using `anse.app`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions