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

sync fork #4582

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
47a4436
Update layout.tsx
yjding Sep 24, 2023
d4c89b5
Update sidebar.tsx
yjding Sep 24, 2023
1c97b77
Update chat.tsx
yjding Sep 24, 2023
7e91336
Merge pull request #1 from yjding/Remove-titles
yjding Sep 24, 2023
6e9491f
Update index.ts
yjding Sep 24, 2023
76e23df
Create user_agent_validator.js
yjding Sep 24, 2023
204c696
Update layout.tsx
yjding Sep 24, 2023
7c30bd0
Add files via upload
yjding Sep 24, 2023
1a51c70
Delete app/user_agent_validator.js
yjding Sep 24, 2023
7b9ccaa
Merge pull request #2 from yjding/default-to-chinese
yjding Sep 24, 2023
1717480
Add back the settings icon
yjding Apr 28, 2024
2c9ed30
Remove settings button
yjding Apr 28, 2024
03d457d
Merge branch 'main' into main
yjding Apr 29, 2024
960c29c
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 1, 2024
2c2eac5
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 7, 2024
765bdd4
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 8, 2024
9975f01
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 14, 2024
5898ec9
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 15, 2024
7edffce
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 16, 2024
006b0b7
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 17, 2024
c444260
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 21, 2024
f2a899d
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 23, 2024
a778141
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user May 28, 2024
58a81c6
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user Jun 8, 2024
dfead51
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user Jun 25, 2024
e061f01
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user Jun 27, 2024
9db098c
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,6 @@ function _Chat() {

<div className={styles["chat-input-panel"]}>
<PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} />

<ChatActions
uploadImage={uploadImage}
setAttachImages={setAttachImages}
Expand Down
39 changes: 1 addition & 38 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,39 +155,12 @@ export function SideBar(props: { className?: string }) {
>
<div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region>
NextChat
</div>
<div className={styles["sidebar-sub-title"]}>
Build your own AI assistant.
聊天列表
</div>
<div className={styles["sidebar-logo"] + " no-dark"}>
<ChatGptIcon />
</div>
</div>

<div className={styles["sidebar-header-bar"]}>
<IconButton
icon={<MaskIcon />}
text={shouldNarrow ? undefined : Locale.Mask.Name}
className={styles["sidebar-bar-button"]}
onClick={() => {
if (config.dontShowMaskSplashScreen !== true) {
navigate(Path.NewChat, { state: { fromHome: true } });
} else {
navigate(Path.Masks, { state: { fromHome: true } });
}
}}
shadow
/>
<IconButton
icon={<PluginIcon />}
text={shouldNarrow ? undefined : Locale.Plugin.Name}
className={styles["sidebar-bar-button"]}
onClick={() => showToast(Locale.WIP)}
shadow
/>
</div>

<div
className={styles["sidebar-body"]}
onClick={(e) => {
Expand All @@ -211,16 +184,6 @@ export function SideBar(props: { className?: string }) {
}}
/>
</div>
<div className={styles["sidebar-action"]}>
<Link to={Path.Settings}>
<IconButton icon={<SettingsIcon />} shadow />
</Link>
</div>
<div className={styles["sidebar-action"]}>
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
<IconButton icon={<GithubIcon />} shadow />
</a>
</div>
</div>
<div>
<IconButton
Expand Down
7 changes: 4 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { GoogleTagManager } from "@next/third-parties/google";
const serverConfig = getServerSideConfig();

export const metadata: Metadata = {
title: "NextChat",
description: "Your personal ChatGPT Chat Bot.",
title: "聊天机器人",
description: "",
viewport: {
width: "device-width",
initialScale: 1,
Expand All @@ -22,7 +22,7 @@ export const metadata: Metadata = {
{ media: "(prefers-color-scheme: dark)", color: "#151515" },
],
appleWebApp: {
title: "NextChat",
title: "聊天机器人",
statusBarStyle: "default",
},
};
Expand All @@ -39,6 +39,7 @@ export default function RootLayout({
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="manifest" href="/site.webmanifest"></link>
<script src="/serviceWorkerRegister.js" defer></script>
<script src="/userAgentValidator.js" defer></script>
</head>
<body>
{children}
Expand Down
4 changes: 2 additions & 2 deletions app/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export const ALL_LANG_OPTIONS: Record<Lang, string> = {
};

const LANG_KEY = "lang";
const DEFAULT_LANG = "en";
const DEFAULT_LANG = "cn";

const fallbackLang = en;
const fallbackLang = cn;
const targetLang = ALL_LANGS[getLang()] as LocaleType;

// if target lang missing some fields, it will use fallback lang string
Expand Down
8 changes: 8 additions & 0 deletions public/userAgentValidator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
var isAndroid = ua.indexOf('android') != -1;
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
Comment on lines +1 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace var with const and use strict equality checks.

- var ua = navigator.userAgent.toLowerCase();
- var isWeixin = ua.indexOf('micromessenger') != -1;
- var isAndroid = ua.indexOf('android') != -1;
- var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
+ const ua = navigator.userAgent.toLowerCase();
+ const isWeixin = ua.indexOf('micromessenger') !== -1;
+ const isAndroid = ua.indexOf('android') !== -1;
+ const isIos = (ua.indexOf('iphone') !== -1) || (ua.indexOf('ipad') !== -1);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
var isAndroid = ua.indexOf('android') != -1;
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
const ua = navigator.userAgent.toLowerCase();
const isWeixin = ua.indexOf('micromessenger') !== -1;
const isAndroid = ua.indexOf('android') !== -1;
const isIos = (ua.indexOf('iphone') !== -1) || (ua.indexOf('ipad') !== -1);

if (!isWeixin) {
document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">';
document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>';
}
Comment on lines +5 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid direct manipulation of innerHTML due to security risks and potential loss of existing content.

- document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">';
- document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>';
+ const title = document.createElement('title');
+ title.textContent = '抱歉,出错了';
+ document.head.appendChild(title);
+ // Add other head elements similarly
+ const bodyDiv = document.createElement('div');
+ bodyDiv.className = 'weui_msg';
+ bodyDiv.innerHTML = '<div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div>';
+ document.body.appendChild(bodyDiv);

Committable suggestion was skipped due low confidence.

Loading