Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 一个有关 replaceAll 的兼容性的bug: #2376

Closed
sbetamaster opened this issue Jul 13, 2023 · 10 comments
Closed

[Bug] 一个有关 replaceAll 的兼容性的bug: #2376

sbetamaster opened this issue Jul 13, 2023 · 10 comments

Comments

@sbetamaster
Copy link

Describe the bug
一个有关 replaceAll 兼容性的 bug 。

To Reproduce
我在手机上用 via 浏览器时,会出现一个奇怪的现象,输入文字并且点击按钮发送请求后,列表中并没有象正常那样把用户输入的文字显示在列表框中,而是消失不见,并且一直无法收到响应。然而用Chrome或者Edge浏览器并没有这种问题。

通过调试发现问题出在 app/store/chat.ts 文件中的以下代码处:
Object.entries(vars).forEach(([name, value]) => {
output = output.replaceAll({{${name}}}, value);
});

以上代码产生了异常,从而导致后续的代码都没有正常执行,于是出现了上述描述的现象。

其中 output.replaceAll 这一行代码编译后,在 via 浏览器运行时会出现异常,提示 o.replaceAll not is a function。
通过询问 chatgpt ,提示问题出现的原因为:”而您可能使用的是不支持该方法的JavaScript引擎“。因此这可能是个兼容性的问题。

chatgpt 提供了以下解决方案,即修改代码为:
Object.entries(vars).forEach(([name, value]) => {
output = output.replace(new RegExp({{${name}}}, 'g'), value);
});

经过测试后可行。

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jul 13, 2023

手机系统版本?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Mobile phone system version?

@imzhoukunqiang
Copy link

image
这个函数版本要求确实比较高, @sbetamaster 可以升级webview试一下

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


image
The version requirements of this function are indeed relatively high, @sbetamaster can upgrade the webview to try

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jul 14, 2023

我加一个 polyfill 吧。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Let me add a polyfill.

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jul 14, 2023

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jul 14, 2023

I am going to introduce babel/preset-env to solve the polyfill issues: https://babeljs.io/docs/babel-preset-env

Yidadaa added a commit that referenced this issue Jul 16, 2023
feat: close #2376 add babel polyfill
@Yidadaa
Copy link
Collaborator

Yidadaa commented Jul 16, 2023

@sbetamaster 已经尝试在主线增加 babel 转译,请使用演示站点测试此 bug 是否依然存在:https://chatgpt1.nextweb.fun/

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


@sbetamaster has tried adding babel transpilation to the mainline, please use the demo site to test if the bug persists: https://chatgpt1.nextweb.fun/

JMcn pushed a commit to JMcn/ChatGPT-Next-Web that referenced this issue Jul 30, 2023
jenreh added a commit to arvato-systems-aila-solutions/KnowledgeAI-Chat that referenced this issue Jul 30, 2023
* main:
  Added Azure OpenAI capabilities
  Update tauri.conf.json
  Update home.tsx
  Update mask.tsx
  feat: add type for import
  feat: add typings for metadata
  feat: close ChatGPTNextWeb#2376 add babel polyfill
  fix: ChatGPTNextWeb#2367 do not copy in async callback after sharing to ShareGPT
  feat: improve dnd icon
  Update README.md
  dev: use current inject configuration
  fix: enable `enableInjectSystemPrompts` attribute for old sessions
  fixed react key
  fixed openai base url if empty
  feat: drag and drop in contextual prompts
alchemist139 pushed a commit to alchemist139/ChatGPT-Next-Web that referenced this issue Sep 21, 2023
alchemist139 pushed a commit to alchemist139/ChatGPT-Next-Web that referenced this issue Sep 21, 2023
chenzeyu pushed a commit to neutronsg/ChatGPT-Next-Web that referenced this issue Nov 8, 2023
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants