背单词可以设置索引

This commit is contained in:
2025-11-24 16:01:53 +08:00
parent 7bf3fd9b17
commit 4cbde97f41
3 changed files with 17 additions and 7 deletions

View File

@@ -94,7 +94,6 @@
"reverse": "Reverse", "reverse": "Reverse",
"dictation": "Dictation", "dictation": "Dictation",
"noTextPairs": "No text pairs available", "noTextPairs": "No text pairs available",
"progress": "{current}/{total}",
"disorder": "Disorder", "disorder": "Disorder",
"previous": "Previous" "previous": "Previous"
}, },

View File

@@ -98,7 +98,6 @@
"reverse": "反向", "reverse": "反向",
"dictation": "听写", "dictation": "听写",
"noTextPairs": "没有可用的文本对", "noTextPairs": "没有可用的文本对",
"progress": "{current}/{total}",
"disorder": "乱序", "disorder": "乱序",
"previous": "上一个" "previous": "上一个"
}, },

View File

@@ -10,6 +10,7 @@ import { getTTSAudioUrl } from "@/lib/browser/tts";
import { VOICES } from "@/config/locales"; import { VOICES } from "@/config/locales";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import localFont from "next/font/local"; import localFont from "next/font/local";
import { isNonNegativeInteger } from "@/lib/utils";
const myFont = localFont({ const myFont = localFont({
src: "../../../../public/fonts/NotoNaskhArabic-VariableFont_wght.ttf", src: "../../../../public/fonts/NotoNaskhArabic-VariableFont_wght.ttf",
@@ -51,11 +52,22 @@ const Memorize: React.FC<MemorizeProps> = ({ textPairs }) => {
<div <div
className={`h-36 flex flex-col gap-2 justify-start items-center ${myFont.className} text-3xl`} className={`h-36 flex flex-col gap-2 justify-start items-center ${myFont.className} text-3xl`}
> >
<div className="text-sm text-gray-500"> <div
{t("progress", { className="text-sm text-gray-500"
current: index + 1, onClick={() => {
total: getTextPairs().length, const newIndex = prompt("Input a index number.")?.trim();
})} if (
newIndex &&
isNonNegativeInteger(newIndex) &&
parseInt(newIndex) <= textPairs.length &&
parseInt(newIndex) > 0
) {
setIndex(parseInt(newIndex) - 1);
}
}}
>
{index + 1}
{"/" + getTextPairs().length}
</div> </div>
{dictation ? ( {dictation ? (
show === "question" ? ( show === "question" ? (