diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index 670b4d5..2eb8a06 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -22,7 +22,7 @@ import {
} from "../store";
import { Avatar, PromptHints } from "./home";
-import Locale, { changeLang, getLang } from "../locales";
+import Locale, { AllLangs, changeLang, getLang } from "../locales";
import { getCurrentCommitId } from "../utils";
import Link from "next/link";
import { UPDATE_URL } from "../constant";
@@ -212,26 +212,18 @@ export function Settings(props: { closeSettings: () => void }) {
-
-
+ ))}
+
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 81f1396..8eb379c 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -66,6 +66,16 @@ const en: LocaleType = {
SendKey: "Send Key",
Theme: "Theme",
TightBorder: "Tight Border",
+ Prompt: {
+ Disable: {
+ Title: "Disable auto-completion",
+ SubTitle: "After disabling, auto-completion will not be available",
+ },
+ List: "Prompt List",
+ ListCount: (builtin: number, custom: number) =>
+ `${builtin} built-in, ${custom} user-defined`,
+ Edit: "Edit",
+ },
HistoryCount: {
Title: "Attached Messages Count",
SubTitle: "Number of sent messages attached per request",
diff --git a/app/locales/index.ts b/app/locales/index.ts
index bb6b0de..43d4755 100644
--- a/app/locales/index.ts
+++ b/app/locales/index.ts
@@ -1,56 +1,57 @@
-import CN from './cn'
-import EN from './en'
-import TW from './tw'
+import CN from "./cn";
+import EN from "./en";
+import TW from "./tw";
-export type { LocaleType } from './cn'
+export type { LocaleType } from "./cn";
-type Lang = 'en' | 'cn' | 'tw'
+export const AllLangs = ["en", "cn", "tw"] as const;
+type Lang = typeof AllLangs[number];
-const LANG_KEY = 'lang'
+const LANG_KEY = "lang";
function getItem(key: string) {
- try {
- return localStorage.getItem(key)
- } catch {
- return null
- }
+ try {
+ return localStorage.getItem(key);
+ } catch {
+ return null;
+ }
}
function setItem(key: string, value: string) {
- try {
- localStorage.setItem(key, value)
- } catch { }
+ try {
+ localStorage.setItem(key, value);
+ } catch {}
}
function getLanguage() {
- try {
- return navigator.language.toLowerCase()
- } catch {
- return 'cn'
- }
+ try {
+ return navigator.language.toLowerCase();
+ } catch {
+ return "cn";
+ }
}
export function getLang(): Lang {
- const savedLang = getItem(LANG_KEY)
+ const savedLang = getItem(LANG_KEY);
- if (['en', 'cn', 'tw'].includes(savedLang ?? '')) {
- return savedLang as Lang
- }
+ if (AllLangs.includes((savedLang ?? "") as Lang)) {
+ return savedLang as Lang;
+ }
- const lang = getLanguage()
+ const lang = getLanguage();
- if (lang.includes('zh') || lang.includes('cn')) {
- return 'cn'
- } else if (lang.includes('tw')) {
- return 'tw'
- } else {
- return 'en'
- }
+ if (lang.includes("zh") || lang.includes("cn")) {
+ return "cn";
+ } else if (lang.includes("tw")) {
+ return "tw";
+ } else {
+ return "en";
+ }
}
export function changeLang(lang: Lang) {
- setItem(LANG_KEY, lang)
- location.reload()
+ setItem(LANG_KEY, lang);
+ location.reload();
}
-export default { en: EN, cn: CN, tw: TW }[getLang()]
\ No newline at end of file
+export default { en: EN, cn: CN, tw: TW }[getLang()];
diff --git a/app/locales/tw.ts b/app/locales/tw.ts
index 514c31a..9774362 100644
--- a/app/locales/tw.ts
+++ b/app/locales/tw.ts
@@ -64,6 +64,16 @@ const tw: LocaleType = {
SendKey: "發送鍵",
Theme: "主題",
TightBorder: "緊湊邊框",
+ Prompt: {
+ Disable: {
+ Title: "禁用提示詞自動補全",
+ SubTitle: "禁用後將無法自動根據輸入補全",
+ },
+ List: "自定義提示詞列表",
+ ListCount: (builtin: number, custom: number) =>
+ `內置 ${builtin} 條,用戶定義 ${custom} 條`,
+ Edit: "編輯",
+ },
HistoryCount: {
Title: "附帶歷史消息數",
SubTitle: "每次請求攜帶的歷史消息數",
@@ -117,4 +127,3 @@ const tw: LocaleType = {
};
export default tw;
-
diff --git a/app/store/prompt.ts b/app/store/prompt.ts
index a909293..97da8ca 100644
--- a/app/store/prompt.ts
+++ b/app/store/prompt.ts
@@ -1,7 +1,6 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import Fuse from "fuse.js";
-import { showToast } from "../components/ui-lib";
export interface Prompt {
id?: number;
@@ -111,7 +110,6 @@ export const usePromptStore = create
()(
);
SearchService.count.builtin = res.en.length + res.cn.length;
SearchService.init(allPromptsForSearch);
- showToast(`已加载 ${allPromptsForSearch.length} 条 Prompts`);
});
},
}