From 7b5062e5dae9ccda78f70f32d98e5f3ab61f15e0 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sun, 31 Mar 2024 20:16:26 +0530 Subject: [PATCH] Add about section to settings.json for multiple locales --- src/assets/locale/en/settings.json | 10 ++ src/assets/locale/ja-JP/settings.json | 12 ++- src/assets/locale/ml/settings.json | 13 ++- src/assets/locale/zh/settings.json | 12 ++- .../Layouts/SettingsOptionLayout.tsx | 14 ++- src/components/Option/Settings/about.tsx | 102 ++++++++++++++++++ src/libs/db.ts | 5 +- src/routes/index.tsx | 4 + src/routes/option-settings-about.tsx | 13 +++ src/routes/option-settings-knowledge.tsx | 12 +++ 10 files changed, 191 insertions(+), 6 deletions(-) create mode 100644 src/components/Option/Settings/about.tsx create mode 100644 src/routes/option-settings-about.tsx create mode 100644 src/routes/option-settings-knowledge.tsx diff --git a/src/assets/locale/en/settings.json b/src/assets/locale/en/settings.json index 7a6fe6f..2aa6083 100644 --- a/src/assets/locale/en/settings.json +++ b/src/assets/locale/en/settings.json @@ -232,5 +232,15 @@ "manageSearch": { "title": "Manage Web Search", "heading": "Configure Web Search" + }, + "about": { + "title": "About", + "heading": "About", + "chromeVersion": "Page Assist Version", + "ollamaVersion": "Ollama Version", + "support": "You can support the Page Assist project by donating or sponsoring through the following platforms:", + "koFi": "Support on Ko-fi", + "githubSponsor": "Sponsor on GitHub", + "githubRepo": "GitHub Repository" } } \ No newline at end of file diff --git a/src/assets/locale/ja-JP/settings.json b/src/assets/locale/ja-JP/settings.json index 15a0ad4..607532e 100644 --- a/src/assets/locale/ja-JP/settings.json +++ b/src/assets/locale/ja-JP/settings.json @@ -235,5 +235,15 @@ "manageSearch": { "title": "Web検索の管理", "heading": "Web検索を設定する" - } + }, + "about": { + "title": "About", + "heading": "About", + "chromeVersion": "Page Assistのバージョン", + "ollamaVersion": "Ollamaのバージョン", + "support": "Page Assistプロジェクトは、以下のプラットフォームで寄付やスポンサーシップをすることで支援できます:", + "koFi": "Ko-fiで支援する", + "githubSponsor": "GitHubでスポンサーする", + "githubRepo": "GitHubリポジトリ" + } } \ No newline at end of file diff --git a/src/assets/locale/ml/settings.json b/src/assets/locale/ml/settings.json index 940b0c2..84ab01e 100644 --- a/src/assets/locale/ml/settings.json +++ b/src/assets/locale/ml/settings.json @@ -235,5 +235,16 @@ "manageSearch": { "heading": "Web തിരയൽ സജ്ജമാക്കുക", "title": "Web തിരയൽ നിയന്ത്രിക്കുക" - } + }, + "about": { + "title": "വിവരങ്ങൾ", + "heading": "വിവരങ്ങൾ", + "chromeVersion": "പേജ് അസിസ്റ്റ് വേർഷൻ", + "ollamaVersion": "ഓളാമ വേർഷൻ", + "support": "താഴെ പറയുന്ന പ്ലാറ്റ്ഫോമുകളിലൂടെ ദാനം ചെയ്യുകയോ സ്പോൺസർ ചെയ്യുകയോ ചെയ്ത് പേജ് അസിസ്റ്റ് പ്രോജക്റ്റിനെ പിന്തുണയ്ക്കാവുന്നതാണ്:", + "koFi": "കോഫിയിൽ പിന്തുണയ്ക്കുക", + "githubSponsor": "ഗിറ്റ്ഹബ്ബിൽ സ്പോൺസർ ചെയ്യുക", + "githubRepo": "ഗിറ്റ്ഹബ്ബ് റെപ്പോസിറ്ററി" + } + } \ No newline at end of file diff --git a/src/assets/locale/zh/settings.json b/src/assets/locale/zh/settings.json index ea7af68..b99fead 100644 --- a/src/assets/locale/zh/settings.json +++ b/src/assets/locale/zh/settings.json @@ -236,5 +236,15 @@ "manageSearch": { "heading": "配置网络搜索", "title": "管理网络搜索" - } + }, + "about": { + "title": "关于", + "heading": "关于", + "chromeVersion": "Page Assist版本", + "ollamaVersion": "Ollama版本", + "support": "您可以通过以下平台捐赠或赞助Page Assist项目:", + "koFi": "在Ko-fi上支持", + "githubSponsor": "在GitHub上赞助", + "githubRepo": "GitHub仓库" + } } \ No newline at end of file diff --git a/src/components/Layouts/SettingsOptionLayout.tsx b/src/components/Layouts/SettingsOptionLayout.tsx index 6d83d33..372dc0d 100644 --- a/src/components/Layouts/SettingsOptionLayout.tsx +++ b/src/components/Layouts/SettingsOptionLayout.tsx @@ -1,4 +1,4 @@ -import { Book, BrainCircuit, Orbit, Share } from "lucide-react" +import { Book, BrainCircuit, Orbit, Share, BlocksIcon , InfoIcon} from "lucide-react" import { useTranslation } from "react-i18next" import { Link, useLocation } from "react-router-dom" import { OllamaIcon } from "../Icons/Ollama" @@ -68,6 +68,12 @@ export const SettingsLayout = ({ children }: { children: React.ReactNode }) => { current={location.pathname} icon={BrainCircuit} /> + {/* */} { icon={Share} current={location.pathname} /> + diff --git a/src/components/Option/Settings/about.tsx b/src/components/Option/Settings/about.tsx new file mode 100644 index 0000000..b30f39d --- /dev/null +++ b/src/components/Option/Settings/about.tsx @@ -0,0 +1,102 @@ +import { getOllamaURL } from "~/services/ollama" +import { useTranslation } from "react-i18next" +import { useQuery } from "@tanstack/react-query" +import { Skeleton } from "antd" +import { cleanUrl } from "@/libs/clean-url" + +export const AboutApp = () => { + const { t } = useTranslation("settings") + + const { data, status } = useQuery({ + queryKey: ["fetchOllamURL"], + queryFn: async () => { + const chromeVersion = chrome.runtime.getManifest().version + try { + const url = await getOllamaURL() + const req = await fetch(`${cleanUrl(url)}/api/version`) + + if (!req.ok) { + return { + ollama: "N/A", + chromeVersion + } + } + + const res = (await req.json()) as { version: string } + return { + ollama: res.version, + chromeVersion + } + } catch { + return { + ollama: "N/A", + chromeVersion + } + } + } + }) + + return ( +
+ {status === "pending" && } + {status === "success" && ( +
+
+
+

+ {t("about.heading")} +

+
+
+
+ +
+
+
+ + {t("about.chromeVersion")} + + + {data.chromeVersion} + +
+ +
+ + {t("about.ollamaVersion")} + + + {data.ollama} + +
+
+
+ +
+

+ {t("about.support")} +

+ + +
+
+ )} +
+ ) +} diff --git a/src/libs/db.ts b/src/libs/db.ts index bc4d851..bab011a 100644 --- a/src/libs/db.ts +++ b/src/libs/db.ts @@ -6,6 +6,7 @@ import { type HistoryInfo = { id: string title: string + is_rag: boolean createdAt: number } @@ -214,10 +215,10 @@ export const generateID = () => { }) } -export const saveHistory = async (title: string) => { +export const saveHistory = async (title: string, is_rag?: boolean) => { const id = generateID() const createdAt = Date.now() - const history = { id, title, createdAt } + const history = { id, title, createdAt, is_rag } const db = new PageAssitDatabase() await db.addChatHistory(history) return history diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 87c6c4e..c474548 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -8,6 +8,8 @@ import { OptionPrompt } from "./option-settings-prompt" import { OptionOllamaSettings } from "./options-settings-ollama" import { OptionSettings } from "./option-settings" import { OptionShare } from "./option-settings-share" +import { OptionKnowledgeBase } from "./option-settings-knowledge" +import { OptionAbout } from "./option-settings-about" export const OptionRouting = () => { const { mode } = useDarkMode() @@ -21,6 +23,8 @@ export const OptionRouting = () => { } /> } /> } /> + } /> + } /> ) diff --git a/src/routes/option-settings-about.tsx b/src/routes/option-settings-about.tsx new file mode 100644 index 0000000..982f1ea --- /dev/null +++ b/src/routes/option-settings-about.tsx @@ -0,0 +1,13 @@ +import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout" +import OptionLayout from "~/components/Layouts/Layout" +import { AboutApp } from "@/components/Option/Settings/about" + +export const OptionAbout = () => { + return ( + + + + + + ) +} diff --git a/src/routes/option-settings-knowledge.tsx b/src/routes/option-settings-knowledge.tsx new file mode 100644 index 0000000..0d8c573 --- /dev/null +++ b/src/routes/option-settings-knowledge.tsx @@ -0,0 +1,12 @@ +import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout" +import OptionLayout from "~/components/Layouts/Layout" + +export const OptionKnowledgeBase = () => { + return ( + + + hey + + + ) +}