From 9cb76701325cb9fd0fc3dfb5af214f7218e64f49 Mon Sep 17 00:00:00 2001 From: Richasy Date: Mon, 8 Jul 2024 13:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E6=97=B6=E5=BC=B9=E5=87=BA=E6=8F=90=E9=86=92=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 在数据库缺失时弹出提醒 * Update --- docs/.vitepress/en.mts | 1 + docs/.vitepress/zh.mts | 1 + docs/en/faq.md | 15 ++++++++ docs/faq.md | 15 ++++++++ .../RodelAgent.UI/Pages/SettingsPage.xaml.cs | 36 +++++++++++++++++++ .../Resources/en-US/Resources.resw | 9 +++++ .../Resources/zh-Hans-CN/Resources.resw | 9 +++++ 7 files changed, 86 insertions(+) create mode 100644 docs/en/faq.md create mode 100644 docs/faq.md diff --git a/docs/.vitepress/en.mts b/docs/.vitepress/en.mts index 28f2118..009e3fc 100644 --- a/docs/.vitepress/en.mts +++ b/docs/.vitepress/en.mts @@ -22,6 +22,7 @@ export const en = defineConfig({ { text: 'Installation', link: '/en/install' }, { text: 'Supported services', link: '/en/services' }, { text: 'Work directory & Data sync', link: '/en/work-directory' }, + { text: 'FAQ', link: './faq' }, { text: 'V1 data migration', link: '/en/v1-migration' }, { text: 'Privacy Policy', link: '/en/privacy' } ] diff --git a/docs/.vitepress/zh.mts b/docs/.vitepress/zh.mts index 7a3bf47..8bbcaf2 100644 --- a/docs/.vitepress/zh.mts +++ b/docs/.vitepress/zh.mts @@ -22,6 +22,7 @@ export const zh = defineConfig({ { text: '安装应用', link: '/install' }, { text: '支持的服务', link: '/services' }, { text: '工作目录与数据同步', link: '/work-directory' }, + { text: '常见问题', link: './faq' }, { text: 'V1 数据迁移', link: '/v1-migration' }, { text: '隐私策略', link: '/privacy' } ] diff --git a/docs/en/faq.md b/docs/en/faq.md new file mode 100644 index 0000000..ea505f0 --- /dev/null +++ b/docs/en/faq.md @@ -0,0 +1,15 @@ +# FAQ + +## I can't configure the service (the service setup page is blank) + +When the app initializes, it attempts to copy the blank database file in the app to the working directory, but in a few rare cases, there may be an issue where the copy fails. + +If the necessary database is not copied to the working directory, you will observe that the app is unable to configure various AI services, resulting in a blank page for the relevant service on the settings page. + +In this case, you need to manually download the database file and copy it to the working directory. + +The specific steps are as follows: + +1. Download [database.zip](https://github.com/Richasy/Rodel.Agent/releases/download/empty-db/database.zip) to your local machine. +2. Extract the database file (with the `.db` extension) from the zip file to your working directory. +3. Restart the application. \ No newline at end of file diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 0000000..2290bad --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,15 @@ +# 常见问题 + +## 我无法配置服务(服务设置页面空白) + +应用在初始化工作目录时会尝试把应用内的空白数据库文件复制到工作目录中,但是在少数未知情况下,会出现无法复制的情况。 + +一旦必要的数据库没有复制到工作目录,你就会观察到应用无法配置各种 AI 服务,表现为设置页面的相关服务页面会显示一片空白。 + +这需要你手动下载数据库文件,然后复制到工作目录。 + +具体操作步骤如下: + +1. 下载 [database.zip](https://github.com/Richasy/Rodel.Agent/releases/download/empty-db/database.zip) 到本地。 +2. 将其中的数据库文件(后缀为 `.db`)解压到您的工作目录中。 +3. 重启应用程序。 \ No newline at end of file diff --git a/src/Desktop/RodelAgent.UI/Pages/SettingsPage.xaml.cs b/src/Desktop/RodelAgent.UI/Pages/SettingsPage.xaml.cs index 4ad18e3..c80cc68 100644 --- a/src/Desktop/RodelAgent.UI/Pages/SettingsPage.xaml.cs +++ b/src/Desktop/RodelAgent.UI/Pages/SettingsPage.xaml.cs @@ -3,7 +3,9 @@ using Microsoft.UI.Xaml.Media.Animation; using RodelAgent.Interfaces; using RodelAgent.UI.Models.Constants; +using RodelAgent.UI.Toolkits; using RodelAgent.UI.ViewModels.Pages; +using Windows.System; namespace RodelAgent.UI.Pages; @@ -13,6 +15,7 @@ namespace RodelAgent.UI.Pages; public sealed partial class SettingsPage : SettingsPageBase { private SettingSectionType? _previousSection; + private bool _isDatabaseVerified; /// /// Initializes a new instance of the class. @@ -27,6 +30,10 @@ public SettingsPage() protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) => SaveSettings(); + /// + protected override async void OnPageLoaded() + => await VerifyDatabaseAsync(); + /// protected override void OnPageUnloaded() => SaveSettings(); @@ -68,6 +75,35 @@ private void OnSettingSectionChanged(SelectorBar sender, SelectorBarSelectionCha SectionFrame.Navigate(pageType, default, new SlideNavigationTransitionInfo { Effect = animationType }); } } + + private async Task VerifyDatabaseAsync() + { + if (_isDatabaseVerified) + { + return; + } + + var workDir = SettingsToolkit.ReadLocalSetting(SettingNames.WorkingDirectory, string.Empty); + _isDatabaseVerified = File.Exists(Path.Combine(workDir, "secret.db")); + if (!_isDatabaseVerified) + { + var dialog = new ContentDialog + { + Title = ResourceToolkit.GetLocalizedString(StringNames.DatabaseMissed), + Content = ResourceToolkit.GetLocalizedString(StringNames.DatabaseMissedDescription), + PrimaryButtonText = ResourceToolkit.GetLocalizedString(StringNames.Solution), + CloseButtonText = ResourceToolkit.GetLocalizedString(StringNames.Cancel), + DefaultButton = ContentDialogButton.Primary, + XamlRoot = XamlRoot, + }; + + var result = await dialog.ShowAsync(); + if (result == ContentDialogResult.Primary) + { + await Launcher.LaunchUriAsync(new Uri("https://agent.richasy.net/faq")); + } + } + } } /// diff --git a/src/Desktop/RodelAgent.UI/Resources/en-US/Resources.resw b/src/Desktop/RodelAgent.UI/Resources/en-US/Resources.resw index a87fece..73556f7 100644 --- a/src/Desktop/RodelAgent.UI/Resources/en-US/Resources.resw +++ b/src/Desktop/RodelAgent.UI/Resources/en-US/Resources.resw @@ -390,6 +390,12 @@ Dash Scope + + Database Missing + + + It appears that there was a problem during database initialization. The necessary database was not detected in your working directory. Please click the button below to see how to fix this problem. + Delete @@ -967,6 +973,9 @@ You can manually adjust the limit, and the application will capture the specifie Smart rename + + Solution + Source language diff --git a/src/Desktop/RodelAgent.UI/Resources/zh-Hans-CN/Resources.resw b/src/Desktop/RodelAgent.UI/Resources/zh-Hans-CN/Resources.resw index bd3b8ea..9b61512 100644 --- a/src/Desktop/RodelAgent.UI/Resources/zh-Hans-CN/Resources.resw +++ b/src/Desktop/RodelAgent.UI/Resources/zh-Hans-CN/Resources.resw @@ -390,6 +390,12 @@ 阿里灵积 + + 数据库缺失 + + + 看上去在数据库初始化的过程中出现了问题,未在你的工作目录中检测到必须的数据库。请点击下方的按钮查看如何修复这个问题 + 删除 @@ -967,6 +973,9 @@ 智能重命名 + + 解决方案 + 源语言