Skip to content

Commit 8349455

Browse files
fengsh27Algorithm5838YidadaalifeericH0llyW00dzZ
authored
merge upstream/main to main (#6)
* Update chat.tsx * Update chat.tsx * [ADDED] MacOS detect * [FIXED] now the default key should be CMD on MacOS * [FIXED] now it should detects all macintosh * UI Page [Auth Page] [+] feat(auth.tsx): add support for resetting access token in resetAccessCode function [+] fix(auth.tsx): fix formatting issue in resetAccessCode function [+] feat(locales): add support for sub tips in Auth component for multiple languages : - Add sub tips in Arabic locale (ar.ts) - Add sub tips in Bengali locale (bn.ts) - Add sub tips in Chinese locale (cn.ts) - Add sub tips in English locale (en.ts) - Add sub tips in Indonesian locale (id.ts) * Feat & Fix UI Page [Auth Page] [+] feat(auth.tsx): add goChat function to navigate to chat page [+] fix(auth.tsx): change onClick event from goHome to goChat * Refactor Locale Indonesia [+] refactor(id.ts): remove unused import and isApp variable [+] fix(id.ts): update Unauthorized error message * Fix & Refactor UI Page [Auth Page] [+] fix(auth.tsx): fix conditional rendering of token input field [+] refactor(auth.tsx): improve code readability by using conditional rendering for token input field * Client App [Notification] [+] feat(global.d.ts): add support for window.__TAURI__.notification methods [+] feat(update.ts): add notification for new version availability [+] fix(Cargo.toml): add tauri feature "notification-all" to enable notifications [+] fix(tauri.conf.json): enable all notification features in tauri configuration * Client App Fix Issue [Bug] 'export' button does not work ChatGPTNextWeb#2884 [+] fix(exporter.tsx): add async keyword to download function [+] feat(exporter.tsx): add support for saving image file using window.__TAURI__ API [+] feat(global.d.ts): add types for window.__TAURI__ API methods [+] feat(locales): add translations for download success and failure messages [+] feat(sync.ts): add support for generating backup file name with date and time [+] fix(utils.ts): add async keyword to downloadAs function and add support for saving file using window.__TAURI__ API * Fix & Feat Client App [Notification] [+] fix(update.ts): remove unnecessary notification sending when permission is not granted [+] feat(update.ts): add notification for already up to date version * Feat & Fix "Client App [Notification]" [+] feat(update.ts): add support for localization in update notifications [+] fix(update.ts): add missing semicolon in useUpdateStore function * Change log - config.ts - line 72 remove type confirmation of x as x always has type 'number' - line 135 remove redundant local variable - chat.ts - delete unused import * Change log - config.ts - line 72: remove type confirmation of x as x always has type 'number' - line 135: remove the redundant local variable - chat.ts - delete the unused import * Improve tw locale * Update tauri.conf.json * 修改界面 似乎这里引入了一个逻辑判断错误,会导致打包之后的界面变宽变高。 * Update tauri.conf.json * fix: ChatGPTNextWeb#2981 full screen button not works * Fix type in sync.ts Simple typo fix. * Refactor Mask UI Page [Masks] [+] refactor(mask.tsx): refactor simple search to be case-insensitive * 提供同步聊天记录教程,同时翻译多国语言 * Update constant.ts * 已拆分单个文件、翻译多国语言版本 * docs: fix typo in app/masks/en.ts * fix serviceWorker cache * Fix typo in README.md passsword -> password * Update README.md * feat: close ChatGPTNextWeb#3031 user can set larger font size * Update synchronise-chat-logs-cn.md * Update README_CN.md * Update README_KO.md * Update README_KO.md * Revert "fix serviceWorker cache: auto caching files by workbox" --------- Co-authored-by: Algorithm5838 <[email protected]> Co-authored-by: Yifei Zhang <[email protected]> Co-authored-by: Eric R <[email protected]> Co-authored-by: H0llyW00dzZ <[email protected]> Co-authored-by: KeithHello <[email protected]> Co-authored-by: Peter Dave Hello <[email protected]> Co-authored-by: GH Action - Upstream Sync <[email protected]> Co-authored-by: Kong Gaowen <[email protected]> Co-authored-by: Jason O'Gray <[email protected]> Co-authored-by: H0llyW00dzZ <[email protected]> Co-authored-by: mcheping520 <[email protected]> Co-authored-by: Surav Shrestha <[email protected]> Co-authored-by: Jesse <[email protected]> Co-authored-by: Ikko Eltociear Ashimine <[email protected]>
1 parent 9835206 commit 8349455

37 files changed

+404
-73
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Your openai api key.
159159

160160
### `CODE` (optional)
161161

162-
Access passsword, separated by comma.
162+
Access password, separated by comma.
163163

164164
### `BASE_URL` (optional)
165165

@@ -257,6 +257,10 @@ If your proxy needs password, use:
257257
bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/scripts/setup.sh)
258258
```
259259

260+
## Synchronizing Chat Records (UpStash)
261+
262+
| [简体中文](./docs/synchronise-chat-logs-cn.md) | [English](./docs/synchronise-chat-logs-en.md) | [Italiano](./docs/synchronise-chat-logs-es.md) | [日本語](./docs/synchronise-chat-logs-ja.md) | [한국어](./docs/synchronise-chat-logs-ko.md)
263+
260264
## Documentation
261265

262266
> Please go to the [docs][./docs] directory for more documentation instructions.
@@ -309,6 +313,7 @@ If you want to add a new translation, read this [document](./docs/translation.md
309313
[@AnsonHyq](https://github.com/AnsonHyq)
310314
[@synwith](https://github.com/synwith)
311315
[@piksonGit](https://github.com/piksonGit)
316+
[@ouyangzhiping](https://github.com/ouyangzhiping)
312317

313318
### Contributor
314319

README_CN.md

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s
169169

170170
⚠️ 注意:如果你安装过程中遇到了问题,请使用 docker 部署。
171171

172+
172173
## 鸣谢
173174

174175
### 捐赠者
@@ -185,3 +186,4 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s
185186
## 开源协议
186187

187188
[MIT](https://opensource.org/license/mit/)
189+

README_KO.md

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s
169169

170170
⚠️ 주의: 설치 중 문제가 발생한 경우, docker로 배포하세요.
171171

172+
172173
## 감사의 말
173174

174175
### 기부자
@@ -185,3 +186,4 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s
185186
## 오픈소스 라이센스
186187

187188
[MIT](https://opensource.org/license/mit/)
189+

app/components/auth.tsx

+24-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export function AuthPage() {
1515
const access = useAccessStore();
1616

1717
const goHome = () => navigate(Path.Home);
18-
const resetAccessCode = () => access.updateCode(""); // Reset access code to empty string
18+
const goChat = () => navigate(Path.Chat);
19+
const resetAccessCode = () => { access.updateCode(""); access.updateToken(""); }; // Reset access code to empty string
1920

2021
useEffect(() => {
2122
if (getClientConfig()?.isApp) {
@@ -42,17 +43,34 @@ export function AuthPage() {
4243
access.updateCode(e.currentTarget.value);
4344
}}
4445
/>
46+
{!access.hideUserApiKey ? (
47+
<>
48+
<div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>
49+
<input
50+
className={styles["auth-input"]}
51+
type="password"
52+
placeholder={Locale.Settings.Token.Placeholder}
53+
value={access.token}
54+
onChange={(e) => {
55+
access.updateToken(e.currentTarget.value);
56+
}}
57+
/>
58+
</>
59+
) : null}
4560

4661
<div className={styles["auth-actions"]}>
4762
<IconButton
4863
text={Locale.Auth.Confirm}
4964
type="primary"
50-
onClick={goHome}
65+
onClick={goChat}
66+
/>
67+
<IconButton
68+
text={Locale.Auth.Later}
69+
onClick={() => {
70+
resetAccessCode();
71+
goHome();
72+
}}
5173
/>
52-
<IconButton text={Locale.Auth.Later} onClick={() => {
53-
resetAccessCode();
54-
goHome();
55-
}} />
5674
</div>
5775
</div>
5876
);

app/components/chat.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,13 @@ function _Chat() {
11551155
{isUser ? (
11561156
<Avatar avatar={config.avatar} />
11571157
) : (
1158-
<MaskAvatar mask={session.mask} />
1158+
<>
1159+
{["system"].includes(message.role) ? (
1160+
<Avatar avatar="2699-fe0f" />
1161+
) : (
1162+
<MaskAvatar mask={session.mask} />
1163+
)}
1164+
</>
11591165
)}
11601166
</div>
11611167

app/components/exporter.tsx

+44-14
Original file line numberDiff line numberDiff line change
@@ -433,25 +433,55 @@ export function ImagePreviewer(props: {
433433

434434
const isMobile = useMobileScreen();
435435

436-
const download = () => {
436+
const download = async () => {
437437
showToast(Locale.Export.Image.Toast);
438438
const dom = previewRef.current;
439439
if (!dom) return;
440-
toPng(dom)
441-
.then((blob) => {
442-
if (!blob) return;
443-
444-
if (isMobile || getClientConfig()?.isApp) {
445-
showImageModal(blob);
440+
441+
const isApp = getClientConfig()?.isApp;
442+
443+
try {
444+
const blob = await toPng(dom);
445+
if (!blob) return;
446+
447+
if (isMobile || (isApp && window.__TAURI__)) {
448+
if (isApp && window.__TAURI__) {
449+
const result = await window.__TAURI__.dialog.save({
450+
defaultPath: `${props.topic}.png`,
451+
filters: [
452+
{
453+
name: "PNG Files",
454+
extensions: ["png"],
455+
},
456+
{
457+
name: "All Files",
458+
extensions: ["*"],
459+
},
460+
],
461+
});
462+
463+
if (result !== null) {
464+
const response = await fetch(blob);
465+
const buffer = await response.arrayBuffer();
466+
const uint8Array = new Uint8Array(buffer);
467+
await window.__TAURI__.fs.writeBinaryFile(result, uint8Array);
468+
showToast(Locale.Download.Success);
469+
} else {
470+
showToast(Locale.Download.Failed);
471+
}
446472
} else {
447-
const link = document.createElement("a");
448-
link.download = `${props.topic}.png`;
449-
link.href = blob;
450-
link.click();
451-
refreshPreview();
473+
showImageModal(blob);
452474
}
453-
})
454-
.catch((e) => console.log("[Export Image] ", e));
475+
} else {
476+
const link = document.createElement("a");
477+
link.download = `${props.topic}.png`;
478+
link.href = blob;
479+
link.click();
480+
refreshPreview();
481+
}
482+
} catch (error) {
483+
showToast(Locale.Download.Failed);
484+
}
455485
};
456486

457487
const refreshPreview = () => {

app/components/home.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ function Screen() {
128128
const isHome = location.pathname === Path.Home;
129129
const isAuth = location.pathname === Path.Auth;
130130
const isMobileScreen = useMobileScreen();
131-
const shouldTightBorder =
132-
config.tightBorder && !isMobileScreen && !getClientConfig()?.isApp;
131+
const shouldTightBorder = getClientConfig()?.isApp || (config.tightBorder && !isMobileScreen);
133132

134133
useEffect(() => {
135134
loadAsyncGoogleFont();

app/components/mask.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,13 @@ export function MaskPage() {
393393
const [searchText, setSearchText] = useState("");
394394
const masks = searchText.length > 0 ? searchMasks : allMasks;
395395

396-
// simple search, will refactor later
396+
// refactored already, now it accurate
397397
const onSearch = (text: string) => {
398398
setSearchText(text);
399399
if (text.length > 0) {
400-
const result = allMasks.filter((m) => m.name.includes(text));
400+
const result = allMasks.filter((m) =>
401+
m.name.toLowerCase().includes(text.toLowerCase())
402+
);
401403
setSearchMasks(result);
402404
} else {
403405
setSearchMasks(allMasks);

app/components/settings.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ export function Settings() {
753753
title={`${config.fontSize ?? 14}px`}
754754
value={config.fontSize}
755755
min="12"
756-
max="18"
756+
max="40"
757757
step="1"
758758
onChange={(e) =>
759759
updateConfig(

app/constant.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/c
88
export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`;
99
export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
1010

