Skip to content

Commit 0ed2423

Browse files
committed
在主页中添加增量扫描支持提示组件,并更新国际化文本以反映增量索引功能的变化,确保多语言支持的准确性和一致性。
1 parent 34dbfbd commit 0ed2423

4 files changed

Lines changed: 143 additions & 4 deletions

File tree

src/app/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import SettingsButton from "../components/SettingsModal";
2020
import BrowserCompatCheck from "../components/BrowserCompatCheck";
2121
import KnowledgeModal from "../components/KnowledgeModal";
2222
import MultiThreadScanAlert from "../components/MultiThreadScanAlert";
23+
import IncrementalScanAlert from "../components/IncrementalScanAlert";
2324
import RssFeed from "../components/RssFeed";
2425

2526
export default function Home() {
@@ -556,6 +557,9 @@ export default function Home() {
556557
{/* 多线程扫描支持检测提示 */}
557558
<MultiThreadScanAlert />
558559

560+
{/* 增量扫描支持提示 */}
561+
<IncrementalScanAlert />
562+
559563
<section className="bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden transition-colors duration-300 border border-gray-200 dark:border-gray-700">
560564
<div className="p-6">
561565
<div className="flex items-center justify-between mb-4">
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
"use client";
2+
3+
import { useState, useEffect } from "react";
4+
import { isFileSystemObserverSupported } from "../lib/fileObserver";
5+
import { useTranslations } from "./LocaleProvider";
6+
import { motion, AnimatePresence } from "framer-motion";
7+
8+
export default function IncrementalScanAlert() {
9+
const [showAlert, setShowAlert] = useState(false);
10+
const [isSupported, setIsSupported] = useState(true);
11+
const { t } = useTranslations();
12+
13+
useEffect(() => {
14+
// 只在客户端执行
15+
if (typeof window === "undefined") return;
16+
17+
// 检查是否支持FileSystemObserver API
18+
const supported = isFileSystemObserverSupported();
19+
setIsSupported(supported);
20+
21+
// 无论是否支持,都显示提示
22+
setShowAlert(true);
23+
}, []);
24+
25+
// 如果用户关闭了提示,则不显示
26+
if (!showAlert) return null;
27+
28+
return (
29+
<AnimatePresence>
30+
<motion.div
31+
initial={{ opacity: 0, y: -10 }}
32+
animate={{ opacity: 1, y: 0 }}
33+
exit={{ opacity: 0, y: -10 }}
34+
className={`mb-4 ${
35+
isSupported
36+
? "bg-green-50 dark:bg-green-900/30 border-green-200 dark:border-green-700"
37+
: "bg-yellow-50 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-700"
38+
} border rounded-lg p-4 flex items-start`}
39+
>
40+
<div
41+
className={`flex-shrink-0 ${
42+
isSupported
43+
? "text-green-500 dark:text-green-400"
44+
: "text-yellow-500 dark:text-yellow-400"
45+
}`}
46+
>
47+
{isSupported ? (
48+
// 支持增量扫描时显示的图标
49+
<svg
50+
xmlns="http://www.w3.org/2000/svg"
51+
className="h-5 w-5"
52+
viewBox="0 0 20 20"
53+
fill="currentColor"
54+
>
55+
<path
56+
fillRule="evenodd"
57+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
58+
clipRule="evenodd"
59+
/>
60+
</svg>
61+
) : (
62+
// 不支持增量扫描时显示的图标
63+
<svg
64+
xmlns="http://www.w3.org/2000/svg"
65+
className="h-5 w-5"
66+
viewBox="0 0 20 20"
67+
fill="currentColor"
68+
>
69+
<path
70+
fillRule="evenodd"
71+
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
72+
clipRule="evenodd"
73+
/>
74+
</svg>
75+
)}
76+
</div>
77+
<div className="ml-3 flex-1">
78+
<div
79+
className={`text-sm ${
80+
isSupported
81+
? "text-green-700 dark:text-green-300"
82+
: "text-yellow-700 dark:text-yellow-300"
83+
}`}
84+
>
85+
{isSupported ? (
86+
// 支持增量扫描时显示的文本
87+
<>
88+
<p className="font-medium mb-1">
89+
{t("incrementalScan.supported")}
90+
</p>
91+
</>
92+
) : (
93+
// 不支持增量扫描时显示的文本
94+
<>
95+
<p className="font-medium mb-1">
96+
{t("incrementalScan.notSupported")}
97+
</p>
98+
</>
99+
)}
100+
</div>
101+
</div>
102+
<button
103+
onClick={() => setShowAlert(false)}
104+
className={`ml-auto flex-shrink-0 ${
105+
isSupported
106+
? "text-green-500 hover:text-green-700 dark:text-green-400 dark:hover:text-green-300"
107+
: "text-yellow-500 hover:text-yellow-700 dark:text-yellow-400 dark:hover:text-yellow-300"
108+
} focus:outline-none`}
109+
aria-label="关闭提示"
110+
>
111+
<svg
112+
className="h-5 w-5"
113+
xmlns="http://www.w3.org/2000/svg"
114+
viewBox="0 0 20 20"
115+
fill="currentColor"
116+
>
117+
<path
118+
fillRule="evenodd"
119+
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
120+
clipRule="evenodd"
121+
/>
122+
</svg>
123+
</button>
124+
</motion.div>
125+
</AnimatePresence>
126+
);
127+
}

src/messages/en.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@
5151
"refresh": "Refresh",
5252
"refreshing": "Refreshing...",
5353
"multiThreadSupport": {
54-
"supported": "Your browser supports multi-threaded scanning. Scanning will be faster!",
55-
"notSupported": "Your browser doesn't support multi-threaded scanning. Scanning will be slower, please be patient :)"
54+
"supported": "Your browser supports multi-threaded indexing. Indexing will be faster!",
55+
"notSupported": "Your browser doesn't support multi-threaded indexing. Indexing will be slower, please be patient :)"
5656
}
5757
},
58+
"incrementalScan": {
59+
"supported": "Your browser supports FileSystemObserver API for incremental indexing. File changes will be detected in real-time!",
60+
"notSupported": "Your browser doesn't support FileSystemObserver API. Each index will be a full index which may be slower. We recommend using Chrome or Edge for better performance."
61+
},
5862
"folderPicker": {
5963
"selectFolder": "Select Folder",
6064
"selecting": "Selecting...",

src/messages/zh.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@
5151
"refresh": "刷新",
5252
"refreshing": "刷新中...",
5353
"multiThreadSupport": {
54-
"supported": "当前浏览器支持多线程扫描,扫描速度将更快",
55-
"notSupported": "当前浏览器不支持多线程扫描 扫描会有点慢 耐心等一下:)"
54+
"supported": "当前浏览器支持多线程索引,索引速度将更快",
55+
"notSupported": "当前浏览器不支持多线程索引,索引会有点慢 耐心等一下:)"
5656
}
5757
},
58+
"incrementalScan": {
59+
"supported": "当前浏览器支持FileSystemObserver API进行增量索引!",
60+
"notSupported": "当前环境不支持FileSystemObserver API增量索引,每次索引都是全量索引,这会很慢。建议使用Chrome或Edge浏览器获得更好的性能。"
61+
},
5862
"folderPicker": {
5963
"selectFolder": "选择文件夹",
6064
"selecting": "选择中...",

0 commit comments

Comments
 (0)