11-
export const DEFAULT_CORS_HOST = "https://nb.nextweb.fun";
11+
export const DEFAULT_CORS_HOST = "https://ab.nextweb.fun";
1212
export const DEFAULT_API_HOST = `${DEFAULT_CORS_HOST}/api/proxy`;
1313

1414
export enum Path {

app/global.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,17 @@ declare module "*.svg";
1313
declare interface Window {
1414
__TAURI__?: {
1515
writeText(text: string): Promise<void>;
16+
invoke(command: string, payload?: Record<string, unknown>): Promise<any>;
17+
dialog: {
18+
save(options?: Record<string, unknown>): Promise<string | null>;
19+
};
20+
fs: {
21+
writeBinaryFile(path: string, data: Uint8Array): Promise<void>;
22+
};
23+
notification:{
24+
requestPermission(): Promise<Permission>;
25+
isPermissionGranted(): Promise<boolean>;
26+
sendNotification(options: string | Options): void;
27+
};
1628
};
1729
}

app/locales/ar.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ar: PartialLocaleType = {
1010
Auth: {
1111
Title: "تحتاج إلى رمز الوصول",
1212
Tips: "يرجى إدخال رمز الوصول أدناه",
13+
SubTips: "أو أدخل مفتاح واجهة برمجة تطبيقات OpenAI الخاص بك",
1314
Input: "رمز الوصول",
1415
Confirm: "تأكيد",
1516
Later: "لاحقًا",

app/locales/bn.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const bn: PartialLocaleType = {
1010
Auth: {
1111
Title: "একটি অ্যাক্সেস কোড প্রয়োজন",
1212
Tips: "নীচে অ্যাক্সেস কোড ইনপুট করুন",
13+
SubTips: "অথবা আপনার OpenAI API কী প্রবেশ করুন",
1314
Input: "অ্যাক্সেস কোড",
1415
Confirm: "নিশ্চিত করুন",
1516
Later: "পরে",

app/locales/cn.ts

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const cn = {
1313
Auth: {
1414
Title: "需要密码",
1515
Tips: "管理员开启了密码验证,请在下方填入访问码",
16+
SubTips: "或者输入你的 OpenAI API 密钥",
1617
Input: "在此处填写访问码",
1718
Confirm: "确认",
1819
Later: "稍后再说",
@@ -323,6 +324,10 @@ const cn = {
323324
Success: "已写入剪切板",
324325
Failed: "复制失败,请赋予剪切板权限",
325326
},
327+
Download: {
328+
Success: "内容已下载到您的目录。",
329+
Failed: "下载失败。",
330+
},
326331
Context: {
327332
Toast: (x: any) => `包含 ${x} 条预设提示词`,
328333
Edit: "当前对话设置",

app/locales/en.ts

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const en: LocaleType = {
1515
Auth: {
1616
Title: "Need Access Code",
1717
Tips: "Please enter access code below",
18+
SubTips: "Or enter your OpenAI API Key",
1819
Input: "access code",
1920
Confirm: "Confirm",
2021
Later: "Later",
@@ -329,6 +330,10 @@ const en: LocaleType = {
329330
Success: "Copied to clipboard",
330331
Failed: "Copy failed, please grant permission to access clipboard",
331332
},
333+
Download: {
334+
Success: "Content downloaded to your directory.",
335+
Failed: "Download failed.",
336+
},
332337
Context: {
333338
Toast: (x: any) => `With ${x} contextual prompts`,
334339
Edit: "Current Chat Settings",

app/locales/id.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { PartialLocaleType } from "./index";
44
const id: PartialLocaleType = {
55
WIP: "Coming Soon...",
66
Error: {
7-
Unauthorized:
8-
"Akses tidak diizinkan. Silakan [otorisasi](/#/auth) dengan memasukkan kode akses.",
9-
},
7+
Unauthorized: "Akses tidak diizinkan, silakan masukkan kode akses atau masukkan kunci API OpenAI Anda. di halaman [autentikasi](/#/auth) atau di halaman [Pengaturan](/#/settings).",
8+
},
109
Auth: {
1110
Title: "Diperlukan Kode Akses",
1211
Tips: "Masukkan kode akses di bawah",
12+
SubTips: "Atau masukkan kunci API OpenAI Anda",
1313
Input: "Kode Akses",
1414
Confirm: "Konfirmasi",
1515
Later: "Nanti",
@@ -301,6 +301,10 @@ const id: PartialLocaleType = {
301301
Failed:
302302
"Gagal menyalin, mohon berikan izin untuk mengakses clipboard atau Clipboard API tidak didukung (Tauri)",
303303
},
304+
Download: {
305+
Success: "Konten berhasil diunduh ke direktori Anda.",
306+
Failed: "Unduhan gagal.",
307+
},
304308
Context: {
305309
Toast: (x: any) => `Dengan ${x} promp kontekstual`,
306310
Edit: "Pengaturan Obrolan Saat Ini",

0 commit comments

Comments
 (0)