Compare commits
40 Commits
main
...
911343ce0d
| Author | SHA1 | Date | |
|---|---|---|---|
| 911343ce0d | |||
| 130ab226ff | |||
| 59d22ccf4c | |||
| 06012c43f2 | |||
| c54376cbe6 | |||
| 3ed3478c66 | |||
| bc7608e049 | |||
| 1ef337801d | |||
| 286add7fff | |||
| de7c1321c2 | |||
| 95ce49378b | |||
| 2f5ec1c0f0 | |||
| f53fa5e2a1 | |||
| 1d5732abc8 | |||
| ada2f249ee | |||
| bc0b392875 | |||
| a68951f1d3 | |||
| c525bd4591 | |||
| 6213dd2338 | |||
| af684a15ce | |||
| 279eee2953 | |||
| 168f0c161e | |||
| 7c71ffcf31 | |||
| 4243cdc68b | |||
| cbb9326f84 | |||
| 49ad953add | |||
| f1eafa8015 | |||
| 12e502313b | |||
| 13e8f51ada | |||
| 7ba31a37bd | |||
| 4d4062985d | |||
| 804c28ada9 | |||
| e68e24a9fb | |||
| 8099320e00 | |||
| db0b0ff348 | |||
| 6f4b123a84 | |||
| 57ad1b8699 | |||
| 9b78fd5215 | |||
| 683a4104ec | |||
| abcae1b8d1 |
54
AGENTS.md
54
AGENTS.md
@@ -104,6 +104,60 @@ log.info("Fetched folders", { count: folders.length });
|
|||||||
log.error("Failed to fetch folders", { error });
|
log.error("Failed to fetch folders", { error });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### i18n 翻译检查
|
||||||
|
**注意:翻译缺失不会被 build 检测出来。**
|
||||||
|
|
||||||
|
**系统性检查翻译缺失的方法(改进版):**
|
||||||
|
|
||||||
|
#### 步骤 1: 使用 AST-grep 搜索所有翻译模式
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 搜索所有 useTranslations 和 getTranslations 声明
|
||||||
|
ast-grep --pattern 'useTranslations($ARG)' --lang tsx --paths src/
|
||||||
|
|
||||||
|
# 搜索所有带插值的 t() 调用
|
||||||
|
ast-grep --pattern 't($ARG, $OPTS)' --lang tsx --paths src/
|
||||||
|
|
||||||
|
# 搜索所有简单 t() 调用
|
||||||
|
ast-grep --pattern 't($ARG)' --lang tsx --paths src/
|
||||||
|
```
|
||||||
|
|
||||||
|
**AST-grep 能捕获 31 种不同的翻译键模式, 而 grep 只能捕获 1 种模式。**
|
||||||
|
|
||||||
|
#### 步骤 2: 按文件提取所有翻译键
|
||||||
|
|
||||||
|
逐个 `.tsx` 文件检查使用的翻译键:
|
||||||
|
1. 找到该文件使用的 namespace(`useTranslations("namespace")` 或 `getTranslations("namespace")`)
|
||||||
|
2. 提取该文件中所有 `t("...")` 调用
|
||||||
|
3. 注意动态键模式:
|
||||||
|
- 模板字面量: `t(\`prefix.${variable}\`)`
|
||||||
|
- 条件键: `t(condition ? "a" : "b")`
|
||||||
|
- 变量键: `t(variable)`
|
||||||
|
4. 对比 `messages/en-US.json`,找出缺失的键
|
||||||
|
|
||||||
|
5. 先补全 `en-US.json`(作为基准语言)
|
||||||
|
6. 再根据 `en-US.json` 补全其他 7 种语言
|
||||||
|
|
||||||
|
#### 步骤 3: 验证 JSON 文件结构
|
||||||
|
**注意:JSON 语法错误会导致 build 失败,常见错误:**
|
||||||
|
- 重复的键(同一对象中出现两次相同的键名)
|
||||||
|
- 缺少逗号或多余的逗号
|
||||||
|
- 缺少闭合括号 `}`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 验证 JSON 格式
|
||||||
|
node -e "console.log(JSON.parse(require('fs').readFileSync('messages/en-US.json', 'utf8')))"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 步骤 4: 对比验证
|
||||||
|
```bash
|
||||||
|
# 列出代码中使用的所有 namespace
|
||||||
|
ast-grep --pattern 'useTranslations($ARG)' --lang tsx --paths src/ | grep -o 'useTranslations\|getTranslations' | sort | uniq
|
||||||
|
|
||||||
|
# 对比 messages/en-US.json 中的 namespace 列表
|
||||||
|
node -e "console.log(Object.keys(JSON.parse(require('fs').readFileSync('messages/en-US.json', 'utf8'))).join('\n'))"
|
||||||
|
```
|
||||||
|
|
||||||
## 反模式 (本项目)
|
## 反模式 (本项目)
|
||||||
|
|
||||||
- ❌ `index.ts` barrel exports
|
- ❌ `index.ts` barrel exports
|
||||||
|
|||||||
@@ -46,6 +46,38 @@
|
|||||||
"unfavorite": "Aus Favoriten entfernen",
|
"unfavorite": "Aus Favoriten entfernen",
|
||||||
"pleaseLogin": "Bitte melden Sie sich zuerst an"
|
"pleaseLogin": "Bitte melden Sie sich zuerst an"
|
||||||
},
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Decks",
|
||||||
|
"noDecks": "Noch keine Decks",
|
||||||
|
"deckName": "Deckname",
|
||||||
|
"totalCards": "Gesamtkarten",
|
||||||
|
"createdAt": "Erstellt am",
|
||||||
|
"actions": "Aktionen",
|
||||||
|
"view": "Anzeigen",
|
||||||
|
"subtitle": "Lern-Decks verwalten",
|
||||||
|
"newDeck": "Neues Deck",
|
||||||
|
"noDecksYet": "Noch keine Decks",
|
||||||
|
"loading": "Laden...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards} Karten",
|
||||||
|
"enterDeckName": "Deck-Name eingeben:",
|
||||||
|
"enterNewName": "Neuen Namen eingeben:",
|
||||||
|
"confirmDelete": "\"{name}\" eingeben zum Löschen:",
|
||||||
|
"public": "Öffentlich",
|
||||||
|
"private": "Privat",
|
||||||
|
"setPublic": "Öffentlich machen",
|
||||||
|
"setPrivate": "Privat machen",
|
||||||
|
"importApkg": "APKG importieren",
|
||||||
|
"exportApkg": "APKG exportieren",
|
||||||
|
"clickToUpload": "Klicken zum Hochladen",
|
||||||
|
"apkgFilesOnly": "Nur .apkg Dateien",
|
||||||
|
"parsing": "Analysieren...",
|
||||||
|
"foundDecks": "{count} Decks gefunden",
|
||||||
|
"back": "Zurück",
|
||||||
|
"import": "Importieren",
|
||||||
|
"importing": "Importieren...",
|
||||||
|
"exportSuccess": "Export erfolgreich",
|
||||||
|
"goToDecks": "Zu Decks"
|
||||||
|
},
|
||||||
"folder_id": {
|
"folder_id": {
|
||||||
"unauthorized": "Sie sind nicht der Besitzer dieses Ordners",
|
"unauthorized": "Sie sind nicht der Besitzer dieses Ordners",
|
||||||
"back": "Zurück",
|
"back": "Zurück",
|
||||||
@@ -157,6 +189,9 @@
|
|||||||
"resetPasswordFailed": "Reset-E-Mail konnte nicht gesendet werden",
|
"resetPasswordFailed": "Reset-E-Mail konnte nicht gesendet werden",
|
||||||
"resetPasswordEmailSent": "Reset-E-Mail erfolgreich gesendet",
|
"resetPasswordEmailSent": "Reset-E-Mail erfolgreich gesendet",
|
||||||
"resetPasswordEmailSentHint": "Wir haben einen Link zum Zurücksetzen Ihres Passworts an Ihre E-Mail-Adresse gesendet. Bitte überprüfen Sie Ihren Posteingang.",
|
"resetPasswordEmailSentHint": "Wir haben einen Link zum Zurücksetzen Ihres Passworts an Ihre E-Mail-Adresse gesendet. Bitte überprüfen Sie Ihren Posteingang.",
|
||||||
|
"verifyYourEmail": "E-Mail bestätigen",
|
||||||
|
"verificationEmailSent": "Bestätigungs-E-Mail gesendet",
|
||||||
|
"verificationEmailSentHint": "Wir haben eine Bestätigungs-E-Mail an {email} gesendet. Bitte klicken Sie auf den Link in der E-Mail, um Ihr Konto zu bestätigen.",
|
||||||
"checkYourEmail": "Überprüfen Sie Ihre E-Mail",
|
"checkYourEmail": "Überprüfen Sie Ihre E-Mail",
|
||||||
"backToLogin": "Zurück zur Anmeldung",
|
"backToLogin": "Zurück zur Anmeldung",
|
||||||
"resetPassword": "Passwort zurücksetzen",
|
"resetPassword": "Passwort zurücksetzen",
|
||||||
@@ -166,25 +201,47 @@
|
|||||||
"requestNewToken": "Neuen Reset-Link anfordern",
|
"requestNewToken": "Neuen Reset-Link anfordern",
|
||||||
"resetPasswordSuccess": "Passwort erfolgreich zurückgesetzt",
|
"resetPasswordSuccess": "Passwort erfolgreich zurückgesetzt",
|
||||||
"resetPasswordSuccessTitle": "Passwort-Zurücksetzung abgeschlossen",
|
"resetPasswordSuccessTitle": "Passwort-Zurücksetzung abgeschlossen",
|
||||||
"resetPasswordSuccessHint": "Ihr Passwort wurde erfolgreich zurückgesetzt. Sie können sich jetzt mit Ihrem neuen Passwort anmelden."
|
"resetPasswordSuccessHint": "Ihr Passwort wurde erfolgreich zurückgesetzt. Sie können sich jetzt mit Ihrem neuen Passwort anmelden.",
|
||||||
|
"emailNotVerified": "Bitte verifizieren Sie Ihre E-Mail-Adresse",
|
||||||
|
"emailNotVerifiedHint": "Ihre E-Mail-Adresse wurde nicht verifiziert. Bitte überprüfen Sie Ihren Posteingang oder fordern Sie eine neue Verifizierungs-E-Mail an.",
|
||||||
|
"resendVerification": "Verifizierungs-E-Mail erneut senden",
|
||||||
|
"resendSuccess": "Verifizierungs-E-Mail gesendet! Bitte überprüfen Sie Ihren Posteingang.",
|
||||||
|
"resendFailed": "Verifizierungs-E-Mail konnte nicht gesendet werden"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "Wählen Sie einen Ordner",
|
"selectDeck": "Deck wählen",
|
||||||
"noFolders": "Keine Ordner gefunden",
|
"noDecks": "Keine Decks",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "Zu Decks",
|
||||||
|
"noCards": "Keine Karten",
|
||||||
|
"new": "Neu",
|
||||||
|
"learning": "Lernen",
|
||||||
|
"review": "Wiederholen",
|
||||||
|
"due": "Fällig"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "Antwort",
|
"loading": "Laden...",
|
||||||
"next": "Weiter",
|
"backToDecks": "Zurück zu Decks",
|
||||||
"reverse": "Umkehren",
|
"allDone": "Alles erledigt!",
|
||||||
"dictation": "Diktat",
|
"allDoneDesc": "Lernen für heute abgeschlossen!",
|
||||||
"noTextPairs": "Keine Textpaare verfügbar",
|
"reviewedCount": "{count} Karten wiederholt",
|
||||||
"disorder": "Mischen",
|
"progress": "{current} / {total}",
|
||||||
"previous": "Zurück"
|
"nextReview": "Nächste Wiederholung",
|
||||||
|
"interval": "Intervall",
|
||||||
|
"ease": "Schwierigkeit",
|
||||||
|
"lapses": "Fehler",
|
||||||
|
"showAnswer": "Antwort zeigen",
|
||||||
|
"nextCard": "Weiter",
|
||||||
|
"again": "Nochmal",
|
||||||
|
"restart": "Neustart",
|
||||||
|
"orderLimited": "Reihenfolge begrenzt",
|
||||||
|
"orderInfinite": "Reihenfolge unbegrenzt",
|
||||||
|
"randomLimited": "Zufällig begrenzt",
|
||||||
|
"randomInfinite": "Zufällig unbegrenzt",
|
||||||
|
"noIpa": "Kein IPA verfügbar"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "Sie sind nicht berechtigt, auf diesen Ordner zuzugreifen"
|
"unauthorized": "Nicht autorisiert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
@@ -192,15 +249,66 @@
|
|||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "Anmelden",
|
"sign_in": "Anmelden",
|
||||||
"profile": "Profil",
|
"profile": "Profil",
|
||||||
"folders": "Ordner",
|
"folders": "Decks",
|
||||||
"explore": "Entdecken",
|
"explore": "Erkunden",
|
||||||
"favorites": "Favoriten"
|
"favorites": "Favoriten",
|
||||||
|
"settings": "Einstellungen"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR-Erkennung",
|
||||||
|
"description": "Text aus Bildern extrahieren",
|
||||||
|
"uploadImage": "Bild hochladen",
|
||||||
|
"dragDropHint": "Ziehen und ablegen",
|
||||||
|
"supportedFormats": "Unterstützt: JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "Deck wählen",
|
||||||
|
"chooseDeck": "Deck wählen",
|
||||||
|
"noDecks": "Keine Decks verfügbar",
|
||||||
|
"languageHints": "Sprachhinweise",
|
||||||
|
"sourceLanguageHint": "Quellsprache",
|
||||||
|
"targetLanguageHint": "Zielsprache",
|
||||||
|
"process": "Verarbeiten",
|
||||||
|
"processing": "Verarbeiten...",
|
||||||
|
"preview": "Vorschau",
|
||||||
|
"extractedPairs": "Extrahierte Paare",
|
||||||
|
"word": "Wort",
|
||||||
|
"definition": "Definition",
|
||||||
|
"pairsCount": "{count} Paare",
|
||||||
|
"savePairs": "Speichern",
|
||||||
|
"saving": "Speichern...",
|
||||||
|
"saved": "Gespeichert",
|
||||||
|
"saveFailed": "Speichern fehlgeschlagen",
|
||||||
|
"noImage": "Bitte Bild hochladen",
|
||||||
|
"noDeck": "Bitte Deck wählen",
|
||||||
|
"processingFailed": "Verarbeitung fehlgeschlagen",
|
||||||
|
"tryAgain": "Erneut versuchen",
|
||||||
|
"detectedLanguages": "Erkannte Sprachen",
|
||||||
|
"invalidFileType": "Ungültiger Dateityp",
|
||||||
|
"ocrFailed": "OCR fehlgeschlagen",
|
||||||
|
"uploadSection": "Bild hochladen",
|
||||||
|
"dropOrClick": "Ablegen oder klicken",
|
||||||
|
"changeImage": "Bild ändern",
|
||||||
|
"deckSelection": "Deck wählen",
|
||||||
|
"sourceLanguagePlaceholder": "z.B. Englisch",
|
||||||
|
"targetLanguagePlaceholder": "z.B. Deutsch",
|
||||||
|
"processButton": "Erkennung starten",
|
||||||
|
"resultsPreview": "Ergebnisvorschau",
|
||||||
|
"saveButton": "In Deck speichern",
|
||||||
|
"ocrSuccess": "OCR erfolgreich",
|
||||||
|
"savedToDeck": "In Deck gespeichert",
|
||||||
|
"noResultsToSave": "Keine Ergebnisse",
|
||||||
|
"detectedSourceLanguage": "Erkannte Quellsprache",
|
||||||
|
"detectedTargetLanguage": "Erkannte Zielsprache"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "Mein Profil",
|
"myProfile": "Mein Profil",
|
||||||
"email": "E-Mail: {email}",
|
"email": "E-Mail: {email}",
|
||||||
"logout": "Abmelden"
|
"logout": "Abmelden"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "Einstellungen",
|
||||||
|
"themeColor": "Designfarbe",
|
||||||
|
"themeColorDescription": "Wählen Sie Ihre bevorzugte Designfarbe"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "Video hochladen",
|
"uploadVideo": "Video hochladen",
|
||||||
"uploadSubtitle": "Untertitel hochladen",
|
"uploadSubtitle": "Untertitel hochladen",
|
||||||
@@ -230,15 +338,48 @@
|
|||||||
"videoUploadFailed": "Video-Upload fehlgeschlagen",
|
"videoUploadFailed": "Video-Upload fehlgeschlagen",
|
||||||
"subtitleUploadFailed": "Untertitel-Upload fehlgeschlagen",
|
"subtitleUploadFailed": "Untertitel-Upload fehlgeschlagen",
|
||||||
"subtitleLoadSuccess": "Untertitel erfolgreich geladen",
|
"subtitleLoadSuccess": "Untertitel erfolgreich geladen",
|
||||||
"subtitleLoadFailed": "Laden der Untertitel fehlgeschlagen"
|
"subtitleLoadFailed": "Laden der Untertitel fehlgeschlagen",
|
||||||
|
"settings": "Einstellungen",
|
||||||
|
"shortcuts": "Tastenkürzel",
|
||||||
|
"keyboardShortcuts": "Tastaturkürzel",
|
||||||
|
"playPause": "Wiedergabe/Pause",
|
||||||
|
"autoPauseToggle": "Auto-Pause",
|
||||||
|
"subtitleSettings": "Untertiteleinstellungen",
|
||||||
|
"fontSize": "Schriftgröße",
|
||||||
|
"textColor": "Textfarbe",
|
||||||
|
"backgroundColor": "Hintergrundfarbe",
|
||||||
|
"position": "Position",
|
||||||
|
"opacity": "Deckkraft",
|
||||||
|
"top": "Oben",
|
||||||
|
"center": "Mitte",
|
||||||
|
"bottom": "Unten"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "IPA generieren",
|
"generateIPA": "IPA generieren",
|
||||||
"viewSavedItems": "Gespeicherte Einträge anzeigen",
|
"viewSavedItems": "Gespeicherte Einträge anzeigen",
|
||||||
"confirmDeleteAll": "Sind Sie sicher, dass Sie alles löschen möchten? (J/N)"
|
"confirmDeleteAll": "Sind Sie sicher, dass Sie alles löschen möchten? (J/N)",
|
||||||
|
"saved": "Gespeichert",
|
||||||
|
"clearAll": "Alles löschen",
|
||||||
|
"language": "Sprache",
|
||||||
|
"customLanguage": "oder Sprache eingeben...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "Automatisch",
|
||||||
|
"chinese": "Chinesisch",
|
||||||
|
"english": "Englisch",
|
||||||
|
"japanese": "Japanisch",
|
||||||
|
"korean": "Koreanisch",
|
||||||
|
"french": "Französisch",
|
||||||
|
"german": "Deutsch",
|
||||||
|
"italian": "Italienisch",
|
||||||
|
"spanish": "Spanisch",
|
||||||
|
"portuguese": "Portugiesisch",
|
||||||
|
"russian": "Russisch"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "Sprache erkennen",
|
"detectLanguage": "Sprache erkennen",
|
||||||
|
"sourceLanguage": "Quellsprache",
|
||||||
|
"auto": "Automatisch",
|
||||||
"generateIPA": "IPA generieren",
|
"generateIPA": "IPA generieren",
|
||||||
"translateInto": "übersetzen in",
|
"translateInto": "übersetzen in",
|
||||||
"chinese": "Chinesisch",
|
"chinese": "Chinesisch",
|
||||||
@@ -266,7 +407,20 @@
|
|||||||
"success": "Textpaar zum Ordner hinzugefügt",
|
"success": "Textpaar zum Ordner hinzugefügt",
|
||||||
"error": "Fehler beim Hinzufügen des Textpaars zum Ordner"
|
"error": "Fehler beim Hinzufügen des Textpaars zum Ordner"
|
||||||
},
|
},
|
||||||
"autoSave": "Autom. Speichern"
|
"autoSave": "Autom. Speichern",
|
||||||
|
"customLanguage": "oder Sprache eingeben...",
|
||||||
|
"pleaseLogin": "Bitte anmelden um Karten zu speichern",
|
||||||
|
"pleaseCreateDeck": "Bitte erst zuerst ein Deck",
|
||||||
|
"noTranslationToSave": "Keine Übersetzung zum Speichern",
|
||||||
|
"noDeckSelected": "Kein Deck ausgewählt",
|
||||||
|
"saveAsCard": "Als Karte speichern",
|
||||||
|
"selectDeck": "Deck wählen",
|
||||||
|
"front": "Vorderseite",
|
||||||
|
"back": "Rückseite",
|
||||||
|
"cancel": "Abbrechen",
|
||||||
|
"save": "Speichern",
|
||||||
|
"savedToDeck": "Karte in {deckName} gespeichert",
|
||||||
|
"saveFailed": "Karte speichern fehlgeschlagen"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "Wörterbuch",
|
"title": "Wörterbuch",
|
||||||
@@ -311,7 +465,9 @@
|
|||||||
"unfavorite": "Aus Favoriten entfernen",
|
"unfavorite": "Aus Favoriten entfernen",
|
||||||
"pleaseLogin": "Bitte melden Sie sich zuerst an",
|
"pleaseLogin": "Bitte melden Sie sich zuerst an",
|
||||||
"sortByFavorites": "Nach Favoriten sortieren",
|
"sortByFavorites": "Nach Favoriten sortieren",
|
||||||
"sortByFavoritesActive": "Sortierung nach Favoriten aufheben"
|
"sortByFavoritesActive": "Sortierung nach Favoriten aufheben",
|
||||||
|
"noDecks": "Keine öffentlichen Decks",
|
||||||
|
"deckInfo": "{userName} · {totalCards} Karten"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "Ordnerdetails",
|
"title": "Ordnerdetails",
|
||||||
@@ -325,7 +481,8 @@
|
|||||||
"unfavorite": "Aus Favoriten entfernen",
|
"unfavorite": "Aus Favoriten entfernen",
|
||||||
"favorited": "Favorisiert",
|
"favorited": "Favorisiert",
|
||||||
"unfavorited": "Aus Favoriten entfernt",
|
"unfavorited": "Aus Favoriten entfernt",
|
||||||
"pleaseLogin": "Bitte melden Sie sich zuerst an"
|
"pleaseLogin": "Bitte melden Sie sich zuerst an",
|
||||||
|
"totalCards": "{count} Karten"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "Meine Favoriten",
|
"title": "Meine Favoriten",
|
||||||
@@ -347,14 +504,119 @@
|
|||||||
"notSet": "Nicht festgelegt",
|
"notSet": "Nicht festgelegt",
|
||||||
"memberSince": "Mitglied seit",
|
"memberSince": "Mitglied seit",
|
||||||
"logout": "Abmelden",
|
"logout": "Abmelden",
|
||||||
|
"deleteAccount": {
|
||||||
|
"button": "Konto löschen",
|
||||||
|
"title": "Konto löschen",
|
||||||
|
"warning": "Diese Aktion ist unwiderruflich. Alle Ihre Daten werden dauerhaft gelöscht.",
|
||||||
|
"warningDecks": "Alle Ihre Decks und Karten",
|
||||||
|
"warningCards": "All Ihr Lernfortschritt",
|
||||||
|
"warningHistory": "All Ihr Übersetzungs- und Wörterbuchverlauf",
|
||||||
|
"warningPermanent": "Diese Aktion kann nicht rückgängig gemacht werden",
|
||||||
|
"confirmLabel": "Geben Sie Ihren Benutzernamen zur Bestätigung ein:",
|
||||||
|
"usernameMismatch": "Benutzername stimmt nicht überein",
|
||||||
|
"cancel": "Abbrechen",
|
||||||
|
"confirm": "Mein Konto löschen",
|
||||||
|
"success": "Konto erfolgreich gelöscht",
|
||||||
|
"failed": "Konto konnte nicht gelöscht werden"
|
||||||
|
},
|
||||||
"folders": {
|
"folders": {
|
||||||
"title": "Ordner",
|
"title": "Decks",
|
||||||
"noFolders": "Noch keine Ordner",
|
"noFolders": "Noch keine Decks",
|
||||||
"folderName": "Ordnername",
|
"folderName": "Deckname",
|
||||||
"totalPairs": "Gesamtpaare",
|
"totalPairs": "Gesamtkarten",
|
||||||
"createdAt": "Erstellt am",
|
"createdAt": "Erstellt am",
|
||||||
"actions": "Aktionen",
|
"actions": "Aktionen",
|
||||||
"view": "Anzeigen"
|
"view": "Anzeigen"
|
||||||
}
|
},
|
||||||
|
"joined": "Beigetreten",
|
||||||
|
"decks": {
|
||||||
|
"title": "Meine Decks",
|
||||||
|
"noDecks": "Keine Decks",
|
||||||
|
"deckName": "Deck-Name",
|
||||||
|
"totalCards": "Gesamtkarten",
|
||||||
|
"createdAt": "Erstellt am",
|
||||||
|
"actions": "Aktionen",
|
||||||
|
"view": "Ansehen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "Folgen",
|
||||||
|
"following": "Folge ich",
|
||||||
|
"followers": "Follower",
|
||||||
|
"followersOf": "{username}s Follower",
|
||||||
|
"followingOf": "{username} folgt",
|
||||||
|
"noFollowers": "Noch keine Follower",
|
||||||
|
"noFollowing": "Folgt noch niemandem"
|
||||||
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "Sie sind nicht der Besitzer dieses Decks",
|
||||||
|
"back": "Zurück",
|
||||||
|
"cards": "Karten",
|
||||||
|
"itemsCount": "{count} Elemente",
|
||||||
|
"memorize": "Auswendig lernen",
|
||||||
|
"loadingCards": "Karten werden geladen...",
|
||||||
|
"noCards": "Keine Karten in diesem Deck",
|
||||||
|
"card": "Karte",
|
||||||
|
"addNewCard": "Neue Karte hinzufügen",
|
||||||
|
"add": "Hinzufügen",
|
||||||
|
"adding": "Wird hinzugefügt...",
|
||||||
|
"updateCard": "Karte aktualisieren",
|
||||||
|
"update": "Aktualisieren",
|
||||||
|
"updating": "Wird aktualisiert...",
|
||||||
|
"word": "Wort",
|
||||||
|
"definition": "Definition",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"example": "Beispiel",
|
||||||
|
"wordAndDefinitionRequired": "Wort und Definition sind erforderlich",
|
||||||
|
"edit": "Bearbeiten",
|
||||||
|
"delete": "Löschen",
|
||||||
|
"permissionDenied": "Sie haben keine Berechtigung für diese Aktion",
|
||||||
|
"resetProgress": "Fortschritt zurücksetzen",
|
||||||
|
"resetProgressTitle": "Lernfortschritt zurücksetzen",
|
||||||
|
"resetProgressConfirm": "Fortschritt wirklich zurücksetzen?",
|
||||||
|
"resetSuccess": "Fortschritt zurückgesetzt",
|
||||||
|
"resetting": "Zurücksetzen...",
|
||||||
|
"cancel": "Abbrechen",
|
||||||
|
"settings": "Einstellungen",
|
||||||
|
"settingsTitle": "Deck-Einstellungen",
|
||||||
|
"newPerDay": "Neue pro Tag",
|
||||||
|
"newPerDayHint": "Neue Karten pro Tag",
|
||||||
|
"revPerDay": "Wiederholungen pro Tag",
|
||||||
|
"revPerDayHint": "Wiederholungen pro Tag",
|
||||||
|
"save": "Speichern",
|
||||||
|
"saving": "Speichern...",
|
||||||
|
"settingsSaved": "Einstellungen gespeichert",
|
||||||
|
"todayNew": "Heute neu",
|
||||||
|
"todayReview": "Heute wiederholen",
|
||||||
|
"todayLearning": "Lernen",
|
||||||
|
"error": {
|
||||||
|
"update": "Keine Berechtigung zum Aktualisieren",
|
||||||
|
"delete": "Keine Berechtigung zum Löschen",
|
||||||
|
"add": "Keine Berechtigung zum Hinzufügen"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "IPA eingeben",
|
||||||
|
"examplePlaceholder": "Beispiel eingeben",
|
||||||
|
"wordRequired": "Bitte Wort eingeben",
|
||||||
|
"definitionRequired": "Bitte Definition eingeben",
|
||||||
|
"cardAdded": "Karte hinzugefügt",
|
||||||
|
"cardType": "Kartentyp",
|
||||||
|
"wordCard": "Wortkarte",
|
||||||
|
"phraseCard": "Phrasenkarte",
|
||||||
|
"sentenceCard": "Satzkarte",
|
||||||
|
"sentence": "Satz",
|
||||||
|
"sentencePlaceholder": "Satz eingeben",
|
||||||
|
"wordPlaceholder": "Wort eingeben",
|
||||||
|
"queryLang": "Abfragesprache",
|
||||||
|
"enterLanguageName": "Bitte Sprachnamen eingeben",
|
||||||
|
"english": "Englisch",
|
||||||
|
"chinese": "Chinesisch",
|
||||||
|
"japanese": "Japanisch",
|
||||||
|
"korean": "Koreanisch",
|
||||||
|
"meanings": "Bedeutungen",
|
||||||
|
"addMeaning": "Bedeutung hinzufügen",
|
||||||
|
"partOfSpeech": "Wortart",
|
||||||
|
"deleteConfirm": "Karte wirklich löschen?",
|
||||||
|
"cardDeleted": "Karte gelöscht",
|
||||||
|
"cardUpdated": "Karte aktualisiert"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,77 @@
|
|||||||
"deleteFolder": "You do not have permission to delete this folder."
|
"deleteFolder": "You do not have permission to delete this folder."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "You are not the owner of this deck",
|
||||||
|
"back": "Back",
|
||||||
|
"cards": "Cards",
|
||||||
|
"itemsCount": "{count} items",
|
||||||
|
"memorize": "Memorize",
|
||||||
|
"loadingCards": "Loading cards...",
|
||||||
|
"noCards": "No cards in this deck",
|
||||||
|
"card": "Card",
|
||||||
|
"addNewCard": "Add New Card",
|
||||||
|
"add": "Add",
|
||||||
|
"adding": "Adding...",
|
||||||
|
"updateCard": "Update Card",
|
||||||
|
"update": "Update",
|
||||||
|
"updating": "Updating...",
|
||||||
|
"word": "Word",
|
||||||
|
"definition": "Definition",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"ipaPlaceholder": "Enter IPA pronunciation",
|
||||||
|
"example": "Example",
|
||||||
|
"examplePlaceholder": "Enter an example sentence",
|
||||||
|
"wordAndDefinitionRequired": "Word and definition are required",
|
||||||
|
"wordRequired": "Word is required",
|
||||||
|
"definitionRequired": "At least one definition is required",
|
||||||
|
"cardAdded": "Card added successfully",
|
||||||
|
"cardType": "Card Type",
|
||||||
|
"wordCard": "Word",
|
||||||
|
"phraseCard": "Phrase",
|
||||||
|
"sentenceCard": "Sentence",
|
||||||
|
"sentence": "Sentence",
|
||||||
|
"sentencePlaceholder": "Enter a sentence",
|
||||||
|
"wordPlaceholder": "Enter a word",
|
||||||
|
"queryLang": "Language",
|
||||||
|
"enterLanguageName": "Please enter language name",
|
||||||
|
"english": "English",
|
||||||
|
"chinese": "Chinese",
|
||||||
|
"japanese": "Japanese",
|
||||||
|
"korean": "Korean",
|
||||||
|
"meanings": "Meanings",
|
||||||
|
"addMeaning": "Add Meaning",
|
||||||
|
"partOfSpeech": "Part of Speech",
|
||||||
|
"edit": "Edit",
|
||||||
|
"delete": "Delete",
|
||||||
|
"deleteConfirm": "Are you sure you want to delete this card?",
|
||||||
|
"cardDeleted": "Card deleted",
|
||||||
|
"permissionDenied": "You do not have permission to perform this action",
|
||||||
|
"resetProgress": "Reset",
|
||||||
|
"resetProgressTitle": "Reset Deck Progress",
|
||||||
|
"resetProgressConfirm": "This will reset all cards in this deck to new state. Your learning progress will be lost. Are you sure?",
|
||||||
|
"resetSuccess": "Successfully reset {count} cards",
|
||||||
|
"resetting": "Resetting...",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"settings": "Settings",
|
||||||
|
"settingsTitle": "Deck Settings",
|
||||||
|
"newPerDay": "New Cards Per Day",
|
||||||
|
"newPerDayHint": "Maximum new cards to learn each day",
|
||||||
|
"revPerDay": "Review Cards Per Day",
|
||||||
|
"revPerDayHint": "Maximum review cards each day",
|
||||||
|
"save": "Save",
|
||||||
|
"saving": "Saving...",
|
||||||
|
"settingsSaved": "Settings saved",
|
||||||
|
"todayNew": "New",
|
||||||
|
"todayReview": "Review",
|
||||||
|
"todayLearning": "Learning",
|
||||||
|
"cardUpdated": "Card updated",
|
||||||
|
"error": {
|
||||||
|
"update": "You do not have permission to update this card.",
|
||||||
|
"delete": "You do not have permission to delete this card.",
|
||||||
|
"add": "You do not have permission to add cards to this deck."
|
||||||
|
}
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "Learn Languages",
|
"title": "Learn Languages",
|
||||||
"description": "Here is a very useful website to help you learn almost every language in the world, including constructed ones.",
|
"description": "Here is a very useful website to help you learn almost every language in the world, including constructed ones.",
|
||||||
@@ -157,6 +228,9 @@
|
|||||||
"resetPasswordFailed": "Failed to send reset email",
|
"resetPasswordFailed": "Failed to send reset email",
|
||||||
"resetPasswordEmailSent": "Reset email sent successfully",
|
"resetPasswordEmailSent": "Reset email sent successfully",
|
||||||
"resetPasswordEmailSentHint": "We've sent a password reset link to your email address. Please check your inbox.",
|
"resetPasswordEmailSentHint": "We've sent a password reset link to your email address. Please check your inbox.",
|
||||||
|
"verifyYourEmail": "Verify Your Email",
|
||||||
|
"verificationEmailSent": "Verification email sent",
|
||||||
|
"verificationEmailSentHint": "We've sent a verification email to {email}. Please click the link in the email to verify your account.",
|
||||||
"checkYourEmail": "Check Your Email",
|
"checkYourEmail": "Check Your Email",
|
||||||
"backToLogin": "Back to Login",
|
"backToLogin": "Back to Login",
|
||||||
"resetPassword": "Reset Password",
|
"resetPassword": "Reset Password",
|
||||||
@@ -166,25 +240,72 @@
|
|||||||
"requestNewToken": "Request New Reset Link",
|
"requestNewToken": "Request New Reset Link",
|
||||||
"resetPasswordSuccess": "Password reset successfully",
|
"resetPasswordSuccess": "Password reset successfully",
|
||||||
"resetPasswordSuccessTitle": "Password Reset Complete",
|
"resetPasswordSuccessTitle": "Password Reset Complete",
|
||||||
"resetPasswordSuccessHint": "Your password has been reset successfully. You can now log in with your new password."
|
"resetPasswordSuccessHint": "Your password has been reset successfully. You can now log in with your new password.",
|
||||||
|
"emailNotVerified": "Please verify your email address",
|
||||||
|
"emailNotVerifiedHint": "Your email has not been verified. Please check your inbox or request a new verification email.",
|
||||||
|
"resendVerification": "Resend Verification Email",
|
||||||
|
"resendSuccess": "Verification email sent! Please check your inbox.",
|
||||||
|
"resendFailed": "Failed to send verification email"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "Select a folder",
|
"selectDeck": "Select a deck",
|
||||||
"noFolders": "No folders found",
|
"noDecks": "No decks found",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "Go to Decks",
|
||||||
|
"noCards": "No cards",
|
||||||
|
"new": "New",
|
||||||
|
"learning": "Learning",
|
||||||
|
"review": "Review",
|
||||||
|
"due": "Due"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "Answer",
|
"loading": "Loading cards...",
|
||||||
"next": "Next",
|
"backToDecks": "Back to Decks",
|
||||||
|
"allDone": "All Done!",
|
||||||
|
"allDoneDesc": "You've reviewed all due cards.",
|
||||||
|
"reviewedCount": "Reviewed {count} cards",
|
||||||
|
"progress": "{current} / {total}",
|
||||||
|
"nextReview": "Next review",
|
||||||
|
"interval": "Interval",
|
||||||
|
"ease": "Ease",
|
||||||
|
"lapses": "Lapses",
|
||||||
|
"showAnswer": "Show Answer",
|
||||||
|
"nextCard": "Next",
|
||||||
|
"again": "Again",
|
||||||
|
"hard": "Hard",
|
||||||
|
"good": "Good",
|
||||||
|
"easy": "Easy",
|
||||||
|
"now": "now",
|
||||||
|
"lessThanMinute": "<1 min",
|
||||||
|
"inMinutes": "{count} min",
|
||||||
|
"inHours": "{count}h",
|
||||||
|
"inDays": "{count}d",
|
||||||
|
"inMonths": "{count}mo",
|
||||||
|
"minutes": "<1 min",
|
||||||
|
"days": "{count}d",
|
||||||
|
"months": "{count}mo",
|
||||||
|
"minAbbr": "m",
|
||||||
|
"dayAbbr": "d",
|
||||||
|
"cardTypeNew": "New",
|
||||||
|
"cardTypeLearning": "Learning",
|
||||||
|
"cardTypeReview": "Review",
|
||||||
|
"cardTypeRelearning": "Relearning",
|
||||||
"reverse": "Reverse",
|
"reverse": "Reverse",
|
||||||
"dictation": "Dictation",
|
"dictation": "Dictation",
|
||||||
"noTextPairs": "No text pairs available",
|
"clickToPlay": "Click to play audio",
|
||||||
"disorder": "Disorder",
|
"restart": "Restart",
|
||||||
"previous": "Previous"
|
"yourAnswer": "Your answer",
|
||||||
|
"typeWhatYouHear": "Type what you hear...",
|
||||||
|
"correct": "Correct",
|
||||||
|
"incorrect": "Incorrect",
|
||||||
|
"orderLimited": "Order",
|
||||||
|
"orderInfinite": "Loop",
|
||||||
|
"randomLimited": "Random",
|
||||||
|
"randomInfinite": "Random Loop",
|
||||||
|
"noIpa": "No IPA available"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "You are not authorized to access this folder"
|
"unauthorized": "You are not authorized to access this deck"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
@@ -192,15 +313,66 @@
|
|||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "Sign In",
|
"sign_in": "Sign In",
|
||||||
"profile": "Profile",
|
"profile": "Profile",
|
||||||
"folders": "Folders",
|
"folders": "Decks",
|
||||||
"explore": "Explore",
|
"explore": "Explore",
|
||||||
"favorites": "Favorites"
|
"favorites": "Favorites",
|
||||||
|
"settings": "Settings"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR Vocabulary Extractor",
|
||||||
|
"description": "Upload vocabulary table screenshots from textbooks to extract word-definition pairs",
|
||||||
|
"uploadSection": "Upload Image",
|
||||||
|
"uploadImage": "Upload Image",
|
||||||
|
"dragDropHint": "Drag and drop an image here, or click to select",
|
||||||
|
"dropOrClick": "Drag and drop an image here, or click to select",
|
||||||
|
"changeImage": "Click to change image",
|
||||||
|
"supportedFormats": "Supports: JPG, PNG, WebP",
|
||||||
|
"invalidFileType": "Invalid file type. Please upload an image file (JPG, PNG, or WebP).",
|
||||||
|
"deckSelection": "Select Deck",
|
||||||
|
"selectDeck": "Select a deck",
|
||||||
|
"chooseDeck": "Choose a deck to save extracted pairs",
|
||||||
|
"noDecks": "No decks available. Please create a deck first.",
|
||||||
|
"languageHints": "Language Hints (Optional)",
|
||||||
|
"sourceLanguageHint": "Source language (e.g., English)",
|
||||||
|
"targetLanguageHint": "Target/Translation language (e.g., Chinese)",
|
||||||
|
"sourceLanguagePlaceholder": "Source language (e.g., English)",
|
||||||
|
"targetLanguagePlaceholder": "Target/Translation language (e.g., Chinese)",
|
||||||
|
"process": "Process Image",
|
||||||
|
"processButton": "Process Image",
|
||||||
|
"processing": "Processing...",
|
||||||
|
"preview": "Preview",
|
||||||
|
"resultsPreview": "Results Preview",
|
||||||
|
"extractedPairs": "Extracted {count} pairs",
|
||||||
|
"word": "Word",
|
||||||
|
"definition": "Definition",
|
||||||
|
"pairsCount": "{count} pairs extracted",
|
||||||
|
"savePairs": "Save to Deck",
|
||||||
|
"saveButton": "Save",
|
||||||
|
"saving": "Saving...",
|
||||||
|
"saved": "Successfully saved {count} pairs to {deck}",
|
||||||
|
"ocrSuccess": "Successfully extracted {count} pairs to {deck}",
|
||||||
|
"ocrFailed": "OCR processing failed. Please try again.",
|
||||||
|
"savedToDeck": "Saved to {deckName}",
|
||||||
|
"saveFailed": "Failed to save pairs",
|
||||||
|
"noImage": "Please upload an image first",
|
||||||
|
"noDeck": "Please select a deck",
|
||||||
|
"noResultsToSave": "No results to save",
|
||||||
|
"processingFailed": "OCR processing failed",
|
||||||
|
"tryAgain": "Please try again with a clearer image",
|
||||||
|
"detectedLanguages": "Detected: {source} → {target}",
|
||||||
|
"detectedSourceLanguage": "Detected source language",
|
||||||
|
"detectedTargetLanguage": "Detected target language"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "My Profile",
|
"myProfile": "My Profile",
|
||||||
"email": "Email: {email}",
|
"email": "Email: {email}",
|
||||||
"logout": "Logout"
|
"logout": "Logout"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "Settings",
|
||||||
|
"themeColor": "Theme Color",
|
||||||
|
"themeColorDescription": "Choose your preferred theme color"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "Upload Video",
|
"uploadVideo": "Upload Video",
|
||||||
"uploadSubtitle": "Upload Subtitle",
|
"uploadSubtitle": "Upload Subtitle",
|
||||||
@@ -230,17 +402,51 @@
|
|||||||
"videoUploadFailed": "Video upload failed",
|
"videoUploadFailed": "Video upload failed",
|
||||||
"subtitleUploadFailed": "Subtitle upload failed",
|
"subtitleUploadFailed": "Subtitle upload failed",
|
||||||
"subtitleLoadSuccess": "Subtitle loaded successfully",
|
"subtitleLoadSuccess": "Subtitle loaded successfully",
|
||||||
"subtitleLoadFailed": "Subtitle load failed"
|
"subtitleLoadFailed": "Subtitle load failed",
|
||||||
|
"settings": "Settings",
|
||||||
|
"shortcuts": "Shortcuts",
|
||||||
|
"keyboardShortcuts": "Keyboard Shortcuts",
|
||||||
|
"playPause": "Play/Pause",
|
||||||
|
"autoPauseToggle": "Toggle Auto Pause",
|
||||||
|
"subtitleSettings": "Subtitle Settings",
|
||||||
|
"fontSize": "Font Size",
|
||||||
|
"textColor": "Text Color",
|
||||||
|
"backgroundColor": "Background Color",
|
||||||
|
"position": "Position",
|
||||||
|
"opacity": "Opacity",
|
||||||
|
"top": "Top",
|
||||||
|
"center": "Center",
|
||||||
|
"bottom": "Bottom"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "Generate IPA",
|
"generateIPA": "Generate IPA",
|
||||||
"viewSavedItems": "View Saved Items",
|
"viewSavedItems": "View Saved Items",
|
||||||
"confirmDeleteAll": "Are you sure you want to delete everything? (Y/N)"
|
"confirmDeleteAll": "Are you sure you want to delete everything? (Y/N)",
|
||||||
|
"saved": "Saved",
|
||||||
|
"clearAll": "Clear All",
|
||||||
|
"language": "Language",
|
||||||
|
"customLanguage": "or type language...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "Auto",
|
||||||
|
"chinese": "Chinese",
|
||||||
|
"english": "English",
|
||||||
|
"japanese": "Japanese",
|
||||||
|
"korean": "Korean",
|
||||||
|
"french": "French",
|
||||||
|
"german": "German",
|
||||||
|
"italian": "Italian",
|
||||||
|
"spanish": "Spanish",
|
||||||
|
"portuguese": "Portuguese",
|
||||||
|
"russian": "Russian"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "detect language",
|
"detectLanguage": "detect language",
|
||||||
|
"sourceLanguage": "source language",
|
||||||
|
"auto": "Auto",
|
||||||
"generateIPA": "generate ipa",
|
"generateIPA": "generate ipa",
|
||||||
"translateInto": "translate into",
|
"translateInto": "translate into",
|
||||||
|
"customLanguage": "or type language...",
|
||||||
"chinese": "Chinese",
|
"chinese": "Chinese",
|
||||||
"english": "English",
|
"english": "English",
|
||||||
"french": "French",
|
"french": "French",
|
||||||
@@ -266,7 +472,19 @@
|
|||||||
"success": "Text pair added to folder",
|
"success": "Text pair added to folder",
|
||||||
"error": "Failed to add text pair to folder"
|
"error": "Failed to add text pair to folder"
|
||||||
},
|
},
|
||||||
"autoSave": "Auto Save"
|
"autoSave": "Auto Save",
|
||||||
|
"pleaseLogin": "Please login to save cards",
|
||||||
|
"pleaseCreateDeck": "Please create a deck first",
|
||||||
|
"noTranslationToSave": "No translation to save",
|
||||||
|
"noDeckSelected": "No deck selected",
|
||||||
|
"saveAsCard": "Save as Card",
|
||||||
|
"selectDeck": "Select Deck",
|
||||||
|
"front": "Front",
|
||||||
|
"back": "Back",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"save": "Save",
|
||||||
|
"savedToDeck": "Card saved to {deckName}",
|
||||||
|
"saveFailed": "Failed to save card"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "Dictionary",
|
"title": "Dictionary",
|
||||||
@@ -301,11 +519,11 @@
|
|||||||
},
|
},
|
||||||
"explore": {
|
"explore": {
|
||||||
"title": "Explore",
|
"title": "Explore",
|
||||||
"subtitle": "Discover public folders",
|
"subtitle": "Discover public decks",
|
||||||
"searchPlaceholder": "Search public folders...",
|
"searchPlaceholder": "Search public decks...",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
"noFolders": "No public folders found",
|
"noDecks": "No public decks found",
|
||||||
"folderInfo": "{userName} • {totalPairs} pairs",
|
"deckInfo": "{userName} • {cardCount} cards",
|
||||||
"unknownUser": "Unknown User",
|
"unknownUser": "Unknown User",
|
||||||
"favorite": "Favorite",
|
"favorite": "Favorite",
|
||||||
"unfavorite": "Unfavorite",
|
"unfavorite": "Unfavorite",
|
||||||
@@ -314,10 +532,10 @@
|
|||||||
"sortByFavoritesActive": "Undo sort by favorites"
|
"sortByFavoritesActive": "Undo sort by favorites"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "Folder Details",
|
"title": "Deck Details",
|
||||||
"createdBy": "Created by: {name}",
|
"createdBy": "Created by: {name}",
|
||||||
"unknownUser": "Unknown User",
|
"unknownUser": "Unknown User",
|
||||||
"totalPairs": "Total Pairs",
|
"totalCards": "Total Cards",
|
||||||
"favorites": "Favorites",
|
"favorites": "Favorites",
|
||||||
"createdAt": "Created At",
|
"createdAt": "Created At",
|
||||||
"viewContent": "View Content",
|
"viewContent": "View Content",
|
||||||
@@ -346,15 +564,67 @@
|
|||||||
"displayName": "Display Name",
|
"displayName": "Display Name",
|
||||||
"notSet": "Not Set",
|
"notSet": "Not Set",
|
||||||
"memberSince": "Member Since",
|
"memberSince": "Member Since",
|
||||||
|
"joined": "Joined",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "Folders",
|
"button": "Delete Account",
|
||||||
"noFolders": "No folders yet",
|
"title": "Delete Account",
|
||||||
"folderName": "Folder Name",
|
"warning": "This action is irreversible. All your data will be permanently deleted.",
|
||||||
"totalPairs": "Total Pairs",
|
"warningDecks": "All your decks and cards",
|
||||||
|
"warningCards": "All your learning progress",
|
||||||
|
"warningHistory": "All your translation and dictionary history",
|
||||||
|
"warningPermanent": "This action cannot be undone",
|
||||||
|
"confirmLabel": "Type your username to confirm:",
|
||||||
|
"usernameMismatch": "Username does not match",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"confirm": "Delete My Account",
|
||||||
|
"success": "Account deleted successfully",
|
||||||
|
"failed": "Failed to delete account"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Decks",
|
||||||
|
"noDecks": "No decks yet",
|
||||||
|
"deckName": "Deck Name",
|
||||||
|
"totalCards": "Total Cards",
|
||||||
"createdAt": "Created At",
|
"createdAt": "Created At",
|
||||||
"actions": "Actions",
|
"actions": "Actions",
|
||||||
"view": "View"
|
"view": "View"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Decks",
|
||||||
|
"subtitle": "Manage your flashcard decks",
|
||||||
|
"newDeck": "New Deck",
|
||||||
|
"noDecksYet": "No decks yet",
|
||||||
|
"loading": "Loading...",
|
||||||
|
"deckInfo": "ID: {id} • {totalCards} cards",
|
||||||
|
"enterDeckName": "Enter deck name:",
|
||||||
|
"enterNewName": "Enter new name:",
|
||||||
|
"confirmDelete": "Type \"{name}\" to delete:",
|
||||||
|
"public": "Public",
|
||||||
|
"private": "Private",
|
||||||
|
"setPublic": "Set Public",
|
||||||
|
"setPrivate": "Set Private",
|
||||||
|
"importApkg": "Import APKG",
|
||||||
|
"exportApkg": "Export APKG",
|
||||||
|
"clickToUpload": "Click to upload an APKG file",
|
||||||
|
"apkgFilesOnly": "Only .apkg files are supported",
|
||||||
|
"parsing": "Parsing...",
|
||||||
|
"foundDecks": "Found {count} deck(s)",
|
||||||
|
"deckName": "Deck Name",
|
||||||
|
"back": "Back",
|
||||||
|
"import": "Import",
|
||||||
|
"importing": "Importing...",
|
||||||
|
"exportSuccess": "Deck exported successfully",
|
||||||
|
"goToDecks": "Go to Decks"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "Follow",
|
||||||
|
"following": "Following",
|
||||||
|
"followers": "Followers",
|
||||||
|
"followersOf": "{username}'s Followers",
|
||||||
|
"followingOf": "{username}'s Following",
|
||||||
|
"noFollowers": "No followers yet",
|
||||||
|
"noFollowing": "Not following anyone yet"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,38 @@
|
|||||||
"unfavorite": "Retirer des favoris",
|
"unfavorite": "Retirer des favoris",
|
||||||
"pleaseLogin": "Veuillez vous connecter d'abord"
|
"pleaseLogin": "Veuillez vous connecter d'abord"
|
||||||
},
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Decks",
|
||||||
|
"noDecks": "Pas encore de decks",
|
||||||
|
"deckName": "Nom du deck",
|
||||||
|
"totalCards": "Total des cartes",
|
||||||
|
"createdAt": "Créé le",
|
||||||
|
"actions": "Actions",
|
||||||
|
"view": "Voir",
|
||||||
|
"subtitle": "Gérer vos decks d'apprentissage",
|
||||||
|
"newDeck": "Nouveau deck",
|
||||||
|
"noDecksYet": "Pas encore de decks",
|
||||||
|
"loading": "Chargement...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards} cartes",
|
||||||
|
"enterDeckName": "Nom du deck:",
|
||||||
|
"enterNewName": "Nouveau nom:",
|
||||||
|
"confirmDelete": "Tapez \"{name}\" pour supprimer:",
|
||||||
|
"public": "Public",
|
||||||
|
"private": "Privé",
|
||||||
|
"setPublic": "Rendre public",
|
||||||
|
"setPrivate": "Rendre privé",
|
||||||
|
"importApkg": "Importer APKG",
|
||||||
|
"exportApkg": "Exporter APKG",
|
||||||
|
"clickToUpload": "Cliquez pour télécharger",
|
||||||
|
"apkgFilesOnly": "Fichiers .apkg uniquement",
|
||||||
|
"parsing": "Analyse...",
|
||||||
|
"foundDecks": "{count} decks trouvés",
|
||||||
|
"back": "Retour",
|
||||||
|
"import": "Importer",
|
||||||
|
"importing": "Import...",
|
||||||
|
"exportSuccess": "Export réussi",
|
||||||
|
"goToDecks": "Aller aux decks"
|
||||||
|
},
|
||||||
"folder_id": {
|
"folder_id": {
|
||||||
"unauthorized": "Vous n'êtes pas le propriétaire de ce dossier",
|
"unauthorized": "Vous n'êtes pas le propriétaire de ce dossier",
|
||||||
"back": "Retour",
|
"back": "Retour",
|
||||||
@@ -74,6 +106,77 @@
|
|||||||
"deleteFolder": "Vous n'avez pas la permission de supprimer ce dossier."
|
"deleteFolder": "Vous n'avez pas la permission de supprimer ce dossier."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "Vous n'êtes pas le propriétaire de ce deck",
|
||||||
|
"back": "Retour",
|
||||||
|
"cards": "Cartes",
|
||||||
|
"itemsCount": "{count} éléments",
|
||||||
|
"memorize": "Mémoriser",
|
||||||
|
"loadingCards": "Chargement des cartes...",
|
||||||
|
"noCards": "Aucune carte dans ce deck",
|
||||||
|
"card": "Carte",
|
||||||
|
"addNewCard": "Ajouter une nouvelle carte",
|
||||||
|
"add": "Ajouter",
|
||||||
|
"adding": "Ajout en cours...",
|
||||||
|
"updateCard": "Mettre à jour la carte",
|
||||||
|
"update": "Mettre à jour",
|
||||||
|
"updating": "Mise à jour en cours...",
|
||||||
|
"word": "Mot",
|
||||||
|
"definition": "Définition",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"example": "Exemple",
|
||||||
|
"wordAndDefinitionRequired": "Le mot et la définition sont requis",
|
||||||
|
"edit": "Modifier",
|
||||||
|
"delete": "Supprimer",
|
||||||
|
"permissionDenied": "Vous n'avez pas la permission d'effectuer cette action",
|
||||||
|
"resetProgress": "Réinitialiser progression",
|
||||||
|
"resetProgressTitle": "Réinitialiser la progression",
|
||||||
|
"resetProgressConfirm": "Réinitialiser la progression?",
|
||||||
|
"resetSuccess": "Progression réinitialisée",
|
||||||
|
"resetting": "Réinitialisation...",
|
||||||
|
"cancel": "Annuler",
|
||||||
|
"settings": "Paramètres",
|
||||||
|
"settingsTitle": "Paramètres du deck",
|
||||||
|
"newPerDay": "Nouvelles par jour",
|
||||||
|
"newPerDayHint": "Nouvelles cartes par jour",
|
||||||
|
"revPerDay": "Révisions par jour",
|
||||||
|
"revPerDayHint": "Révisions par jour",
|
||||||
|
"save": "Enregistrer",
|
||||||
|
"saving": "Enregistrement...",
|
||||||
|
"settingsSaved": "Paramètres enregistrés",
|
||||||
|
"todayNew": "Nouvelles aujourd'hui",
|
||||||
|
"todayReview": "Révisions aujourd'hui",
|
||||||
|
"todayLearning": "En apprentissage",
|
||||||
|
"error": {
|
||||||
|
"update": "Pas autorisé à modifier",
|
||||||
|
"delete": "Pas autorisé à supprimer",
|
||||||
|
"add": "Pas autorisé à ajouter"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "Entrer IPA",
|
||||||
|
"examplePlaceholder": "Entrer exemple",
|
||||||
|
"wordRequired": "Veuillez entrer un mot",
|
||||||
|
"definitionRequired": "Veuillez entrer une définition",
|
||||||
|
"cardAdded": "Carte ajoutée",
|
||||||
|
"cardType": "Type de carte",
|
||||||
|
"wordCard": "Carte mot",
|
||||||
|
"phraseCard": "Carte phrase",
|
||||||
|
"sentenceCard": "Carte phrase",
|
||||||
|
"sentence": "Phrase",
|
||||||
|
"sentencePlaceholder": "Entrer phrase",
|
||||||
|
"wordPlaceholder": "Entrer mot",
|
||||||
|
"queryLang": "Langue de requête",
|
||||||
|
"enterLanguageName": "Veuillez entrer le nom de la langue",
|
||||||
|
"english": "Anglais",
|
||||||
|
"chinese": "Chinois",
|
||||||
|
"japanese": "Japonais",
|
||||||
|
"korean": "Coréen",
|
||||||
|
"meanings": "Significations",
|
||||||
|
"addMeaning": "Ajouter signification",
|
||||||
|
"partOfSpeech": "Partie du discours",
|
||||||
|
"deleteConfirm": "Supprimer cette carte?",
|
||||||
|
"cardDeleted": "Carte supprimée",
|
||||||
|
"cardUpdated": "Carte mise à jour"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "Apprendre les langues",
|
"title": "Apprendre les langues",
|
||||||
"description": "Voici un site Web très utile pour vous aider à apprendre presque toutes les langues du monde, y compris les langues construites.",
|
"description": "Voici un site Web très utile pour vous aider à apprendre presque toutes les langues du monde, y compris les langues construites.",
|
||||||
@@ -157,6 +260,9 @@
|
|||||||
"resetPasswordFailed": "Échec de l'envoi de l'e-mail de réinitialisation",
|
"resetPasswordFailed": "Échec de l'envoi de l'e-mail de réinitialisation",
|
||||||
"resetPasswordEmailSent": "E-mail de réinitialisation envoyé avec succès",
|
"resetPasswordEmailSent": "E-mail de réinitialisation envoyé avec succès",
|
||||||
"resetPasswordEmailSentHint": "Nous avons envoyé un lien de réinitialisation de mot de passe à votre adresse e-mail. Veuillez vérifier votre boîte de réception.",
|
"resetPasswordEmailSentHint": "Nous avons envoyé un lien de réinitialisation de mot de passe à votre adresse e-mail. Veuillez vérifier votre boîte de réception.",
|
||||||
|
"verifyYourEmail": "Vérifier votre e-mail",
|
||||||
|
"verificationEmailSent": "E-mail de vérification envoyé",
|
||||||
|
"verificationEmailSentHint": "Nous avons envoyé un e-mail de vérification à {email}. Veuillez cliquer sur le lien dans l'e-mail pour vérifier votre compte.",
|
||||||
"checkYourEmail": "Vérifiez votre e-mail",
|
"checkYourEmail": "Vérifiez votre e-mail",
|
||||||
"backToLogin": "Retour à la connexion",
|
"backToLogin": "Retour à la connexion",
|
||||||
"resetPassword": "Réinitialiser le mot de passe",
|
"resetPassword": "Réinitialiser le mot de passe",
|
||||||
@@ -166,41 +272,114 @@
|
|||||||
"requestNewToken": "Demander un nouveau lien de réinitialisation",
|
"requestNewToken": "Demander un nouveau lien de réinitialisation",
|
||||||
"resetPasswordSuccess": "Mot de passe réinitialisé avec succès",
|
"resetPasswordSuccess": "Mot de passe réinitialisé avec succès",
|
||||||
"resetPasswordSuccessTitle": "Réinitialisation du mot de passe terminée",
|
"resetPasswordSuccessTitle": "Réinitialisation du mot de passe terminée",
|
||||||
"resetPasswordSuccessHint": "Votre mot de passe a été réinitialisé avec succès. Vous pouvez maintenant vous connecter avec votre nouveau mot de passe."
|
"resetPasswordSuccessHint": "Votre mot de passe a été réinitialisé avec succès. Vous pouvez maintenant vous connecter avec votre nouveau mot de passe.",
|
||||||
|
"emailNotVerified": "Veuillez vérifier votre adresse e-mail",
|
||||||
|
"emailNotVerifiedHint": "Votre adresse e-mail n'a pas été vérifiée. Veuillez vérifier votre boîte de réception ou demander un nouvel e-mail de vérification.",
|
||||||
|
"resendVerification": "Renvoyer l'e-mail de vérification",
|
||||||
|
"resendSuccess": "E-mail de vérification envoyé ! Veuillez vérifier votre boîte de réception.",
|
||||||
|
"resendFailed": "Échec de l'envoi de l'e-mail de vérification"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "Sélectionner un dossier",
|
"selectDeck": "Choisir deck",
|
||||||
"noFolders": "Aucun dossier trouvé",
|
"noDecks": "Pas de decks",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "Aller aux decks",
|
||||||
|
"noCards": "Pas de cartes",
|
||||||
|
"new": "Nouveau",
|
||||||
|
"learning": "Apprentissage",
|
||||||
|
"review": "Révision",
|
||||||
|
"due": "À faire"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "Réponse",
|
"loading": "Chargement...",
|
||||||
"next": "Suivant",
|
"backToDecks": "Retour aux decks",
|
||||||
"reverse": "Inverser",
|
"allDone": "Tout terminé!",
|
||||||
"dictation": "Dictée",
|
"allDoneDesc": "Apprentissage terminé pour aujourd'hui!",
|
||||||
"noTextPairs": "Aucune paire de texte disponible",
|
"reviewedCount": "{count} cartes révisées",
|
||||||
"disorder": "Désordre",
|
"progress": "{current} / {total}",
|
||||||
"previous": "Précédent"
|
"nextReview": "Prochaine révision",
|
||||||
|
"interval": "Intervalle",
|
||||||
|
"ease": "Facilité",
|
||||||
|
"lapses": "Erreurs",
|
||||||
|
"showAnswer": "Montrer réponse",
|
||||||
|
"nextCard": "Suivant",
|
||||||
|
"again": "Encore",
|
||||||
|
"restart": "Recommencer",
|
||||||
|
"orderLimited": "Ordre limité",
|
||||||
|
"orderInfinite": "Ordre infini",
|
||||||
|
"randomLimited": "Aléatoire limité",
|
||||||
|
"randomInfinite": "Aléatoire infini",
|
||||||
|
"noIpa": "Pas d'IPA disponible"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "Vous n'êtes pas autorisé à accéder à ce dossier"
|
"unauthorized": "Non autorisé"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
"title": "apprendre-langues",
|
"title": "learn-languages",
|
||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "Se connecter",
|
"sign_in": "Connexion",
|
||||||
"profile": "Profil",
|
"profile": "Profil",
|
||||||
"folders": "Dossiers",
|
"folders": "Decks",
|
||||||
"explore": "Explorer",
|
"explore": "Explorer",
|
||||||
"favorites": "Favoris"
|
"favorites": "Favoris",
|
||||||
|
"settings": "Paramètres"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "Reconnaissance OCR",
|
||||||
|
"description": "Extraire le texte des images",
|
||||||
|
"uploadImage": "Télécharger image",
|
||||||
|
"dragDropHint": "Glisser-déposer",
|
||||||
|
"supportedFormats": "Formats: JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "Choisir deck",
|
||||||
|
"chooseDeck": "Choisir un deck",
|
||||||
|
"noDecks": "Pas de decks disponibles",
|
||||||
|
"languageHints": "Indications de langue",
|
||||||
|
"sourceLanguageHint": "Langue source",
|
||||||
|
"targetLanguageHint": "Langue cible",
|
||||||
|
"process": "Traiter",
|
||||||
|
"processing": "Traitement...",
|
||||||
|
"preview": "Aperçu",
|
||||||
|
"extractedPairs": "Paires extraites",
|
||||||
|
"word": "Mot",
|
||||||
|
"definition": "Définition",
|
||||||
|
"pairsCount": "{count} paires",
|
||||||
|
"savePairs": "Enregistrer",
|
||||||
|
"saving": "Enregistrement...",
|
||||||
|
"saved": "Enregistré",
|
||||||
|
"saveFailed": "Échec de l'enregistrement",
|
||||||
|
"noImage": "Veuillez télécharger une image",
|
||||||
|
"noDeck": "Veuillez choisir un deck",
|
||||||
|
"processingFailed": "Traitement échoué",
|
||||||
|
"tryAgain": "Réessayer",
|
||||||
|
"detectedLanguages": "Langues détectées",
|
||||||
|
"uploadSection": "Télécharger image",
|
||||||
|
"dropOrClick": "Déposer ou cliquer",
|
||||||
|
"changeImage": "Changer image",
|
||||||
|
"invalidFileType": "Type de fichier invalide",
|
||||||
|
"deckSelection": "Choisir deck",
|
||||||
|
"sourceLanguagePlaceholder": "ex: Anglais",
|
||||||
|
"targetLanguagePlaceholder": "ex: Français",
|
||||||
|
"processButton": "Démarrer reconnaissance",
|
||||||
|
"resultsPreview": "Aperçu des résultats",
|
||||||
|
"saveButton": "Enregistrer dans le deck",
|
||||||
|
"ocrSuccess": "OCR réussi",
|
||||||
|
"ocrFailed": "OCR échoué",
|
||||||
|
"savedToDeck": "Enregistré dans le deck",
|
||||||
|
"noResultsToSave": "Pas de résultats",
|
||||||
|
"detectedSourceLanguage": "Langue source détectée",
|
||||||
|
"detectedTargetLanguage": "Langue cible détectée"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "Mon profil",
|
"myProfile": "Mon profil",
|
||||||
"email": "E-mail : {email}",
|
"email": "E-mail : {email}",
|
||||||
"logout": "Déconnexion"
|
"logout": "Déconnexion"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "Paramètres",
|
||||||
|
"themeColor": "Couleur du thème",
|
||||||
|
"themeColorDescription": "Choisissez votre couleur de thème préférée"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "Télécharger la vidéo",
|
"uploadVideo": "Télécharger la vidéo",
|
||||||
"uploadSubtitle": "Télécharger les sous-titres",
|
"uploadSubtitle": "Télécharger les sous-titres",
|
||||||
@@ -230,15 +409,48 @@
|
|||||||
"videoUploadFailed": "Échec du téléchargement de la vidéo",
|
"videoUploadFailed": "Échec du téléchargement de la vidéo",
|
||||||
"subtitleUploadFailed": "Échec du téléchargement des sous-titres",
|
"subtitleUploadFailed": "Échec du téléchargement des sous-titres",
|
||||||
"subtitleLoadSuccess": "Sous-titres chargés avec succès",
|
"subtitleLoadSuccess": "Sous-titres chargés avec succès",
|
||||||
"subtitleLoadFailed": "Échec du chargement des sous-titres"
|
"subtitleLoadFailed": "Échec du chargement des sous-titres",
|
||||||
|
"settings": "Paramètres",
|
||||||
|
"shortcuts": "Raccourcis",
|
||||||
|
"keyboardShortcuts": "Raccourcis clavier",
|
||||||
|
"playPause": "Lecture/Pause",
|
||||||
|
"autoPauseToggle": "Pause auto",
|
||||||
|
"subtitleSettings": "Paramètres sous-titres",
|
||||||
|
"fontSize": "Taille police",
|
||||||
|
"textColor": "Couleur texte",
|
||||||
|
"backgroundColor": "Couleur fond",
|
||||||
|
"position": "Position",
|
||||||
|
"opacity": "Opacité",
|
||||||
|
"top": "Haut",
|
||||||
|
"center": "Centre",
|
||||||
|
"bottom": "Bas"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "Générer l'API",
|
"generateIPA": "Générer l'API",
|
||||||
"viewSavedItems": "Voir les éléments enregistrés",
|
"viewSavedItems": "Voir les éléments enregistrés",
|
||||||
"confirmDeleteAll": "Êtes-vous sûr de vouloir tout supprimer ? (O/N)"
|
"confirmDeleteAll": "Êtes-vous sûr de vouloir tout supprimer ? (O/N)",
|
||||||
|
"saved": "Enregistré",
|
||||||
|
"clearAll": "Tout effacer",
|
||||||
|
"language": "Langue",
|
||||||
|
"customLanguage": "ou entrer une langue...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "Auto",
|
||||||
|
"chinese": "Chinois",
|
||||||
|
"english": "Anglais",
|
||||||
|
"japanese": "Japonais",
|
||||||
|
"korean": "Coréen",
|
||||||
|
"french": "Français",
|
||||||
|
"german": "Allemand",
|
||||||
|
"italian": "Italien",
|
||||||
|
"spanish": "Espagnol",
|
||||||
|
"portuguese": "Portugais",
|
||||||
|
"russian": "Russe"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "détecter la langue",
|
"detectLanguage": "détecter la langue",
|
||||||
|
"sourceLanguage": "langue source",
|
||||||
|
"auto": "Auto",
|
||||||
"generateIPA": "générer l'api",
|
"generateIPA": "générer l'api",
|
||||||
"translateInto": "traduire en",
|
"translateInto": "traduire en",
|
||||||
"chinese": "Chinois",
|
"chinese": "Chinois",
|
||||||
@@ -266,7 +478,20 @@
|
|||||||
"success": "Paire de texte ajoutée au dossier",
|
"success": "Paire de texte ajoutée au dossier",
|
||||||
"error": "Échec de l'ajout de la paire de texte au dossier"
|
"error": "Échec de l'ajout de la paire de texte au dossier"
|
||||||
},
|
},
|
||||||
"autoSave": "Sauvegarde automatique"
|
"autoSave": "Sauvegarde automatique",
|
||||||
|
"customLanguage": "ou tapez la langue...",
|
||||||
|
"pleaseLogin": "Connectez-vous pour sauvegarder",
|
||||||
|
"pleaseCreateDeck": "Créez d'abord un deck",
|
||||||
|
"noTranslationToSave": "Pas de traduction à sauvegarder",
|
||||||
|
"noDeckSelected": "Aucun deck sélectionné",
|
||||||
|
"saveAsCard": "Sauvegarder comme carte",
|
||||||
|
"selectDeck": "Sélectionner deck",
|
||||||
|
"front": "Recto",
|
||||||
|
"back": "Verso",
|
||||||
|
"cancel": "Annuler",
|
||||||
|
"save": "Sauvegarder",
|
||||||
|
"savedToDeck": "Carte sauvegardée dans {deckName}",
|
||||||
|
"saveFailed": "Échec de la sauvegarde"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "Dictionnaire",
|
"title": "Dictionnaire",
|
||||||
@@ -311,7 +536,9 @@
|
|||||||
"unfavorite": "Retirer des favoris",
|
"unfavorite": "Retirer des favoris",
|
||||||
"pleaseLogin": "Veuillez vous connecter d'abord",
|
"pleaseLogin": "Veuillez vous connecter d'abord",
|
||||||
"sortByFavorites": "Trier par favoris",
|
"sortByFavorites": "Trier par favoris",
|
||||||
"sortByFavoritesActive": "Annuler le tri par favoris"
|
"sortByFavoritesActive": "Annuler le tri par favoris",
|
||||||
|
"noDecks": "Pas de decks publics",
|
||||||
|
"deckInfo": "{userName} · {totalCards} cartes"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "Détails du dossier",
|
"title": "Détails du dossier",
|
||||||
@@ -325,7 +552,8 @@
|
|||||||
"unfavorite": "Retirer des favoris",
|
"unfavorite": "Retirer des favoris",
|
||||||
"favorited": "Ajouté aux favoris",
|
"favorited": "Ajouté aux favoris",
|
||||||
"unfavorited": "Retiré des favoris",
|
"unfavorited": "Retiré des favoris",
|
||||||
"pleaseLogin": "Veuillez vous connecter d'abord"
|
"pleaseLogin": "Veuillez vous connecter d'abord",
|
||||||
|
"totalCards": "{count} cartes"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "Mes favoris",
|
"title": "Mes favoris",
|
||||||
@@ -347,14 +575,39 @@
|
|||||||
"notSet": "Non défini",
|
"notSet": "Non défini",
|
||||||
"memberSince": "Membre depuis",
|
"memberSince": "Membre depuis",
|
||||||
"logout": "Déconnexion",
|
"logout": "Déconnexion",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "Dossiers",
|
"button": "Supprimer le compte",
|
||||||
"noFolders": "Pas encore de dossiers",
|
"title": "Supprimer le compte",
|
||||||
"folderName": "Nom du dossier",
|
"warning": "Cette action est irréversible. Toutes vos données seront définitivement supprimées.",
|
||||||
"totalPairs": "Total des paires",
|
"warningDecks": "Tous vos decks et cartes",
|
||||||
|
"warningCards": "Tout votre progression d'apprentissage",
|
||||||
|
"warningHistory": "Tout votre historique de traduction et de dictionnaire",
|
||||||
|
"warningPermanent": "Cette action ne peut pas être annulée",
|
||||||
|
"confirmLabel": "Tapez votre nom d'utilisateur pour confirmer :",
|
||||||
|
"usernameMismatch": "Le nom d'utilisateur ne correspond pas",
|
||||||
|
"cancel": "Annuler",
|
||||||
|
"confirm": "Supprimer mon compte",
|
||||||
|
"success": "Compte supprimé avec succès",
|
||||||
|
"failed": "Échec de la suppression du compte"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Decks",
|
||||||
|
"noDecks": "Pas encore de decks",
|
||||||
|
"deckName": "Nom du deck",
|
||||||
|
"totalCards": "Total des cartes",
|
||||||
"createdAt": "Créé le",
|
"createdAt": "Créé le",
|
||||||
"actions": "Actions",
|
"actions": "Actions",
|
||||||
"view": "Voir"
|
"view": "Voir"
|
||||||
}
|
},
|
||||||
|
"joined": "Inscrit le"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "Suivre",
|
||||||
|
"following": "Abonné",
|
||||||
|
"followers": "Abonnés",
|
||||||
|
"followersOf": "Abonnés de {username}",
|
||||||
|
"followingOf": "Abonnements de {username}",
|
||||||
|
"noFollowers": "Pas encore d'abonnés",
|
||||||
|
"noFollowing": "Ne suit personne"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,38 @@
|
|||||||
"unfavorite": "Rimuovi dai preferiti",
|
"unfavorite": "Rimuovi dai preferiti",
|
||||||
"pleaseLogin": "Per favore accedi prima"
|
"pleaseLogin": "Per favore accedi prima"
|
||||||
},
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Mazzi",
|
||||||
|
"noDecks": "Nessun mazzo ancora",
|
||||||
|
"deckName": "Nome del mazzo",
|
||||||
|
"totalCards": "Totale carte",
|
||||||
|
"createdAt": "Creato il",
|
||||||
|
"actions": "Azioni",
|
||||||
|
"view": "Visualizza",
|
||||||
|
"subtitle": "Gestisci i tuoi deck",
|
||||||
|
"newDeck": "Nuovo deck",
|
||||||
|
"noDecksYet": "Nessun deck ancora",
|
||||||
|
"loading": "Caricamento...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards} carte",
|
||||||
|
"enterDeckName": "Nome deck:",
|
||||||
|
"enterNewName": "Nuovo nome:",
|
||||||
|
"confirmDelete": "Digita \"{name}\" per eliminare:",
|
||||||
|
"public": "Pubblico",
|
||||||
|
"private": "Privato",
|
||||||
|
"setPublic": "Rendi pubblico",
|
||||||
|
"setPrivate": "Rendi privato",
|
||||||
|
"importApkg": "Importa APKG",
|
||||||
|
"exportApkg": "Esporta APKG",
|
||||||
|
"clickToUpload": "Clicca per caricare",
|
||||||
|
"apkgFilesOnly": "Solo file .apkg",
|
||||||
|
"parsing": "Analisi...",
|
||||||
|
"foundDecks": "{count} deck trovati",
|
||||||
|
"back": "Indietro",
|
||||||
|
"import": "Importa",
|
||||||
|
"importing": "Importazione...",
|
||||||
|
"exportSuccess": "Esportazione riuscita",
|
||||||
|
"goToDecks": "Vai ai deck"
|
||||||
|
},
|
||||||
"folder_id": {
|
"folder_id": {
|
||||||
"unauthorized": "Non sei il proprietario di questa cartella",
|
"unauthorized": "Non sei il proprietario di questa cartella",
|
||||||
"back": "Indietro",
|
"back": "Indietro",
|
||||||
@@ -74,6 +106,77 @@
|
|||||||
"deleteFolder": "Non hai il permesso di eliminare questa cartella."
|
"deleteFolder": "Non hai il permesso di eliminare questa cartella."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "Non sei il proprietario di questo deck",
|
||||||
|
"back": "Indietro",
|
||||||
|
"cards": "Schede",
|
||||||
|
"itemsCount": "{count} elementi",
|
||||||
|
"memorize": "Memorizza",
|
||||||
|
"loadingCards": "Caricamento schede...",
|
||||||
|
"noCards": "Nessuna scheda in questo deck",
|
||||||
|
"card": "Scheda",
|
||||||
|
"addNewCard": "Aggiungi nuova scheda",
|
||||||
|
"add": "Aggiungi",
|
||||||
|
"adding": "Aggiunta in corso...",
|
||||||
|
"updateCard": "Aggiorna scheda",
|
||||||
|
"update": "Aggiorna",
|
||||||
|
"updating": "Aggiornamento in corso...",
|
||||||
|
"word": "Parola",
|
||||||
|
"definition": "Definizione",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"example": "Esempio",
|
||||||
|
"wordAndDefinitionRequired": "Parola e definizione sono obbligatori",
|
||||||
|
"edit": "Modifica",
|
||||||
|
"delete": "Elimina",
|
||||||
|
"permissionDenied": "Non hai il permesso per questa accion",
|
||||||
|
"resetProgress": "Reimposta progresso",
|
||||||
|
"resetProgressTitle": "Reimposta progresso di apprendimento",
|
||||||
|
"resetProgressConfirm": "Reimpostare il progresso?",
|
||||||
|
"resetSuccess": "Progresso reimpostato",
|
||||||
|
"resetting": "Reimpostazione...",
|
||||||
|
"cancel": "Annulla",
|
||||||
|
"settings": "Impostazioni",
|
||||||
|
"settingsTitle": "Impostazioni deck",
|
||||||
|
"newPerDay": "Nuove al giorno",
|
||||||
|
"newPerDayHint": "Nuove carte al giorno",
|
||||||
|
"revPerDay": "Ripassate al giorno",
|
||||||
|
"revPerDayHint": "Ripassi al giorno",
|
||||||
|
"save": "Salva",
|
||||||
|
"saving": "Salvataggio...",
|
||||||
|
"settingsSaved": "Impostazioni salvate",
|
||||||
|
"todayNew": "Oggi nuove",
|
||||||
|
"todayReview": "Oggi ripasso",
|
||||||
|
"todayLearning": "In apprendimento",
|
||||||
|
"error": {
|
||||||
|
"update": "Nessun permesso di aggiornare",
|
||||||
|
"delete": "Nessun permesso di eliminare",
|
||||||
|
"add": "Nessun permesso di aggiungere"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "Inserisci IPA",
|
||||||
|
"examplePlaceholder": "Inserisci esempio",
|
||||||
|
"wordRequired": "Inserisci una parola",
|
||||||
|
"definitionRequired": "Inserisci una definizione",
|
||||||
|
"cardAdded": "Carta aggiunta",
|
||||||
|
"cardType": "Tipo di carta",
|
||||||
|
"wordCard": "Carta parola",
|
||||||
|
"phraseCard": "Carta frase",
|
||||||
|
"sentenceCard": "Carta frase",
|
||||||
|
"sentence": "Frase",
|
||||||
|
"sentencePlaceholder": "Inserisci frase",
|
||||||
|
"wordPlaceholder": "Inserisci parola",
|
||||||
|
"queryLang": "Lingua di query",
|
||||||
|
"enterLanguageName": "Inserisci il nome della lingua",
|
||||||
|
"english": "Inglese",
|
||||||
|
"chinese": "Cinese",
|
||||||
|
"japanese": "Giapponese",
|
||||||
|
"korean": "Coreano",
|
||||||
|
"meanings": "Significati",
|
||||||
|
"addMeaning": "Aggiungi significato",
|
||||||
|
"partOfSpeech": "Parte del discorso",
|
||||||
|
"deleteConfirm": "Eliminare questa carta?",
|
||||||
|
"cardDeleted": "Carta eliminata",
|
||||||
|
"cardUpdated": "Carta aggiornata"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "Impara le Lingue",
|
"title": "Impara le Lingue",
|
||||||
"description": "Ecco un sito molto utile per aiutarti a imparare quasi tutte le lingue del mondo, incluse quelle costruite.",
|
"description": "Ecco un sito molto utile per aiutarti a imparare quasi tutte le lingue del mondo, incluse quelle costruite.",
|
||||||
@@ -157,6 +260,9 @@
|
|||||||
"resetPasswordFailed": "Impossibile inviare email di reset",
|
"resetPasswordFailed": "Impossibile inviare email di reset",
|
||||||
"resetPasswordEmailSent": "Email di reset inviata con successo",
|
"resetPasswordEmailSent": "Email di reset inviata con successo",
|
||||||
"resetPasswordEmailSentHint": "Abbiamo inviato un link per reimpostare la password al tuo indirizzo email. Controlla la tua casella di posta.",
|
"resetPasswordEmailSentHint": "Abbiamo inviato un link per reimpostare la password al tuo indirizzo email. Controlla la tua casella di posta.",
|
||||||
|
"verifyYourEmail": "Verifica la tua Email",
|
||||||
|
"verificationEmailSent": "Email di verifica inviata",
|
||||||
|
"verificationEmailSentHint": "Abbiamo inviato un'email di verifica a {email}. Clicca sul link nell'email per verificare il tuo account.",
|
||||||
"checkYourEmail": "Controlla la tua Email",
|
"checkYourEmail": "Controlla la tua Email",
|
||||||
"backToLogin": "Torna al Login",
|
"backToLogin": "Torna al Login",
|
||||||
"resetPassword": "Reimposta Password",
|
"resetPassword": "Reimposta Password",
|
||||||
@@ -166,41 +272,139 @@
|
|||||||
"requestNewToken": "Richiedi Nuovo Link di Reset",
|
"requestNewToken": "Richiedi Nuovo Link di Reset",
|
||||||
"resetPasswordSuccess": "Password reimpostata con successo",
|
"resetPasswordSuccess": "Password reimpostata con successo",
|
||||||
"resetPasswordSuccessTitle": "Reimpostazione Password Completata",
|
"resetPasswordSuccessTitle": "Reimpostazione Password Completata",
|
||||||
"resetPasswordSuccessHint": "La tua password è stata reimpostata con successo. Ora puoi accedere con la tua nuova password."
|
"resetPasswordSuccessHint": "La tua password è stata reimpostata con successo. Ora puoi accedere con la tua nuova password.",
|
||||||
|
"emailNotVerified": "Verifica il tuo indirizzo email",
|
||||||
|
"emailNotVerifiedHint": "Il tuo indirizzo email non è stato verificato. Controlla la tua casella di posta o richiedi una nuova email di verifica.",
|
||||||
|
"resendVerification": "Invia di nuovo email di verifica",
|
||||||
|
"resendSuccess": "Email di verifica inviata! Controlla la tua casella di posta.",
|
||||||
|
"resendFailed": "Impossibile inviare l'email di verifica"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "Seleziona una cartella",
|
"selectDeck": "Seleziona deck",
|
||||||
"noFolders": "Nessuna cartella trovata",
|
"noDecks": "Nessun deck",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "Vai ai deck",
|
||||||
|
"noCards": "Nessuna carta",
|
||||||
|
"new": "Nuovo",
|
||||||
|
"learning": "Apprendimento",
|
||||||
|
"review": "Ripasso",
|
||||||
|
"due": "In scadenza"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "Risposta",
|
"loading": "Caricamento...",
|
||||||
"next": "Successivo",
|
"backToDecks": "Torna ai deck",
|
||||||
|
"allDone": "Tutto fatto!",
|
||||||
|
"allDoneDesc": "Apprendimento di oggi completato!",
|
||||||
|
"reviewedCount": "{count} carte ripassate",
|
||||||
|
"progress": "{current} / {total}",
|
||||||
|
"nextReview": "Prossimo ripasso",
|
||||||
|
"interval": "Intervallo",
|
||||||
|
"ease": "Difficoltà",
|
||||||
|
"lapses": "Errori",
|
||||||
|
"showAnswer": "Mostra risposta",
|
||||||
|
"nextCard": "Prossima",
|
||||||
|
"again": "Ancora",
|
||||||
|
"restart": "Ricomincia",
|
||||||
|
"hard": "Difficile",
|
||||||
|
"good": "Buono",
|
||||||
|
"easy": "Facile",
|
||||||
|
"now": "Ora",
|
||||||
|
"lessThanMinute": "meno di 1 minuto",
|
||||||
|
"inMinutes": "tra {n} minuti",
|
||||||
|
"inHours": "tra {n} ore",
|
||||||
|
"inDays": "tra {n} giorni",
|
||||||
|
"inMonths": "tra {n} mesi",
|
||||||
|
"minutes": "minuti",
|
||||||
|
"days": "giorni",
|
||||||
|
"months": "mesi",
|
||||||
|
"minAbbr": "min",
|
||||||
|
"dayAbbr": "g",
|
||||||
|
"cardTypeNew": "Nuovo",
|
||||||
|
"cardTypeLearning": "Apprendimento",
|
||||||
|
"cardTypeReview": "Ripasso",
|
||||||
|
"cardTypeRelearning": "Riapprendimento",
|
||||||
"reverse": "Inverti",
|
"reverse": "Inverti",
|
||||||
"dictation": "Dettatura",
|
"dictation": "Dettato",
|
||||||
"noTextPairs": "Nessuna coppia di testo disponibile",
|
"clickToPlay": "Clicca per riprodurre",
|
||||||
"disorder": "Disordina",
|
"yourAnswer": "La tua risposta",
|
||||||
"previous": "Precedente"
|
"typeWhatYouHear": "Scrivi cosa senti",
|
||||||
|
"correct": "Corretto!",
|
||||||
|
"incorrect": "Errato",
|
||||||
|
"orderLimited": "Ordine limitato",
|
||||||
|
"orderInfinite": "Ordine infinito",
|
||||||
|
"randomLimited": "Casuale limitato",
|
||||||
|
"randomInfinite": "Casuale infinito",
|
||||||
|
"noIpa": "Nessun IPA disponibile"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "Non sei autorizzato ad accedere a questa cartella"
|
"unauthorized": "Non autorizzato"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
"title": "impara-lingue",
|
"title": "learn-languages",
|
||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "Accedi",
|
"sign_in": "Accedi",
|
||||||
"profile": "Profilo",
|
"profile": "Profilo",
|
||||||
"folders": "Cartelle",
|
"folders": "Mazzi",
|
||||||
"explore": "Esplora",
|
"explore": "Esplora",
|
||||||
"favorites": "Preferiti"
|
"favorites": "Preferiti",
|
||||||
|
"settings": "Impostazioni"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "Riconoscimento OCR",
|
||||||
|
"description": "Estrai testo dalle immagini",
|
||||||
|
"uploadImage": "Carica immagine",
|
||||||
|
"dragDropHint": "Trascina e rilascia",
|
||||||
|
"supportedFormats": "Supportati: JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "Seleziona deck",
|
||||||
|
"chooseDeck": "Scegli un deck",
|
||||||
|
"noDecks": "Nessun deck disponibile",
|
||||||
|
"languageHints": "Suggerimenti lingua",
|
||||||
|
"sourceLanguageHint": "Lingua sorgente",
|
||||||
|
"targetLanguageHint": "Lingua target",
|
||||||
|
"process": "Elabora",
|
||||||
|
"processing": "Elaborazione...",
|
||||||
|
"preview": "Anteprima",
|
||||||
|
"extractedPairs": "Coppie estratte",
|
||||||
|
"word": "Parola",
|
||||||
|
"definition": "Definizione",
|
||||||
|
"pairsCount": "{count} coppie",
|
||||||
|
"savePairs": "Salva",
|
||||||
|
"saving": "Salvataggio...",
|
||||||
|
"saved": "Salvato",
|
||||||
|
"saveFailed": "Salvataggio fallito",
|
||||||
|
"noImage": "Carica un'immagine",
|
||||||
|
"noDeck": "Seleziona un deck",
|
||||||
|
"processingFailed": "Elaborazione fallita",
|
||||||
|
"tryAgain": "Riprova",
|
||||||
|
"detectedLanguages": "Lingue rilevate",
|
||||||
|
"uploadSection": "Carica immagine",
|
||||||
|
"dropOrClick": "Rilascia o clicca",
|
||||||
|
"changeImage": "Cambia immagine",
|
||||||
|
"invalidFileType": "Tipo di file non valido",
|
||||||
|
"deckSelection": "Seleziona deck",
|
||||||
|
"sourceLanguagePlaceholder": "es: Inglese",
|
||||||
|
"targetLanguagePlaceholder": "es: Italiano",
|
||||||
|
"processButton": "Avvia riconoscimento",
|
||||||
|
"resultsPreview": "Anteprima risultati",
|
||||||
|
"saveButton": "Salva nel deck",
|
||||||
|
"ocrSuccess": "OCR riuscito",
|
||||||
|
"ocrFailed": "OCR fallito",
|
||||||
|
"savedToDeck": "Salvato nel deck",
|
||||||
|
"noResultsToSave": "Nessun risultato",
|
||||||
|
"detectedSourceLanguage": "Lingua sorgente rilevata",
|
||||||
|
"detectedTargetLanguage": "Lingua target rilevata"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "Il Mio Profilo",
|
"myProfile": "Il Mio Profilo",
|
||||||
"email": "Email: {email}",
|
"email": "Email: {email}",
|
||||||
"logout": "Esci"
|
"logout": "Esci"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "Impostazioni",
|
||||||
|
"themeColor": "Colore del tema",
|
||||||
|
"themeColorDescription": "Scegli il tuo colore del tema preferito"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "Carica Video",
|
"uploadVideo": "Carica Video",
|
||||||
"uploadSubtitle": "Carica Sottotitoli",
|
"uploadSubtitle": "Carica Sottotitoli",
|
||||||
@@ -230,15 +434,48 @@
|
|||||||
"videoUploadFailed": "Caricamento video fallito",
|
"videoUploadFailed": "Caricamento video fallito",
|
||||||
"subtitleUploadFailed": "Caricamento sottotitoli fallito",
|
"subtitleUploadFailed": "Caricamento sottotitoli fallito",
|
||||||
"subtitleLoadSuccess": "Sottotitoli caricati con successo",
|
"subtitleLoadSuccess": "Sottotitoli caricati con successo",
|
||||||
"subtitleLoadFailed": "Caricamento sottotitoli fallito"
|
"subtitleLoadFailed": "Caricamento sottotitoli fallito",
|
||||||
|
"settings": "Impostazioni",
|
||||||
|
"shortcuts": "Scorciatoie",
|
||||||
|
"keyboardShortcuts": "Scorciatoie tastiera",
|
||||||
|
"playPause": "Riproduci/Pausa",
|
||||||
|
"autoPauseToggle": "Auto-pausa",
|
||||||
|
"subtitleSettings": "Impostazioni sottotitoli",
|
||||||
|
"fontSize": "Dimensione carattere",
|
||||||
|
"textColor": "Colore testo",
|
||||||
|
"backgroundColor": "Colore sfondo",
|
||||||
|
"position": "Posizione",
|
||||||
|
"opacity": "Opacità",
|
||||||
|
"top": "Alto",
|
||||||
|
"center": "Centro",
|
||||||
|
"bottom": "Basso"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "Genera IPA",
|
"generateIPA": "Genera IPA",
|
||||||
"viewSavedItems": "Visualizza Elementi Salvati",
|
"viewSavedItems": "Visualizza Elementi Salvati",
|
||||||
"confirmDeleteAll": "Sei sicuro di voler eliminare tutto? (S/N)"
|
"confirmDeleteAll": "Sei sicuro di voler eliminare tutto? (S/N)",
|
||||||
|
"saved": "Salvato",
|
||||||
|
"clearAll": "Cancella tutto",
|
||||||
|
"language": "Lingua",
|
||||||
|
"customLanguage": "o inserisci lingua...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "Auto",
|
||||||
|
"chinese": "Cinese",
|
||||||
|
"english": "Inglese",
|
||||||
|
"japanese": "Giapponese",
|
||||||
|
"korean": "Coreano",
|
||||||
|
"french": "Francese",
|
||||||
|
"german": "Tedesco",
|
||||||
|
"italian": "Italiano",
|
||||||
|
"spanish": "Spagnolo",
|
||||||
|
"portuguese": "Portoghese",
|
||||||
|
"russian": "Russo"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "rileva lingua",
|
"detectLanguage": "rileva lingua",
|
||||||
|
"sourceLanguage": "lingua di origine",
|
||||||
|
"auto": "Auto",
|
||||||
"generateIPA": "genera ipa",
|
"generateIPA": "genera ipa",
|
||||||
"translateInto": "traduci in",
|
"translateInto": "traduci in",
|
||||||
"chinese": "Cinese",
|
"chinese": "Cinese",
|
||||||
@@ -266,7 +503,20 @@
|
|||||||
"success": "Coppia di testo aggiunta alla cartella",
|
"success": "Coppia di testo aggiunta alla cartella",
|
||||||
"error": "Impossibile aggiungere coppia di testo alla cartella"
|
"error": "Impossibile aggiungere coppia di testo alla cartella"
|
||||||
},
|
},
|
||||||
"autoSave": "Salvataggio Automatico"
|
"autoSave": "Salvataggio Automatico",
|
||||||
|
"customLanguage": "o digita lingua...",
|
||||||
|
"pleaseLogin": "Accedi per salvare le carte",
|
||||||
|
"pleaseCreateDeck": "Crea prima un deck",
|
||||||
|
"noTranslationToSave": "Nessuna traduzione da salvare",
|
||||||
|
"noDeckSelected": "Nessun deck selezionato",
|
||||||
|
"saveAsCard": "Salva come carta",
|
||||||
|
"selectDeck": "Seleziona deck",
|
||||||
|
"front": "Fronte",
|
||||||
|
"back": "Retro",
|
||||||
|
"cancel": "Annulla",
|
||||||
|
"save": "Salva",
|
||||||
|
"savedToDeck": "Carta salvata in {deckName}",
|
||||||
|
"saveFailed": "Salvataggio fallito"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "Dizionario",
|
"title": "Dizionario",
|
||||||
@@ -311,7 +561,9 @@
|
|||||||
"unfavorite": "Rimuovi dai preferiti",
|
"unfavorite": "Rimuovi dai preferiti",
|
||||||
"pleaseLogin": "Per favore accedi prima",
|
"pleaseLogin": "Per favore accedi prima",
|
||||||
"sortByFavorites": "Ordina per preferiti",
|
"sortByFavorites": "Ordina per preferiti",
|
||||||
"sortByFavoritesActive": "Annulla ordinamento per preferiti"
|
"sortByFavoritesActive": "Annulla ordinamento per preferiti",
|
||||||
|
"noDecks": "Nessun deck pubblico",
|
||||||
|
"deckInfo": "{userName} · {totalCards} carte"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "Dettagli Cartella",
|
"title": "Dettagli Cartella",
|
||||||
@@ -325,7 +577,8 @@
|
|||||||
"unfavorite": "Rimuovi dai preferiti",
|
"unfavorite": "Rimuovi dai preferiti",
|
||||||
"favorited": "Aggiunto ai preferiti",
|
"favorited": "Aggiunto ai preferiti",
|
||||||
"unfavorited": "Rimosso dai preferiti",
|
"unfavorited": "Rimosso dai preferiti",
|
||||||
"pleaseLogin": "Per favore accedi prima"
|
"pleaseLogin": "Per favore accedi prima",
|
||||||
|
"totalCards": "{count} carte"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "I Miei Preferiti",
|
"title": "I Miei Preferiti",
|
||||||
@@ -347,14 +600,39 @@
|
|||||||
"notSet": "Non Impostato",
|
"notSet": "Non Impostato",
|
||||||
"memberSince": "Membro Dal",
|
"memberSince": "Membro Dal",
|
||||||
"logout": "Esci",
|
"logout": "Esci",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "Cartelle",
|
"button": "Elimina Account",
|
||||||
"noFolders": "Nessuna cartella ancora",
|
"title": "Elimina Account",
|
||||||
"folderName": "Nome Cartella",
|
"warning": "Questa azione è irreversibile. Tutti i tuoi dati saranno eliminati definitivamente.",
|
||||||
"totalPairs": "Coppie Totali",
|
"warningDecks": "Tutti i tuoi mazzi e le tue carte",
|
||||||
|
"warningCards": "Tutto il tuo progresso di apprendimento",
|
||||||
|
"warningHistory": "Tutto il tuo cronologia di traduzione e dizionario",
|
||||||
|
"warningPermanent": "Questa azione non può essere annullata",
|
||||||
|
"confirmLabel": "Digita il tuo nome utente per confermare:",
|
||||||
|
"usernameMismatch": "Il nome utente non corrisponde",
|
||||||
|
"cancel": "Annulla",
|
||||||
|
"confirm": "Elimina il mio account",
|
||||||
|
"success": "Account eliminato con successo",
|
||||||
|
"failed": "Impossibile eliminare l'account"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "Mazzi",
|
||||||
|
"noDecks": "Nessun mazzo ancora",
|
||||||
|
"deckName": "Nome del mazzo",
|
||||||
|
"totalCards": "Totale carte",
|
||||||
"createdAt": "Creata Il",
|
"createdAt": "Creata Il",
|
||||||
"actions": "Azioni",
|
"actions": "Azioni",
|
||||||
"view": "Visualizza"
|
"view": "Visualizza"
|
||||||
}
|
},
|
||||||
|
"joined": "Iscritto il"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "Segui",
|
||||||
|
"following": "Stai seguendo",
|
||||||
|
"followers": "Seguaci",
|
||||||
|
"followersOf": "Seguaci di {username}",
|
||||||
|
"followingOf": "Seguiti da {username}",
|
||||||
|
"noFollowers": "Nessun seguace ancora",
|
||||||
|
"noFollowing": "Non segui ancora nessuno"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,77 @@
|
|||||||
"deleteFolder": "このフォルダーを削除する権限がありません。"
|
"deleteFolder": "このフォルダーを削除する権限がありません。"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "このデッキの所有者ではありません",
|
||||||
|
"back": "戻る",
|
||||||
|
"cards": "カード",
|
||||||
|
"itemsCount": "{count}件",
|
||||||
|
"memorize": "暗記",
|
||||||
|
"loadingCards": "カードを読み込み中...",
|
||||||
|
"noCards": "このデッキにはカードがありません",
|
||||||
|
"card": "カード",
|
||||||
|
"addNewCard": "新しいカードを追加",
|
||||||
|
"add": "追加",
|
||||||
|
"adding": "追加中...",
|
||||||
|
"updateCard": "カードを更新",
|
||||||
|
"update": "更新",
|
||||||
|
"updating": "更新中...",
|
||||||
|
"word": "単語",
|
||||||
|
"definition": "定義",
|
||||||
|
"ipa": "発音記号",
|
||||||
|
"example": "例文",
|
||||||
|
"wordAndDefinitionRequired": "単語と定義は必須です",
|
||||||
|
"edit": "編集",
|
||||||
|
"delete": "削除",
|
||||||
|
"permissionDenied": "この操作を実行する権限がありません",
|
||||||
|
"resetProgress": "進捗をリセット",
|
||||||
|
"resetProgressTitle": "学習進捗をリセット",
|
||||||
|
"resetProgressConfirm": "このデッキの学習進捗をリセットしますか?",
|
||||||
|
"resetSuccess": "リセットしました",
|
||||||
|
"resetting": "リセット中...",
|
||||||
|
"cancel": "キャンセル",
|
||||||
|
"settings": "設定",
|
||||||
|
"settingsTitle": "デッキ設定",
|
||||||
|
"newPerDay": "1日の新規カード",
|
||||||
|
"newPerDayHint": "毎日の新規カード数",
|
||||||
|
"revPerDay": "1日の復習",
|
||||||
|
"revPerDayHint": "毎日の復習数",
|
||||||
|
"save": "保存",
|
||||||
|
"saving": "保存中...",
|
||||||
|
"settingsSaved": "設定を保存しました",
|
||||||
|
"todayNew": "今日の新規",
|
||||||
|
"todayReview": "今日の復習",
|
||||||
|
"todayLearning": "学習中",
|
||||||
|
"error": {
|
||||||
|
"update": "更新する権限がありません",
|
||||||
|
"delete": "削除する権限がありません",
|
||||||
|
"add": "追加する権限がありません"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "IPAを入力",
|
||||||
|
"examplePlaceholder": "例文を入力",
|
||||||
|
"wordRequired": "単語を入力してください",
|
||||||
|
"definitionRequired": "定義を入力してください",
|
||||||
|
"cardAdded": "カードを追加しました",
|
||||||
|
"cardType": "カードタイプ",
|
||||||
|
"wordCard": "単語カード",
|
||||||
|
"phraseCard": "フレーズカード",
|
||||||
|
"sentenceCard": "文章カード",
|
||||||
|
"sentence": "文章",
|
||||||
|
"sentencePlaceholder": "文章を入力",
|
||||||
|
"wordPlaceholder": "単語を入力",
|
||||||
|
"queryLang": "検索言語",
|
||||||
|
"enterLanguageName": "言語名を入力してください",
|
||||||
|
"english": "英語",
|
||||||
|
"chinese": "中国語",
|
||||||
|
"japanese": "日本語",
|
||||||
|
"korean": "韓国語",
|
||||||
|
"meanings": "意味",
|
||||||
|
"addMeaning": "意味を追加",
|
||||||
|
"partOfSpeech": "品詞",
|
||||||
|
"deleteConfirm": "このカードを削除しますか?",
|
||||||
|
"cardDeleted": "カードを削除しました",
|
||||||
|
"cardUpdated": "カードを更新しました"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "言語を学ぶ",
|
"title": "言語を学ぶ",
|
||||||
"description": "ここは世界のほぼすべての言語(人工言語を含む)を学ぶのに役立つ非常に便利なウェブサイトです。",
|
"description": "ここは世界のほぼすべての言語(人工言語を含む)を学ぶのに役立つ非常に便利なウェブサイトです。",
|
||||||
@@ -157,6 +228,9 @@
|
|||||||
"resetPasswordFailed": "リセットメールの送信に失敗しました",
|
"resetPasswordFailed": "リセットメールの送信に失敗しました",
|
||||||
"resetPasswordEmailSent": "リセットメールを送信しました",
|
"resetPasswordEmailSent": "リセットメールを送信しました",
|
||||||
"resetPasswordEmailSentHint": "パスワードリセット用のリンクをメールでお送りしました。受信トレイをご確認ください。",
|
"resetPasswordEmailSentHint": "パスワードリセット用のリンクをメールでお送りしました。受信トレイをご確認ください。",
|
||||||
|
"verifyYourEmail": "メールアドレスを確認",
|
||||||
|
"verificationEmailSent": "確認メールを送信しました",
|
||||||
|
"verificationEmailSentHint": "{email} に確認メールを送信しました。メール内のリンクをクリックしてアカウントを確認してください。",
|
||||||
"checkYourEmail": "メールをご確認ください",
|
"checkYourEmail": "メールをご確認ください",
|
||||||
"backToLogin": "ログインに戻る",
|
"backToLogin": "ログインに戻る",
|
||||||
"resetPassword": "パスワードをリセット",
|
"resetPassword": "パスワードをリセット",
|
||||||
@@ -166,25 +240,72 @@
|
|||||||
"requestNewToken": "新しいリセットリンクをリクエスト",
|
"requestNewToken": "新しいリセットリンクをリクエスト",
|
||||||
"resetPasswordSuccess": "パスワードのリセットに成功しました",
|
"resetPasswordSuccess": "パスワードのリセットに成功しました",
|
||||||
"resetPasswordSuccessTitle": "パスワードリセット完了",
|
"resetPasswordSuccessTitle": "パスワードリセット完了",
|
||||||
"resetPasswordSuccessHint": "パスワードが正常にリセットされました。新しいパスワードでログインできます。"
|
"resetPasswordSuccessHint": "パスワードが正常にリセットされました。新しいパスワードでログインできます。",
|
||||||
|
"emailNotVerified": "メールアドレスを確認してください",
|
||||||
|
"emailNotVerifiedHint": "メールアドレスが確認されていません。受信トレイをご確認いただくか、新しい確認メールをリクエストしてください。",
|
||||||
|
"resendVerification": "確認メールを再送信",
|
||||||
|
"resendSuccess": "確認メールを送信しました!受信トレイをご確認ください。",
|
||||||
|
"resendFailed": "確認メールの送信に失敗しました"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "フォルダーを選択",
|
"selectDeck": "デッキを選択",
|
||||||
"noFolders": "フォルダーが見つかりません",
|
"noDecks": "デッキが見つかりません",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "デッキへ移動",
|
||||||
|
"noCards": "カードなし",
|
||||||
|
"new": "新規",
|
||||||
|
"learning": "学習中",
|
||||||
|
"review": "復習",
|
||||||
|
"due": "予定"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "答え",
|
"loading": "読み込み中...",
|
||||||
"next": "次へ",
|
"backToDecks": "デッキに戻る",
|
||||||
"reverse": "逆順",
|
"allDone": "完了!",
|
||||||
"dictation": "書き取り",
|
"allDoneDesc": "すべての復習カードが完了しました。",
|
||||||
"noTextPairs": "利用可能なテキストペアがありません",
|
"reviewedCount": "{count} 枚のカードを復習",
|
||||||
"disorder": "シャッフル",
|
"progress": "{current} / {total}",
|
||||||
"previous": "前へ"
|
"nextReview": "次の復習",
|
||||||
|
"interval": "間隔",
|
||||||
|
"ease": "易しさ",
|
||||||
|
"lapses": "忘回数",
|
||||||
|
"showAnswer": "答えを表示",
|
||||||
|
"nextCard": "次へ",
|
||||||
|
"again": "もう一度",
|
||||||
|
"hard": "難しい",
|
||||||
|
"good": "普通",
|
||||||
|
"easy": "簡単",
|
||||||
|
"now": "今",
|
||||||
|
"lessThanMinute": "<1分",
|
||||||
|
"inMinutes": "{count}分",
|
||||||
|
"inHours": "{count}時間",
|
||||||
|
"inDays": "{count}日",
|
||||||
|
"inMonths": "{count}ヶ月",
|
||||||
|
"minutes": "<1分",
|
||||||
|
"days": "{count}日",
|
||||||
|
"months": "{count}ヶ月",
|
||||||
|
"minAbbr": "分",
|
||||||
|
"dayAbbr": "日",
|
||||||
|
"cardTypeNew": "新規",
|
||||||
|
"cardTypeLearning": "学習中",
|
||||||
|
"cardTypeReview": "復習",
|
||||||
|
"cardTypeRelearning": "再学習",
|
||||||
|
"reverse": "反転",
|
||||||
|
"dictation": "聴き取り",
|
||||||
|
"clickToPlay": "クリックして再生",
|
||||||
|
"yourAnswer": "あなたの答え",
|
||||||
|
"typeWhatYouHear": "聞こえた内容を入力",
|
||||||
|
"correct": "正解",
|
||||||
|
"incorrect": "不正解",
|
||||||
|
"restart": "最初から",
|
||||||
|
"orderLimited": "順序制限",
|
||||||
|
"orderInfinite": "順序無限",
|
||||||
|
"randomLimited": "ランダム制限",
|
||||||
|
"randomInfinite": "ランダム無限",
|
||||||
|
"noIpa": "IPAなし"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "このフォルダーにアクセスする権限がありません"
|
"unauthorized": "このデッキにアクセスする権限がありません"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
@@ -192,15 +313,66 @@
|
|||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "サインイン",
|
"sign_in": "サインイン",
|
||||||
"profile": "プロフィール",
|
"profile": "プロフィール",
|
||||||
"folders": "フォルダー",
|
"folders": "デッキ",
|
||||||
"explore": "探索",
|
"explore": "探索",
|
||||||
"favorites": "お気に入り"
|
"favorites": "お気に入り",
|
||||||
|
"settings": "設定"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR認識",
|
||||||
|
"description": "画像からテキストを抽出",
|
||||||
|
"uploadImage": "画像をアップロード",
|
||||||
|
"dragDropHint": "ドラッグ&ドロップ",
|
||||||
|
"supportedFormats": "対応形式:JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "デッキを選択",
|
||||||
|
"chooseDeck": "デッキを選択",
|
||||||
|
"noDecks": "デッキがありません",
|
||||||
|
"languageHints": "言語ヒント",
|
||||||
|
"sourceLanguageHint": "ソース言語ヒント",
|
||||||
|
"targetLanguageHint": "ターゲット言語ヒント",
|
||||||
|
"process": "処理",
|
||||||
|
"processing": "処理中...",
|
||||||
|
"preview": "プレビュー",
|
||||||
|
"extractedPairs": "抽出ペア",
|
||||||
|
"word": "単語",
|
||||||
|
"definition": "定義",
|
||||||
|
"pairsCount": "{count}ペア",
|
||||||
|
"savePairs": "保存",
|
||||||
|
"saving": "保存中...",
|
||||||
|
"saved": "保存済み",
|
||||||
|
"saveFailed": "保存失敗",
|
||||||
|
"noImage": "画像をアップロードしてください",
|
||||||
|
"noDeck": "デッキを選択してください",
|
||||||
|
"processingFailed": "処理失敗",
|
||||||
|
"tryAgain": "再試行",
|
||||||
|
"detectedLanguages": "検出言語",
|
||||||
|
"invalidFileType": "無効なファイル形式",
|
||||||
|
"ocrFailed": "OCR失敗",
|
||||||
|
"uploadSection": "画像をアップロード",
|
||||||
|
"dropOrClick": "ドロップまたはクリック",
|
||||||
|
"changeImage": "画像を変更",
|
||||||
|
"deckSelection": "デッキを選択",
|
||||||
|
"sourceLanguagePlaceholder": "例:英語",
|
||||||
|
"targetLanguagePlaceholder": "例:日本語",
|
||||||
|
"processButton": "認識開始",
|
||||||
|
"resultsPreview": "結果プレビュー",
|
||||||
|
"saveButton": "デッキに保存",
|
||||||
|
"ocrSuccess": "OCR成功",
|
||||||
|
"savedToDeck": "デッキに保存しました",
|
||||||
|
"noResultsToSave": "結果がありません",
|
||||||
|
"detectedSourceLanguage": "検出ソース言語",
|
||||||
|
"detectedTargetLanguage": "検出ターゲット言語"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "マイプロフィール",
|
"myProfile": "マイプロフィール",
|
||||||
"email": "メール: {email}",
|
"email": "メール: {email}",
|
||||||
"logout": "ログアウト"
|
"logout": "ログアウト"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "設定",
|
||||||
|
"themeColor": "テーマカラー",
|
||||||
|
"themeColorDescription": "お好みのテーマカラーを選択してください"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "ビデオをアップロード",
|
"uploadVideo": "ビデオをアップロード",
|
||||||
"uploadSubtitle": "字幕をアップロード",
|
"uploadSubtitle": "字幕をアップロード",
|
||||||
@@ -230,15 +402,48 @@
|
|||||||
"videoUploadFailed": "ビデオのアップロードに失敗しました",
|
"videoUploadFailed": "ビデオのアップロードに失敗しました",
|
||||||
"subtitleUploadFailed": "字幕のアップロードに失敗しました",
|
"subtitleUploadFailed": "字幕のアップロードに失敗しました",
|
||||||
"subtitleLoadSuccess": "字幕の読み込みに成功しました",
|
"subtitleLoadSuccess": "字幕の読み込みに成功しました",
|
||||||
"subtitleLoadFailed": "字幕の読み込みに失敗しました"
|
"subtitleLoadFailed": "字幕の読み込みに失敗しました",
|
||||||
|
"settings": "設定",
|
||||||
|
"shortcuts": "ショートカット",
|
||||||
|
"keyboardShortcuts": "キーボードショートカット",
|
||||||
|
"playPause": "再生/一時停止",
|
||||||
|
"autoPauseToggle": "自動一時停止",
|
||||||
|
"subtitleSettings": "字幕設定",
|
||||||
|
"fontSize": "フォントサイズ",
|
||||||
|
"textColor": "文字色",
|
||||||
|
"backgroundColor": "背景色",
|
||||||
|
"position": "位置",
|
||||||
|
"opacity": "不透明度",
|
||||||
|
"top": "上",
|
||||||
|
"center": "中央",
|
||||||
|
"bottom": "下"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "IPAを生成",
|
"generateIPA": "IPAを生成",
|
||||||
"viewSavedItems": "保存済み項目を表示",
|
"viewSavedItems": "保存済み項目を表示",
|
||||||
"confirmDeleteAll": "すべて削除してもよろしいですか? (Y/N)"
|
"confirmDeleteAll": "すべて削除してもよろしいですか? (Y/N)",
|
||||||
|
"saved": "保存済み",
|
||||||
|
"clearAll": "すべてクリア",
|
||||||
|
"language": "言語",
|
||||||
|
"customLanguage": "または言語を入力...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "自動",
|
||||||
|
"chinese": "中国語",
|
||||||
|
"english": "英語",
|
||||||
|
"japanese": "日本語",
|
||||||
|
"korean": "韓国語",
|
||||||
|
"french": "フランス語",
|
||||||
|
"german": "ドイツ語",
|
||||||
|
"italian": "イタリア語",
|
||||||
|
"spanish": "スペイン語",
|
||||||
|
"portuguese": "ポルトガル語",
|
||||||
|
"russian": "ロシア語"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "言語を検出",
|
"detectLanguage": "言語を検出",
|
||||||
|
"sourceLanguage": "ソース言語",
|
||||||
|
"auto": "自動",
|
||||||
"generateIPA": "ipaを生成",
|
"generateIPA": "ipaを生成",
|
||||||
"translateInto": "翻訳先",
|
"translateInto": "翻訳先",
|
||||||
"chinese": "中国語",
|
"chinese": "中国語",
|
||||||
@@ -266,7 +471,20 @@
|
|||||||
"success": "テキストペアがフォルダーに追加されました",
|
"success": "テキストペアがフォルダーに追加されました",
|
||||||
"error": "テキストペアをフォルダーに追加できませんでした"
|
"error": "テキストペアをフォルダーに追加できませんでした"
|
||||||
},
|
},
|
||||||
"autoSave": "自動保存"
|
"autoSave": "自動保存",
|
||||||
|
"customLanguage": "または言語を入力...",
|
||||||
|
"pleaseLogin": "ログインしてカードを保存",
|
||||||
|
"pleaseCreateDeck": "先にデッキを作成",
|
||||||
|
"noTranslationToSave": "保存する翻訳なし",
|
||||||
|
"noDeckSelected": "デッキ未選択",
|
||||||
|
"saveAsCard": "カードとして保存",
|
||||||
|
"selectDeck": "デッキ選択",
|
||||||
|
"front": "表面",
|
||||||
|
"back": "裏面",
|
||||||
|
"cancel": "キャンセル",
|
||||||
|
"save": "保存",
|
||||||
|
"savedToDeck": "{deckName}に保存",
|
||||||
|
"saveFailed": "保存失敗"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "辞書",
|
"title": "辞書",
|
||||||
@@ -311,7 +529,9 @@
|
|||||||
"unfavorite": "お気に入り解除",
|
"unfavorite": "お気に入り解除",
|
||||||
"pleaseLogin": "まずログインしてください",
|
"pleaseLogin": "まずログインしてください",
|
||||||
"sortByFavorites": "お気に入り順に並べ替え",
|
"sortByFavorites": "お気に入り順に並べ替え",
|
||||||
"sortByFavoritesActive": "お気に入り順の並べ替えを解除"
|
"sortByFavoritesActive": "お気に入り順の並べ替えを解除",
|
||||||
|
"noDecks": "公開デッキなし",
|
||||||
|
"deckInfo": "{userName} · {totalCards}枚"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "フォルダー詳細",
|
"title": "フォルダー詳細",
|
||||||
@@ -325,7 +545,8 @@
|
|||||||
"unfavorite": "お気に入り解除",
|
"unfavorite": "お気に入り解除",
|
||||||
"favorited": "お気に入りに追加しました",
|
"favorited": "お気に入りに追加しました",
|
||||||
"unfavorited": "お気に入りから削除しました",
|
"unfavorited": "お気に入りから削除しました",
|
||||||
"pleaseLogin": "まずログインしてください"
|
"pleaseLogin": "まずログインしてください",
|
||||||
|
"totalCards": "{count}枚"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "マイお気に入り",
|
"title": "マイお気に入り",
|
||||||
@@ -347,14 +568,66 @@
|
|||||||
"notSet": "未設定",
|
"notSet": "未設定",
|
||||||
"memberSince": "登録日",
|
"memberSince": "登録日",
|
||||||
"logout": "ログアウト",
|
"logout": "ログアウト",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "フォルダー",
|
"button": "アカウント削除",
|
||||||
"noFolders": "まだフォルダーがありません",
|
"title": "アカウント削除",
|
||||||
"folderName": "フォルダー名",
|
"warning": "この操作は取り消せません。すべてのデータが完全に削除されます。",
|
||||||
"totalPairs": "合計ペア数",
|
"warningDecks": "すべてのデッキとカード",
|
||||||
|
"warningCards": "すべての学習履歴",
|
||||||
|
"warningHistory": "すべての翻訳と辞書の履歴",
|
||||||
|
"warningPermanent": "この操作は取り消せません",
|
||||||
|
"confirmLabel": "確認のためユーザー名を入力してください:",
|
||||||
|
"usernameMismatch": "ユーザー名が一致しません",
|
||||||
|
"cancel": "キャンセル",
|
||||||
|
"confirm": "アカウントを削除する",
|
||||||
|
"success": "アカウントが正常に削除されました",
|
||||||
|
"failed": "アカウントの削除に失敗しました"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "デッキ",
|
||||||
|
"noDecks": "まだデッキがありません",
|
||||||
|
"deckName": "デッキ名",
|
||||||
|
"totalCards": "合計カード数",
|
||||||
"createdAt": "作成日",
|
"createdAt": "作成日",
|
||||||
"actions": "アクション",
|
"actions": "アクション",
|
||||||
"view": "表示"
|
"view": "表示"
|
||||||
}
|
},
|
||||||
|
"joined": "登録日"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "デッキ",
|
||||||
|
"subtitle": "学習デッキを管理",
|
||||||
|
"newDeck": "新規デッキ",
|
||||||
|
"noDecksYet": "デッキなし",
|
||||||
|
"loading": "読込中...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards}枚",
|
||||||
|
"enterDeckName": "デッキ名:",
|
||||||
|
"enterNewName": "新しい名前:",
|
||||||
|
"confirmDelete": "削除確認:「{name}」を入力",
|
||||||
|
"public": "公開",
|
||||||
|
"private": "非公開",
|
||||||
|
"setPublic": "公開に設定",
|
||||||
|
"setPrivate": "非公開に設定",
|
||||||
|
"importApkg": "APKGインポート",
|
||||||
|
"exportApkg": "APKGエクスポート",
|
||||||
|
"clickToUpload": "クリックでアップロード",
|
||||||
|
"apkgFilesOnly": ".apkgのみ",
|
||||||
|
"parsing": "解析中...",
|
||||||
|
"foundDecks": "{count}デッキ発見",
|
||||||
|
"deckName": "デッキ名",
|
||||||
|
"back": "戻る",
|
||||||
|
"import": "インポート",
|
||||||
|
"importing": "インポート中...",
|
||||||
|
"exportSuccess": "エクスポート成功",
|
||||||
|
"goToDecks": "デッキへ"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "フォロー",
|
||||||
|
"following": "フォロー中",
|
||||||
|
"followers": "フォロワー",
|
||||||
|
"followersOf": "{username}のフォロワー",
|
||||||
|
"followingOf": "{username}のフォロー中",
|
||||||
|
"noFollowers": "まだフォロワーがいません",
|
||||||
|
"noFollowing": "まだ誰もフォローしていません"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,38 @@
|
|||||||
"unfavorite": "즐겨찾기 해제",
|
"unfavorite": "즐겨찾기 해제",
|
||||||
"pleaseLogin": "먼저 로그인해주세요"
|
"pleaseLogin": "먼저 로그인해주세요"
|
||||||
},
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "덱",
|
||||||
|
"noDecks": "덱이 없습니다",
|
||||||
|
"deckName": "덱 이름",
|
||||||
|
"totalCards": "총 카드",
|
||||||
|
"createdAt": "생성일",
|
||||||
|
"actions": "작업",
|
||||||
|
"view": "보기",
|
||||||
|
"subtitle": "학습 덱 관리",
|
||||||
|
"newDeck": "새 덱",
|
||||||
|
"noDecksYet": "덱이 없습니다",
|
||||||
|
"loading": "로딩 중...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards}장",
|
||||||
|
"enterDeckName": "덱 이름 입력:",
|
||||||
|
"enterNewName": "새 이름 입력:",
|
||||||
|
"confirmDelete": "삭제하려면 \"{name}\" 입력:",
|
||||||
|
"public": "공개",
|
||||||
|
"private": "비공개",
|
||||||
|
"setPublic": "공개로 설정",
|
||||||
|
"setPrivate": "비공개로 설정",
|
||||||
|
"importApkg": "APKG 가져오기",
|
||||||
|
"exportApkg": "APKG 내보내기",
|
||||||
|
"clickToUpload": "클릭하여 업로드",
|
||||||
|
"apkgFilesOnly": ".apkg 파일만",
|
||||||
|
"parsing": "파싱 중...",
|
||||||
|
"foundDecks": "{count}개 덱 발견",
|
||||||
|
"back": "뒤로",
|
||||||
|
"import": "가져오기",
|
||||||
|
"importing": "가져오는 중...",
|
||||||
|
"exportSuccess": "내보내기 성공",
|
||||||
|
"goToDecks": "덱으로"
|
||||||
|
},
|
||||||
"folder_id": {
|
"folder_id": {
|
||||||
"unauthorized": "이 폴더의 소유자가 아닙니다",
|
"unauthorized": "이 폴더의 소유자가 아닙니다",
|
||||||
"back": "뒤로",
|
"back": "뒤로",
|
||||||
@@ -74,6 +106,77 @@
|
|||||||
"deleteFolder": "이 폴더를 삭제할 권한이 없습니다."
|
"deleteFolder": "이 폴더를 삭제할 권한이 없습니다."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "이 덱의 소유자가 아닙니다",
|
||||||
|
"back": "뒤로",
|
||||||
|
"cards": "카드",
|
||||||
|
"itemsCount": "{count}개",
|
||||||
|
"memorize": "암기",
|
||||||
|
"loadingCards": "카드 불러오는 중...",
|
||||||
|
"noCards": "이 덱에 카드가 없습니다",
|
||||||
|
"card": "카드",
|
||||||
|
"addNewCard": "새 카드 추가",
|
||||||
|
"add": "추가",
|
||||||
|
"adding": "추가 중...",
|
||||||
|
"updateCard": "카드 업데이트",
|
||||||
|
"update": "업데이트",
|
||||||
|
"updating": "업데이트 중...",
|
||||||
|
"word": "단어",
|
||||||
|
"definition": "정의",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"example": "예문",
|
||||||
|
"wordAndDefinitionRequired": "단어와 정의는 필수입니다",
|
||||||
|
"edit": "편집",
|
||||||
|
"delete": "삭제",
|
||||||
|
"permissionDenied": "이 작업을 수행할 권한이 없습니다",
|
||||||
|
"resetProgress": "진행 초기화",
|
||||||
|
"resetProgressTitle": "학습 진행 초기화",
|
||||||
|
"resetProgressConfirm": "이 덱의 학습 진행을 초기화하시겠습니까?",
|
||||||
|
"resetSuccess": "초기화됨",
|
||||||
|
"resetting": "초기화 중...",
|
||||||
|
"cancel": "취소",
|
||||||
|
"settings": "설정",
|
||||||
|
"settingsTitle": "덱 설정",
|
||||||
|
"newPerDay": "일일 새 카드",
|
||||||
|
"newPerDayHint": "매일 학습할 새 카드 수",
|
||||||
|
"revPerDay": "일일 복습",
|
||||||
|
"revPerDayHint": "매일 복습할 카드 수",
|
||||||
|
"save": "저장",
|
||||||
|
"saving": "저장 중...",
|
||||||
|
"settingsSaved": "설정 저장됨",
|
||||||
|
"todayNew": "오늘 새 카드",
|
||||||
|
"todayReview": "오늘 복습",
|
||||||
|
"todayLearning": "학습 중",
|
||||||
|
"error": {
|
||||||
|
"update": "업데이트 권한이 없습니다",
|
||||||
|
"delete": "삭제 권한이 없습니다",
|
||||||
|
"add": "추가 권한이 없습니다"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "IPA 입력",
|
||||||
|
"examplePlaceholder": "예문 입력",
|
||||||
|
"wordRequired": "단어를 입력하세요",
|
||||||
|
"definitionRequired": "정의를 입력하세요",
|
||||||
|
"cardAdded": "카드 추가됨",
|
||||||
|
"cardType": "카드 유형",
|
||||||
|
"wordCard": "단어 카드",
|
||||||
|
"phraseCard": "구문 카드",
|
||||||
|
"sentenceCard": "문장 카드",
|
||||||
|
"sentence": "문장",
|
||||||
|
"sentencePlaceholder": "문장 입력",
|
||||||
|
"wordPlaceholder": "단어 입력",
|
||||||
|
"queryLang": "검색 언어",
|
||||||
|
"enterLanguageName": "언어 이름을 입력하세요",
|
||||||
|
"english": "영어",
|
||||||
|
"chinese": "중국어",
|
||||||
|
"japanese": "일본어",
|
||||||
|
"korean": "한국어",
|
||||||
|
"meanings": "의미",
|
||||||
|
"addMeaning": "의미 추가",
|
||||||
|
"partOfSpeech": "품사",
|
||||||
|
"deleteConfirm": "이 카드를 삭제하시겠습니까?",
|
||||||
|
"cardDeleted": "카드 삭제됨",
|
||||||
|
"cardUpdated": "카드 업데이트됨"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "언어 배우기",
|
"title": "언어 배우기",
|
||||||
"description": "세계의 거의 모든 언어(인공어 포함)를 배우는 데 도움이 되는 매우 유용한 웹사이트입니다.",
|
"description": "세계의 거의 모든 언어(인공어 포함)를 배우는 데 도움이 되는 매우 유용한 웹사이트입니다.",
|
||||||
@@ -157,6 +260,9 @@
|
|||||||
"resetPasswordFailed": "재설정 이메일 전송 실패",
|
"resetPasswordFailed": "재설정 이메일 전송 실패",
|
||||||
"resetPasswordEmailSent": "재설정 이메일이 전송되었습니다",
|
"resetPasswordEmailSent": "재설정 이메일이 전송되었습니다",
|
||||||
"resetPasswordEmailSentHint": "비밀번호 재설정 링크를 이메일로 보냈습니다. 받은 편지함을 확인해주세요.",
|
"resetPasswordEmailSentHint": "비밀번호 재설정 링크를 이메일로 보냈습니다. 받은 편지함을 확인해주세요.",
|
||||||
|
"verifyYourEmail": "이메일 인증",
|
||||||
|
"verificationEmailSent": "인증 이메일이 전송되었습니다",
|
||||||
|
"verificationEmailSentHint": "{email}로 인증 이메일을 보냈습니다. 이메일의 링크를 클릭하여 계정을 인증해주세요.",
|
||||||
"checkYourEmail": "이메일을 확인하세요",
|
"checkYourEmail": "이메일을 확인하세요",
|
||||||
"backToLogin": "로그인으로 돌아가기",
|
"backToLogin": "로그인으로 돌아가기",
|
||||||
"resetPassword": "비밀번호 재설정",
|
"resetPassword": "비밀번호 재설정",
|
||||||
@@ -166,25 +272,47 @@
|
|||||||
"requestNewToken": "새 재설정 링크 요청",
|
"requestNewToken": "새 재설정 링크 요청",
|
||||||
"resetPasswordSuccess": "비밀번호 재설정 성공",
|
"resetPasswordSuccess": "비밀번호 재설정 성공",
|
||||||
"resetPasswordSuccessTitle": "비밀번호 재설정 완료",
|
"resetPasswordSuccessTitle": "비밀번호 재설정 완료",
|
||||||
"resetPasswordSuccessHint": "비밀번호가 성공적으로 재설정되었습니다. 새 비밀번호로 로그인할 수 있습니다."
|
"resetPasswordSuccessHint": "비밀번호가 성공적으로 재설정되었습니다. 새 비밀번호로 로그인할 수 있습니다.",
|
||||||
|
"emailNotVerified": "이메일 주소를 인증해 주세요",
|
||||||
|
"emailNotVerifiedHint": "이메일이 인증되지 않았습니다. 받은 편지함을 확인하거나 새 인증 이메일을 요청해 주세요.",
|
||||||
|
"resendVerification": "인증 이메일 다시 보내기",
|
||||||
|
"resendSuccess": "인증 이메일이 발송되었습니다! 받은 편지함을 확인해 주세요.",
|
||||||
|
"resendFailed": "인증 이메일 발송에 실패했습니다"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "폴더 선택",
|
"selectDeck": "덱 선택",
|
||||||
"noFolders": "폴더를 찾을 수 없습니다",
|
"noDecks": "덱이 없습니다",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "덱으로 이동",
|
||||||
|
"noCards": "카드가 없습니다",
|
||||||
|
"new": "새로",
|
||||||
|
"learning": "학습 중",
|
||||||
|
"review": "복습",
|
||||||
|
"due": "예정"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "정답",
|
"loading": "로딩 중...",
|
||||||
"next": "다음",
|
"backToDecks": "덱으로 돌아가기",
|
||||||
"reverse": "반대",
|
"allDone": "모두 완료!",
|
||||||
"dictation": "받아쓰기",
|
"allDoneDesc": "오늘의 학습을 완료했습니다!",
|
||||||
"noTextPairs": "사용 가능한 텍스트 쌍이 없습니다",
|
"reviewedCount": "{count}장 복습 완료",
|
||||||
"disorder": "무작위",
|
"progress": "{current} / {total}",
|
||||||
"previous": "이전"
|
"nextReview": "다음 복습",
|
||||||
|
"interval": "간격",
|
||||||
|
"ease": "난이도",
|
||||||
|
"lapses": "실패 횟수",
|
||||||
|
"showAnswer": "정답 보기",
|
||||||
|
"nextCard": "다음",
|
||||||
|
"again": "다시",
|
||||||
|
"restart": "다시 시작",
|
||||||
|
"orderLimited": "순서 제한",
|
||||||
|
"orderInfinite": "순서 무제한",
|
||||||
|
"randomLimited": "무작위 제한",
|
||||||
|
"randomInfinite": "무작위 무제한",
|
||||||
|
"noIpa": "IPA 없음"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "이 폴더에 접근할 권한이 없습니다"
|
"unauthorized": "권한이 없습니다"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
@@ -192,15 +320,66 @@
|
|||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "로그인",
|
"sign_in": "로그인",
|
||||||
"profile": "프로필",
|
"profile": "프로필",
|
||||||
"folders": "폴더",
|
"folders": "덱",
|
||||||
"explore": "탐색",
|
"explore": "탐색",
|
||||||
"favorites": "즐겨찾기"
|
"favorites": "즐겨찾기",
|
||||||
|
"settings": "설정"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR 인식",
|
||||||
|
"description": "이미지에서 텍스트 추출",
|
||||||
|
"uploadImage": "이미지 업로드",
|
||||||
|
"dragDropHint": "드래그 앤 드롭",
|
||||||
|
"supportedFormats": "지원 형식: JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "덱 선택",
|
||||||
|
"chooseDeck": "덱 선택",
|
||||||
|
"noDecks": "덱이 없습니다",
|
||||||
|
"languageHints": "언어 힌트",
|
||||||
|
"sourceLanguageHint": "원본 언어 힌트",
|
||||||
|
"targetLanguageHint": "대상 언어 힌트",
|
||||||
|
"process": "처리",
|
||||||
|
"processing": "처리 중...",
|
||||||
|
"preview": "미리보기",
|
||||||
|
"extractedPairs": "추출된 쌍",
|
||||||
|
"word": "단어",
|
||||||
|
"definition": "정의",
|
||||||
|
"pairsCount": "{count}쌍",
|
||||||
|
"savePairs": "저장",
|
||||||
|
"saving": "저장 중...",
|
||||||
|
"saved": "저장됨",
|
||||||
|
"saveFailed": "저장 실패",
|
||||||
|
"noImage": "이미지를 업로드하세요",
|
||||||
|
"noDeck": "덱을 선택하세요",
|
||||||
|
"processingFailed": "처리 실패",
|
||||||
|
"tryAgain": "재시도",
|
||||||
|
"detectedLanguages": "감지된 언어",
|
||||||
|
"uploadSection": "이미지 업로드",
|
||||||
|
"dropOrClick": "드롭 또는 클릭",
|
||||||
|
"changeImage": "이미지 변경",
|
||||||
|
"invalidFileType": "잘못된 파일 형식",
|
||||||
|
"deckSelection": "덱 선택",
|
||||||
|
"sourceLanguagePlaceholder": "예: 영어",
|
||||||
|
"targetLanguagePlaceholder": "예: 한국어",
|
||||||
|
"processButton": "인식 시작",
|
||||||
|
"resultsPreview": "결과 미리보기",
|
||||||
|
"saveButton": "덱에 저장",
|
||||||
|
"ocrSuccess": "OCR 성공",
|
||||||
|
"ocrFailed": "OCR 실패",
|
||||||
|
"savedToDeck": "덱에 저장됨",
|
||||||
|
"noResultsToSave": "저장할 결과 없음",
|
||||||
|
"detectedSourceLanguage": "감지된 원본 언어",
|
||||||
|
"detectedTargetLanguage": "감지된 대상 언어"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "내 프로필",
|
"myProfile": "내 프로필",
|
||||||
"email": "이메일: {email}",
|
"email": "이메일: {email}",
|
||||||
"logout": "로그아웃"
|
"logout": "로그아웃"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "설정",
|
||||||
|
"themeColor": "테마 색상",
|
||||||
|
"themeColorDescription": "원하는 테마 색상을 선택하세요"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "비디오 업로드",
|
"uploadVideo": "비디오 업로드",
|
||||||
"uploadSubtitle": "자막 업로드",
|
"uploadSubtitle": "자막 업로드",
|
||||||
@@ -230,15 +409,48 @@
|
|||||||
"videoUploadFailed": "비디오 업로드 실패",
|
"videoUploadFailed": "비디오 업로드 실패",
|
||||||
"subtitleUploadFailed": "자막 업로드 실패",
|
"subtitleUploadFailed": "자막 업로드 실패",
|
||||||
"subtitleLoadSuccess": "자막 로드 성공",
|
"subtitleLoadSuccess": "자막 로드 성공",
|
||||||
"subtitleLoadFailed": "자막 로드 실패"
|
"subtitleLoadFailed": "자막 로드 실패",
|
||||||
|
"settings": "설정",
|
||||||
|
"shortcuts": "단축키",
|
||||||
|
"keyboardShortcuts": "키보드 단축키",
|
||||||
|
"playPause": "재생/일시정지",
|
||||||
|
"autoPauseToggle": "자동 일시정지",
|
||||||
|
"subtitleSettings": "자막 설정",
|
||||||
|
"fontSize": "글꼴 크기",
|
||||||
|
"textColor": "글자 색",
|
||||||
|
"backgroundColor": "배경색",
|
||||||
|
"position": "위치",
|
||||||
|
"opacity": "불투명도",
|
||||||
|
"top": "위",
|
||||||
|
"center": "중앙",
|
||||||
|
"bottom": "아래"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "IPA 생성",
|
"generateIPA": "IPA 생성",
|
||||||
"viewSavedItems": "저장된 항목 보기",
|
"viewSavedItems": "저장된 항목 보기",
|
||||||
"confirmDeleteAll": "모든 것을 삭제하시겠습니까? (Y/N)"
|
"confirmDeleteAll": "모든 것을 삭제하시겠습니까? (Y/N)",
|
||||||
|
"saved": "저장됨",
|
||||||
|
"clearAll": "모두 지우기",
|
||||||
|
"language": "언어",
|
||||||
|
"customLanguage": "또는 언어 입력...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "자동",
|
||||||
|
"chinese": "중국어",
|
||||||
|
"english": "영어",
|
||||||
|
"japanese": "일본어",
|
||||||
|
"korean": "한국어",
|
||||||
|
"french": "프랑스어",
|
||||||
|
"german": "독일어",
|
||||||
|
"italian": "이탈리아어",
|
||||||
|
"spanish": "스페인어",
|
||||||
|
"portuguese": "포르투갈어",
|
||||||
|
"russian": "러시아어"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "언어 감지",
|
"detectLanguage": "언어 감지",
|
||||||
|
"sourceLanguage": "원본 언어",
|
||||||
|
"auto": "자동",
|
||||||
"generateIPA": "IPA 생성",
|
"generateIPA": "IPA 생성",
|
||||||
"translateInto": "번역할 언어",
|
"translateInto": "번역할 언어",
|
||||||
"chinese": "중국어",
|
"chinese": "중국어",
|
||||||
@@ -266,7 +478,20 @@
|
|||||||
"success": "텍스트 쌍이 폴더에 추가됨",
|
"success": "텍스트 쌍이 폴더에 추가됨",
|
||||||
"error": "폴더에 텍스트 쌍 추가 실패"
|
"error": "폴더에 텍스트 쌍 추가 실패"
|
||||||
},
|
},
|
||||||
"autoSave": "자동 저장"
|
"autoSave": "자동 저장",
|
||||||
|
"customLanguage": "또는 언어 입력...",
|
||||||
|
"pleaseLogin": "카드를 저장하려면 로그인하세요",
|
||||||
|
"pleaseCreateDeck": "먼저 덱을 만드세요",
|
||||||
|
"noTranslationToSave": "저장할 번역이 없습니다",
|
||||||
|
"noDeckSelected": "덱이 선택되지 않았습니다",
|
||||||
|
"saveAsCard": "카드로 저장",
|
||||||
|
"selectDeck": "덱 선택",
|
||||||
|
"front": "앞면",
|
||||||
|
"back": "뒷면",
|
||||||
|
"cancel": "취소",
|
||||||
|
"save": "저장",
|
||||||
|
"savedToDeck": "{deckName}에 카드 저장됨",
|
||||||
|
"saveFailed": "카드 저장 실패"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "사전",
|
"title": "사전",
|
||||||
@@ -311,7 +536,9 @@
|
|||||||
"unfavorite": "즐겨찾기 해제",
|
"unfavorite": "즐겨찾기 해제",
|
||||||
"pleaseLogin": "먼저 로그인해주세요",
|
"pleaseLogin": "먼저 로그인해주세요",
|
||||||
"sortByFavorites": "즐겨찾기순 정렬",
|
"sortByFavorites": "즐겨찾기순 정렬",
|
||||||
"sortByFavoritesActive": "즐겨찾기순 정렬 해제"
|
"sortByFavoritesActive": "즐겨찾기순 정렬 해제",
|
||||||
|
"noDecks": "공개 덱 없음",
|
||||||
|
"deckInfo": "{userName} · {totalCards}장"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "폴더 상세",
|
"title": "폴더 상세",
|
||||||
@@ -325,7 +552,8 @@
|
|||||||
"unfavorite": "즐겨찾기 해제",
|
"unfavorite": "즐겨찾기 해제",
|
||||||
"favorited": "즐겨찾기됨",
|
"favorited": "즐겨찾기됨",
|
||||||
"unfavorited": "즐겨찾기 해제됨",
|
"unfavorited": "즐겨찾기 해제됨",
|
||||||
"pleaseLogin": "먼저 로그인해주세요"
|
"pleaseLogin": "먼저 로그인해주세요",
|
||||||
|
"totalCards": "총 {count}장"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "내 즐겨찾기",
|
"title": "내 즐겨찾기",
|
||||||
@@ -347,14 +575,48 @@
|
|||||||
"notSet": "설정되지 않음",
|
"notSet": "설정되지 않음",
|
||||||
"memberSince": "가입일",
|
"memberSince": "가입일",
|
||||||
"logout": "로그아웃",
|
"logout": "로그아웃",
|
||||||
|
"deleteAccount": {
|
||||||
|
"button": "계정 삭제",
|
||||||
|
"title": "계정 삭제",
|
||||||
|
"warning": "이 작업은 되돌릴 수 없습니다. 모든 데이터가 영구적으로 삭제됩니다.",
|
||||||
|
"warningDecks": "모든 덱과 카드",
|
||||||
|
"warningCards": "모든 학습 진행 상황",
|
||||||
|
"warningHistory": "모든 번역 및 사전 기록",
|
||||||
|
"warningPermanent": "이 작업은 취소할 수 없습니다",
|
||||||
|
"confirmLabel": "확인을 위해 사용자명을 입력하세요:",
|
||||||
|
"usernameMismatch": "사용자명이 일치하지 않습니다",
|
||||||
|
"cancel": "취소",
|
||||||
|
"confirm": "내 계정 삭제",
|
||||||
|
"success": "계정이 성공적으로 삭제되었습니다",
|
||||||
|
"failed": "계정 삭제에 실패했습니다"
|
||||||
|
},
|
||||||
"folders": {
|
"folders": {
|
||||||
"title": "폴더",
|
"title": "덱",
|
||||||
"noFolders": "아직 폴더가 없습니다",
|
"noFolders": "아직 덱이 없습니다",
|
||||||
"folderName": "폴더 이름",
|
"folderName": "덱 이름",
|
||||||
"totalPairs": "총 쌍",
|
"totalPairs": "총 카드 수",
|
||||||
|
"createdAt": "생성일",
|
||||||
|
"actions": "작업",
|
||||||
|
"view": "보기"
|
||||||
|
},
|
||||||
|
"joined": "가입일",
|
||||||
|
"decks": {
|
||||||
|
"title": "내 덱",
|
||||||
|
"noDecks": "덱이 없습니다",
|
||||||
|
"deckName": "덱 이름",
|
||||||
|
"totalCards": "총 카드",
|
||||||
"createdAt": "생성일",
|
"createdAt": "생성일",
|
||||||
"actions": "작업",
|
"actions": "작업",
|
||||||
"view": "보기"
|
"view": "보기"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "팔로우",
|
||||||
|
"following": "팔로잉",
|
||||||
|
"followers": "팔로워",
|
||||||
|
"followersOf": "{username}의 팔로워",
|
||||||
|
"followingOf": "{username}의 팔로잉",
|
||||||
|
"noFollowers": "아직 팔로워가 없습니다",
|
||||||
|
"noFollowing": "아직 팔로우하는 사람이 없습니다"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,38 @@
|
|||||||
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
||||||
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ"
|
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ"
|
||||||
},
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "دېكلار",
|
||||||
|
"noDecks": "تېخى دېك يوق",
|
||||||
|
"deckName": "دېك ئاتى",
|
||||||
|
"totalCards": "جەمئىي كارتا",
|
||||||
|
"createdAt": "قۇرۇلغان ۋاقتى",
|
||||||
|
"actions": "مەشغۇلاتلار",
|
||||||
|
"view": "كۆرۈش",
|
||||||
|
"subtitle": "دېكلەرنى باشقۇرۇڭ",
|
||||||
|
"newDeck": "يېڭى دېك",
|
||||||
|
"noDecksYet": "دېك يوق",
|
||||||
|
"loading": "يۈكلىنىۋاتىدۇ...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards} كارتا",
|
||||||
|
"enterDeckName": "دېك ئاتى:",
|
||||||
|
"enterNewName": "يېڭى ئات:",
|
||||||
|
"confirmDelete": "ئۆچۈرۈش: \"{name}\"",
|
||||||
|
"public": "ئاممىۋىي",
|
||||||
|
"private": "شەخسىي",
|
||||||
|
"setPublic": "ئاممىۋىي قىلىش",
|
||||||
|
"setPrivate": "شەخسىي قىلىش",
|
||||||
|
"importApkg": "APKG ئەكىرىش",
|
||||||
|
"exportApkg": "APKG چىقىرىش",
|
||||||
|
"clickToUpload": "چېكىپ يۈكلەش",
|
||||||
|
"apkgFilesOnly": ".apkg ھۆججىتىلا",
|
||||||
|
"parsing": "تەھلىل قىلىنىۋاتىدۇ...",
|
||||||
|
"foundDecks": "{count} دېك تېپىلدى",
|
||||||
|
"back": "قايتىش",
|
||||||
|
"import": "ئەكىرىش",
|
||||||
|
"importing": "ئەكىرىلىۋاتىدۇ...",
|
||||||
|
"exportSuccess": "چىقىرىش مۇۋەپپەقىيەتلىك",
|
||||||
|
"goToDecks": "دېكلەرگە بېرىش"
|
||||||
|
},
|
||||||
"folder_id": {
|
"folder_id": {
|
||||||
"unauthorized": "بۇ قىسقۇچنىڭ ئىگىسى ئەمەسسىز",
|
"unauthorized": "بۇ قىسقۇچنىڭ ئىگىسى ئەمەسسىز",
|
||||||
"back": "قايتىش",
|
"back": "قايتىش",
|
||||||
@@ -74,6 +106,77 @@
|
|||||||
"deleteFolder": "بۇ قىسقۇچنى ئۆچۈرۈش ھوقۇقىڭىز يوق."
|
"deleteFolder": "بۇ قىسقۇچنى ئۆچۈرۈش ھوقۇقىڭىز يوق."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "بۇ دېكنىڭ ئىگىسى ئەمەس",
|
||||||
|
"back": "قايتىش",
|
||||||
|
"cards": "كارتلار",
|
||||||
|
"itemsCount": "{count} تۈر",
|
||||||
|
"memorize": "يادلاش",
|
||||||
|
"loadingCards": "كارتلار يۈكلىنىۋاتىدۇ...",
|
||||||
|
"noCards": "بۇ دېكتا كارت يوق",
|
||||||
|
"card": "كارتا",
|
||||||
|
"addNewCard": "يېڭى كارتا قوشۇش",
|
||||||
|
"add": "قوشۇش",
|
||||||
|
"adding": "قوشۇلىۋاتىدۇ...",
|
||||||
|
"updateCard": "كارتىنى يېڭىلاش",
|
||||||
|
"update": "يېڭىلاش",
|
||||||
|
"updating": "يېڭىلىنىۋاتىدۇ...",
|
||||||
|
"word": "سۆز",
|
||||||
|
"definition": "ئېنىقلىما",
|
||||||
|
"ipa": "IPA",
|
||||||
|
"example": "مىسال",
|
||||||
|
"wordAndDefinitionRequired": "سۆز ۋە ئېنىقلىما زۆرۈر",
|
||||||
|
"edit": "تەھرىرلەش",
|
||||||
|
"delete": "ئۆچۈرۈش",
|
||||||
|
"permissionDenied": "بۇ مەشغۇلاتنى ئېلىپ بېرىش ھوقۇقىڭىز يوق",
|
||||||
|
"resetProgress": "ئىلگىرىلەشنى ئەسلىگە قايتۇرۇش",
|
||||||
|
"resetProgressTitle": "ئۆگىنىش ئىلگىرىلەشىنى ئەسلىگە قايتۇرۇش",
|
||||||
|
"resetProgressConfirm": "ئىلگىرىلەشنى ئەسلىگە قايتۇرامسىز؟",
|
||||||
|
"resetSuccess": "ئەسلىگە قايتۇرۇلدى",
|
||||||
|
"resetting": "ئەسلىگە قايتۇرۇۋاتىدۇ...",
|
||||||
|
"cancel": "بىكار قىلىش",
|
||||||
|
"settings": "تەڭشەكلەر",
|
||||||
|
"settingsTitle": "دېك تەڭشەكلىرى",
|
||||||
|
"newPerDay": "كۈندىلىك يېڭى",
|
||||||
|
"newPerDayHint": "كۈندە يېڭى كارتا سانى",
|
||||||
|
"revPerDay": "كۈندىلىك تەكرار",
|
||||||
|
"revPerDayHint": "كۈندە تەكرار سانى",
|
||||||
|
"save": "ساقلاش",
|
||||||
|
"saving": "ساقلاۋاتىدۇ...",
|
||||||
|
"settingsSaved": "تەڭشەكلەر ساقلاندى",
|
||||||
|
"todayNew": "بۈگۈنكى يېڭى",
|
||||||
|
"todayReview": "بۈگۈنكى تەكرار",
|
||||||
|
"todayLearning": "ئۆگىنىۋاتىدۇ",
|
||||||
|
"error": {
|
||||||
|
"update": "يېڭىلاش ھوقۇقى يوق",
|
||||||
|
"delete": "ئۆچۈرۈش ھوقۇقى يوق",
|
||||||
|
"add": "قوشۇش ھوقۇقى يوق"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "IPA كىرگۈزۈڭ",
|
||||||
|
"examplePlaceholder": "مىسال كىرگۈزۈڭ",
|
||||||
|
"wordRequired": "سۆز كىرگۈزۈڭ",
|
||||||
|
"definitionRequired": "ئېنىقلىما كىرگۈزۈڭ",
|
||||||
|
"cardAdded": "كارتا قوشۇلدى",
|
||||||
|
"cardType": "كارتا تىپى",
|
||||||
|
"wordCard": "سۆز كارتىسى",
|
||||||
|
"phraseCard": "جۈملە كارتىسى",
|
||||||
|
"sentenceCard": "جۈملە كارتىسى",
|
||||||
|
"sentence": "جۈملە",
|
||||||
|
"sentencePlaceholder": "جۈملە كىرگۈزۈڭ",
|
||||||
|
"wordPlaceholder": "سۆز كىرگۈزۈڭ",
|
||||||
|
"queryLang": "سۈرۈشتۈرۈش تىلى",
|
||||||
|
"enterLanguageName": "تىل ئاتىنى كىرگۈزۈڭ",
|
||||||
|
"english": "ئىنگىلىزچە",
|
||||||
|
"chinese": "خەنزۇچە",
|
||||||
|
"japanese": "ياپونچە",
|
||||||
|
"korean": "كورىيەچە",
|
||||||
|
"meanings": "مەنىلىرى",
|
||||||
|
"addMeaning": "مەنا قوشۇش",
|
||||||
|
"partOfSpeech": "سۆز بۆلىكى",
|
||||||
|
"deleteConfirm": "بۇ كارتىنى ئۆچۈرەمسىز؟",
|
||||||
|
"cardDeleted": "كارتا ئۆچۈرۈلدى",
|
||||||
|
"cardUpdated": "كارتا يېڭىلاندى"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "تىل ئۆگىنىش",
|
"title": "تىل ئۆگىنىش",
|
||||||
"description": "بۇ دۇنيادىكى almost ھەر بىر تىلنى، جۈملىدىن سۈنئىي تىللارنى ئۆگىنىشىڭىزگە ياردەم بېرىدىغان ئىنتايىن قوللىنىشلىق تور بېكەت.",
|
"description": "بۇ دۇنيادىكى almost ھەر بىر تىلنى، جۈملىدىن سۈنئىي تىللارنى ئۆگىنىشىڭىزگە ياردەم بېرىدىغان ئىنتايىن قوللىنىشلىق تور بېكەت.",
|
||||||
@@ -157,6 +260,9 @@
|
|||||||
"resetPasswordFailed": "ئەسلىگە قايتۇرۇش ئېلخېتى ئەۋەتىش مەغلۇپ بولدى",
|
"resetPasswordFailed": "ئەسلىگە قايتۇرۇش ئېلخېتى ئەۋەتىش مەغلۇپ بولدى",
|
||||||
"resetPasswordEmailSent": "ئەسلىگە قايتۇرۇش ئېلخېتى مۇۋەپپەقىيەتلىك ئەۋەتىلدى",
|
"resetPasswordEmailSent": "ئەسلىگە قايتۇرۇش ئېلخېتى مۇۋەپپەقىيەتلىك ئەۋەتىلدى",
|
||||||
"resetPasswordEmailSentHint": "پارولنى ئەسلىگە قايتۇرۇش ئۇلانمىسىنى ئېلخەت ئادرېسىڭىزغا ئەۋەتتۇق. ئېلخەت ساندۇقىڭىزنى تەكشۈرۈڭ.",
|
"resetPasswordEmailSentHint": "پارولنى ئەسلىگە قايتۇرۇش ئۇلانمىسىنى ئېلخەت ئادرېسىڭىزغا ئەۋەتتۇق. ئېلخەت ساندۇقىڭىزنى تەكشۈرۈڭ.",
|
||||||
|
"verifyYourEmail": "ئېلخەتنى دەلىللەش",
|
||||||
|
"verificationEmailSent": "دەلىللەش ئېلخېتى ئەۋەتىلدى",
|
||||||
|
"verificationEmailSentHint": "{email} غا دەلىللەش ئېلخېتى ئەۋەتتۇق. ئېلخەتتىكى ئۇلانمىنى چېكىپ ھېساباتىڭىزنى دەلىللەڭ.",
|
||||||
"checkYourEmail": "ئېلخېتىڭىزنى تەكشۈرۈڭ",
|
"checkYourEmail": "ئېلخېتىڭىزنى تەكشۈرۈڭ",
|
||||||
"backToLogin": "كىرىشكە قايتىش",
|
"backToLogin": "كىرىشكە قايتىش",
|
||||||
"resetPassword": "پارولنى ئەسلىگە قايتۇرۇش",
|
"resetPassword": "پارولنى ئەسلىگە قايتۇرۇش",
|
||||||
@@ -166,41 +272,139 @@
|
|||||||
"requestNewToken": "يېڭى ئەسلىگە قايتۇرۇش ئۇلانمىسى سوراش",
|
"requestNewToken": "يېڭى ئەسلىگە قايتۇرۇش ئۇلانمىسى سوراش",
|
||||||
"resetPasswordSuccess": "پارول مۇۋەپپەقىيەتلىك ئەسلىگە قايتۇرۇلدى",
|
"resetPasswordSuccess": "پارول مۇۋەپپەقىيەتلىك ئەسلىگە قايتۇرۇلدى",
|
||||||
"resetPasswordSuccessTitle": "پارول ئەسلىگە قايتۇرۇش تاماملاندى",
|
"resetPasswordSuccessTitle": "پارول ئەسلىگە قايتۇرۇش تاماملاندى",
|
||||||
"resetPasswordSuccessHint": "پارولىڭىز مۇۋەپپەقىيەتلىك ئەسلىگە قايتۇرۇلدى. يېڭى پارول بىلەن كىرسىڭىز بولىدۇ."
|
"resetPasswordSuccessHint": "پارولىڭىز مۇۋەپپەقىيەتلىك ئەسلىگە قايتۇرۇلدى. يېڭى پارول بىلەن كىرسىڭىز بولىدۇ.",
|
||||||
|
"emailNotVerified": "ئېلخەت ئادرېسىڭىزنى دەلىللەڭ",
|
||||||
|
"emailNotVerifiedHint": "ئېلخەت ئادرېسىڭىز دەلىللەنمىگەن. ئېلخەت ساندۇقىڭىزنى تەكشۈرۈڭ ياكى يېڭى دەلىللەش ئېلخېتى سوراڭ.",
|
||||||
|
"resendVerification": "دەلىللەش ئېلخېتىنى قايتا ئەۋەتىش",
|
||||||
|
"resendSuccess": "دەلىللەش ئېلخېتى ئەۋەتىلدى! ئېلخەت ساندۇقىڭىزنى تەكشۈرۈڭ.",
|
||||||
|
"resendFailed": "دەلىللەش ئېلخېتى ئەۋەتىش مەغلۇپ بولدى"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "بىر قىسقۇچ تاللاڭ",
|
"selectDeck": "دېك تاللاش",
|
||||||
"noFolders": "قىسقۇچ تېپىلمىدى",
|
"noDecks": "دېك يوق",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "دېكلەرگە بار",
|
||||||
|
"noCards": "كارتا يوق",
|
||||||
|
"new": "يېڭى",
|
||||||
|
"learning": "ئۆگىنىش",
|
||||||
|
"review": "تەكرار",
|
||||||
|
"due": "ۋاقتى كەلدى"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "جاۋاب",
|
"loading": "يۈكلىنىۋاتىدۇ...",
|
||||||
"next": "كېيىنكى",
|
"backToDecks": "دېكلەرگە قايتىش",
|
||||||
"reverse": "تەتۈر",
|
"allDone": "ھەممىسى تامام!",
|
||||||
"dictation": "دىكتات",
|
"allDoneDesc": "بۈگۈنكى ئۆگىنىش تامام!",
|
||||||
"noTextPairs": "تېكىست جۈپى يوق",
|
"reviewedCount": "{count} كارتا تەكرارلاندى",
|
||||||
"disorder": "قالايمىقانلاشتۇرۇش",
|
"progress": "{current} / {total}",
|
||||||
"previous": "ئالدىنقى"
|
"nextReview": "كېيىنكى تەكرار",
|
||||||
|
"interval": "ئارىلىق",
|
||||||
|
"ease": "قىيىنلىق",
|
||||||
|
"lapses": "خاتالىق",
|
||||||
|
"showAnswer": "جاۋابنى كۆرسەت",
|
||||||
|
"nextCard": "كېيىنكى",
|
||||||
|
"again": "يەنە",
|
||||||
|
"hard": "قىيىن",
|
||||||
|
"good": "ياخشى",
|
||||||
|
"easy": "ئاسان",
|
||||||
|
"now": "ھازىر",
|
||||||
|
"lessThanMinute": "1 مىنۇتتىن ئاز",
|
||||||
|
"inMinutes": "{n} مىنۇتتىن كېيىن",
|
||||||
|
"inHours": "{n} سائەتتىن كېيىن",
|
||||||
|
"inDays": "{n} كۈندىن كېيىن",
|
||||||
|
"inMonths": "{n} ئايدىن كېيىن",
|
||||||
|
"minutes": "مىنۇت",
|
||||||
|
"days": "كۈن",
|
||||||
|
"months": "ئاي",
|
||||||
|
"minAbbr": "مىن",
|
||||||
|
"dayAbbr": "كۈن",
|
||||||
|
"cardTypeNew": "يېڭى",
|
||||||
|
"cardTypeLearning": "ئۆگىنىش",
|
||||||
|
"cardTypeReview": "تەكرار",
|
||||||
|
"cardTypeRelearning": "قايتا ئۆگىنىش",
|
||||||
|
"reverse": "ئەكسىچە",
|
||||||
|
"dictation": "ئىملا",
|
||||||
|
"clickToPlay": "چېكىپ قويۇش",
|
||||||
|
"yourAnswer": "جاۋابىڭىز",
|
||||||
|
"typeWhatYouHear": "ئاڭلىغىنىڭىزنى يېزىڭ",
|
||||||
|
"correct": "توغرا!",
|
||||||
|
"incorrect": "خاتا",
|
||||||
|
"restart": "قايتا باشلا",
|
||||||
|
"orderLimited": "تەرتىپلى چەكلەنگەن",
|
||||||
|
"orderInfinite": "تەرتىپلى چەكسىز",
|
||||||
|
"randomLimited": "ئىختىيارى چەكلەنگەن",
|
||||||
|
"randomInfinite": "ئىختىيارى چەكسىز",
|
||||||
|
"noIpa": "IPA يوق"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "بۇ قىسقۇچنى زىيارەت قىلىش ھوقۇقىڭىز يوق"
|
"unauthorized": "ھوقۇقسىز"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
"title": "تىل-ئۆگىنىش",
|
"title": "learn-languages",
|
||||||
"sourceCode": "GitHub",
|
"sourceCode": "GitHub",
|
||||||
"sign_in": "كىرىش",
|
"sign_in": "كىرىش",
|
||||||
"profile": "شەخسىي ئۇچۇر",
|
"profile": "شەخسىي ئۇچۇر",
|
||||||
"folders": "قىسقۇچلار",
|
"folders": "دېكلار",
|
||||||
"explore": "ئىزدىنىش",
|
"explore": "ئىزدىنىش",
|
||||||
"favorites": "يىغىپ ساقلانغانلار"
|
"favorites": "يىغىپ ساقلاش",
|
||||||
|
"settings": "تەڭشەكلەر"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR تونۇش",
|
||||||
|
"description": "رەسىمدىن تېكىست ئېلىش",
|
||||||
|
"uploadImage": "رەسىم يۈكلەش",
|
||||||
|
"dragDropHint": "سۆرەپ تاشلاش",
|
||||||
|
"supportedFormats": "قوللايدىغان فورمات: JPG, PNG, WEBP",
|
||||||
|
"selectDeck": "دېك تاللاش",
|
||||||
|
"chooseDeck": "دېك تاللاڭ",
|
||||||
|
"noDecks": "دېك يوق",
|
||||||
|
"languageHints": "تىل بېشارىتى",
|
||||||
|
"sourceLanguageHint": "مەنبە تىلى",
|
||||||
|
"targetLanguageHint": "نىشان تىلى",
|
||||||
|
"process": "بىر تەرەپ قىلىش",
|
||||||
|
"processing": "بىر تەرەپ قىلىنىۋاتىدۇ...",
|
||||||
|
"preview": "ئالدىن كۆرۈش",
|
||||||
|
"extractedPairs": "ئېلىنغان جۈپلەر",
|
||||||
|
"word": "سۆز",
|
||||||
|
"definition": "ئېنىقلىما",
|
||||||
|
"pairsCount": "{count} جۈپ",
|
||||||
|
"savePairs": "ساقلاش",
|
||||||
|
"saving": "ساقلاۋاتىدۇ...",
|
||||||
|
"saved": "ساقلاندى",
|
||||||
|
"saveFailed": "ساقلاش مەغلۇپ بولدى",
|
||||||
|
"noImage": "رەسىم يۈكلەڭ",
|
||||||
|
"noDeck": "دېك تاللاڭ",
|
||||||
|
"processingFailed": "بىر تەرەپ قىلىش مەغلۇپ بولدى",
|
||||||
|
"tryAgain": "قايتا سىناڭ",
|
||||||
|
"detectedLanguages": "تونۇلغان تىللار",
|
||||||
|
"uploadSection": "رەسىم يۈكلەش",
|
||||||
|
"dropOrClick": "تاشلاش ياكى چېكىش",
|
||||||
|
"changeImage": "رەسىم ئالماشتۇرۇش",
|
||||||
|
"invalidFileType": "ئىناۋەتسىز فايىل تىپى",
|
||||||
|
"deckSelection": "دېك تاللاش",
|
||||||
|
"sourceLanguagePlaceholder": "مەسىلەن: ئىنگلىزچە",
|
||||||
|
"targetLanguagePlaceholder": "مەسىلەن: ئۇيغۇرچە",
|
||||||
|
"processButton": "تونۇشنى باشلاش",
|
||||||
|
"resultsPreview": "نەتىجە ئالدىن كۆرۈش",
|
||||||
|
"saveButton": "دېككە ساقلاش",
|
||||||
|
"ocrSuccess": "OCR مۇۋەپپەقىيەتلىك",
|
||||||
|
"ocrFailed": "OCR مەغلۇپ بولدى",
|
||||||
|
"savedToDeck": "دېككە ساقلاندى",
|
||||||
|
"noResultsToSave": "نەتىجە يوق",
|
||||||
|
"detectedSourceLanguage": "تونۇلغان مەنبە تىلى",
|
||||||
|
"detectedTargetLanguage": "تونۇلغان نىشان تىلى"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "شەخسىي ئۇچۇرۇم",
|
"myProfile": "شەخسىي ئۇچۇرۇم",
|
||||||
"email": "ئېلخەت: {email}",
|
"email": "ئېلخەت: {email}",
|
||||||
"logout": "چىكىنىش"
|
"logout": "چىكىنىش"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "تەڭشەكلەر",
|
||||||
|
"themeColor": "تېما رەڭگى",
|
||||||
|
"themeColorDescription": "ياقتۇرىدىغان تېما رەڭگىڭىزنى تاللاڭ"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"uploadVideo": "ۋىدېئو يۈكلەش",
|
"uploadVideo": "ۋىدېئو يۈكلەش",
|
||||||
"uploadSubtitle": "تر پودكاست يۈكلەش",
|
"uploadSubtitle": "تر پودكاست يۈكلەش",
|
||||||
@@ -230,15 +434,48 @@
|
|||||||
"videoUploadFailed": "ۋىدېئو يۈكلەش مەغلۇپ بولدى",
|
"videoUploadFailed": "ۋىدېئو يۈكلەش مەغلۇپ بولدى",
|
||||||
"subtitleUploadFailed": "تر پودكاست يۈكلەش مەغلۇپ بولدى",
|
"subtitleUploadFailed": "تر پودكاست يۈكلەش مەغلۇپ بولدى",
|
||||||
"subtitleLoadSuccess": "تر پودكاست مۇۋەپپەقىيەتلىك يۈكلەندى",
|
"subtitleLoadSuccess": "تر پودكاست مۇۋەپپەقىيەتلىك يۈكلەندى",
|
||||||
"subtitleLoadFailed": "تر پودكاست يۈكلەش مەغلۇپ بولدى"
|
"subtitleLoadFailed": "تر پودكاست يۈكلەش مەغلۇپ بولدى",
|
||||||
|
"settings": "تەڭشەكلەر",
|
||||||
|
"shortcuts": "تېزلەتمەلەر",
|
||||||
|
"keyboardShortcuts": "كۇنۇپكا تاختىسى تېزلەتمەلىرى",
|
||||||
|
"playPause": "قويۇش/توختىتىش",
|
||||||
|
"autoPauseToggle": "ئاپتوماتىك توختىتىش",
|
||||||
|
"subtitleSettings": "ئاستى سىزىق تەڭشەكلىرى",
|
||||||
|
"fontSize": "خەت چوڭلۇقى",
|
||||||
|
"textColor": "خەت رەڭگى",
|
||||||
|
"backgroundColor": "تەگلىك رەڭگى",
|
||||||
|
"position": "ئورنى",
|
||||||
|
"opacity": "سۈزۈكلۈك",
|
||||||
|
"top": "ئۈستى",
|
||||||
|
"center": "ئوتتۇرا",
|
||||||
|
"bottom": "ئاستى"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "IPA ھاسىل قىلىش",
|
"generateIPA": "IPA ھاسىل قىلىش",
|
||||||
"viewSavedItems": "ساقلانغان تۈرلەرنى كۆرۈش",
|
"viewSavedItems": "ساقلانغان تۈرلەرنى كۆرۈش",
|
||||||
"confirmDeleteAll": "ھەممىنى ئۆچۈرەمسىز؟ (Y/N)"
|
"confirmDeleteAll": "ھەممىنى ئۆچۈرەمسىز؟ (Y/N)",
|
||||||
|
"saved": "ساقلاندى",
|
||||||
|
"clearAll": "ھەممىنى تازىلاش",
|
||||||
|
"language": "تىل",
|
||||||
|
"customLanguage": "ياكى تىل كىرگۈزۈڭ...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "ئاپتوماتىك",
|
||||||
|
"chinese": "خەنزۇچە",
|
||||||
|
"english": "ئىنگلىزچە",
|
||||||
|
"japanese": "ياپونچە",
|
||||||
|
"korean": "كورېيەچە",
|
||||||
|
"french": "فرانسۇزچە",
|
||||||
|
"german": "گېرمانچە",
|
||||||
|
"italian": "ئىتاليانچە",
|
||||||
|
"spanish": "ئىسپانچە",
|
||||||
|
"portuguese": "پورتۇگالچە",
|
||||||
|
"russian": "رۇسچە"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "تىلنى تونۇش",
|
"detectLanguage": "تىلنى تونۇش",
|
||||||
|
"sourceLanguage": "مەنبە تىلى",
|
||||||
|
"auto": "ئاپتوماتىك",
|
||||||
"generateIPA": "ipa ھاسىل قىلىش",
|
"generateIPA": "ipa ھاسىل قىلىش",
|
||||||
"translateInto": "تەرجىمە قىلىش",
|
"translateInto": "تەرجىمە قىلىش",
|
||||||
"chinese": "خەنزۇچە",
|
"chinese": "خەنزۇچە",
|
||||||
@@ -266,7 +503,20 @@
|
|||||||
"success": "تېكىست جۈپى قىسقۇچقا قوشۇلدى",
|
"success": "تېكىست جۈپى قىسقۇچقا قوشۇلدى",
|
||||||
"error": "تېكىست جۈپىنى قىسقۇچقا قوشۇش مەغلۇپ بولدى"
|
"error": "تېكىست جۈپىنى قىسقۇچقا قوشۇش مەغلۇپ بولدى"
|
||||||
},
|
},
|
||||||
"autoSave": "ئاپتوماتىك ساقلاش"
|
"autoSave": "ئاپتوماتىك ساقلاش",
|
||||||
|
"customLanguage": "ياكى تىل تىل كىرۇڭ...",
|
||||||
|
"pleaseLogin": "كارتا ساقلاش ئۈچۈن كىرىڭ",
|
||||||
|
"pleaseCreateDeck": "ئاۋۋال دېك قۇرۇڭ",
|
||||||
|
"noTranslationToSave": "ساقلايدىغان تەرجىمە يوق",
|
||||||
|
"noDeckSelected": "دېك تاللانمىدى",
|
||||||
|
"saveAsCard": "كارتا ساقلاش",
|
||||||
|
"selectDeck": "دېك تاللاش",
|
||||||
|
"front": "ئالدى",
|
||||||
|
"back": "كەينى",
|
||||||
|
"cancel": "بىكار قىلىش",
|
||||||
|
"save": "ساقلاش",
|
||||||
|
"savedToDeck": "{deckName} غا ساقلاندى",
|
||||||
|
"saveFailed": "ساقلاش مەغلۇپ"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "لۇغەت",
|
"title": "لۇغەت",
|
||||||
@@ -311,7 +561,9 @@
|
|||||||
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
||||||
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ",
|
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ",
|
||||||
"sortByFavorites": "يىغىپ ساقلاش بويىچە تەرتىپلەش",
|
"sortByFavorites": "يىغىپ ساقلاش بويىچە تەرتىپلەش",
|
||||||
"sortByFavoritesActive": "يىغىپ ساقلاش بويىچە تەرتىپلەشنى بىكار قىلىش"
|
"sortByFavoritesActive": "يىغىپ ساقلاش بويىچە تەرتىپلەشنى بىكار قىلىش",
|
||||||
|
"noDecks": "ئاممىۋىي دېك يوق",
|
||||||
|
"deckInfo": "{userName} · {totalCards} كارتا"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "قىسقۇچ تەپسىلاتلىرى",
|
"title": "قىسقۇچ تەپسىلاتلىرى",
|
||||||
@@ -325,7 +577,8 @@
|
|||||||
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
"unfavorite": "يىغىپ ساقلاشنى بىكار قىل",
|
||||||
"favorited": "يىغىپ ساقلاندى",
|
"favorited": "يىغىپ ساقلاندى",
|
||||||
"unfavorited": "يىغىپ ساقلاش بىكار قىلىندى",
|
"unfavorited": "يىغىپ ساقلاش بىكار قىلىندى",
|
||||||
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ"
|
"pleaseLogin": "ئاۋۋال تىزىمغا كىرىڭ",
|
||||||
|
"totalCards": "{count} كارتا"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "يىغىپ ساقلىغانلىرىم",
|
"title": "يىغىپ ساقلىغانلىرىم",
|
||||||
@@ -347,14 +600,39 @@
|
|||||||
"notSet": "تەڭشەلمىگەن",
|
"notSet": "تەڭشەلمىگەن",
|
||||||
"memberSince": "ئەزا بولغاندىن بېرى",
|
"memberSince": "ئەزا بولغاندىن بېرى",
|
||||||
"logout": "چىكىنىش",
|
"logout": "چىكىنىش",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "قىسقۇچلار",
|
"button": "ھېساباتنى ئۆچۈرۈش",
|
||||||
"noFolders": "تېخى قىسقۇچ يوق",
|
"title": "ھېساباتنى ئۆچۈرۈش",
|
||||||
"folderName": "قىسقۇچ ئاتى",
|
"warning": "بۇ مەشغۇلاتنى ئەسلىگە قايتۇرغىلى بولمايدۇ. بارلىق سانلىق مەلۇماتلىرىڭىز مەڭگۈلۈك ئۆچۈرۈلىدۇ.",
|
||||||
"totalPairs": "جەمئىي جۈپ",
|
"warningDecks": "بارلىق دېك ۋە كارتلىرىڭىز",
|
||||||
|
"warningCards": "بارلىق ئۆگىنىش ئىلگىرىلەشلىرىڭىز",
|
||||||
|
"warningHistory": "بارلىق تەرجىمە ۋە لۇغەت تارىخىڭىز",
|
||||||
|
"warningPermanent": "بۇ مەشغۇلاتنى بىكار قىلغىلى بولمايدۇ",
|
||||||
|
"confirmLabel": "جەزىملەش ئۈچۈن ئىشلەتكۈچى ئاتىڭىزنى كىرگۈزۈڭ:",
|
||||||
|
"usernameMismatch": "ئىشلەتكۈچى ئاتى ماس كەلمەيدۇ",
|
||||||
|
"cancel": "بىكار قىلىش",
|
||||||
|
"confirm": "ھېساباتىمنى ئۆچۈرۈش",
|
||||||
|
"success": "ھېسابات مۇۋەپپەقىيەتلىك ئۆچۈرۈلدى",
|
||||||
|
"failed": "ھېساباتنى ئۆچۈرۈش مەغلۇپ بولدى"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "دېكلار",
|
||||||
|
"noDecks": "تېخى دېك يوق",
|
||||||
|
"deckName": "دېك ئاتى",
|
||||||
|
"totalCards": "جەمئىي كارتا",
|
||||||
"createdAt": "قۇرۇلغان ۋاقتى",
|
"createdAt": "قۇرۇلغان ۋاقتى",
|
||||||
"actions": "مەشغۇلاتلار",
|
"actions": "مەشغۇلاتلار",
|
||||||
"view": "كۆرۈش"
|
"view": "كۆرۈش"
|
||||||
}
|
},
|
||||||
|
"joined": "قوشۇلدى"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "ئەگىشىش",
|
||||||
|
"following": "ئەگىشىۋاتىدۇ",
|
||||||
|
"followers": "ئەگەشكۈچىلەر",
|
||||||
|
"followersOf": "{username} نىڭ ئەگەشكۈچىلىرى",
|
||||||
|
"followingOf": "{username} نىڭ ئەگىشىدىغانلىرى",
|
||||||
|
"noFollowers": "تېخى ئەگەشكۈچى يوق",
|
||||||
|
"noFollowing": "تېخى ئەگىشىدىغان ئادەم يوق"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,77 @@
|
|||||||
"deleteFolder": "您没有权限删除此文件夹"
|
"deleteFolder": "您没有权限删除此文件夹"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deck_id": {
|
||||||
|
"unauthorized": "您不是此牌组的所有者",
|
||||||
|
"back": "返回",
|
||||||
|
"cards": "卡片",
|
||||||
|
"itemsCount": "{count} 个",
|
||||||
|
"memorize": "记忆",
|
||||||
|
"loadingCards": "加载卡片中...",
|
||||||
|
"noCards": "此牌组中没有卡片",
|
||||||
|
"card": "卡片",
|
||||||
|
"addNewCard": "添加新卡片",
|
||||||
|
"add": "添加",
|
||||||
|
"adding": "添加中...",
|
||||||
|
"updateCard": "更新卡片",
|
||||||
|
"update": "更新",
|
||||||
|
"updating": "更新中...",
|
||||||
|
"word": "单词",
|
||||||
|
"definition": "释义",
|
||||||
|
"ipa": "音标",
|
||||||
|
"example": "例句",
|
||||||
|
"wordAndDefinitionRequired": "单词和释义都是必需的",
|
||||||
|
"edit": "编辑",
|
||||||
|
"delete": "删除",
|
||||||
|
"permissionDenied": "您没有权限执行此操作",
|
||||||
|
"resetProgress": "重置进度",
|
||||||
|
"resetProgressTitle": "重置学习进度",
|
||||||
|
"resetProgressConfirm": "确定要重置这个卡组的学习进度吗?",
|
||||||
|
"resetSuccess": "进度已重置",
|
||||||
|
"resetting": "重置中...",
|
||||||
|
"cancel": "取消",
|
||||||
|
"settings": "设置",
|
||||||
|
"settingsTitle": "卡组设置",
|
||||||
|
"newPerDay": "每日新卡",
|
||||||
|
"newPerDayHint": "每天学习的新卡片数量",
|
||||||
|
"revPerDay": "每日复习",
|
||||||
|
"revPerDayHint": "每天复习的卡片数量",
|
||||||
|
"save": "保存",
|
||||||
|
"saving": "保存中...",
|
||||||
|
"settingsSaved": "设置已保存",
|
||||||
|
"todayNew": "今日新卡",
|
||||||
|
"todayReview": "今日复习",
|
||||||
|
"todayLearning": "学习中",
|
||||||
|
"error": {
|
||||||
|
"update": "您没有权限更新此卡片",
|
||||||
|
"delete": "您没有权限删除此卡片",
|
||||||
|
"add": "您没有权限向此牌组添加卡片"
|
||||||
|
},
|
||||||
|
"ipaPlaceholder": "输入IPA音标",
|
||||||
|
"examplePlaceholder": "输入例句",
|
||||||
|
"wordRequired": "请输入单词",
|
||||||
|
"definitionRequired": "请输入至少一个释义",
|
||||||
|
"cardAdded": "卡片已添加",
|
||||||
|
"cardType": "卡片类型",
|
||||||
|
"wordCard": "单词卡",
|
||||||
|
"phraseCard": "短语卡",
|
||||||
|
"sentenceCard": "句子卡",
|
||||||
|
"sentence": "句子",
|
||||||
|
"sentencePlaceholder": "输入句子",
|
||||||
|
"wordPlaceholder": "输入单词",
|
||||||
|
"queryLang": "查询语言",
|
||||||
|
"enterLanguageName": "请输入语言名称",
|
||||||
|
"english": "英语",
|
||||||
|
"chinese": "中文",
|
||||||
|
"japanese": "日语",
|
||||||
|
"korean": "韩语",
|
||||||
|
"meanings": "释义",
|
||||||
|
"addMeaning": "添加释义",
|
||||||
|
"partOfSpeech": "词性",
|
||||||
|
"deleteConfirm": "确定删除这张卡片吗?",
|
||||||
|
"cardDeleted": "卡片已删除",
|
||||||
|
"cardUpdated": "卡片已更新"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "学语言",
|
"title": "学语言",
|
||||||
"description": "这里是一个非常有用的网站,可以帮助您学习世界上几乎每一种语言,包括人造语言。",
|
"description": "这里是一个非常有用的网站,可以帮助您学习世界上几乎每一种语言,包括人造语言。",
|
||||||
@@ -157,6 +228,9 @@
|
|||||||
"resetPasswordFailed": "发送重置邮件失败",
|
"resetPasswordFailed": "发送重置邮件失败",
|
||||||
"resetPasswordEmailSent": "重置邮件已发送",
|
"resetPasswordEmailSent": "重置邮件已发送",
|
||||||
"resetPasswordEmailSentHint": "我们已向您的邮箱发送了密码重置链接,请查收。",
|
"resetPasswordEmailSentHint": "我们已向您的邮箱发送了密码重置链接,请查收。",
|
||||||
|
"verifyYourEmail": "验证您的邮箱",
|
||||||
|
"verificationEmailSent": "验证邮件已发送",
|
||||||
|
"verificationEmailSentHint": "我们已向 {email} 发送了验证邮件,请点击邮件中的链接完成验证。",
|
||||||
"checkYourEmail": "请查收邮件",
|
"checkYourEmail": "请查收邮件",
|
||||||
"backToLogin": "返回登录",
|
"backToLogin": "返回登录",
|
||||||
"resetPassword": "重置密码",
|
"resetPassword": "重置密码",
|
||||||
@@ -166,25 +240,72 @@
|
|||||||
"requestNewToken": "重新申请重置链接",
|
"requestNewToken": "重新申请重置链接",
|
||||||
"resetPasswordSuccess": "密码重置成功",
|
"resetPasswordSuccess": "密码重置成功",
|
||||||
"resetPasswordSuccessTitle": "密码重置完成",
|
"resetPasswordSuccessTitle": "密码重置完成",
|
||||||
"resetPasswordSuccessHint": "您的密码已成功重置,现在可以使用新密码登录了。"
|
"resetPasswordSuccessHint": "您的密码已成功重置,现在可以使用新密码登录了。",
|
||||||
|
"emailNotVerified": "请验证您的邮箱地址",
|
||||||
|
"emailNotVerifiedHint": "您的邮箱尚未验证。请检查收件箱或重新发送验证邮件。",
|
||||||
|
"resendVerification": "重新发送验证邮件",
|
||||||
|
"resendSuccess": "验证邮件已发送!请检查您的收件箱。",
|
||||||
|
"resendFailed": "发送验证邮件失败"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"memorize": {
|
||||||
"folder_selector": {
|
"deck_selector": {
|
||||||
"selectFolder": "选择文件夹",
|
"selectDeck": "选择牌组",
|
||||||
"noFolders": "未找到文件夹",
|
"noDecks": "未找到牌组",
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
"goToDecks": "前往牌组",
|
||||||
|
"noCards": "无卡片",
|
||||||
|
"new": "新卡片",
|
||||||
|
"learning": "学习中",
|
||||||
|
"review": "复习",
|
||||||
|
"due": "待复习"
|
||||||
},
|
},
|
||||||
"memorize": {
|
"review": {
|
||||||
"answer": "答案",
|
"loading": "加载中...",
|
||||||
"next": "下一个",
|
"backToDecks": "返回牌组",
|
||||||
|
"allDone": "全部完成!",
|
||||||
|
"allDoneDesc": "您已完成所有待复习卡片。",
|
||||||
|
"reviewedCount": "已复习 {count} 张卡片",
|
||||||
|
"progress": "{current} / {total}",
|
||||||
|
"nextReview": "下次复习",
|
||||||
|
"interval": "间隔",
|
||||||
|
"ease": "难度系数",
|
||||||
|
"lapses": "遗忘次数",
|
||||||
|
"showAnswer": "显示答案",
|
||||||
|
"nextCard": "下一张",
|
||||||
|
"again": "重来",
|
||||||
|
"hard": "困难",
|
||||||
|
"good": "良好",
|
||||||
|
"easy": "简单",
|
||||||
|
"now": "现在",
|
||||||
|
"lessThanMinute": "<1 分钟",
|
||||||
|
"inMinutes": "{count} 分钟",
|
||||||
|
"inHours": "{count} 小时",
|
||||||
|
"inDays": "{count} 天",
|
||||||
|
"inMonths": "{count} 个月",
|
||||||
|
"minutes": "<1 分钟",
|
||||||
|
"days": "{count} 天",
|
||||||
|
"months": "{count} 个月",
|
||||||
|
"minAbbr": "分",
|
||||||
|
"dayAbbr": "天",
|
||||||
|
"cardTypeNew": "新卡片",
|
||||||
|
"cardTypeLearning": "学习中",
|
||||||
|
"cardTypeReview": "复习中",
|
||||||
|
"cardTypeRelearning": "重学中",
|
||||||
"reverse": "反向",
|
"reverse": "反向",
|
||||||
"dictation": "听写",
|
"dictation": "听写",
|
||||||
"noTextPairs": "没有可用的文本对",
|
"clickToPlay": "点击播放",
|
||||||
"disorder": "乱序",
|
"yourAnswer": "你的答案",
|
||||||
"previous": "上一个"
|
"typeWhatYouHear": "输入你听到的内容",
|
||||||
|
"correct": "正确",
|
||||||
|
"incorrect": "错误",
|
||||||
|
"restart": "重新开始",
|
||||||
|
"orderLimited": "顺序有限",
|
||||||
|
"orderInfinite": "顺序无限",
|
||||||
|
"randomLimited": "随机有限",
|
||||||
|
"randomInfinite": "随机无限",
|
||||||
|
"noIpa": "无音标"
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
"unauthorized": "您无权访问该文件夹"
|
"unauthorized": "您无权访问该牌组"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"navbar": {
|
"navbar": {
|
||||||
@@ -192,15 +313,66 @@
|
|||||||
"sourceCode": "源码",
|
"sourceCode": "源码",
|
||||||
"sign_in": "登录",
|
"sign_in": "登录",
|
||||||
"profile": "个人资料",
|
"profile": "个人资料",
|
||||||
"folders": "文件夹",
|
"folders": "牌组",
|
||||||
"explore": "探索",
|
"explore": "探索",
|
||||||
"favorites": "收藏"
|
"favorites": "收藏",
|
||||||
|
"settings": "设置"
|
||||||
|
},
|
||||||
|
"ocr": {
|
||||||
|
"title": "OCR文字识别",
|
||||||
|
"description": "从图片中提取文字创建学习卡片",
|
||||||
|
"uploadSection": "上传图片",
|
||||||
|
"uploadImage": "上传图片",
|
||||||
|
"dragDropHint": "拖放或点击上传",
|
||||||
|
"dropOrClick": "拖放或点击",
|
||||||
|
"changeImage": "更换图片",
|
||||||
|
"supportedFormats": "支持格式:JPG, PNG, WEBP",
|
||||||
|
"invalidFileType": "无效的文件类型",
|
||||||
|
"deckSelection": "选择卡组",
|
||||||
|
"selectDeck": "选择卡组",
|
||||||
|
"chooseDeck": "选择卡组保存",
|
||||||
|
"noDecks": "没有可用的卡组",
|
||||||
|
"languageHints": "语言提示",
|
||||||
|
"sourceLanguageHint": "源语言提示",
|
||||||
|
"targetLanguageHint": "目标语言提示",
|
||||||
|
"sourceLanguagePlaceholder": "如:英语",
|
||||||
|
"targetLanguagePlaceholder": "如:中文",
|
||||||
|
"process": "处理",
|
||||||
|
"processButton": "开始识别",
|
||||||
|
"processing": "处理中...",
|
||||||
|
"preview": "预览",
|
||||||
|
"resultsPreview": "结果预览",
|
||||||
|
"extractedPairs": "提取的语言对",
|
||||||
|
"word": "单词",
|
||||||
|
"definition": "释义",
|
||||||
|
"pairsCount": "{count}对",
|
||||||
|
"savePairs": "保存",
|
||||||
|
"saveButton": "保存到卡组",
|
||||||
|
"saving": "保存中...",
|
||||||
|
"saved": "已保存",
|
||||||
|
"ocrSuccess": "OCR识别成功",
|
||||||
|
"savedToDeck": "已保存到卡组",
|
||||||
|
"saveFailed": "保存失败",
|
||||||
|
"noImage": "请上传图片",
|
||||||
|
"noDeck": "请选择卡组",
|
||||||
|
"noResultsToSave": "无结果可保存",
|
||||||
|
"processingFailed": "处理失败",
|
||||||
|
"tryAgain": "重试",
|
||||||
|
"detectedLanguages": "检测到的语言",
|
||||||
|
"detectedSourceLanguage": "检测到的源语言",
|
||||||
|
"detectedTargetLanguage": "检测到的目标语言",
|
||||||
|
"ocrFailed": "OCR识别失败"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"myProfile": "我的个人资料",
|
"myProfile": "我的个人资料",
|
||||||
"email": "邮箱:{email}",
|
"email": "邮箱:{email}",
|
||||||
"logout": "退出登录"
|
"logout": "退出登录"
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"title": "设置",
|
||||||
|
"themeColor": "主题色",
|
||||||
|
"themeColorDescription": "选择您喜欢的主题色"
|
||||||
|
},
|
||||||
"srt_player": {
|
"srt_player": {
|
||||||
"upload": "上传",
|
"upload": "上传",
|
||||||
"uploadVideo": "上传视频",
|
"uploadVideo": "上传视频",
|
||||||
@@ -230,15 +402,48 @@
|
|||||||
"videoUploadFailed": "视频上传失败",
|
"videoUploadFailed": "视频上传失败",
|
||||||
"subtitleUploadFailed": "字幕上传失败",
|
"subtitleUploadFailed": "字幕上传失败",
|
||||||
"subtitleLoadSuccess": "字幕加载成功",
|
"subtitleLoadSuccess": "字幕加载成功",
|
||||||
"subtitleLoadFailed": "字幕加载失败"
|
"subtitleLoadFailed": "字幕加载失败",
|
||||||
|
"settings": "设置",
|
||||||
|
"shortcuts": "快捷键",
|
||||||
|
"keyboardShortcuts": "键盘快捷键",
|
||||||
|
"playPause": "播放/暂停",
|
||||||
|
"autoPauseToggle": "自动暂停开关",
|
||||||
|
"subtitleSettings": "字幕设置",
|
||||||
|
"fontSize": "字体大小",
|
||||||
|
"textColor": "文字颜色",
|
||||||
|
"backgroundColor": "背景颜色",
|
||||||
|
"position": "位置",
|
||||||
|
"opacity": "透明度",
|
||||||
|
"top": "顶部",
|
||||||
|
"center": "居中",
|
||||||
|
"bottom": "底部"
|
||||||
},
|
},
|
||||||
"text_speaker": {
|
"text_speaker": {
|
||||||
"generateIPA": "生成IPA",
|
"generateIPA": "生成IPA",
|
||||||
"viewSavedItems": "查看保存项",
|
"viewSavedItems": "查看保存项",
|
||||||
"confirmDeleteAll": "确定删光吗?(Y/N)"
|
"confirmDeleteAll": "确定删光吗?(Y/N)",
|
||||||
|
"saved": "已保存",
|
||||||
|
"clearAll": "清空全部",
|
||||||
|
"language": "语言",
|
||||||
|
"customLanguage": "或输入语言...",
|
||||||
|
"languages": {
|
||||||
|
"auto": "自动",
|
||||||
|
"chinese": "中文",
|
||||||
|
"english": "英语",
|
||||||
|
"japanese": "日语",
|
||||||
|
"korean": "韩语",
|
||||||
|
"french": "法语",
|
||||||
|
"german": "德语",
|
||||||
|
"italian": "意大利语",
|
||||||
|
"spanish": "西班牙语",
|
||||||
|
"portuguese": "葡萄牙语",
|
||||||
|
"russian": "俄语"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"translator": {
|
"translator": {
|
||||||
"detectLanguage": "检测语言",
|
"detectLanguage": "检测语言",
|
||||||
|
"sourceLanguage": "源语言",
|
||||||
|
"auto": "自动",
|
||||||
"generateIPA": "生成国际音标",
|
"generateIPA": "生成国际音标",
|
||||||
"translateInto": "翻译为",
|
"translateInto": "翻译为",
|
||||||
"chinese": "中文",
|
"chinese": "中文",
|
||||||
@@ -266,7 +471,20 @@
|
|||||||
"success": "文本对已添加到文件夹",
|
"success": "文本对已添加到文件夹",
|
||||||
"error": "添加文本对到文件夹失败"
|
"error": "添加文本对到文件夹失败"
|
||||||
},
|
},
|
||||||
"autoSave": "自动保存"
|
"autoSave": "自动保存",
|
||||||
|
"customLanguage": "或输入语言...",
|
||||||
|
"pleaseLogin": "请登录后保存卡片",
|
||||||
|
"pleaseCreateDeck": "请先创建卡组",
|
||||||
|
"noTranslationToSave": "没有可保存的翻译",
|
||||||
|
"noDeckSelected": "未选择卡组",
|
||||||
|
"saveAsCard": "保存为卡片",
|
||||||
|
"selectDeck": "选择卡组",
|
||||||
|
"front": "正面",
|
||||||
|
"back": "背面",
|
||||||
|
"cancel": "取消",
|
||||||
|
"save": "保存",
|
||||||
|
"savedToDeck": "已保存到 {deckName}",
|
||||||
|
"saveFailed": "保存失败"
|
||||||
},
|
},
|
||||||
"dictionary": {
|
"dictionary": {
|
||||||
"title": "词典",
|
"title": "词典",
|
||||||
@@ -301,11 +519,11 @@
|
|||||||
},
|
},
|
||||||
"explore": {
|
"explore": {
|
||||||
"title": "探索",
|
"title": "探索",
|
||||||
"subtitle": "发现公开文件夹",
|
"subtitle": "发现公开牌组",
|
||||||
"searchPlaceholder": "搜索公开文件夹...",
|
"searchPlaceholder": "搜索公开牌组...",
|
||||||
"loading": "加载中...",
|
"loading": "加载中...",
|
||||||
"noFolders": "没有找到公开文件夹",
|
"noDecks": "暂无公开卡组",
|
||||||
"folderInfo": "{userName} • {totalPairs} 个文本对",
|
"deckInfo": "{userName} · {totalCards} 张",
|
||||||
"unknownUser": "未知用户",
|
"unknownUser": "未知用户",
|
||||||
"favorite": "收藏",
|
"favorite": "收藏",
|
||||||
"unfavorite": "取消收藏",
|
"unfavorite": "取消收藏",
|
||||||
@@ -314,10 +532,10 @@
|
|||||||
"sortByFavoritesActive": "取消按收藏数排序"
|
"sortByFavoritesActive": "取消按收藏数排序"
|
||||||
},
|
},
|
||||||
"exploreDetail": {
|
"exploreDetail": {
|
||||||
"title": "文件夹详情",
|
"title": "牌组详情",
|
||||||
"createdBy": "创建者:{name}",
|
"createdBy": "创建者:{name}",
|
||||||
"unknownUser": "未知用户",
|
"unknownUser": "未知用户",
|
||||||
"totalPairs": "词对数量",
|
"totalCards": "共 {count} 张",
|
||||||
"favorites": "收藏数",
|
"favorites": "收藏数",
|
||||||
"createdAt": "创建时间",
|
"createdAt": "创建时间",
|
||||||
"viewContent": "查看内容",
|
"viewContent": "查看内容",
|
||||||
@@ -346,15 +564,67 @@
|
|||||||
"displayName": "显示名称",
|
"displayName": "显示名称",
|
||||||
"notSet": "未设置",
|
"notSet": "未设置",
|
||||||
"memberSince": "注册时间",
|
"memberSince": "注册时间",
|
||||||
|
"joined": "注册于",
|
||||||
"logout": "登出",
|
"logout": "登出",
|
||||||
"folders": {
|
"deleteAccount": {
|
||||||
"title": "文件夹",
|
"button": "注销账号",
|
||||||
"noFolders": "还没有文件夹",
|
"title": "注销账号",
|
||||||
"folderName": "文件夹名称",
|
"warning": "此操作不可逆,您的所有数据将被永久删除。",
|
||||||
"totalPairs": "文本对数量",
|
"warningDecks": "您的所有牌组和卡片",
|
||||||
|
"warningCards": "您的所有学习进度",
|
||||||
|
"warningHistory": "您的所有翻译和词典历史",
|
||||||
|
"warningPermanent": "此操作无法撤销",
|
||||||
|
"confirmLabel": "输入您的用户名以确认:",
|
||||||
|
"usernameMismatch": "用户名不匹配",
|
||||||
|
"cancel": "取消",
|
||||||
|
"confirm": "注销我的账号",
|
||||||
|
"success": "账号已成功注销",
|
||||||
|
"failed": "注销账号失败"
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "牌组",
|
||||||
|
"noDecks": "还没有牌组",
|
||||||
|
"deckName": "牌组名称",
|
||||||
|
"totalCards": "卡片数量",
|
||||||
"createdAt": "创建时间",
|
"createdAt": "创建时间",
|
||||||
"actions": "操作",
|
"actions": "操作",
|
||||||
"view": "查看"
|
"view": "查看"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"decks": {
|
||||||
|
"title": "牌组",
|
||||||
|
"subtitle": "管理你的学习卡组",
|
||||||
|
"newDeck": "新建卡组",
|
||||||
|
"noDecksYet": "暂无卡组",
|
||||||
|
"loading": "加载中...",
|
||||||
|
"deckInfo": "ID: {id} · {totalCards} 张",
|
||||||
|
"enterDeckName": "输入卡组名称:",
|
||||||
|
"enterNewName": "输入新名称:",
|
||||||
|
"confirmDelete": "输入 \"{name}\" 确认删除:",
|
||||||
|
"public": "公开",
|
||||||
|
"private": "私有",
|
||||||
|
"setPublic": "设为公开",
|
||||||
|
"setPrivate": "设为私有",
|
||||||
|
"importApkg": "导入 APKG",
|
||||||
|
"exportApkg": "导出 APKG",
|
||||||
|
"clickToUpload": "点击上传",
|
||||||
|
"apkgFilesOnly": "仅支持 .apkg 文件",
|
||||||
|
"parsing": "解析中...",
|
||||||
|
"foundDecks": "发现 {count} 个卡组",
|
||||||
|
"deckName": "卡组名称",
|
||||||
|
"back": "返回",
|
||||||
|
"import": "导入",
|
||||||
|
"importing": "导入中...",
|
||||||
|
"exportSuccess": "导出成功",
|
||||||
|
"goToDecks": "前往卡组"
|
||||||
|
},
|
||||||
|
"follow": {
|
||||||
|
"follow": "关注",
|
||||||
|
"following": "已关注",
|
||||||
|
"followers": "粉丝",
|
||||||
|
"followersOf": "{username} 的粉丝",
|
||||||
|
"followingOf": "{username} 的关注",
|
||||||
|
"noFollowers": "还没有粉丝",
|
||||||
|
"noFollowing": "还没有关注任何人"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
|
"jszip": "^3.10.1",
|
||||||
"lucide-react": "^0.562.0",
|
"lucide-react": "^0.562.0",
|
||||||
"next": "16.1.1",
|
"next": "16.1.1",
|
||||||
"next-intl": "^4.7.0",
|
"next-intl": "^4.7.0",
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
"react": "19.2.3",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.3",
|
"react-dom": "19.2.3",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
|
"sql.js": "^1.14.1",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"unstorage": "^1.17.3",
|
"unstorage": "^1.17.3",
|
||||||
"winston": "^3.19.0",
|
"winston": "^3.19.0",
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
"@types/nodemailer": "^7.0.11",
|
"@types/nodemailer": "^7.0.11",
|
||||||
"@types/react": "19.2.7",
|
"@types/react": "19.2.7",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react-dom": "19.2.3",
|
||||||
|
"@types/sql.js": "^1.4.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
||||||
"@typescript-eslint/parser": "^8.51.0",
|
"@typescript-eslint/parser": "^8.51.0",
|
||||||
"babel-plugin-react-compiler": "^1.0.0",
|
"babel-plugin-react-compiler": "^1.0.0",
|
||||||
|
|||||||
121
pnpm-lock.yaml
generated
121
pnpm-lock.yaml
generated
@@ -23,7 +23,7 @@ importers:
|
|||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
better-auth:
|
better-auth:
|
||||||
specifier: ^1.4.10
|
specifier: ^1.4.10
|
||||||
version: 1.4.10(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
version: 1.4.10(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
class-variance-authority:
|
class-variance-authority:
|
||||||
specifier: ^0.7.1
|
specifier: ^0.7.1
|
||||||
version: 0.7.1
|
version: 0.7.1
|
||||||
@@ -33,6 +33,9 @@ importers:
|
|||||||
dotenv:
|
dotenv:
|
||||||
specifier: ^17.2.3
|
specifier: ^17.2.3
|
||||||
version: 17.2.3
|
version: 17.2.3
|
||||||
|
jszip:
|
||||||
|
specifier: ^3.10.1
|
||||||
|
version: 3.10.1
|
||||||
lucide-react:
|
lucide-react:
|
||||||
specifier: ^0.562.0
|
specifier: ^0.562.0
|
||||||
version: 0.562.0(react@19.2.3)
|
version: 0.562.0(react@19.2.3)
|
||||||
@@ -60,6 +63,9 @@ importers:
|
|||||||
sonner:
|
sonner:
|
||||||
specifier: ^2.0.7
|
specifier: ^2.0.7
|
||||||
version: 2.0.7(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
version: 2.0.7(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
|
sql.js:
|
||||||
|
specifier: ^1.14.1
|
||||||
|
version: 1.14.1
|
||||||
tailwind-merge:
|
tailwind-merge:
|
||||||
specifier: ^3.4.0
|
specifier: ^3.4.0
|
||||||
version: 3.4.0
|
version: 3.4.0
|
||||||
@@ -78,7 +84,7 @@ importers:
|
|||||||
devDependencies:
|
devDependencies:
|
||||||
'@better-auth/cli':
|
'@better-auth/cli':
|
||||||
specifier: ^1.4.10
|
specifier: ^1.4.10
|
||||||
version: 1.4.10(@better-fetch/fetch@1.1.21)(@electric-sql/pglite@0.3.15)(@types/react@19.2.7)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(mysql2@3.15.3)(nanostores@1.1.0)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
version: 1.4.10(@better-fetch/fetch@1.1.21)(@electric-sql/pglite@0.3.15)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(mysql2@3.15.3)(nanostores@1.1.0)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sql.js@1.14.1)
|
||||||
'@eslint/eslintrc':
|
'@eslint/eslintrc':
|
||||||
specifier: ^3.3.3
|
specifier: ^3.3.3
|
||||||
version: 3.3.3
|
version: 3.3.3
|
||||||
@@ -97,6 +103,9 @@ importers:
|
|||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
specifier: 19.2.3
|
specifier: 19.2.3
|
||||||
version: 19.2.3(@types/react@19.2.7)
|
version: 19.2.3(@types/react@19.2.7)
|
||||||
|
'@types/sql.js':
|
||||||
|
specifier: ^1.4.9
|
||||||
|
version: 1.4.9
|
||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
specifier: ^8.51.0
|
specifier: ^8.51.0
|
||||||
version: 8.51.0(@typescript-eslint/parser@8.51.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
version: 8.51.0(@typescript-eslint/parser@8.51.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
||||||
@@ -1046,6 +1055,9 @@ packages:
|
|||||||
'@tybys/wasm-util@0.10.1':
|
'@tybys/wasm-util@0.10.1':
|
||||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||||
|
|
||||||
|
'@types/emscripten@1.41.5':
|
||||||
|
resolution: {integrity: sha512-cMQm7pxu6BxtHyqJ7mQZ2kXWV5SLmugybFdHCBbJ5eHzOo6VhBckEgAT3//rP5FwPHNPeEiq4SmQ5ucBwsOo4Q==}
|
||||||
|
|
||||||
'@types/estree@1.0.8':
|
'@types/estree@1.0.8':
|
||||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||||
|
|
||||||
@@ -1072,6 +1084,9 @@ packages:
|
|||||||
'@types/react@19.2.7':
|
'@types/react@19.2.7':
|
||||||
resolution: {integrity: sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==}
|
resolution: {integrity: sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==}
|
||||||
|
|
||||||
|
'@types/sql.js@1.4.9':
|
||||||
|
resolution: {integrity: sha512-ep8b36RKHlgWPqjNG9ToUrPiwkhwh0AEzy883mO5Xnd+cL6VBH1EvSjBAAuxLUFF2Vn/moE3Me6v9E1Lo+48GQ==}
|
||||||
|
|
||||||
'@types/triple-beam@1.3.5':
|
'@types/triple-beam@1.3.5':
|
||||||
resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==}
|
resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==}
|
||||||
|
|
||||||
@@ -1620,6 +1635,9 @@ packages:
|
|||||||
cookie-es@1.2.2:
|
cookie-es@1.2.2:
|
||||||
resolution: {integrity: sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==}
|
resolution: {integrity: sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==}
|
||||||
|
|
||||||
|
core-util-is@1.0.3:
|
||||||
|
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
|
||||||
|
|
||||||
cross-spawn@7.0.6:
|
cross-spawn@7.0.6:
|
||||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
@@ -2218,6 +2236,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==}
|
resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==}
|
||||||
engines: {node: '>= 4'}
|
engines: {node: '>= 4'}
|
||||||
|
|
||||||
|
immediate@3.0.6:
|
||||||
|
resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==}
|
||||||
|
|
||||||
import-fresh@3.3.1:
|
import-fresh@3.3.1:
|
||||||
resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==}
|
resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
@@ -2366,6 +2387,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==}
|
resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
|
|
||||||
|
isarray@1.0.0:
|
||||||
|
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
|
||||||
|
|
||||||
isarray@2.0.5:
|
isarray@2.0.5:
|
||||||
resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==}
|
resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==}
|
||||||
|
|
||||||
@@ -2417,6 +2441,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
|
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
|
||||||
engines: {node: '>=4.0'}
|
engines: {node: '>=4.0'}
|
||||||
|
|
||||||
|
jszip@3.10.1:
|
||||||
|
resolution: {integrity: sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==}
|
||||||
|
|
||||||
keyv@4.5.4:
|
keyv@4.5.4:
|
||||||
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
|
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
|
||||||
|
|
||||||
@@ -2442,6 +2469,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
|
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
|
|
||||||
|
lie@3.3.0:
|
||||||
|
resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==}
|
||||||
|
|
||||||
lightningcss-android-arm64@1.30.2:
|
lightningcss-android-arm64@1.30.2:
|
||||||
resolution: {integrity: sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A==}
|
resolution: {integrity: sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A==}
|
||||||
engines: {node: '>= 12.0.0'}
|
engines: {node: '>= 12.0.0'}
|
||||||
@@ -2762,6 +2792,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
|
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
|
pako@1.0.11:
|
||||||
|
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
|
||||||
|
|
||||||
parent-module@1.0.1:
|
parent-module@1.0.1:
|
||||||
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
|
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
@@ -2900,6 +2933,9 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
process-nextick-args@2.0.1:
|
||||||
|
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||||
|
|
||||||
prompts@2.4.2:
|
prompts@2.4.2:
|
||||||
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
|
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
@@ -2945,6 +2981,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==}
|
resolution: {integrity: sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
readable-stream@2.3.8:
|
||||||
|
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
||||||
|
|
||||||
readable-stream@3.6.2:
|
readable-stream@3.6.2:
|
||||||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
@@ -3005,6 +3044,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==}
|
resolution: {integrity: sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==}
|
||||||
engines: {node: '>=0.4'}
|
engines: {node: '>=0.4'}
|
||||||
|
|
||||||
|
safe-buffer@5.1.2:
|
||||||
|
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
|
||||||
|
|
||||||
safe-buffer@5.2.1:
|
safe-buffer@5.2.1:
|
||||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||||
|
|
||||||
@@ -3053,6 +3095,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==}
|
resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
setimmediate@1.0.5:
|
||||||
|
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
|
||||||
|
|
||||||
sharp@0.34.5:
|
sharp@0.34.5:
|
||||||
resolution: {integrity: sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==}
|
resolution: {integrity: sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -3111,6 +3156,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
|
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
|
||||||
engines: {node: '>= 10.x'}
|
engines: {node: '>= 10.x'}
|
||||||
|
|
||||||
|
sql.js@1.14.1:
|
||||||
|
resolution: {integrity: sha512-gcj8zBWU5cFsi9WUP+4bFNXAyF1iRpA3LLyS/DP5xlrNzGmPIizUeBggKa8DbDwdqaKwUcTEnChtd2grWo/x/A==}
|
||||||
|
|
||||||
sqlstring@2.3.3:
|
sqlstring@2.3.3:
|
||||||
resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==}
|
resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
@@ -3151,6 +3199,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==}
|
resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
string_decoder@1.1.1:
|
||||||
|
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
|
||||||
|
|
||||||
string_decoder@1.3.0:
|
string_decoder@1.3.0:
|
||||||
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
||||||
|
|
||||||
@@ -3699,7 +3750,7 @@ snapshots:
|
|||||||
'@babel/helper-string-parser': 7.27.1
|
'@babel/helper-string-parser': 7.27.1
|
||||||
'@babel/helper-validator-identifier': 7.28.5
|
'@babel/helper-validator-identifier': 7.28.5
|
||||||
|
|
||||||
'@better-auth/cli@1.4.10(@better-fetch/fetch@1.1.21)(@electric-sql/pglite@0.3.15)(@types/react@19.2.7)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(mysql2@3.15.3)(nanostores@1.1.0)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)':
|
'@better-auth/cli@1.4.10(@better-fetch/fetch@1.1.21)(@electric-sql/pglite@0.3.15)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(mysql2@3.15.3)(nanostores@1.1.0)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sql.js@1.14.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.28.5
|
'@babel/core': 7.28.5
|
||||||
'@babel/preset-react': 7.28.5(@babel/core@7.28.5)
|
'@babel/preset-react': 7.28.5(@babel/core@7.28.5)
|
||||||
@@ -3711,13 +3762,13 @@ snapshots:
|
|||||||
'@mrleebo/prisma-ast': 0.13.1
|
'@mrleebo/prisma-ast': 0.13.1
|
||||||
'@prisma/client': 5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))
|
'@prisma/client': 5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))
|
||||||
'@types/pg': 8.15.6
|
'@types/pg': 8.15.6
|
||||||
better-auth: 1.4.10(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
better-auth: 1.4.10(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
better-sqlite3: 12.5.0
|
better-sqlite3: 12.5.0
|
||||||
c12: 3.3.2
|
c12: 3.3.2
|
||||||
chalk: 5.6.2
|
chalk: 5.6.2
|
||||||
commander: 12.1.0
|
commander: 12.1.0
|
||||||
dotenv: 17.2.3
|
dotenv: 17.2.3
|
||||||
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)
|
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1)
|
||||||
open: 10.2.0
|
open: 10.2.0
|
||||||
pg: 8.16.3
|
pg: 8.16.3
|
||||||
prettier: 3.7.4
|
prettier: 3.7.4
|
||||||
@@ -4411,6 +4462,8 @@ snapshots:
|
|||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@types/emscripten@1.41.5': {}
|
||||||
|
|
||||||
'@types/estree@1.0.8': {}
|
'@types/estree@1.0.8': {}
|
||||||
|
|
||||||
'@types/json-schema@7.0.15': {}
|
'@types/json-schema@7.0.15': {}
|
||||||
@@ -4439,6 +4492,11 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
csstype: 3.2.3
|
csstype: 3.2.3
|
||||||
|
|
||||||
|
'@types/sql.js@1.4.9':
|
||||||
|
dependencies:
|
||||||
|
'@types/emscripten': 1.41.5
|
||||||
|
'@types/node': 25.0.3
|
||||||
|
|
||||||
'@types/triple-beam@1.3.5': {}
|
'@types/triple-beam@1.3.5': {}
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.48.1(@typescript-eslint/parser@8.48.1(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)':
|
'@typescript-eslint/eslint-plugin@8.48.1(@typescript-eslint/parser@8.48.1(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)':
|
||||||
@@ -4810,7 +4868,7 @@ snapshots:
|
|||||||
|
|
||||||
bcryptjs@3.0.3: {}
|
bcryptjs@3.0.3: {}
|
||||||
|
|
||||||
better-auth@1.4.10(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
better-auth@1.4.10(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0)
|
'@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0)
|
||||||
'@better-auth/telemetry': 1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0))
|
'@better-auth/telemetry': 1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0))
|
||||||
@@ -4827,7 +4885,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@prisma/client': 5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))
|
'@prisma/client': 5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))
|
||||||
better-sqlite3: 12.5.0
|
better-sqlite3: 12.5.0
|
||||||
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)
|
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1)
|
||||||
mysql2: 3.15.3
|
mysql2: 3.15.3
|
||||||
next: 16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
next: 16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
pg: 8.16.3
|
pg: 8.16.3
|
||||||
@@ -4835,7 +4893,7 @@ snapshots:
|
|||||||
react: 19.2.3
|
react: 19.2.3
|
||||||
react-dom: 19.2.3(react@19.2.3)
|
react-dom: 19.2.3(react@19.2.3)
|
||||||
|
|
||||||
better-auth@1.4.10(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
better-auth@1.4.10(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(better-sqlite3@12.5.0)(drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@5.22.0(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1))(mysql2@3.15.3)(next@16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(pg@8.16.3)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0)
|
'@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0)
|
||||||
'@better-auth/telemetry': 1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0))
|
'@better-auth/telemetry': 1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.3.5))(jose@6.1.3)(kysely@0.28.8)(nanostores@1.1.0))
|
||||||
@@ -4852,7 +4910,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@prisma/client': 7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3)
|
'@prisma/client': 7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3)
|
||||||
better-sqlite3: 12.5.0
|
better-sqlite3: 12.5.0
|
||||||
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)
|
drizzle-orm: 0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1)
|
||||||
mysql2: 3.15.3
|
mysql2: 3.15.3
|
||||||
next: 16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
next: 16.1.1(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
pg: 8.16.3
|
pg: 8.16.3
|
||||||
@@ -5034,6 +5092,8 @@ snapshots:
|
|||||||
|
|
||||||
cookie-es@1.2.2: {}
|
cookie-es@1.2.2: {}
|
||||||
|
|
||||||
|
core-util-is@1.0.3: {}
|
||||||
|
|
||||||
cross-spawn@7.0.6:
|
cross-spawn@7.0.6:
|
||||||
dependencies:
|
dependencies:
|
||||||
path-key: 3.1.1
|
path-key: 3.1.1
|
||||||
@@ -5125,12 +5185,13 @@ snapshots:
|
|||||||
|
|
||||||
dotenv@17.2.3: {}
|
dotenv@17.2.3: {}
|
||||||
|
|
||||||
drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3):
|
drizzle-orm@0.33.0(@electric-sql/pglite@0.3.15)(@prisma/client@7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.15.6)(@types/react@19.2.7)(@types/sql.js@1.4.9)(better-sqlite3@12.5.0)(kysely@0.28.8)(mysql2@3.15.3)(pg@8.16.3)(postgres@3.4.7)(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react@19.2.3)(sql.js@1.14.1):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@electric-sql/pglite': 0.3.15
|
'@electric-sql/pglite': 0.3.15
|
||||||
'@prisma/client': 7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3)
|
'@prisma/client': 7.4.2(prisma@7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3)
|
||||||
'@types/pg': 8.15.6
|
'@types/pg': 8.15.6
|
||||||
'@types/react': 19.2.7
|
'@types/react': 19.2.7
|
||||||
|
'@types/sql.js': 1.4.9
|
||||||
better-sqlite3: 12.5.0
|
better-sqlite3: 12.5.0
|
||||||
kysely: 0.28.8
|
kysely: 0.28.8
|
||||||
mysql2: 3.15.3
|
mysql2: 3.15.3
|
||||||
@@ -5138,6 +5199,7 @@ snapshots:
|
|||||||
postgres: 3.4.7
|
postgres: 3.4.7
|
||||||
prisma: 7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)
|
prisma: 7.4.2(@types/react@19.2.7)(better-sqlite3@12.5.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)
|
||||||
react: 19.2.3
|
react: 19.2.3
|
||||||
|
sql.js: 1.14.1
|
||||||
|
|
||||||
dunder-proto@1.0.1:
|
dunder-proto@1.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -5685,6 +5747,8 @@ snapshots:
|
|||||||
|
|
||||||
ignore@7.0.5: {}
|
ignore@7.0.5: {}
|
||||||
|
|
||||||
|
immediate@3.0.6: {}
|
||||||
|
|
||||||
import-fresh@3.3.1:
|
import-fresh@3.3.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
parent-module: 1.0.1
|
parent-module: 1.0.1
|
||||||
@@ -5837,6 +5901,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-inside-container: 1.0.0
|
is-inside-container: 1.0.0
|
||||||
|
|
||||||
|
isarray@1.0.0: {}
|
||||||
|
|
||||||
isarray@2.0.5: {}
|
isarray@2.0.5: {}
|
||||||
|
|
||||||
isexe@2.0.0: {}
|
isexe@2.0.0: {}
|
||||||
@@ -5881,6 +5947,13 @@ snapshots:
|
|||||||
object.assign: 4.1.7
|
object.assign: 4.1.7
|
||||||
object.values: 1.2.1
|
object.values: 1.2.1
|
||||||
|
|
||||||
|
jszip@3.10.1:
|
||||||
|
dependencies:
|
||||||
|
lie: 3.3.0
|
||||||
|
pako: 1.0.11
|
||||||
|
readable-stream: 2.3.8
|
||||||
|
setimmediate: 1.0.5
|
||||||
|
|
||||||
keyv@4.5.4:
|
keyv@4.5.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
json-buffer: 3.0.1
|
json-buffer: 3.0.1
|
||||||
@@ -5902,6 +5975,10 @@ snapshots:
|
|||||||
prelude-ls: 1.2.1
|
prelude-ls: 1.2.1
|
||||||
type-check: 0.4.0
|
type-check: 0.4.0
|
||||||
|
|
||||||
|
lie@3.3.0:
|
||||||
|
dependencies:
|
||||||
|
immediate: 3.0.6
|
||||||
|
|
||||||
lightningcss-android-arm64@1.30.2:
|
lightningcss-android-arm64@1.30.2:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
@@ -6204,6 +6281,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-limit: 3.1.0
|
p-limit: 3.1.0
|
||||||
|
|
||||||
|
pako@1.0.11: {}
|
||||||
|
|
||||||
parent-module@1.0.1:
|
parent-module@1.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
callsites: 3.1.0
|
callsites: 3.1.0
|
||||||
@@ -6333,6 +6412,8 @@ snapshots:
|
|||||||
- react
|
- react
|
||||||
- react-dom
|
- react-dom
|
||||||
|
|
||||||
|
process-nextick-args@2.0.1: {}
|
||||||
|
|
||||||
prompts@2.4.2:
|
prompts@2.4.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
kleur: 3.0.3
|
kleur: 3.0.3
|
||||||
@@ -6384,6 +6465,16 @@ snapshots:
|
|||||||
|
|
||||||
react@19.2.3: {}
|
react@19.2.3: {}
|
||||||
|
|
||||||
|
readable-stream@2.3.8:
|
||||||
|
dependencies:
|
||||||
|
core-util-is: 1.0.3
|
||||||
|
inherits: 2.0.4
|
||||||
|
isarray: 1.0.0
|
||||||
|
process-nextick-args: 2.0.1
|
||||||
|
safe-buffer: 5.1.2
|
||||||
|
string_decoder: 1.1.1
|
||||||
|
util-deprecate: 1.0.2
|
||||||
|
|
||||||
readable-stream@3.6.2:
|
readable-stream@3.6.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
inherits: 2.0.4
|
inherits: 2.0.4
|
||||||
@@ -6452,6 +6543,8 @@ snapshots:
|
|||||||
has-symbols: 1.1.0
|
has-symbols: 1.1.0
|
||||||
isarray: 2.0.5
|
isarray: 2.0.5
|
||||||
|
|
||||||
|
safe-buffer@5.1.2: {}
|
||||||
|
|
||||||
safe-buffer@5.2.1: {}
|
safe-buffer@5.2.1: {}
|
||||||
|
|
||||||
safe-push-apply@1.0.0:
|
safe-push-apply@1.0.0:
|
||||||
@@ -6501,6 +6594,8 @@ snapshots:
|
|||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
es-object-atoms: 1.1.1
|
es-object-atoms: 1.1.1
|
||||||
|
|
||||||
|
setimmediate@1.0.5: {}
|
||||||
|
|
||||||
sharp@0.34.5:
|
sharp@0.34.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@img/colour': 1.0.0
|
'@img/colour': 1.0.0
|
||||||
@@ -6590,6 +6685,8 @@ snapshots:
|
|||||||
|
|
||||||
split2@4.2.0: {}
|
split2@4.2.0: {}
|
||||||
|
|
||||||
|
sql.js@1.14.1: {}
|
||||||
|
|
||||||
sqlstring@2.3.3: {}
|
sqlstring@2.3.3: {}
|
||||||
|
|
||||||
stable-hash@0.0.5: {}
|
stable-hash@0.0.5: {}
|
||||||
@@ -6653,6 +6750,10 @@ snapshots:
|
|||||||
define-properties: 1.2.1
|
define-properties: 1.2.1
|
||||||
es-object-atoms: 1.1.1
|
es-object-atoms: 1.1.1
|
||||||
|
|
||||||
|
string_decoder@1.1.1:
|
||||||
|
dependencies:
|
||||||
|
safe-buffer: 5.1.2
|
||||||
|
|
||||||
string_decoder@1.3.0:
|
string_decoder@1.3.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer: 5.2.1
|
safe-buffer: 5.2.1
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "user" ADD COLUMN "bio" TEXT;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "follows" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"follower_id" TEXT NOT NULL,
|
||||||
|
"following_id" TEXT NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "follows_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "follows_follower_id_idx" ON "follows"("follower_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "follows_following_id_idx" ON "follows"("following_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "follows_follower_id_following_id_key" ON "follows"("follower_id", "following_id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "follows" ADD CONSTRAINT "follows_follower_id_fkey" FOREIGN KEY ("follower_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "follows" ADD CONSTRAINT "follows_following_id_fkey" FOREIGN KEY ("following_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
207
prisma/migrations/20260310111728_anki_refactor/migration.sql
Normal file
207
prisma/migrations/20260310111728_anki_refactor/migration.sql
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `folder_favorites` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `folders` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `pairs` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "CardType" AS ENUM ('NEW', 'LEARNING', 'REVIEW', 'RELEARNING');
|
||||||
|
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "CardQueue" AS ENUM ('USER_BURIED', 'SCHED_BURIED', 'SUSPENDED', 'NEW', 'LEARNING', 'REVIEW', 'IN_LEARNING', 'PREVIEW');
|
||||||
|
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "NoteKind" AS ENUM ('STANDARD', 'CLOZE');
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "folder_favorites" DROP CONSTRAINT "folder_favorites_folder_id_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "folder_favorites" DROP CONSTRAINT "folder_favorites_user_id_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "folders" DROP CONSTRAINT "folders_user_id_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "pairs" DROP CONSTRAINT "pairs_folder_id_fkey";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "folder_favorites";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "folders";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "pairs";
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "note_types" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"kind" "NoteKind" NOT NULL DEFAULT 'STANDARD',
|
||||||
|
"css" TEXT NOT NULL DEFAULT '',
|
||||||
|
"fields" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"templates" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "note_types_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "decks" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"desc" TEXT NOT NULL DEFAULT '',
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"visibility" "Visibility" NOT NULL DEFAULT 'PRIVATE',
|
||||||
|
"collapsed" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"conf" JSONB NOT NULL DEFAULT '{}',
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "decks_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "deck_favorites" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"deck_id" INTEGER NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "deck_favorites_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "notes" (
|
||||||
|
"id" BIGINT NOT NULL,
|
||||||
|
"guid" TEXT NOT NULL,
|
||||||
|
"note_type_id" INTEGER NOT NULL,
|
||||||
|
"mod" INTEGER NOT NULL,
|
||||||
|
"usn" INTEGER NOT NULL DEFAULT -1,
|
||||||
|
"tags" TEXT NOT NULL DEFAULT ' ',
|
||||||
|
"flds" TEXT NOT NULL,
|
||||||
|
"sfld" TEXT NOT NULL,
|
||||||
|
"csum" INTEGER NOT NULL,
|
||||||
|
"flags" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"data" TEXT NOT NULL DEFAULT '',
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "notes_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "cards" (
|
||||||
|
"id" BIGINT NOT NULL,
|
||||||
|
"note_id" BIGINT NOT NULL,
|
||||||
|
"deck_id" INTEGER NOT NULL,
|
||||||
|
"ord" INTEGER NOT NULL,
|
||||||
|
"mod" INTEGER NOT NULL,
|
||||||
|
"usn" INTEGER NOT NULL DEFAULT -1,
|
||||||
|
"type" "CardType" NOT NULL DEFAULT 'NEW',
|
||||||
|
"queue" "CardQueue" NOT NULL DEFAULT 'NEW',
|
||||||
|
"due" INTEGER NOT NULL,
|
||||||
|
"ivl" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"factor" INTEGER NOT NULL DEFAULT 2500,
|
||||||
|
"reps" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"lapses" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"left" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"odue" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"odid" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"flags" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"data" TEXT NOT NULL DEFAULT '',
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "cards_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "revlogs" (
|
||||||
|
"id" BIGINT NOT NULL,
|
||||||
|
"card_id" BIGINT NOT NULL,
|
||||||
|
"usn" INTEGER NOT NULL DEFAULT -1,
|
||||||
|
"ease" INTEGER NOT NULL,
|
||||||
|
"ivl" INTEGER NOT NULL,
|
||||||
|
"lastIvl" INTEGER NOT NULL,
|
||||||
|
"factor" INTEGER NOT NULL,
|
||||||
|
"time" INTEGER NOT NULL,
|
||||||
|
"type" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "revlogs_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "note_types_user_id_idx" ON "note_types"("user_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "decks_user_id_idx" ON "decks"("user_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "decks_visibility_idx" ON "decks"("visibility");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "deck_favorites_user_id_idx" ON "deck_favorites"("user_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "deck_favorites_deck_id_idx" ON "deck_favorites"("deck_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "deck_favorites_user_id_deck_id_key" ON "deck_favorites"("user_id", "deck_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "notes_guid_key" ON "notes"("guid");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "notes_user_id_idx" ON "notes"("user_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "notes_note_type_id_idx" ON "notes"("note_type_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "notes_csum_idx" ON "notes"("csum");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "cards_note_id_idx" ON "cards"("note_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "cards_deck_id_idx" ON "cards"("deck_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "cards_deck_id_queue_due_idx" ON "cards"("deck_id", "queue", "due");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "revlogs_card_id_idx" ON "revlogs"("card_id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "note_types" ADD CONSTRAINT "note_types_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "decks" ADD CONSTRAINT "decks_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "deck_favorites" ADD CONSTRAINT "deck_favorites_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "deck_favorites" ADD CONSTRAINT "deck_favorites_deck_id_fkey" FOREIGN KEY ("deck_id") REFERENCES "decks"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "notes" ADD CONSTRAINT "notes_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "notes" ADD CONSTRAINT "notes_note_type_id_fkey" FOREIGN KEY ("note_type_id") REFERENCES "note_types"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "cards" ADD CONSTRAINT "cards_note_id_fkey" FOREIGN KEY ("note_id") REFERENCES "notes"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "cards" ADD CONSTRAINT "cards_deck_id_fkey" FOREIGN KEY ("deck_id") REFERENCES "decks"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "revlogs" ADD CONSTRAINT "revlogs_card_id_fkey" FOREIGN KEY ("card_id") REFERENCES "cards"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "decks" ADD COLUMN "new_per_day" INTEGER NOT NULL DEFAULT 20,
|
||||||
|
ADD COLUMN "rev_per_day" INTEGER NOT NULL DEFAULT 200;
|
||||||
@@ -7,6 +7,10 @@ datasource db {
|
|||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// User & Auth
|
||||||
|
// ============================================
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id
|
id String @id
|
||||||
name String
|
name String
|
||||||
@@ -17,12 +21,13 @@ model User {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
displayUsername String?
|
displayUsername String?
|
||||||
username String @unique
|
username String @unique
|
||||||
|
bio String?
|
||||||
accounts Account[]
|
accounts Account[]
|
||||||
dictionaryLookUps DictionaryLookUp[]
|
decks Deck[]
|
||||||
folders Folder[]
|
deckFavorites DeckFavorite[]
|
||||||
folderFavorites FolderFavorite[]
|
|
||||||
sessions Session[]
|
sessions Session[]
|
||||||
translationHistories TranslationHistory[]
|
followers Follow[] @relation("UserFollowers")
|
||||||
|
following Follow[] @relation("UserFollowing")
|
||||||
|
|
||||||
@@map("user")
|
@@map("user")
|
||||||
}
|
}
|
||||||
@@ -74,127 +79,98 @@ model Verification {
|
|||||||
@@map("verification")
|
@@map("verification")
|
||||||
}
|
}
|
||||||
|
|
||||||
model Pair {
|
// ============================================
|
||||||
id Int @id @default(autoincrement())
|
// Deck & Card
|
||||||
language1 String
|
// ============================================
|
||||||
language2 String
|
|
||||||
text1 String
|
|
||||||
text2 String
|
|
||||||
ipa1 String?
|
|
||||||
ipa2 String?
|
|
||||||
folderId Int @map("folder_id")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@unique([folderId, language1, language2, text1, text2])
|
|
||||||
@@index([folderId])
|
|
||||||
@@map("pairs")
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Visibility {
|
enum Visibility {
|
||||||
PRIVATE
|
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
PRIVATE
|
||||||
}
|
}
|
||||||
|
|
||||||
model Folder {
|
enum CardType {
|
||||||
|
WORD
|
||||||
|
PHRASE
|
||||||
|
SENTENCE
|
||||||
|
}
|
||||||
|
|
||||||
|
model Deck {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
name String
|
name String
|
||||||
userId String @map("user_id")
|
desc String @db.Text @default("")
|
||||||
|
userId String
|
||||||
visibility Visibility @default(PRIVATE)
|
visibility Visibility @default(PRIVATE)
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
updatedAt DateTime @updatedAt
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
pairs Pair[]
|
cards Card[]
|
||||||
favorites FolderFavorite[]
|
favorites DeckFavorite[]
|
||||||
|
|
||||||
@@index([userId])
|
@@index([userId])
|
||||||
@@index([visibility])
|
@@index([visibility])
|
||||||
@@map("folders")
|
@@map("decks")
|
||||||
}
|
}
|
||||||
|
|
||||||
model FolderFavorite {
|
model Card {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
userId String @map("user_id")
|
deckId Int
|
||||||
folderId Int @map("folder_id")
|
word String
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@unique([userId, folderId])
|
|
||||||
@@index([userId])
|
|
||||||
@@index([folderId])
|
|
||||||
@@map("folder_favorites")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryLookUp {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
userId String? @map("user_id")
|
|
||||||
text String
|
|
||||||
queryLang String @map("query_lang")
|
|
||||||
definitionLang String @map("definition_lang")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
dictionaryItemId Int? @map("dictionary_item_id")
|
|
||||||
normalizedText String @default("") @map("normalized_text")
|
|
||||||
dictionaryItem DictionaryItem? @relation(fields: [dictionaryItemId], references: [id])
|
|
||||||
user User? @relation(fields: [userId], references: [id])
|
|
||||||
|
|
||||||
@@index([userId])
|
|
||||||
@@index([createdAt])
|
|
||||||
@@index([normalizedText])
|
|
||||||
@@map("dictionary_lookups")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryItem {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
frequency Int @default(1)
|
|
||||||
standardForm String @map("standard_form")
|
|
||||||
queryLang String @map("query_lang")
|
|
||||||
definitionLang String @map("definition_lang")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
entries DictionaryEntry[]
|
|
||||||
lookups DictionaryLookUp[]
|
|
||||||
|
|
||||||
@@unique([standardForm, queryLang, definitionLang])
|
|
||||||
@@index([standardForm])
|
|
||||||
@@index([queryLang, definitionLang])
|
|
||||||
@@map("dictionary_items")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryEntry {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
itemId Int @map("item_id")
|
|
||||||
ipa String?
|
ipa String?
|
||||||
definition String
|
queryLang String
|
||||||
partOfSpeech String? @map("part_of_speech")
|
cardType CardType @default(WORD)
|
||||||
example String
|
createdAt DateTime @default(now())
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
updatedAt DateTime @updatedAt
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade)
|
||||||
item DictionaryItem @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
meanings CardMeaning[]
|
||||||
|
|
||||||
@@index([itemId])
|
@@index([deckId])
|
||||||
@@index([createdAt])
|
@@index([word])
|
||||||
@@map("dictionary_entries")
|
@@map("cards")
|
||||||
}
|
}
|
||||||
|
|
||||||
model TranslationHistory {
|
model CardMeaning {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
userId String? @map("user_id")
|
cardId Int
|
||||||
sourceText String @map("source_text")
|
partOfSpeech String?
|
||||||
sourceLanguage String @map("source_language")
|
definition String
|
||||||
targetLanguage String @map("target_language")
|
example String?
|
||||||
translatedText String @map("translated_text")
|
createdAt DateTime @default(now())
|
||||||
sourceIpa String? @map("source_ipa")
|
updatedAt DateTime @updatedAt
|
||||||
targetIpa String? @map("target_ipa")
|
card Card @relation(fields: [cardId], references: [id], onDelete: Cascade)
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
user User? @relation(fields: [userId], references: [id])
|
|
||||||
|
|
||||||
@@index([userId])
|
@@index([cardId])
|
||||||
@@index([createdAt])
|
@@map("card_meanings")
|
||||||
@@index([sourceText, targetLanguage])
|
}
|
||||||
@@index([translatedText, sourceLanguage, targetLanguage])
|
|
||||||
@@map("translation_history")
|
model DeckFavorite {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
userId String
|
||||||
|
deckId Int
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@unique([userId, deckId])
|
||||||
|
@@index([userId])
|
||||||
|
@@index([deckId])
|
||||||
|
@@map("deck_favorites")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Social
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
model Follow {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
followerId String @map("follower_id")
|
||||||
|
followingId String @map("following_id")
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
|
||||||
|
follower User @relation("UserFollowers", fields: [followerId], references: [id], onDelete: Cascade)
|
||||||
|
following User @relation("UserFollowing", fields: [followingId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@unique([followerId, followingId])
|
||||||
|
@@index([followerId])
|
||||||
|
@@index([followingId])
|
||||||
|
@@map("follows")
|
||||||
}
|
}
|
||||||
|
|||||||
147
scripts/find-missing-translations.ts
Normal file
147
scripts/find-missing-translations.ts
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
* 查找缺失的翻译键
|
||||||
|
* 用法: npx tsx scripts/find-missing-translations.ts [locale]
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
|
const SRC_DIR = "./src";
|
||||||
|
const MESSAGES_DIR = "./messages";
|
||||||
|
const ALL_LOCALES = ["en-US", "zh-CN", "ja-JP", "ko-KR", "de-DE", "fr-FR", "it-IT", "ug-CN"];
|
||||||
|
|
||||||
|
function parseString(s: string): string | null {
|
||||||
|
s = s.trim();
|
||||||
|
if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
|
||||||
|
return s.slice(1, -1);
|
||||||
|
}
|
||||||
|
if (s.startsWith("`") && s.endsWith("`") && !s.includes("${")) {
|
||||||
|
return s.slice(1, -1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBindings(content: string): Map<string, string> {
|
||||||
|
const bindings = new Map<string, string>();
|
||||||
|
const pattern = /(?:const|let|var)\s+(\w+)\s*=\s*(?:await\s+)?(?:useTranslations|getTranslations)\s*\(\s*([^)]*)\s*\)/g;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((match = pattern.exec(content)) !== null) {
|
||||||
|
const varName = match[1];
|
||||||
|
const arg = match[2].trim();
|
||||||
|
bindings.set(varName, arg ? parseString(arg) || "" : "__ROOT__");
|
||||||
|
}
|
||||||
|
|
||||||
|
return bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUsages(content: string, file: string): { file: string; line: number; ns: string; key: string }[] {
|
||||||
|
const usages: { file: string; line: number; ns: string; key: string }[] = [];
|
||||||
|
const bindings = getBindings(content);
|
||||||
|
const lines = content.split("\n");
|
||||||
|
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
const line = lines[i];
|
||||||
|
for (const [varName, ns] of bindings) {
|
||||||
|
const pattern = new RegExp(`\\b${varName}\\s*\\(\\s*("[^"]*"|'[^']*'|\`[^\`]*\`)(?:\\s*,|\\s*\\))`, "g");
|
||||||
|
let match;
|
||||||
|
while ((match = pattern.exec(line)) !== null) {
|
||||||
|
const key = parseString(match[1]);
|
||||||
|
if (key) usages.push({ file, line: i + 1, ns, key });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return usages;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFiles(dir: string): string[] {
|
||||||
|
const files: string[] = [];
|
||||||
|
if (!fs.existsSync(dir)) return files;
|
||||||
|
|
||||||
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||||
|
const p = path.join(dir, entry.name);
|
||||||
|
if (entry.isDirectory()) files.push(...getFiles(p));
|
||||||
|
else if (entry.isFile() && /\.(tsx?|ts)$/.test(entry.name)) files.push(p);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyExists(key: string, ns: string, trans: Record<string, unknown>): boolean {
|
||||||
|
let obj: unknown;
|
||||||
|
|
||||||
|
if (ns === "__ROOT__") {
|
||||||
|
obj = trans;
|
||||||
|
} else {
|
||||||
|
obj = trans[ns];
|
||||||
|
if (typeof obj !== "object" || obj === null) {
|
||||||
|
obj = trans;
|
||||||
|
for (const part of ns.split(".")) {
|
||||||
|
if (typeof obj !== "object" || obj === null) return false;
|
||||||
|
obj = (obj as Record<string, unknown>)[part];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof obj !== "object" || obj === null) return false;
|
||||||
|
|
||||||
|
for (const part of key.split(".")) {
|
||||||
|
if (typeof obj !== "object" || obj === null) return false;
|
||||||
|
obj = (obj as Record<string, unknown>)[part];
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof obj === "string";
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const locales = process.argv[2] ? [process.argv[2]] : ALL_LOCALES;
|
||||||
|
|
||||||
|
const files = getFiles(SRC_DIR);
|
||||||
|
const usages: { file: string; line: number; ns: string; key: string }[] = [];
|
||||||
|
|
||||||
|
for (const f of files) {
|
||||||
|
usages.push(...getUsages(fs.readFileSync(f, "utf-8"), f));
|
||||||
|
}
|
||||||
|
|
||||||
|
const unique = new Map<string, { file: string; line: number; ns: string; key: string }>();
|
||||||
|
for (const u of usages) {
|
||||||
|
unique.set(`${u.file}:${u.line}:${u.ns}:${u.key}`, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Scanned ${files.length} files, ${unique.size} usages\n`);
|
||||||
|
|
||||||
|
for (const locale of locales) {
|
||||||
|
console.log(`\n${"=".repeat(50)}\nLocale: ${locale}\n${"=".repeat(50)}`);
|
||||||
|
|
||||||
|
const filePath = path.join(MESSAGES_DIR, `${locale}.json`);
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
console.log(`File not found: ${filePath}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const trans = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
||||||
|
const missing = Array.from(unique.values()).filter(u => !keyExists(u.key, u.ns, trans));
|
||||||
|
|
||||||
|
if (missing.length === 0) {
|
||||||
|
console.log("All translations exist!");
|
||||||
|
} else {
|
||||||
|
console.log(`\nMissing ${missing.length} translations:\n`);
|
||||||
|
const byFile = new Map<string, typeof missing>();
|
||||||
|
for (const u of missing) {
|
||||||
|
if (!byFile.has(u.file)) byFile.set(u.file, []);
|
||||||
|
byFile.get(u.file)!.push(u);
|
||||||
|
}
|
||||||
|
for (const [file, list] of byFile) {
|
||||||
|
console.log(file);
|
||||||
|
for (const u of list) {
|
||||||
|
console.log(` L${u.line} [${u.ns === "__ROOT__" ? "root" : u.ns}] ${u.key}`);
|
||||||
|
}
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("\nDone!");
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
154
scripts/find-unused-translations.ts
Normal file
154
scripts/find-unused-translations.ts
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/**
|
||||||
|
* 查找多余的翻译键
|
||||||
|
* 用法: npx tsx scripts/find-unused-translations.ts [locale]
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
|
const SRC_DIR = "./src";
|
||||||
|
const MESSAGES_DIR = "./messages";
|
||||||
|
const ALL_LOCALES = ["en-US", "zh-CN", "ja-JP", "ko-KR", "de-DE", "fr-FR", "it-IT", "ug-CN"];
|
||||||
|
|
||||||
|
function parseString(s: string): string | null {
|
||||||
|
s = s.trim();
|
||||||
|
if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
|
||||||
|
return s.slice(1, -1);
|
||||||
|
}
|
||||||
|
if (s.startsWith("`") && s.endsWith("`") && !s.includes("${")) {
|
||||||
|
return s.slice(1, -1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBindings(content: string): Map<string, string> {
|
||||||
|
const bindings = new Map<string, string>();
|
||||||
|
const pattern = /(?:const|let|var)\s+(\w+)\s*=\s*(?:await\s+)?(?:useTranslations|getTranslations)\s*\(\s*([^)]*)\s*\)/g;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((match = pattern.exec(content)) !== null) {
|
||||||
|
const varName = match[1];
|
||||||
|
const arg = match[2].trim();
|
||||||
|
bindings.set(varName, arg ? parseString(arg) || "" : "__ROOT__");
|
||||||
|
}
|
||||||
|
|
||||||
|
return bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUsedKeys(content: string): Map<string, Set<string>> {
|
||||||
|
const used = new Map<string, Set<string>>();
|
||||||
|
const bindings = getBindings(content);
|
||||||
|
|
||||||
|
for (const [varName, ns] of bindings) {
|
||||||
|
const pattern = new RegExp(`\\b${varName}\\s*\\(\\s*("[^"]*"|'[^']*'|\`[^\`]*\`)(?:\\s*,|\\s*\\))`, "g");
|
||||||
|
let match;
|
||||||
|
while ((match = pattern.exec(content)) !== null) {
|
||||||
|
const key = parseString(match[1]);
|
||||||
|
if (key) {
|
||||||
|
if (!used.has(ns)) used.set(ns, new Set());
|
||||||
|
used.get(ns)!.add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return used;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFiles(dir: string): string[] {
|
||||||
|
const files: string[] = [];
|
||||||
|
if (!fs.existsSync(dir)) return files;
|
||||||
|
|
||||||
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||||
|
const p = path.join(dir, entry.name);
|
||||||
|
if (entry.isDirectory()) files.push(...getFiles(p));
|
||||||
|
else if (entry.isFile() && /\.(tsx?|ts)$/.test(entry.name)) files.push(p);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function flattenKeys(obj: Record<string, unknown>, prefix = ""): string[] {
|
||||||
|
const keys: string[] = [];
|
||||||
|
for (const key of Object.keys(obj)) {
|
||||||
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
||||||
|
if (typeof obj[key] === "object" && obj[key] !== null) {
|
||||||
|
keys.push(...flattenKeys(obj[key] as Record<string, unknown>, fullKey));
|
||||||
|
} else if (typeof obj[key] === "string") {
|
||||||
|
keys.push(fullKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUsed(fullKey: string, used: Map<string, Set<string>>): boolean {
|
||||||
|
const parts = fullKey.split(".");
|
||||||
|
|
||||||
|
for (let i = 1; i < parts.length; i++) {
|
||||||
|
const ns = parts.slice(0, i).join(".");
|
||||||
|
const key = parts.slice(i).join(".");
|
||||||
|
|
||||||
|
const nsKeys = used.get(ns);
|
||||||
|
if (nsKeys) {
|
||||||
|
if (nsKeys.has(key)) return true;
|
||||||
|
for (const k of nsKeys) {
|
||||||
|
if (key.startsWith(k + ".")) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootKeys = used.get("__ROOT__");
|
||||||
|
return rootKeys?.has(fullKey) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const locales = process.argv[2] ? [process.argv[2]] : ALL_LOCALES;
|
||||||
|
|
||||||
|
const files = getFiles(SRC_DIR);
|
||||||
|
const allUsed = new Map<string, Set<string>>();
|
||||||
|
|
||||||
|
for (const f of files) {
|
||||||
|
const used = getUsedKeys(fs.readFileSync(f, "utf-8"));
|
||||||
|
for (const [ns, keys] of used) {
|
||||||
|
if (!allUsed.has(ns)) allUsed.set(ns, new Set());
|
||||||
|
for (const k of keys) allUsed.get(ns)!.add(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Scanned ${files.length} files, ${allUsed.size} namespaces\n`);
|
||||||
|
|
||||||
|
for (const locale of locales) {
|
||||||
|
console.log(`\n${"=".repeat(50)}\nLocale: ${locale}\n${"=".repeat(50)}`);
|
||||||
|
|
||||||
|
const filePath = path.join(MESSAGES_DIR, `${locale}.json`);
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
console.log(`File not found: ${filePath}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const trans = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
||||||
|
const allKeys = flattenKeys(trans);
|
||||||
|
const unused = allKeys.filter(k => !isUsed(k, allUsed));
|
||||||
|
|
||||||
|
console.log(`Total: ${allKeys.length} keys`);
|
||||||
|
|
||||||
|
if (unused.length === 0) {
|
||||||
|
console.log("No unused translations!");
|
||||||
|
} else {
|
||||||
|
console.log(`\n${unused.length} potentially unused:\n`);
|
||||||
|
const grouped = new Map<string, string[]>();
|
||||||
|
for (const k of unused) {
|
||||||
|
const [ns, ...rest] = k.split(".");
|
||||||
|
if (!grouped.has(ns)) grouped.set(ns, []);
|
||||||
|
grouped.get(ns)!.push(rest.join("."));
|
||||||
|
}
|
||||||
|
for (const [ns, keys] of grouped) {
|
||||||
|
console.log(`${ns}`);
|
||||||
|
for (const k of keys) console.log(` ${k}`);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("\nDone!");
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -9,6 +8,7 @@ import { Card, CardBody } from "@/design-system/base/card";
|
|||||||
import { Input } from "@/design-system/base/input";
|
import { Input } from "@/design-system/base/input";
|
||||||
import { PrimaryButton } from "@/design-system/base/button";
|
import { PrimaryButton } from "@/design-system/base/button";
|
||||||
import { VStack } from "@/design-system/layout/stack";
|
import { VStack } from "@/design-system/layout/stack";
|
||||||
|
import { actionRequestPasswordReset } from "@/modules/auth/forgot-password-action";
|
||||||
|
|
||||||
export default function ForgotPasswordPage() {
|
export default function ForgotPasswordPage() {
|
||||||
const t = useTranslations("auth");
|
const t = useTranslations("auth");
|
||||||
@@ -23,16 +23,13 @@ export default function ForgotPasswordPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { error } = await authClient.requestPasswordReset({
|
const result = await actionRequestPasswordReset({ email });
|
||||||
email,
|
|
||||||
redirectTo: "/reset-password",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (error) {
|
if (!result.success) {
|
||||||
toast.error(error.message ?? t("resetPasswordFailed"));
|
toast.error(result.message);
|
||||||
} else {
|
} else {
|
||||||
setSent(true);
|
setSent(true);
|
||||||
toast.success(t("resetPasswordEmailSent"));
|
toast.success(result.message);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { toast } from "sonner";
|
|||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Card, CardBody } from "@/design-system/base/card";
|
import { Card, CardBody } from "@/design-system/base/card";
|
||||||
import { Input } from "@/design-system/base/input";
|
import { Input } from "@/design-system/base/input";
|
||||||
import { PrimaryButton } from "@/design-system/base/button";
|
import { PrimaryButton, LinkButton } from "@/design-system/base/button";
|
||||||
import { VStack } from "@/design-system/layout/stack";
|
import { VStack } from "@/design-system/layout/stack";
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
@@ -16,6 +16,9 @@ export default function LoginPage() {
|
|||||||
const [username, setUsername] = useState("");
|
const [username, setUsername] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [resendLoading, setResendLoading] = useState(false);
|
||||||
|
const [showResendOption, setShowResendOption] = useState(false);
|
||||||
|
const [unverifiedEmail, setUnverifiedEmail] = useState("");
|
||||||
|
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const redirectTo = searchParams.get("redirect");
|
const redirectTo = searchParams.get("redirect");
|
||||||
@@ -25,10 +28,31 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPending && session?.user?.username && !redirectTo) {
|
if (!isPending && session?.user?.username && !redirectTo) {
|
||||||
router.push("/folders");
|
router.push("/decks");
|
||||||
}
|
}
|
||||||
}, [session, isPending, router, redirectTo]);
|
}, [session, isPending, router, redirectTo]);
|
||||||
|
|
||||||
|
const handleResendVerification = async () => {
|
||||||
|
if (!unverifiedEmail) return;
|
||||||
|
|
||||||
|
setResendLoading(true);
|
||||||
|
try {
|
||||||
|
const { error } = await authClient.sendVerificationEmail({
|
||||||
|
email: unverifiedEmail,
|
||||||
|
callbackURL: "/login",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
toast.error(t("resendFailed"));
|
||||||
|
} else {
|
||||||
|
toast.success(t("resendSuccess"));
|
||||||
|
setShowResendOption(false);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setResendLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleLogin = async () => {
|
const handleLogin = async () => {
|
||||||
if (!username || !password) {
|
if (!username || !password) {
|
||||||
toast.error(t("enterCredentials"));
|
toast.error(t("enterCredentials"));
|
||||||
@@ -36,6 +60,7 @@ export default function LoginPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
setShowResendOption(false);
|
||||||
try {
|
try {
|
||||||
if (username.includes("@")) {
|
if (username.includes("@")) {
|
||||||
const { error } = await authClient.signIn.email({
|
const { error } = await authClient.signIn.email({
|
||||||
@@ -43,7 +68,13 @@ export default function LoginPage() {
|
|||||||
password: password,
|
password: password,
|
||||||
});
|
});
|
||||||
if (error) {
|
if (error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
setUnverifiedEmail(username);
|
||||||
|
setShowResendOption(true);
|
||||||
|
toast.error(t("emailNotVerified"));
|
||||||
|
} else {
|
||||||
toast.error(error.message ?? t("loginFailed"));
|
toast.error(error.message ?? t("loginFailed"));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -52,11 +83,15 @@ export default function LoginPage() {
|
|||||||
password: password,
|
password: password,
|
||||||
});
|
});
|
||||||
if (error) {
|
if (error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
toast.error(t("emailNotVerified"));
|
||||||
|
} else {
|
||||||
toast.error(error.message ?? t("loginFailed"));
|
toast.error(error.message ?? t("loginFailed"));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
router.push(redirectTo ?? "/folders");
|
router.push(redirectTo ?? "/decks");
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -91,6 +126,21 @@ export default function LoginPage() {
|
|||||||
{t("forgotPassword")}
|
{t("forgotPassword")}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
{showResendOption && (
|
||||||
|
<div className="w-full p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg text-sm">
|
||||||
|
<p className="text-yellow-800 dark:text-yellow-200 mb-2">
|
||||||
|
{t("emailNotVerifiedHint")}
|
||||||
|
</p>
|
||||||
|
<LinkButton
|
||||||
|
onClick={handleResendVerification}
|
||||||
|
loading={resendLoading}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t("resendVerification")}
|
||||||
|
</LinkButton>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
onClick={handleLogin}
|
onClick={handleLogin}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ export default async function ProfilePage() {
|
|||||||
redirect("/login?redirect=/profile");
|
redirect("/login?redirect=/profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(session.user.username ? `/users/${session.user.username}` : "/folders");
|
redirect(session.user.username ? `/users/${session.user.username}` : "/decks");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export default function SignUpPage() {
|
|||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [verificationSent, setVerificationSent] = useState(false);
|
||||||
|
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const redirectTo = searchParams.get("redirect");
|
const redirectTo = searchParams.get("redirect");
|
||||||
@@ -26,10 +27,10 @@ export default function SignUpPage() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPending && session?.user?.username && !redirectTo) {
|
if (!isPending && session?.user?.username && !redirectTo && !verificationSent) {
|
||||||
router.push("/folders");
|
router.push("/decks");
|
||||||
}
|
}
|
||||||
}, [session, isPending, router, redirectTo]);
|
}, [session, isPending, router, redirectTo, verificationSent]);
|
||||||
|
|
||||||
const handleSignUp = async () => {
|
const handleSignUp = async () => {
|
||||||
if (!username || !email || !password) {
|
if (!username || !email || !password) {
|
||||||
@@ -49,12 +50,38 @@ export default function SignUpPage() {
|
|||||||
toast.error(error.message ?? t("signUpFailed"));
|
toast.error(error.message ?? t("signUpFailed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
router.push(redirectTo ?? "/folders");
|
setVerificationSent(true);
|
||||||
|
toast.success(t("verificationEmailSent"));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (verificationSent) {
|
||||||
|
return (
|
||||||
|
<div className="flex justify-center items-center min-h-screen">
|
||||||
|
<Card className="w-96">
|
||||||
|
<CardBody>
|
||||||
|
<VStack gap={4} align="center" justify="center">
|
||||||
|
<h1 className="text-2xl font-bold text-center w-full">
|
||||||
|
{t("verifyYourEmail")}
|
||||||
|
</h1>
|
||||||
|
<p className="text-center text-gray-600">
|
||||||
|
{t("verificationEmailSentHint", { email })}
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href="/login"
|
||||||
|
className="text-primary-500 hover:underline"
|
||||||
|
>
|
||||||
|
{t("backToLogin")}
|
||||||
|
</Link>
|
||||||
|
</VStack>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center min-h-screen">
|
<div className="flex justify-center items-center min-h-screen">
|
||||||
<Card className="w-96">
|
<Card className="w-96">
|
||||||
|
|||||||
103
src/app/(auth)/users/[username]/DeleteAccountButton.tsx
Normal file
103
src/app/(auth)/users/[username]/DeleteAccountButton.tsx
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { Button } from "@/design-system/base/button";
|
||||||
|
import { Modal } from "@/design-system/overlay/modal";
|
||||||
|
import { actionDeleteAccount } from "@/modules/auth/auth-action";
|
||||||
|
|
||||||
|
interface DeleteAccountButtonProps {
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DeleteAccountButton({ username }: DeleteAccountButtonProps) {
|
||||||
|
const t = useTranslations("user_profile");
|
||||||
|
const router = useRouter();
|
||||||
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
const [confirmUsername, setConfirmUsername] = useState("");
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
if (confirmUsername !== username) {
|
||||||
|
toast.error(t("deleteAccount.usernameMismatch"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const result = await actionDeleteAccount();
|
||||||
|
if (result.success) {
|
||||||
|
toast.success(t("deleteAccount.success"));
|
||||||
|
router.push("/");
|
||||||
|
} else {
|
||||||
|
toast.error(result.message || t("deleteAccount.failed"));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
toast.error(t("deleteAccount.failed"));
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
setShowModal(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
onClick={() => setShowModal(true)}
|
||||||
|
className="text-xs text-gray-400 hover:text-red-500 transition-colors"
|
||||||
|
>
|
||||||
|
{t("deleteAccount.button")}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Modal open={showModal} onClose={() => setShowModal(false)}>
|
||||||
|
<div className="p-6">
|
||||||
|
<h2 className="text-xl font-bold text-red-600 mb-4">
|
||||||
|
{t("deleteAccount.title")}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
<p className="text-gray-700">
|
||||||
|
{t("deleteAccount.warning")}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul className="list-disc list-inside text-gray-600 text-sm space-y-1">
|
||||||
|
<li>{t("deleteAccount.warningDecks")}</li>
|
||||||
|
<li>{t("deleteAccount.warningCards")}</li>
|
||||||
|
<li>{t("deleteAccount.warningHistory")}</li>
|
||||||
|
<li>{t("deleteAccount.warningPermanent")}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div className="mt-4">
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
{t("deleteAccount.confirmLabel")} <span className="font-mono font-bold">{username}</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={confirmUsername}
|
||||||
|
onChange={(e) => setConfirmUsername(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-red-500"
|
||||||
|
placeholder={username}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end gap-3 mt-6">
|
||||||
|
<Button variant="secondary" onClick={() => setShowModal(false)}>
|
||||||
|
{t("deleteAccount.cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="error"
|
||||||
|
onClick={handleDelete}
|
||||||
|
loading={loading}
|
||||||
|
disabled={confirmUsername !== username}
|
||||||
|
>
|
||||||
|
{t("deleteAccount.confirm")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
44
src/app/(auth)/users/[username]/followers/page.tsx
Normal file
44
src/app/(auth)/users/[username]/followers/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
|
import { UserList } from "@/components/follow/UserList";
|
||||||
|
import { actionGetUserProfileByUsername } from "@/modules/auth/auth-action";
|
||||||
|
import { actionGetFollowers } from "@/modules/follow/follow-action";
|
||||||
|
|
||||||
|
interface FollowersPageProps {
|
||||||
|
params: Promise<{ username: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function FollowersPage({ params }: FollowersPageProps) {
|
||||||
|
const { username } = await params;
|
||||||
|
const t = await getTranslations("follow");
|
||||||
|
|
||||||
|
const userResult = await actionGetUserProfileByUsername({ username });
|
||||||
|
|
||||||
|
if (!userResult.success || !userResult.data) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = userResult.data;
|
||||||
|
|
||||||
|
const followersResult = await actionGetFollowers({
|
||||||
|
userId: user.id,
|
||||||
|
page: 1,
|
||||||
|
limit: 50,
|
||||||
|
});
|
||||||
|
|
||||||
|
const followers = followersResult.success && followersResult.data
|
||||||
|
? followersResult.data.followers.map((f) => f.user)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<div className="bg-white rounded-lg shadow-md p-6">
|
||||||
|
<h1 className="text-2xl font-bold text-gray-800 mb-6">
|
||||||
|
{t("followersOf", { username: user.displayUsername || user.username || "User" })}
|
||||||
|
</h1>
|
||||||
|
<UserList users={followers} emptyMessage={t("noFollowers")} />
|
||||||
|
</div>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
44
src/app/(auth)/users/[username]/following/page.tsx
Normal file
44
src/app/(auth)/users/[username]/following/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
|
import { UserList } from "@/components/follow/UserList";
|
||||||
|
import { actionGetUserProfileByUsername } from "@/modules/auth/auth-action";
|
||||||
|
import { actionGetFollowing } from "@/modules/follow/follow-action";
|
||||||
|
|
||||||
|
interface FollowingPageProps {
|
||||||
|
params: Promise<{ username: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function FollowingPage({ params }: FollowingPageProps) {
|
||||||
|
const { username } = await params;
|
||||||
|
const t = await getTranslations("follow");
|
||||||
|
|
||||||
|
const userResult = await actionGetUserProfileByUsername({ username });
|
||||||
|
|
||||||
|
if (!userResult.success || !userResult.data) {
|
||||||
|
notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = userResult.data;
|
||||||
|
|
||||||
|
const followingResult = await actionGetFollowing({
|
||||||
|
userId: user.id,
|
||||||
|
page: 1,
|
||||||
|
limit: 50,
|
||||||
|
});
|
||||||
|
|
||||||
|
const following = followingResult.success && followingResult.data
|
||||||
|
? followingResult.data.following.map((f) => f.user)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<div className="bg-white rounded-lg shadow-md p-6">
|
||||||
|
<h1 className="text-2xl font-bold text-gray-800 mb-6">
|
||||||
|
{t("followingOf", { username: user.displayUsername || user.username || "User" })}
|
||||||
|
</h1>
|
||||||
|
<UserList users={following} emptyMessage={t("noFollowing")} />
|
||||||
|
</div>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
import { LightButton, LinkButton } from "@/design-system/base/button";
|
import { LinkButton } from "@/design-system/base/button";
|
||||||
import { actionGetUserProfileByUsername } from "@/modules/auth/auth-action";
|
import { actionGetUserProfileByUsername } from "@/modules/auth/auth-action";
|
||||||
import { repoGetFoldersWithTotalPairsByUserId } from "@/modules/folder/folder-repository";
|
import { repoGetDecksByUserId } from "@/modules/deck/deck-repository";
|
||||||
|
import { actionGetFollowStatus } from "@/modules/follow/follow-action";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
// import { LogoutButton } from "./LogoutButton";
|
import { FollowStats } from "@/components/follow/FollowStats";
|
||||||
|
import { DeleteAccountButton } from "./DeleteAccountButton";
|
||||||
|
|
||||||
interface UserPageProps {
|
interface UserPageProps {
|
||||||
params: Promise<{ username: string; }>;
|
params: Promise<{ username: string; }>;
|
||||||
@@ -18,10 +20,8 @@ export default async function UserPage({ params }: UserPageProps) {
|
|||||||
const { username } = await params;
|
const { username } = await params;
|
||||||
const t = await getTranslations("user_profile");
|
const t = await getTranslations("user_profile");
|
||||||
|
|
||||||
// Get current session
|
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
|
||||||
// Get user profile
|
|
||||||
const result = await actionGetUserProfileByUsername({ username });
|
const result = await actionGetUserProfileByUsername({ username });
|
||||||
|
|
||||||
if (!result.success || !result.data) {
|
if (!result.success || !result.data) {
|
||||||
@@ -30,24 +30,34 @@ export default async function UserPage({ params }: UserPageProps) {
|
|||||||
|
|
||||||
const user = result.data;
|
const user = result.data;
|
||||||
|
|
||||||
// Get user's folders
|
const [decks, followStatus] = await Promise.all([
|
||||||
const folders = await repoGetFoldersWithTotalPairsByUserId(user.id);
|
repoGetDecksByUserId({ userId: user.id }),
|
||||||
|
actionGetFollowStatus({ targetUserId: user.id }),
|
||||||
|
]);
|
||||||
|
|
||||||
// Check if viewing own profile
|
|
||||||
const isOwnProfile = session?.user?.username === username || session?.user?.email === username;
|
const isOwnProfile = session?.user?.username === username || session?.user?.email === username;
|
||||||
|
|
||||||
|
const followersCount = followStatus.success && followStatus.data ? followStatus.data.followersCount : 0;
|
||||||
|
const followingCount = followStatus.success && followStatus.data ? followStatus.data.followingCount : 0;
|
||||||
|
const isFollowing = followStatus.success && followStatus.data ? followStatus.data.isFollowing : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout>
|
<PageLayout>
|
||||||
{/* Header */}
|
|
||||||
<div className="bg-white rounded-lg shadow-md p-6 mb-6">
|
<div className="bg-white rounded-lg shadow-md p-6 mb-6">
|
||||||
<div className="flex items-center justify-between mb-4">
|
<div className="flex items-center justify-between mb-4">
|
||||||
<div></div>
|
<div></div>
|
||||||
{isOwnProfile && <LinkButton href="/logout">{t("logout")}</LinkButton>}
|
<div className="flex items-center gap-3">
|
||||||
|
{isOwnProfile && (
|
||||||
|
<>
|
||||||
|
<LinkButton href="/logout">{t("logout")}</LinkButton>
|
||||||
|
<DeleteAccountButton username={username} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-6">
|
</div>
|
||||||
{/* Avatar */}
|
<div className="flex flex-col sm:flex-row items-start sm:items-center space-y-4 sm:space-y-0 sm:space-x-6">
|
||||||
{user.image ? (
|
{user.image ? (
|
||||||
<div className="relative w-24 h-24 rounded-full border-4 border-primary-500 overflow-hidden">
|
<div className="relative w-24 h-24 rounded-full border-4 border-primary-500 overflow-hidden flex-shrink-0">
|
||||||
<Image
|
<Image
|
||||||
src={user.image}
|
src={user.image}
|
||||||
alt={user.displayUsername || user.username || user.email}
|
alt={user.displayUsername || user.username || user.email}
|
||||||
@@ -57,14 +67,13 @@ export default async function UserPage({ params }: UserPageProps) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-24 h-24 rounded-full bg-primary-500 border-4 border-primary-500 flex items-center justify-center">
|
<div className="w-24 h-24 rounded-full bg-primary-500 border-4 border-primary-500 flex items-center justify-center flex-shrink-0">
|
||||||
<span className="text-3xl font-bold text-white">
|
<span className="text-3xl font-bold text-white">
|
||||||
{(user.displayUsername || user.username || user.email)[0].toUpperCase()}
|
{(user.displayUsername || user.username || user.email)[0].toUpperCase()}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* User Info */}
|
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h1 className="text-3xl font-bold text-gray-800 mb-2">
|
<h1 className="text-3xl font-bold text-gray-800 mb-2">
|
||||||
{user.displayUsername || user.username || t("anonymous")}
|
{user.displayUsername || user.username || t("anonymous")}
|
||||||
@@ -74,27 +83,39 @@ export default async function UserPage({ params }: UserPageProps) {
|
|||||||
@{user.username}
|
@{user.username}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<p className="text-gray-600 text-sm mb-1">
|
{user.bio && (
|
||||||
{user.email}
|
<p className="text-gray-700 mt-2 mb-2">
|
||||||
|
{user.bio}
|
||||||
</p>
|
</p>
|
||||||
<div className="flex items-center space-x-4 text-sm">
|
)}
|
||||||
|
<div className="flex flex-wrap items-center gap-4 text-sm mt-3">
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">
|
||||||
Joined: {new Date(user.createdAt).toLocaleDateString()}
|
{t("joined")}: {new Date(user.createdAt).toLocaleDateString()}
|
||||||
</span>
|
</span>
|
||||||
{user.emailVerified && (
|
{user.emailVerified && (
|
||||||
<span className="flex items-center text-green-600">
|
<span className="flex items-center text-green-600">
|
||||||
<svg className="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
<svg className="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
||||||
<path fillRule="evenodd" 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.293 12.293a1 1 0 101.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
|
<path fillRule="evenodd" 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.293 12.293a1 1 0 101.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
|
||||||
</svg>
|
</svg>
|
||||||
Verified
|
{t("verified")}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mt-3">
|
||||||
|
<FollowStats
|
||||||
|
userId={user.id}
|
||||||
|
initialFollowersCount={followersCount}
|
||||||
|
initialFollowingCount={followingCount}
|
||||||
|
initialIsFollowing={isFollowing}
|
||||||
|
currentUserId={session?.user?.id}
|
||||||
|
isOwnProfile={isOwnProfile}
|
||||||
|
username={user.username || user.id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Account Info */}
|
|
||||||
<div className="bg-white rounded-lg shadow-md p-6 mb-6">
|
<div className="bg-white rounded-lg shadow-md p-6 mb-6">
|
||||||
<h2 className="text-xl font-semibold text-gray-800 mb-4">{t("accountInfo")}</h2>
|
<h2 className="text-xl font-semibold text-gray-800 mb-4">{t("accountInfo")}</h2>
|
||||||
<dl className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
<dl className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||||
@@ -123,47 +144,46 @@ export default async function UserPage({ params }: UserPageProps) {
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Folders Section */}
|
|
||||||
<div className="bg-white rounded-lg shadow-md p-6">
|
<div className="bg-white rounded-lg shadow-md p-6">
|
||||||
<h2 className="text-xl font-semibold text-gray-800 mb-4">{t("folders.title")}</h2>
|
<h2 className="text-xl font-semibold text-gray-800 mb-4">{t("decks.title")}</h2>
|
||||||
{folders.length === 0 ? (
|
{decks.length === 0 ? (
|
||||||
<p className="text-gray-500 text-center py-8">{t("folders.noFolders")}</p>
|
<p className="text-gray-500 text-center py-8">{t("decks.noDecks")}</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="min-w-full divide-y divide-gray-200">
|
<table className="min-w-full divide-y divide-gray-200">
|
||||||
<thead className="bg-gray-50">
|
<thead className="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
{t("folders.folderName")}
|
{t("decks.deckName")}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
{t("folders.totalPairs")}
|
{t("decks.totalCards")}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
{t("folders.createdAt")}
|
{t("decks.createdAt")}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
{t("folders.actions")}
|
{t("decks.actions")}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="bg-white divide-y divide-gray-200">
|
<tbody className="bg-white divide-y divide-gray-200">
|
||||||
{folders.map((folder) => (
|
{decks.map((deck) => (
|
||||||
<tr key={folder.id} className="hover:bg-gray-50">
|
<tr key={deck.id} className="hover:bg-gray-50">
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
<div className="text-sm font-medium text-gray-900">{folder.name}</div>
|
<div className="text-sm font-medium text-gray-900">{deck.name}</div>
|
||||||
<div className="text-sm text-gray-500">ID: {folder.id}</div>
|
<div className="text-sm text-gray-500">ID: {deck.id}</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
<div className="text-sm text-gray-900">{folder.total}</div>
|
<div className="text-sm text-gray-900">{deck.cardCount ?? 0}</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
{new Date(folder.createdAt).toLocaleDateString()}
|
{new Date(deck.createdAt).toLocaleDateString()}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||||
<Link href={`/folders/${folder.id}`}>
|
<Link href={`/decks/${deck.id}`}>
|
||||||
<LinkButton>
|
<LinkButton>
|
||||||
{t("folders.view")}
|
{t("decks.view")}
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -7,19 +7,25 @@ import { useDictionaryStore } from "./stores/dictionaryStore";
|
|||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
import { LightButton } from "@/design-system/base/button";
|
import { LightButton } from "@/design-system/base/button";
|
||||||
import { Input } from "@/design-system/base/input";
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Select } from "@/design-system/base/select";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
|
import { HStack, VStack } from "@/design-system/layout/stack";
|
||||||
import { Plus, RefreshCw } from "lucide-react";
|
import { Plus, RefreshCw } from "lucide-react";
|
||||||
import { DictionaryEntry } from "./DictionaryEntry";
|
import { DictionaryEntry } from "./DictionaryEntry";
|
||||||
import { LanguageSelector } from "./LanguageSelector";
|
import { LanguageSelector } from "./LanguageSelector";
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
import { actionGetFoldersByUserId, actionCreatePair } from "@/modules/folder/folder-action";
|
import { actionGetDecksByUserId } from "@/modules/deck/deck-action";
|
||||||
import { TSharedFolder } from "@/shared/folder-type";
|
import { actionCreateCard } from "@/modules/card/card-action";
|
||||||
|
import type { ActionOutputDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
import type { CardType } from "@/modules/card/card-action-dto";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { getNativeName } from "./stores/dictionaryStore";
|
||||||
|
|
||||||
interface DictionaryClientProps {
|
interface DictionaryClientProps {
|
||||||
initialFolders: TSharedFolder[];
|
initialDecks: ActionOutputDeck[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
export function DictionaryClient({ initialDecks }: DictionaryClientProps) {
|
||||||
const t = useTranslations("dictionary");
|
const t = useTranslations("dictionary");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -39,7 +45,8 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
} = useDictionaryStore();
|
} = useDictionaryStore();
|
||||||
|
|
||||||
const { data: session } = authClient.useSession();
|
const { data: session } = authClient.useSession();
|
||||||
const [folders, setFolders] = useState<TSharedFolder[]>(initialFolders);
|
const [decks, setDecks] = useState<ActionOutputDeck[]>(initialDecks);
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const q = searchParams.get("q") || undefined;
|
const q = searchParams.get("q") || undefined;
|
||||||
@@ -55,9 +62,9 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (session?.user?.id) {
|
if (session?.user?.id) {
|
||||||
actionGetFoldersByUserId(session.user.id).then((result) => {
|
actionGetDecksByUserId(session.user.id).then((result) => {
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setFolders(result.data);
|
setDecks(result.data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -79,37 +86,67 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!session) {
|
if (!session) {
|
||||||
toast.error("Please login first");
|
toast.error(t("pleaseLogin"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (folders.length === 0) {
|
if (decks.length === 0) {
|
||||||
toast.error("Please create a folder first");
|
toast.error(t("pleaseCreateFolder"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!searchResult?.entries?.length) {
|
||||||
|
toast.error("No dictionary item to save. Please search first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const folderSelect = document.getElementById("folder-select") as HTMLSelectElement;
|
const deckSelect = document.getElementById("deck-select") as HTMLSelectElement;
|
||||||
const folderId = folderSelect?.value ? Number(folderSelect.value) : folders[0]?.id;
|
const deckId = deckSelect?.value ? Number(deckSelect.value) : decks[0]?.id;
|
||||||
|
|
||||||
if (!searchResult?.entries?.length) return;
|
if (!deckId) {
|
||||||
|
toast.error("No deck selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const definition = searchResult.entries
|
setIsSaving(true);
|
||||||
.map((e) => e.definition)
|
|
||||||
.join(" | ");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await actionCreatePair({
|
const hasIpa = searchResult.entries.some((e) => e.ipa);
|
||||||
text1: searchResult.standardForm,
|
const hasSpaces = searchResult.standardForm.includes(" ");
|
||||||
text2: definition,
|
let cardType: CardType = "WORD";
|
||||||
language1: queryLang,
|
if (!hasIpa) {
|
||||||
language2: definitionLang,
|
cardType = "SENTENCE";
|
||||||
ipa1: searchResult.entries[0]?.ipa,
|
} else if (hasSpaces) {
|
||||||
folderId: folderId,
|
cardType = "PHRASE";
|
||||||
|
}
|
||||||
|
|
||||||
|
const ipa = searchResult.entries.find((e) => e.ipa)?.ipa || null;
|
||||||
|
const meanings = searchResult.entries.map((e) => ({
|
||||||
|
partOfSpeech: e.partOfSpeech || null,
|
||||||
|
definition: e.definition,
|
||||||
|
example: e.example || null,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const cardResult = await actionCreateCard({
|
||||||
|
deckId,
|
||||||
|
word: searchResult.standardForm,
|
||||||
|
ipa,
|
||||||
|
queryLang: getNativeName(queryLang),
|
||||||
|
cardType,
|
||||||
|
meanings,
|
||||||
});
|
});
|
||||||
|
|
||||||
const folderName = folders.find((f) => f.id === folderId)?.name || "Unknown";
|
if (!cardResult.success) {
|
||||||
toast.success(`Saved to ${folderName}`);
|
toast.error(cardResult.message || t("saveFailed"));
|
||||||
|
setIsSaving(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deckName = decks.find((d) => d.id === deckId)?.name || "Unknown";
|
||||||
|
toast.success(t("savedToFolder", { folderName: deckName }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Save failed");
|
console.error("Save error:", error);
|
||||||
|
toast.error(t("saveFailed"));
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,14 +205,14 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
|
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
{isSearching ? (
|
{isSearching ? (
|
||||||
<div className="text-center py-12">
|
<VStack align="center" className="py-12">
|
||||||
<div className="w-8 h-8 border-2 border-gray-200 border-t-primary-500 rounded-full animate-spin mx-auto mb-3"></div>
|
<Skeleton variant="circular" className="w-8 h-8 mb-3" />
|
||||||
<p className="text-gray-600">{t("searching")}</p>
|
<p className="text-gray-600">{t("searching")}</p>
|
||||||
</div>
|
</VStack>
|
||||||
) : query && !searchResult ? (
|
) : query && !searchResult ? (
|
||||||
<div className="text-center py-12 bg-white/20 rounded-lg">
|
<div className="text-center py-12 bg-white/20 rounded-lg">
|
||||||
<p className="text-gray-800 text-xl">No results found</p>
|
<p className="text-gray-800 text-xl">{t("noResults")}</p>
|
||||||
<p className="text-gray-600 mt-2">Try other words</p>
|
<p className="text-gray-600 mt-2">{t("tryOtherWords")}</p>
|
||||||
</div>
|
</div>
|
||||||
) : searchResult ? (
|
) : searchResult ? (
|
||||||
<div className="bg-white rounded-lg p-6 shadow-lg">
|
<div className="bg-white rounded-lg p-6 shadow-lg">
|
||||||
@@ -185,27 +222,30 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
{searchResult.standardForm}
|
{searchResult.standardForm}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 ml-4">
|
<HStack align="center" gap={2} className="ml-4">
|
||||||
{session && folders.length > 0 && (
|
{session && decks.length > 0 && (
|
||||||
<select
|
<Select
|
||||||
id="folder-select"
|
id="deck-select"
|
||||||
className="px-3 py-2 text-sm border border-gray-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#35786f]"
|
variant="bordered"
|
||||||
|
size="sm"
|
||||||
>
|
>
|
||||||
{folders.map((folder) => (
|
{decks.map((deck) => (
|
||||||
<option key={folder.id} value={folder.id}>
|
<option key={deck.id} value={deck.id}>
|
||||||
{folder.name}
|
{deck.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
<LightButton
|
<LightButton
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
className="w-10 h-10 shrink-0"
|
className="w-10 h-10 shrink-0"
|
||||||
title="Save to folder"
|
title={t("saveToFolder")}
|
||||||
|
loading={isSaving}
|
||||||
|
disabled={isSaving}
|
||||||
>
|
>
|
||||||
<Plus />
|
<Plus />
|
||||||
</LightButton>
|
</LightButton>
|
||||||
</div>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -223,7 +263,7 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
|||||||
loading={isSearching}
|
loading={isSearching}
|
||||||
>
|
>
|
||||||
<RefreshCw className="w-4 h-4" />
|
<RefreshCw className="w-4 h-4" />
|
||||||
Re-lookup
|
{t("relookup")}
|
||||||
</LightButton>
|
</LightButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { DictionaryClient } from "./DictionaryClient";
|
import { DictionaryClient } from "./DictionaryClient";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { actionGetFoldersByUserId } from "@/modules/folder/folder-action";
|
import { actionGetDecksByUserId } from "@/modules/deck/deck-action";
|
||||||
import { TSharedFolder } from "@/shared/folder-type";
|
import type { ActionOutputDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
|
||||||
export default async function DictionaryPage() {
|
export default async function DictionaryPage() {
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
|
||||||
let folders: TSharedFolder[] = [];
|
let decks: ActionOutputDeck[] = [];
|
||||||
|
|
||||||
if (session?.user?.id) {
|
if (session?.user?.id) {
|
||||||
const result = await actionGetFoldersByUserId(session.user.id as string);
|
const result = await actionGetDecksByUserId(session.user.id as string);
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
folders = result.data;
|
decks = result.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <DictionaryClient initialFolders={folders} />;
|
return <DictionaryClient initialDecks={decks} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Folder as Fd,
|
Layers,
|
||||||
Heart,
|
Heart,
|
||||||
Search,
|
Search,
|
||||||
ArrowUpDown,
|
ArrowUpDown,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { CircleButton } from "@/design-system/base/button";
|
import { CircleButton } from "@/design-system/base/button";
|
||||||
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
|
import { HStack } from "@/design-system/layout/stack";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -14,35 +17,35 @@ import { toast } from "sonner";
|
|||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
import { PageHeader } from "@/components/ui/PageHeader";
|
import { PageHeader } from "@/components/ui/PageHeader";
|
||||||
import {
|
import {
|
||||||
actionSearchPublicFolders,
|
actionSearchPublicDecks,
|
||||||
actionToggleFavorite,
|
actionToggleDeckFavorite,
|
||||||
actionCheckFavorite,
|
actionCheckDeckFavorite,
|
||||||
} from "@/modules/folder/folder-action";
|
} from "@/modules/deck/deck-action";
|
||||||
import { TPublicFolder } from "@/shared/folder-type";
|
import type { ActionOutputPublicDeck } from "@/modules/deck/deck-action-dto";
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
|
|
||||||
interface PublicFolderCardProps {
|
interface PublicDeckCardProps {
|
||||||
folder: TPublicFolder;
|
deck: ActionOutputPublicDeck;
|
||||||
currentUserId?: string;
|
currentUserId?: string;
|
||||||
onUpdateFavorite: (folderId: number, isFavorited: boolean, favoriteCount: number) => void;
|
onUpdateFavorite: (deckId: number, isFavorited: boolean, favoriteCount: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PublicFolderCard = ({ folder, currentUserId, onUpdateFavorite }: PublicFolderCardProps) => {
|
const PublicDeckCard = ({ deck, currentUserId, onUpdateFavorite }: PublicDeckCardProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("explore");
|
const t = useTranslations("explore");
|
||||||
const [isFavorited, setIsFavorited] = useState(false);
|
const [isFavorited, setIsFavorited] = useState(false);
|
||||||
const [favoriteCount, setFavoriteCount] = useState(folder.favoriteCount);
|
const [favoriteCount, setFavoriteCount] = useState(deck.favoriteCount);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentUserId) {
|
if (currentUserId) {
|
||||||
actionCheckFavorite(folder.id).then((result) => {
|
actionCheckDeckFavorite({ deckId: deck.id }).then((result) => {
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setIsFavorited(result.data.isFavorited);
|
setIsFavorited(result.data.isFavorited);
|
||||||
setFavoriteCount(result.data.favoriteCount);
|
setFavoriteCount(result.data.favoriteCount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [folder.id, currentUserId]);
|
}, [deck.id, currentUserId]);
|
||||||
|
|
||||||
const handleToggleFavorite = async (e: React.MouseEvent) => {
|
const handleToggleFavorite = async (e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -50,11 +53,11 @@ const PublicFolderCard = ({ folder, currentUserId, onUpdateFavorite }: PublicFol
|
|||||||
toast.error(t("pleaseLogin"));
|
toast.error(t("pleaseLogin"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await actionToggleFavorite(folder.id);
|
const result = await actionToggleDeckFavorite({ deckId: deck.id });
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setIsFavorited(result.data.isFavorited);
|
setIsFavorited(result.data.isFavorited);
|
||||||
setFavoriteCount(result.data.favoriteCount);
|
setFavoriteCount(result.data.favoriteCount);
|
||||||
onUpdateFavorite(folder.id, result.data.isFavorited, result.data.favoriteCount);
|
onUpdateFavorite(deck.id, result.data.isFavorited, result.data.favoriteCount);
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -64,13 +67,13 @@ const PublicFolderCard = ({ folder, currentUserId, onUpdateFavorite }: PublicFol
|
|||||||
<div
|
<div
|
||||||
className="group bg-white border border-gray-200 sm:border-2 rounded-lg p-3 sm:p-5 hover:border-primary-300 hover:shadow-md cursor-pointer transition-all overflow-hidden"
|
className="group bg-white border border-gray-200 sm:border-2 rounded-lg p-3 sm:p-5 hover:border-primary-300 hover:shadow-md cursor-pointer transition-all overflow-hidden"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(`/explore/${folder.id}`);
|
router.push(`/explore/${deck.id}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex items-start justify-between mb-2 sm:mb-3">
|
<div className="flex items-start justify-between mb-2 sm:mb-3">
|
||||||
<div className="shrink-0 w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-primary-50 flex items-center justify-center text-primary-500">
|
<div className="shrink-0 w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-primary-50 flex items-center justify-center text-primary-500">
|
||||||
<Fd size={18} className="sm:hidden" />
|
<Layers size={18} className="sm:hidden" />
|
||||||
<Fd size={22} className="hidden sm:block" />
|
<Layers size={22} className="hidden sm:block" />
|
||||||
</div>
|
</div>
|
||||||
<CircleButton
|
<CircleButton
|
||||||
onClick={handleToggleFavorite}
|
onClick={handleToggleFavorite}
|
||||||
@@ -83,12 +86,12 @@ const PublicFolderCard = ({ folder, currentUserId, onUpdateFavorite }: PublicFol
|
|||||||
</CircleButton>
|
</CircleButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 className="font-semibold text-gray-900 truncate text-sm sm:text-base mb-1 sm:mb-2">{folder.name}</h3>
|
<h3 className="font-semibold text-gray-900 truncate text-sm sm:text-base mb-1 sm:mb-2">{deck.name}</h3>
|
||||||
|
|
||||||
<p className="text-xs sm:text-sm text-gray-500 mb-2 sm:mb-3 line-clamp-2">
|
<p className="text-xs sm:text-sm text-gray-500 mb-2 sm:mb-3 line-clamp-2">
|
||||||
{t("folderInfo", {
|
{t("deckInfo", {
|
||||||
userName: folder.userName ?? folder.userUsername ?? t("unknownUser"),
|
userName: deck.userName ?? deck.userUsername ?? t("unknownUser"),
|
||||||
totalPairs: folder.totalPairs,
|
cardCount: deck.cardCount ?? 0,
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -101,13 +104,13 @@ const PublicFolderCard = ({ folder, currentUserId, onUpdateFavorite }: PublicFol
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface ExploreClientProps {
|
interface ExploreClientProps {
|
||||||
initialPublicFolders: TPublicFolder[];
|
initialPublicDecks: ActionOutputPublicDeck[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExploreClient({ initialPublicFolders }: ExploreClientProps) {
|
export function ExploreClient({ initialPublicDecks }: ExploreClientProps) {
|
||||||
const t = useTranslations("explore");
|
const t = useTranslations("explore");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [publicFolders, setPublicFolders] = useState<TPublicFolder[]>(initialPublicFolders);
|
const [publicDecks, setPublicDecks] = useState<ActionOutputPublicDeck[]>(initialPublicDecks);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [sortByFavorites, setSortByFavorites] = useState(false);
|
const [sortByFavorites, setSortByFavorites] = useState(false);
|
||||||
@@ -117,13 +120,13 @@ export function ExploreClient({ initialPublicFolders }: ExploreClientProps) {
|
|||||||
|
|
||||||
const handleSearch = async () => {
|
const handleSearch = async () => {
|
||||||
if (!searchQuery.trim()) {
|
if (!searchQuery.trim()) {
|
||||||
setPublicFolders(initialPublicFolders);
|
setPublicDecks(initialPublicDecks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const result = await actionSearchPublicFolders(searchQuery.trim());
|
const result = await actionSearchPublicDecks({ query: searchQuery.trim() });
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setPublicFolders(result.data);
|
setPublicDecks(result.data);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
@@ -132,14 +135,14 @@ export function ExploreClient({ initialPublicFolders }: ExploreClientProps) {
|
|||||||
setSortByFavorites((prev) => !prev);
|
setSortByFavorites((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortedFolders = sortByFavorites
|
const sortedDecks = sortByFavorites
|
||||||
? [...publicFolders].sort((a, b) => b.favoriteCount - a.favoriteCount)
|
? [...publicDecks].sort((a, b) => b.favoriteCount - a.favoriteCount)
|
||||||
: publicFolders;
|
: publicDecks;
|
||||||
|
|
||||||
const handleUpdateFavorite = (folderId: number, _isFavorited: boolean, favoriteCount: number) => {
|
const handleUpdateFavorite = (deckId: number, _isFavorited: boolean, favoriteCount: number) => {
|
||||||
setPublicFolders((prev) =>
|
setPublicDecks((prev) =>
|
||||||
prev.map((f) =>
|
prev.map((d) =>
|
||||||
f.id === folderId ? { ...f, favoriteCount } : f
|
d.id === deckId ? { ...d, favoriteCount } : d
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -148,18 +151,16 @@ export function ExploreClient({ initialPublicFolders }: ExploreClientProps) {
|
|||||||
<PageLayout>
|
<PageLayout>
|
||||||
<PageHeader title={t("title")} subtitle={t("subtitle")} />
|
<PageHeader title={t("title")} subtitle={t("subtitle")} />
|
||||||
|
|
||||||
<div className="flex items-center gap-2 mb-6">
|
<HStack align="center" gap={2} className="mb-6">
|
||||||
<div className="relative flex-1">
|
<Input
|
||||||
<Search size={18} className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" />
|
variant="bordered"
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
onKeyDown={(e) => e.key === "Enter" && handleSearch()}
|
onKeyDown={(e) => e.key === "Enter" && handleSearch()}
|
||||||
placeholder={t("searchPlaceholder")}
|
placeholder={t("searchPlaceholder")}
|
||||||
className="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
|
leftIcon={<Search size={18} />}
|
||||||
|
containerClassName="flex-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<CircleButton
|
<CircleButton
|
||||||
onClick={handleToggleSort}
|
onClick={handleToggleSort}
|
||||||
title={sortByFavorites ? t("sortByFavoritesActive") : t("sortByFavorites")}
|
title={sortByFavorites ? t("sortByFavoritesActive") : t("sortByFavorites")}
|
||||||
@@ -170,26 +171,26 @@ export function ExploreClient({ initialPublicFolders }: ExploreClientProps) {
|
|||||||
<CircleButton onClick={handleSearch}>
|
<CircleButton onClick={handleSearch}>
|
||||||
<Search size={18} />
|
<Search size={18} />
|
||||||
</CircleButton>
|
</CircleButton>
|
||||||
</div>
|
</HStack>
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="p-8 text-center">
|
<div className="p-8 text-center">
|
||||||
<div className="w-8 h-8 border-2 border-gray-200 border-t-gray-400 rounded-full animate-spin mx-auto mb-3"></div>
|
<Skeleton variant="circular" className="w-8 h-8 mx-auto mb-3" />
|
||||||
<p className="text-sm text-gray-500">{t("loading")}</p>
|
<p className="text-sm text-gray-500">{t("loading")}</p>
|
||||||
</div>
|
</div>
|
||||||
) : sortedFolders.length === 0 ? (
|
) : sortedDecks.length === 0 ? (
|
||||||
<div className="text-center py-12 text-gray-400">
|
<div className="text-center py-12 text-gray-400">
|
||||||
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
||||||
<Fd size={24} className="text-gray-400" />
|
<Layers size={24} className="text-gray-400" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm">{t("noFolders")}</p>
|
<p className="text-sm">{t("noDecks")}</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
||||||
{sortedFolders.map((folder) => (
|
{sortedDecks.map((deck) => (
|
||||||
<PublicFolderCard
|
<PublicDeckCard
|
||||||
key={folder.id}
|
key={deck.id}
|
||||||
folder={folder}
|
deck={deck}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
onUpdateFavorite={handleUpdateFavorite}
|
onUpdateFavorite={handleUpdateFavorite}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Folder as Fd, Heart, ExternalLink, ArrowLeft } from "lucide-react";
|
import { Layers, Heart, ExternalLink, ArrowLeft } from "lucide-react";
|
||||||
import { CircleButton } from "@/design-system/base/button";
|
import { CircleButton } from "@/design-system/base/button";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -8,42 +8,42 @@ import { useTranslations } from "next-intl";
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {
|
import {
|
||||||
actionToggleFavorite,
|
actionToggleDeckFavorite,
|
||||||
actionCheckFavorite,
|
actionCheckDeckFavorite,
|
||||||
} from "@/modules/folder/folder-action";
|
} from "@/modules/deck/deck-action";
|
||||||
import { ActionOutputPublicFolder } from "@/modules/folder/folder-action-dto";
|
import type { ActionOutputPublicDeck } from "@/modules/deck/deck-action-dto";
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
|
|
||||||
interface ExploreDetailClientProps {
|
interface ExploreDetailClientProps {
|
||||||
folder: ActionOutputPublicFolder;
|
deck: ActionOutputPublicDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExploreDetailClient({ folder }: ExploreDetailClientProps) {
|
export function ExploreDetailClient({ deck }: ExploreDetailClientProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("exploreDetail");
|
const t = useTranslations("exploreDetail");
|
||||||
const [isFavorited, setIsFavorited] = useState(false);
|
const [isFavorited, setIsFavorited] = useState(false);
|
||||||
const [favoriteCount, setFavoriteCount] = useState(folder.favoriteCount);
|
const [favoriteCount, setFavoriteCount] = useState(deck.favoriteCount);
|
||||||
|
|
||||||
const { data: session } = authClient.useSession();
|
const { data: session } = authClient.useSession();
|
||||||
const currentUserId = session?.user?.id;
|
const currentUserId = session?.user?.id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentUserId) {
|
if (currentUserId) {
|
||||||
actionCheckFavorite(folder.id).then((result) => {
|
actionCheckDeckFavorite({ deckId: deck.id }).then((result) => {
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setIsFavorited(result.data.isFavorited);
|
setIsFavorited(result.data.isFavorited);
|
||||||
setFavoriteCount(result.data.favoriteCount);
|
setFavoriteCount(result.data.favoriteCount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [folder.id, currentUserId]);
|
}, [deck.id, currentUserId]);
|
||||||
|
|
||||||
const handleToggleFavorite = async () => {
|
const handleToggleFavorite = async () => {
|
||||||
if (!currentUserId) {
|
if (!currentUserId) {
|
||||||
toast.error(t("pleaseLogin"));
|
toast.error(t("pleaseLogin"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await actionToggleFavorite(folder.id);
|
const result = await actionToggleDeckFavorite({ deckId: deck.id });
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setIsFavorited(result.data.isFavorited);
|
setIsFavorited(result.data.isFavorited);
|
||||||
setFavoriteCount(result.data.favoriteCount);
|
setFavoriteCount(result.data.favoriteCount);
|
||||||
@@ -79,15 +79,15 @@ export function ExploreDetailClient({ folder }: ExploreDetailClientProps) {
|
|||||||
<div className="flex items-start justify-between mb-6">
|
<div className="flex items-start justify-between mb-6">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="w-14 h-14 sm:w-16 sm:h-16 rounded-xl bg-primary-50 flex items-center justify-center text-primary-500">
|
<div className="w-14 h-14 sm:w-16 sm:h-16 rounded-xl bg-primary-50 flex items-center justify-center text-primary-500">
|
||||||
<Fd size={28} className="sm:w-8 sm:h-8" />
|
<Layers size={28} className="sm:w-8 sm:h-8" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl sm:text-2xl font-bold text-gray-900">
|
<h2 className="text-xl sm:text-2xl font-bold text-gray-900">
|
||||||
{folder.name}
|
{deck.name}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-sm text-gray-500 mt-1">
|
<p className="text-sm text-gray-500 mt-1">
|
||||||
{t("createdBy", {
|
{t("createdBy", {
|
||||||
name: folder.userName ?? folder.userUsername ?? t("unknownUser"),
|
name: deck.userName ?? deck.userUsername ?? t("unknownUser"),
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,13 +104,19 @@ export function ExploreDetailClient({ folder }: ExploreDetailClientProps) {
|
|||||||
</CircleButton>
|
</CircleButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{deck.desc && (
|
||||||
|
<p className="text-gray-600 mb-6 text-sm sm:text-base">
|
||||||
|
{deck.desc}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-3 gap-4 mb-6 py-4 border-y border-gray-100">
|
<div className="grid grid-cols-3 gap-4 mb-6 py-4 border-y border-gray-100">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-2xl sm:text-3xl font-bold text-primary-600">
|
<div className="text-2xl sm:text-3xl font-bold text-primary-600">
|
||||||
{folder.totalPairs}
|
{deck.cardCount ?? 0}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs sm:text-sm text-gray-500 mt-1">
|
<div className="text-xs sm:text-sm text-gray-500 mt-1">
|
||||||
{t("totalPairs")}
|
{t("totalCards")}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-center border-x border-gray-100">
|
<div className="text-center border-x border-gray-100">
|
||||||
@@ -124,7 +130,7 @@ export function ExploreDetailClient({ folder }: ExploreDetailClientProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-lg sm:text-xl font-semibold text-gray-700">
|
<div className="text-lg sm:text-xl font-semibold text-gray-700">
|
||||||
{formatDate(folder.createdAt)}
|
{formatDate(deck.createdAt)}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs sm:text-sm text-gray-500 mt-1">
|
<div className="text-xs sm:text-sm text-gray-500 mt-1">
|
||||||
{t("createdAt")}
|
{t("createdAt")}
|
||||||
@@ -133,7 +139,7 @@ export function ExploreDetailClient({ folder }: ExploreDetailClientProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href={`/folders/${folder.id}`}
|
href={`/decks/${deck.id}`}
|
||||||
className="flex items-center justify-center gap-2 w-full py-3 px-4 bg-primary-500 hover:bg-primary-600 text-white rounded-lg font-medium transition-colors"
|
className="flex items-center justify-center gap-2 w-full py-3 px-4 bg-primary-500 hover:bg-primary-600 text-white rounded-lg font-medium transition-colors"
|
||||||
>
|
>
|
||||||
<ExternalLink size={18} />
|
<ExternalLink size={18} />
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { ExploreDetailClient } from "./ExploreDetailClient";
|
import { ExploreDetailClient } from "./ExploreDetailClient";
|
||||||
import { actionGetPublicFolderById } from "@/modules/folder/folder-action";
|
import { actionGetPublicDeckById } from "@/modules/deck/deck-action";
|
||||||
|
|
||||||
export default async function ExploreFolderPage({
|
export default async function ExploreDeckPage({
|
||||||
params,
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: Promise<{ id: string }>;
|
params: Promise<{ id: string }>;
|
||||||
@@ -13,11 +13,11 @@ export default async function ExploreFolderPage({
|
|||||||
redirect("/explore");
|
redirect("/explore");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await actionGetPublicFolderById(Number(id));
|
const result = await actionGetPublicDeckById({ deckId: Number(id) });
|
||||||
|
|
||||||
if (!result.success || !result.data) {
|
if (!result.success || !result.data) {
|
||||||
redirect("/explore");
|
redirect("/explore");
|
||||||
}
|
}
|
||||||
|
|
||||||
return <ExploreDetailClient folder={result.data} />;
|
return <ExploreDetailClient deck={result.data} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ExploreClient } from "./ExploreClient";
|
import { ExploreClient } from "./ExploreClient";
|
||||||
import { actionGetPublicFolders } from "@/modules/folder/folder-action";
|
import { actionGetPublicDecks } from "@/modules/deck/deck-action";
|
||||||
|
|
||||||
export default async function ExplorePage() {
|
export default async function ExplorePage() {
|
||||||
const publicFoldersResult = await actionGetPublicFolders();
|
const publicDecksResult = await actionGetPublicDecks();
|
||||||
const publicFolders = publicFoldersResult.success ? publicFoldersResult.data ?? [] : [];
|
const publicDecks = publicDecksResult.success ? publicDecksResult.data ?? [] : [];
|
||||||
|
|
||||||
return <ExploreClient initialPublicFolders={publicFolders} />;
|
return <ExploreClient initialPublicDecks={publicDecks} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,33 +2,24 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
Folder as Fd,
|
Layers as DeckIcon,
|
||||||
Heart,
|
Heart,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
import { PageHeader } from "@/components/ui/PageHeader";
|
import { PageHeader } from "@/components/ui/PageHeader";
|
||||||
import { CardList } from "@/components/ui/CardList";
|
import { CardList } from "@/components/ui/CardList";
|
||||||
import { actionGetUserFavorites, actionToggleFavorite } from "@/modules/folder/folder-action";
|
import { VStack } from "@/design-system/layout/stack";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
type UserFavorite = {
|
import { actionGetUserFavoriteDecks, actionToggleDeckFavorite } from "@/modules/deck/deck-action";
|
||||||
id: number;
|
import type { ActionOutputUserFavoriteDeck } from "@/modules/deck/deck-action-dto";
|
||||||
folderId: number;
|
|
||||||
folderName: string;
|
|
||||||
folderCreatedAt: Date;
|
|
||||||
folderTotalPairs: number;
|
|
||||||
folderOwnerId: string;
|
|
||||||
folderOwnerName: string | null;
|
|
||||||
folderOwnerUsername: string | null;
|
|
||||||
favoritedAt: Date;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface FavoriteCardProps {
|
interface FavoriteCardProps {
|
||||||
favorite: UserFavorite;
|
favorite: ActionOutputUserFavoriteDeck;
|
||||||
onRemoveFavorite: (folderId: number) => void;
|
onRemoveFavorite: (deckId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FavoriteCard = ({ favorite, onRemoveFavorite }: FavoriteCardProps) => {
|
const FavoriteCard = ({ favorite, onRemoveFavorite }: FavoriteCardProps) => {
|
||||||
@@ -41,9 +32,9 @@ const FavoriteCard = ({ favorite, onRemoveFavorite }: FavoriteCardProps) => {
|
|||||||
if (isRemoving) return;
|
if (isRemoving) return;
|
||||||
|
|
||||||
setIsRemoving(true);
|
setIsRemoving(true);
|
||||||
const result = await actionToggleFavorite(favorite.folderId);
|
const result = await actionToggleDeckFavorite({ deckId: favorite.id });
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
onRemoveFavorite(favorite.folderId);
|
onRemoveFavorite(favorite.id);
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -54,20 +45,20 @@ const FavoriteCard = ({ favorite, onRemoveFavorite }: FavoriteCardProps) => {
|
|||||||
<div
|
<div
|
||||||
className="flex justify-between items-center group py-4 px-5 border-b border-gray-200 last:border-b-0 hover:bg-gray-50 cursor-pointer transition-colors"
|
className="flex justify-between items-center group py-4 px-5 border-b border-gray-200 last:border-b-0 hover:bg-gray-50 cursor-pointer transition-colors"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(`/explore/${favorite.folderId}`);
|
router.push(`/explore/${favorite.id}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-4 flex-1">
|
<div className="flex items-center gap-4 flex-1">
|
||||||
<div className="shrink-0 text-primary-500">
|
<div className="shrink-0 text-primary-500">
|
||||||
<Fd size={24} />
|
<DeckIcon size={24} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<h3 className="font-semibold text-gray-900 truncate">{favorite.folderName}</h3>
|
<h3 className="font-semibold text-gray-900 truncate">{favorite.name}</h3>
|
||||||
<p className="text-sm text-gray-500 mt-0.5">
|
<p className="text-sm text-gray-500 mt-0.5">
|
||||||
{t("folderInfo", {
|
{t("folderInfo", {
|
||||||
userName: favorite.folderOwnerName ?? favorite.folderOwnerUsername ?? t("unknownUser"),
|
userName: favorite.userName ?? favorite.userUsername ?? t("unknownUser"),
|
||||||
totalPairs: favorite.folderTotalPairs,
|
totalPairs: favorite.cardCount ?? 0,
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,29 +77,25 @@ const FavoriteCard = ({ favorite, onRemoveFavorite }: FavoriteCardProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface FavoritesClientProps {
|
interface FavoritesClientProps {
|
||||||
userId: string;
|
initialFavorites: ActionOutputUserFavoriteDeck[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FavoritesClient({ userId }: FavoritesClientProps) {
|
export function FavoritesClient({ initialFavorites }: FavoritesClientProps) {
|
||||||
const t = useTranslations("favorites");
|
const t = useTranslations("favorites");
|
||||||
const [favorites, setFavorites] = useState<UserFavorite[]>([]);
|
const [favorites, setFavorites] = useState<ActionOutputUserFavoriteDeck[]>(initialFavorites);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
loadFavorites();
|
|
||||||
}, [userId]);
|
|
||||||
|
|
||||||
const loadFavorites = async () => {
|
const loadFavorites = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const result = await actionGetUserFavorites();
|
const result = await actionGetUserFavoriteDecks();
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setFavorites(result.data);
|
setFavorites(result.data);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveFavorite = (folderId: number) => {
|
const handleRemoveFavorite = (deckId: number) => {
|
||||||
setFavorites((prev) => prev.filter((f) => f.folderId !== folderId));
|
setFavorites((prev) => prev.filter((f) => f.id !== deckId));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -117,10 +104,10 @@ export function FavoritesClient({ userId }: FavoritesClientProps) {
|
|||||||
|
|
||||||
<CardList>
|
<CardList>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="p-8 text-center">
|
<VStack align="center" className="p-8">
|
||||||
<div className="w-8 h-8 border-2 border-gray-200 border-t-gray-400 rounded-full animate-spin mx-auto mb-3"></div>
|
<Skeleton variant="circular" className="w-8 h-8" />
|
||||||
<p className="text-sm text-gray-500">{t("loading")}</p>
|
<p className="text-sm text-gray-500">{t("loading")}</p>
|
||||||
</div>
|
</VStack>
|
||||||
) : favorites.length === 0 ? (
|
) : favorites.length === 0 ? (
|
||||||
<div className="text-center py-12 text-gray-400">
|
<div className="text-center py-12 text-gray-400">
|
||||||
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { auth } from "@/auth";
|
|||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { FavoritesClient } from "./FavoritesClient";
|
import { FavoritesClient } from "./FavoritesClient";
|
||||||
|
import { actionGetUserFavoriteDecks } from "@/modules/deck/deck-action";
|
||||||
|
import type { ActionOutputUserFavoriteDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
|
||||||
export default async function FavoritesPage() {
|
export default async function FavoritesPage() {
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
@@ -10,5 +12,11 @@ export default async function FavoritesPage() {
|
|||||||
redirect("/login?redirect=/favorites");
|
redirect("/login?redirect=/favorites");
|
||||||
}
|
}
|
||||||
|
|
||||||
return <FavoritesClient userId={session.user.id} />;
|
let favorites: ActionOutputUserFavoriteDeck[] = [];
|
||||||
|
const result = await actionGetUserFavoriteDecks();
|
||||||
|
if (result.success && result.data) {
|
||||||
|
favorites = result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <FavoritesClient initialFavorites={favorites} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { Folder as Fd } from "lucide-react";
|
|
||||||
import { TSharedFolderWithTotalPairs } from "@/shared/folder-type";
|
|
||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
|
||||||
import { PrimaryButton } from "@/design-system/base/button";
|
|
||||||
|
|
||||||
interface FolderSelectorProps {
|
|
||||||
folders: TSharedFolderWithTotalPairs[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const FolderSelector: React.FC<FolderSelectorProps> = ({ folders }) => {
|
|
||||||
const t = useTranslations("memorize.folder_selector");
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageLayout>
|
|
||||||
{folders.length === 0 ? (
|
|
||||||
// 空状态 - 显示提示和跳转按钮
|
|
||||||
<div className="text-center">
|
|
||||||
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-4">
|
|
||||||
{t("noFolders")}
|
|
||||||
</h1>
|
|
||||||
<Link href="/folders">
|
|
||||||
<PrimaryButton className="px-6 py-2">
|
|
||||||
Go to Folders
|
|
||||||
</PrimaryButton>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{/* 页面标题 */}
|
|
||||||
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-6">
|
|
||||||
{t("selectFolder")}
|
|
||||||
</h1>
|
|
||||||
{/* 文件夹列表 */}
|
|
||||||
<div className="border border-gray-200 rounded-lg max-h-96 overflow-y-auto">
|
|
||||||
{folders
|
|
||||||
.toSorted((a, b) => a.id - b.id)
|
|
||||||
.map((folder) => (
|
|
||||||
<div
|
|
||||||
key={folder.id}
|
|
||||||
onClick={() =>
|
|
||||||
router.push(`/memorize?folder_id=${folder.id}`)
|
|
||||||
}
|
|
||||||
className="flex flex-row items-center p-4 gap-3 hover:cursor-pointer hover:bg-gray-50 transition-colors border-b border-gray-100 last:border-b-0"
|
|
||||||
>
|
|
||||||
{/* 文件夹图标 */}
|
|
||||||
<div className="shrink-0">
|
|
||||||
<Fd className="text-gray-600" size="md" />
|
|
||||||
</div>
|
|
||||||
{/* 文件夹信息 */}
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="font-medium text-gray-900">
|
|
||||||
{folder.name}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
|
||||||
{t("folderInfo", {
|
|
||||||
id: folder.id,
|
|
||||||
name: folder.name,
|
|
||||||
count: folder.total,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* 右箭头 */}
|
|
||||||
<div className="text-gray-400">
|
|
||||||
<svg
|
|
||||||
className="w-5 h-5"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M9 5l7 7-7 7"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</PageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { FolderSelector };
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { LinkButton, CircleToggleButton, LightButton } from "@/design-system/base/button";
|
|
||||||
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
|
||||||
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import localFont from "next/font/local";
|
|
||||||
import { isNonNegativeInteger, SeededRandom } from "@/utils/random";
|
|
||||||
import { TSharedPair } from "@/shared/folder-type";
|
|
||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
|
||||||
|
|
||||||
const myFont = localFont({
|
|
||||||
src: "../../../../public/fonts/NotoNaskhArabic-VariableFont_wght.ttf",
|
|
||||||
});
|
|
||||||
|
|
||||||
interface MemorizeProps {
|
|
||||||
textPairs: TSharedPair[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const Memorize: React.FC<MemorizeProps> = ({ textPairs }) => {
|
|
||||||
const t = useTranslations("memorize.memorize");
|
|
||||||
const [reverse, setReverse] = useState(false);
|
|
||||||
const [dictation, setDictation] = useState(false);
|
|
||||||
const [disorder, setDisorder] = useState(false);
|
|
||||||
const [index, setIndex] = useState(0);
|
|
||||||
const [show, setShow] = useState<"question" | "answer">("question");
|
|
||||||
const { load, play } = useAudioPlayer();
|
|
||||||
|
|
||||||
if (textPairs.length === 0) {
|
|
||||||
return (
|
|
||||||
<PageLayout>
|
|
||||||
<p className="text-gray-700 text-center">{t("noTextPairs")}</p>
|
|
||||||
</PageLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const rng = new SeededRandom(textPairs[0].folderId);
|
|
||||||
const disorderedTextPairs = textPairs.toSorted(() => rng.next() - 0.5);
|
|
||||||
|
|
||||||
textPairs.sort((a, b) => a.id - b.id);
|
|
||||||
|
|
||||||
const getTextPairs = () => disorder ? disorderedTextPairs : textPairs;
|
|
||||||
|
|
||||||
const handleIndexClick = () => {
|
|
||||||
const newIndex = prompt("Input a index number.")?.trim();
|
|
||||||
if (
|
|
||||||
newIndex &&
|
|
||||||
isNonNegativeInteger(newIndex) &&
|
|
||||||
parseInt(newIndex) <= textPairs.length &&
|
|
||||||
parseInt(newIndex) > 0
|
|
||||||
) {
|
|
||||||
setIndex(parseInt(newIndex) - 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNext = async () => {
|
|
||||||
if (show === "answer") {
|
|
||||||
const newIndex = (index + 1) % getTextPairs().length;
|
|
||||||
setIndex(newIndex);
|
|
||||||
if (dictation) {
|
|
||||||
const textPair = getTextPairs()[newIndex];
|
|
||||||
const language = textPair[reverse ? "language2" : "language1"];
|
|
||||||
const text = textPair[reverse ? "text2" : "text1"];
|
|
||||||
|
|
||||||
// 映射语言到 TTS 支持的格式
|
|
||||||
const languageMap: Record<string, TTS_SUPPORTED_LANGUAGES> = {
|
|
||||||
"chinese": "Chinese",
|
|
||||||
"english": "English",
|
|
||||||
"japanese": "Japanese",
|
|
||||||
"korean": "Korean",
|
|
||||||
"french": "French",
|
|
||||||
"german": "German",
|
|
||||||
"italian": "Italian",
|
|
||||||
"portuguese": "Portuguese",
|
|
||||||
"spanish": "Spanish",
|
|
||||||
"russian": "Russian",
|
|
||||||
};
|
|
||||||
|
|
||||||
const ttsLanguage = languageMap[language?.toLowerCase()] || "Auto";
|
|
||||||
|
|
||||||
getTTSUrl(text, ttsLanguage).then((url) => {
|
|
||||||
load(url);
|
|
||||||
play();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setShow(show === "question" ? "answer" : "question");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePrevious = () => {
|
|
||||||
setIndex(
|
|
||||||
(index - 1 + getTextPairs().length) % getTextPairs().length,
|
|
||||||
);
|
|
||||||
setShow("question");
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleReverse = () => setReverse(!reverse);
|
|
||||||
const toggleDictation = () => setDictation(!dictation);
|
|
||||||
const toggleDisorder = () => setDisorder(!disorder);
|
|
||||||
|
|
||||||
const createText = (text: string) => {
|
|
||||||
return (
|
|
||||||
<div className="text-gray-900 text-xl md:text-2xl p-6 h-[20dvh] overflow-y-auto text-center">
|
|
||||||
{text}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const [text1, text2] = reverse
|
|
||||||
? [getTextPairs()[index].text2, getTextPairs()[index].text1]
|
|
||||||
: [getTextPairs()[index].text1, getTextPairs()[index].text2];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageLayout>
|
|
||||||
{/* 进度指示器 */}
|
|
||||||
<div className="flex justify-center mb-4">
|
|
||||||
<LinkButton onClick={handleIndexClick} className="text-sm">
|
|
||||||
{index + 1} / {getTextPairs().length}
|
|
||||||
</LinkButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 文本显示区域 */}
|
|
||||||
<div className={`h-[40dvh] ${myFont.className} mb-4`}>
|
|
||||||
{(() => {
|
|
||||||
if (dictation) {
|
|
||||||
if (show === "question") {
|
|
||||||
return (
|
|
||||||
<div className="h-full flex items-center justify-center">
|
|
||||||
<div className="text-gray-400 text-4xl">?</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{createText(text1)}
|
|
||||||
<div className="border-t border-gray-200"></div>
|
|
||||||
{createText(text2)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (show === "question") {
|
|
||||||
return createText(text1);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{createText(text1)}
|
|
||||||
<div className="border-t border-gray-200"></div>
|
|
||||||
{createText(text2)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 底部按钮 */}
|
|
||||||
<div className="flex flex-row gap-2 items-center justify-center flex-wrap">
|
|
||||||
<LightButton
|
|
||||||
onClick={handleNext}
|
|
||||||
className="px-4 py-2 rounded-full text-sm"
|
|
||||||
>
|
|
||||||
{show === "question" ? t("answer") : t("next")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
onClick={handlePrevious}
|
|
||||||
className="px-4 py-2 rounded-full text-sm"
|
|
||||||
>
|
|
||||||
{t("previous")}
|
|
||||||
</LightButton>
|
|
||||||
<CircleToggleButton
|
|
||||||
selected={reverse}
|
|
||||||
onClick={toggleReverse}
|
|
||||||
>
|
|
||||||
{t("reverse")}
|
|
||||||
</CircleToggleButton>
|
|
||||||
<CircleToggleButton
|
|
||||||
selected={dictation}
|
|
||||||
onClick={toggleDictation}
|
|
||||||
>
|
|
||||||
{t("dictation")}
|
|
||||||
</CircleToggleButton>
|
|
||||||
<CircleToggleButton
|
|
||||||
selected={disorder}
|
|
||||||
onClick={toggleDisorder}
|
|
||||||
>
|
|
||||||
{t("disorder")}
|
|
||||||
</CircleToggleButton>
|
|
||||||
</div>
|
|
||||||
</PageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { Memorize };
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import { redirect } from "next/navigation";
|
|
||||||
import { getTranslations } from "next-intl/server";
|
|
||||||
import { isNonNegativeInteger } from "@/utils/random";
|
|
||||||
import { FolderSelector } from "./FolderSelector";
|
|
||||||
import { Memorize } from "./Memorize";
|
|
||||||
import { auth } from "@/auth";
|
|
||||||
import { headers } from "next/headers";
|
|
||||||
import { actionGetFoldersWithTotalPairsByUserId, actionGetPairsByFolderId } from "@/modules/folder/folder-action";
|
|
||||||
|
|
||||||
export default async function MemorizePage({
|
|
||||||
searchParams,
|
|
||||||
}: {
|
|
||||||
searchParams: Promise<{ folder_id?: string; }>;
|
|
||||||
}) {
|
|
||||||
const tParam = (await searchParams).folder_id;
|
|
||||||
|
|
||||||
const t = await getTranslations("memorize.page");
|
|
||||||
|
|
||||||
const folder_id = tParam
|
|
||||||
? isNonNegativeInteger(tParam)
|
|
||||||
? parseInt(tParam)
|
|
||||||
: null
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (!folder_id) {
|
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
|
||||||
if (!session) redirect("/login?redirect=/memorize");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FolderSelector
|
|
||||||
folders={(await actionGetFoldersWithTotalPairsByUserId(session.user.id)).data!}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Memorize textPairs={(await actionGetPairsByFolderId(folder_id)).data!} />;
|
|
||||||
}
|
|
||||||
@@ -70,7 +70,7 @@ export default function SrtPlayerPage() {
|
|||||||
uploadVideo((url) => {
|
uploadVideo((url) => {
|
||||||
setVideoUrl(url);
|
setVideoUrl(url);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
toast.error(t('videoUploadFailed') + ': ' + error.message);
|
toast.error(srtT('videoUploadFailed') + ': ' + error.message);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ export default function SrtPlayerPage() {
|
|||||||
uploadSubtitle((url) => {
|
uploadSubtitle((url) => {
|
||||||
setSubtitleUrl(url);
|
setSubtitleUrl(url);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
toast.error(t('subtitleUploadFailed') + ': ' + error.message);
|
toast.error(srtT('subtitleUploadFailed') + ': ' + error.message);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { LightButton } from "@/design-system/base/button";
|
import { LightButton, IconClick } from "@/design-system/base/button";
|
||||||
import { IconClick } from "@/design-system/base/button";
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Textarea } from "@/design-system/base/textarea";
|
||||||
import { IMAGES } from "@/config/images";
|
import { IMAGES } from "@/config/images";
|
||||||
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
||||||
import {
|
import {
|
||||||
@@ -18,6 +19,38 @@ import { genIPA, genLanguage } from "@/modules/translator/translator-action";
|
|||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
||||||
|
|
||||||
|
const TTS_LANGUAGES = [
|
||||||
|
{ value: "Auto", label: "auto" },
|
||||||
|
{ value: "Chinese", label: "chinese" },
|
||||||
|
{ value: "English", label: "english" },
|
||||||
|
{ value: "Japanese", label: "japanese" },
|
||||||
|
{ value: "Korean", label: "korean" },
|
||||||
|
{ value: "French", label: "french" },
|
||||||
|
{ value: "German", label: "german" },
|
||||||
|
{ value: "Italian", label: "italian" },
|
||||||
|
{ value: "Spanish", label: "spanish" },
|
||||||
|
{ value: "Portuguese", label: "portuguese" },
|
||||||
|
{ value: "Russian", label: "russian" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type TTSLabel = typeof TTS_LANGUAGES[number]["label"];
|
||||||
|
|
||||||
|
function getLanguageLabel(t: (key: string) => string, label: TTSLabel): string {
|
||||||
|
switch (label) {
|
||||||
|
case "auto": return t("languages.auto");
|
||||||
|
case "chinese": return t("languages.chinese");
|
||||||
|
case "english": return t("languages.english");
|
||||||
|
case "japanese": return t("languages.japanese");
|
||||||
|
case "korean": return t("languages.korean");
|
||||||
|
case "french": return t("languages.french");
|
||||||
|
case "german": return t("languages.german");
|
||||||
|
case "italian": return t("languages.italian");
|
||||||
|
case "spanish": return t("languages.spanish");
|
||||||
|
case "portuguese": return t("languages.portuguese");
|
||||||
|
case "russian": return t("languages.russian");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function TextSpeakerPage() {
|
export default function TextSpeakerPage() {
|
||||||
const t = useTranslations("text_speaker");
|
const t = useTranslations("text_speaker");
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
@@ -30,6 +63,8 @@ export default function TextSpeakerPage() {
|
|||||||
const [autopause, setAutopause] = useState(true);
|
const [autopause, setAutopause] = useState(true);
|
||||||
const textRef = useRef("");
|
const textRef = useRef("");
|
||||||
const [language, setLanguage] = useState<string | null>(null);
|
const [language, setLanguage] = useState<string | null>(null);
|
||||||
|
const [selectedLanguage, setSelectedLanguage] = useState<string>("Auto");
|
||||||
|
const [customLanguage, setCustomLanguage] = useState<string>("");
|
||||||
const [ipa, setIPA] = useState<string>("");
|
const [ipa, setIPA] = useState<string>("");
|
||||||
const objurlRef = useRef<string | null>(null);
|
const objurlRef = useRef<string | null>(null);
|
||||||
const [processing, setProcessing] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
@@ -93,8 +128,15 @@ export default function TextSpeakerPage() {
|
|||||||
} else {
|
} else {
|
||||||
// 第一次播放
|
// 第一次播放
|
||||||
try {
|
try {
|
||||||
let theLanguage = language;
|
let theLanguage: string;
|
||||||
if (!theLanguage) {
|
|
||||||
|
if (customLanguage.trim()) {
|
||||||
|
theLanguage = customLanguage.trim();
|
||||||
|
} else if (selectedLanguage !== "Auto") {
|
||||||
|
theLanguage = selectedLanguage;
|
||||||
|
} else if (language) {
|
||||||
|
theLanguage = language;
|
||||||
|
} else {
|
||||||
const tmp_language = await genLanguage(textRef.current.slice(0, 30));
|
const tmp_language = await genLanguage(textRef.current.slice(0, 30));
|
||||||
setLanguage(tmp_language);
|
setLanguage(tmp_language);
|
||||||
theLanguage = tmp_language;
|
theLanguage = tmp_language;
|
||||||
@@ -102,7 +144,6 @@ export default function TextSpeakerPage() {
|
|||||||
|
|
||||||
theLanguage = theLanguage.toLowerCase().replace(/[^a-z]/g, '').replace(/^./, match => match.toUpperCase());
|
theLanguage = theLanguage.toLowerCase().replace(/[^a-z]/g, '').replace(/^./, match => match.toUpperCase());
|
||||||
|
|
||||||
// 检查语言是否在 TTS 支持列表中
|
|
||||||
const supportedLanguages: TTS_SUPPORTED_LANGUAGES[] = [
|
const supportedLanguages: TTS_SUPPORTED_LANGUAGES[] = [
|
||||||
"Auto", "Chinese", "English", "German", "Italian", "Portuguese",
|
"Auto", "Chinese", "English", "German", "Italian", "Portuguese",
|
||||||
"Spanish", "Japanese", "Korean", "French", "Russian"
|
"Spanish", "Japanese", "Korean", "French", "Russian"
|
||||||
@@ -138,6 +179,8 @@ export default function TextSpeakerPage() {
|
|||||||
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
textRef.current = e.target.value.trim();
|
textRef.current = e.target.value.trim();
|
||||||
setLanguage(null);
|
setLanguage(null);
|
||||||
|
setSelectedLanguage("Auto");
|
||||||
|
setCustomLanguage("");
|
||||||
setIPA("");
|
setIPA("");
|
||||||
if (objurlRef.current) URL.revokeObjectURL(objurlRef.current);
|
if (objurlRef.current) URL.revokeObjectURL(objurlRef.current);
|
||||||
objurlRef.current = null;
|
objurlRef.current = null;
|
||||||
@@ -226,11 +269,12 @@ export default function TextSpeakerPage() {
|
|||||||
style={{ fontFamily: "Times New Roman, serif" }}
|
style={{ fontFamily: "Times New Roman, serif" }}
|
||||||
>
|
>
|
||||||
{/* 文本输入框 */}
|
{/* 文本输入框 */}
|
||||||
<textarea
|
<Textarea
|
||||||
className="text-2xl resize-none focus:outline-0 min-h-64 w-full border-gray-200 border-b p-4"
|
variant="bordered"
|
||||||
|
className="text-2xl min-h-64"
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
ref={textareaRef}
|
ref={textareaRef}
|
||||||
></textarea>
|
/>
|
||||||
{/* IPA 显示区域 */}
|
{/* IPA 显示区域 */}
|
||||||
{(ipa.length !== 0 && (
|
{(ipa.length !== 0 && (
|
||||||
<div className="overflow-auto text-gray-600 h-18 border-gray-200 border-b px-4">
|
<div className="overflow-auto text-gray-600 h-18 border-gray-200 border-b px-4">
|
||||||
@@ -317,6 +361,40 @@ export default function TextSpeakerPage() {
|
|||||||
alt="save"
|
alt="save"
|
||||||
className={`${saving ? "bg-gray-200" : ""}`}
|
className={`${saving ? "bg-gray-200" : ""}`}
|
||||||
></IconClick>
|
></IconClick>
|
||||||
|
{/* 语言选择器 */}
|
||||||
|
<div className="w-full flex flex-row flex-wrap gap-2 justify-center items-center">
|
||||||
|
<span className="text-sm text-gray-600">{t("language")}</span>
|
||||||
|
{TTS_LANGUAGES.slice(0, 6).map((lang) => (
|
||||||
|
<LightButton
|
||||||
|
key={lang.value}
|
||||||
|
selected={!customLanguage && selectedLanguage === lang.value}
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedLanguage(lang.value);
|
||||||
|
setCustomLanguage("");
|
||||||
|
if (objurlRef.current) URL.revokeObjectURL(objurlRef.current);
|
||||||
|
objurlRef.current = null;
|
||||||
|
setPause(true);
|
||||||
|
}}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{getLanguageLabel(t, lang.label)}
|
||||||
|
</LightButton>
|
||||||
|
))}
|
||||||
|
<Input
|
||||||
|
variant="bordered"
|
||||||
|
size="sm"
|
||||||
|
value={customLanguage}
|
||||||
|
onChange={(e) => {
|
||||||
|
setCustomLanguage(e.target.value);
|
||||||
|
setSelectedLanguage("Auto");
|
||||||
|
if (objurlRef.current) URL.revokeObjectURL(objurlRef.current);
|
||||||
|
objurlRef.current = null;
|
||||||
|
setPause(true);
|
||||||
|
}}
|
||||||
|
placeholder={t("customLanguage")}
|
||||||
|
className="w-auto min-w-[120px]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/* 功能开关按钮 */}
|
{/* 功能开关按钮 */}
|
||||||
<div className="w-full flex flex-row flex-wrap gap-2 justify-center items-center">
|
<div className="w-full flex flex-row flex-wrap gap-2 justify-center items-center">
|
||||||
<LightButton
|
<LightButton
|
||||||
|
|||||||
@@ -1,35 +1,138 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { LightButton, PrimaryButton, IconClick } from "@/design-system/base/button";
|
import { LightButton, PrimaryButton, IconClick, CircleButton } from "@/design-system/base/button";
|
||||||
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Textarea } from "@/design-system/base/textarea";
|
||||||
|
import { Select } from "@/design-system/base/select";
|
||||||
import { IMAGES } from "@/config/images";
|
import { IMAGES } from "@/config/images";
|
||||||
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { actionTranslateText } from "@/modules/translator/translator-action";
|
import { actionTranslateText } from "@/modules/translator/translator-action";
|
||||||
|
import { actionCreateCard } from "@/modules/card/card-action";
|
||||||
|
import { actionGetDecksByUserId } from "@/modules/deck/deck-action";
|
||||||
|
import type { ActionOutputDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
import type { CardType } from "@/modules/card/card-action-dto";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
||||||
import { TSharedTranslationResult } from "@/shared/translator-type";
|
import { TSharedTranslationResult } from "@/shared/translator-type";
|
||||||
|
import { Plus } from "lucide-react";
|
||||||
|
import { authClient } from "@/lib/auth-client";
|
||||||
|
|
||||||
|
const SOURCE_LANGUAGES = [
|
||||||
|
{ value: "Auto", label: "auto" },
|
||||||
|
{ value: "Chinese", label: "chinese" },
|
||||||
|
{ value: "English", label: "english" },
|
||||||
|
{ value: "Japanese", label: "japanese" },
|
||||||
|
{ value: "Korean", label: "korean" },
|
||||||
|
{ value: "French", label: "french" },
|
||||||
|
{ value: "German", label: "german" },
|
||||||
|
{ value: "Italian", label: "italian" },
|
||||||
|
{ value: "Spanish", label: "spanish" },
|
||||||
|
{ value: "Portuguese", label: "portuguese" },
|
||||||
|
{ value: "Russian", label: "russian" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const TARGET_LANGUAGES = [
|
||||||
|
{ value: "Chinese", label: "chinese" },
|
||||||
|
{ value: "English", label: "english" },
|
||||||
|
{ value: "Japanese", label: "japanese" },
|
||||||
|
{ value: "Korean", label: "korean" },
|
||||||
|
{ value: "French", label: "french" },
|
||||||
|
{ value: "German", label: "german" },
|
||||||
|
{ value: "Italian", label: "italian" },
|
||||||
|
{ value: "Spanish", label: "spanish" },
|
||||||
|
{ value: "Portuguese", label: "portuguese" },
|
||||||
|
{ value: "Russian", label: "russian" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type LangLabel = typeof SOURCE_LANGUAGES[number]["label"];
|
||||||
|
|
||||||
|
function getLangLabel(t: (key: string) => string, label: LangLabel): string {
|
||||||
|
switch (label) {
|
||||||
|
case "auto": return t("auto");
|
||||||
|
case "chinese": return t("chinese");
|
||||||
|
case "english": return t("english");
|
||||||
|
case "japanese": return t("japanese");
|
||||||
|
case "korean": return t("korean");
|
||||||
|
case "french": return t("french");
|
||||||
|
case "german": return t("german");
|
||||||
|
case "italian": return t("italian");
|
||||||
|
case "spanish": return t("spanish");
|
||||||
|
case "portuguese": return t("portuguese");
|
||||||
|
case "russian": return t("russian");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estimated button width in pixels (including gap)
|
||||||
|
const BUTTON_WIDTH = 80;
|
||||||
|
const LABEL_WIDTH = 100;
|
||||||
|
const INPUT_WIDTH = 140;
|
||||||
|
const IPA_BUTTON_WIDTH = 100;
|
||||||
|
|
||||||
export default function TranslatorPage() {
|
export default function TranslatorPage() {
|
||||||
const t = useTranslations("translator");
|
const t = useTranslations("translator");
|
||||||
|
|
||||||
const taref = useRef<HTMLTextAreaElement>(null);
|
const taref = useRef<HTMLTextAreaElement>(null);
|
||||||
|
const sourceContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const targetContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [sourceLanguage, setSourceLanguage] = useState<string>("Auto");
|
||||||
const [targetLanguage, setTargetLanguage] = useState<string>("Chinese");
|
const [targetLanguage, setTargetLanguage] = useState<string>("Chinese");
|
||||||
|
const [customSourceLanguage, setCustomSourceLanguage] = useState<string>("");
|
||||||
|
const [customTargetLanguage, setCustomTargetLanguage] = useState<string>("");
|
||||||
const [translationResult, setTranslationResult] = useState<TSharedTranslationResult | null>(null);
|
const [translationResult, setTranslationResult] = useState<TSharedTranslationResult | null>(null);
|
||||||
const [needIpa, setNeedIpa] = useState(true);
|
const [needIpa, setNeedIpa] = useState(true);
|
||||||
const [processing, setProcessing] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [lastTranslation, setLastTranslation] = useState<{
|
const [lastTranslation, setLastTranslation] = useState<{
|
||||||
sourceText: string;
|
sourceText: string;
|
||||||
|
sourceLanguage: string;
|
||||||
targetLanguage: string;
|
targetLanguage: string;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
const [sourceButtonCount, setSourceButtonCount] = useState(2);
|
||||||
|
const [targetButtonCount, setTargetButtonCount] = useState(2);
|
||||||
const { load, play } = useAudioPlayer();
|
const { load, play } = useAudioPlayer();
|
||||||
const lastTTS = useRef({
|
|
||||||
text: "",
|
|
||||||
url: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const tts = async (text: string, locale: string) => {
|
const { data: session } = authClient.useSession();
|
||||||
if (lastTTS.current.text !== text) {
|
const [decks, setDecks] = useState<ActionOutputDeck[]>([]);
|
||||||
|
const [showSaveModal, setShowSaveModal] = useState(false);
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (session?.user?.id) {
|
||||||
|
actionGetDecksByUserId(session.user.id).then((result) => {
|
||||||
|
if (result.success && result.data) {
|
||||||
|
setDecks(result.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [session?.user?.id]);
|
||||||
|
|
||||||
|
// Calculate how many buttons to show based on container width
|
||||||
|
const calculateButtonCount = useCallback((containerWidth: number, hasIpa: boolean) => {
|
||||||
|
// Reserve space for label, input, and IPA button (for source)
|
||||||
|
const reservedWidth = LABEL_WIDTH + INPUT_WIDTH + (hasIpa ? IPA_BUTTON_WIDTH : 0);
|
||||||
|
const availableWidth = containerWidth - reservedWidth;
|
||||||
|
return Math.max(0, Math.floor(availableWidth / BUTTON_WIDTH));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateButtonCounts = () => {
|
||||||
|
if (sourceContainerRef.current) {
|
||||||
|
const width = sourceContainerRef.current.offsetWidth;
|
||||||
|
setSourceButtonCount(calculateButtonCount(width, true));
|
||||||
|
}
|
||||||
|
if (targetContainerRef.current) {
|
||||||
|
const width = targetContainerRef.current.offsetWidth;
|
||||||
|
setTargetButtonCount(calculateButtonCount(width, false));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateButtonCounts();
|
||||||
|
window.addEventListener("resize", updateButtonCounts);
|
||||||
|
return () => window.removeEventListener("resize", updateButtonCounts);
|
||||||
|
}, [calculateButtonCount]);
|
||||||
|
|
||||||
|
const tts = useCallback(async (text: string, locale: string) => {
|
||||||
try {
|
try {
|
||||||
// Map language name to TTS format
|
// Map language name to TTS format
|
||||||
let theLanguage = locale.toLowerCase().replace(/[^a-z]/g, '').replace(/^./, match => match.toUpperCase());
|
let theLanguage = locale.toLowerCase().replace(/[^a-z]/g, '').replace(/^./, match => match.toUpperCase());
|
||||||
@@ -47,13 +150,10 @@ export default function TranslatorPage() {
|
|||||||
const url = await getTTSUrl(text, theLanguage as TTS_SUPPORTED_LANGUAGES);
|
const url = await getTTSUrl(text, theLanguage as TTS_SUPPORTED_LANGUAGES);
|
||||||
await load(url);
|
await load(url);
|
||||||
await play();
|
await play();
|
||||||
lastTTS.current.text = text;
|
|
||||||
lastTTS.current.url = url;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Failed to generate audio");
|
toast.error("Failed to generate audio");
|
||||||
}
|
}
|
||||||
}
|
}, [load, play]);
|
||||||
};
|
|
||||||
|
|
||||||
const translate = async () => {
|
const translate = async () => {
|
||||||
if (!taref.current || processing) return;
|
if (!taref.current || processing) return;
|
||||||
@@ -61,26 +161,30 @@ export default function TranslatorPage() {
|
|||||||
setProcessing(true);
|
setProcessing(true);
|
||||||
|
|
||||||
const sourceText = taref.current.value;
|
const sourceText = taref.current.value;
|
||||||
|
const effectiveSourceLanguage = customSourceLanguage.trim() || sourceLanguage;
|
||||||
|
const effectiveTargetLanguage = customTargetLanguage.trim() || targetLanguage;
|
||||||
|
|
||||||
// 判断是否需要强制重新翻译
|
// 判断是否需要强制重新翻译
|
||||||
// 只有当源文本和目标语言都与上次相同时,才强制重新翻译
|
|
||||||
const forceRetranslate =
|
const forceRetranslate =
|
||||||
lastTranslation?.sourceText === sourceText &&
|
lastTranslation?.sourceText === sourceText &&
|
||||||
lastTranslation?.targetLanguage === targetLanguage;
|
lastTranslation?.sourceLanguage === effectiveSourceLanguage &&
|
||||||
|
lastTranslation?.targetLanguage === effectiveTargetLanguage;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await actionTranslateText({
|
const result = await actionTranslateText({
|
||||||
sourceText,
|
sourceText,
|
||||||
targetLanguage,
|
targetLanguage: effectiveTargetLanguage,
|
||||||
forceRetranslate,
|
forceRetranslate,
|
||||||
needIpa,
|
needIpa,
|
||||||
|
sourceLanguage: effectiveSourceLanguage === "Auto" ? undefined : effectiveSourceLanguage,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setTranslationResult(result.data);
|
setTranslationResult(result.data);
|
||||||
setLastTranslation({
|
setLastTranslation({
|
||||||
sourceText,
|
sourceText,
|
||||||
targetLanguage,
|
sourceLanguage: effectiveSourceLanguage,
|
||||||
|
targetLanguage: effectiveTargetLanguage,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message || "翻译失败,请重试");
|
toast.error(result.message || "翻译失败,请重试");
|
||||||
@@ -93,6 +197,66 @@ export default function TranslatorPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const visibleSourceButtons = SOURCE_LANGUAGES.slice(0, sourceButtonCount);
|
||||||
|
const visibleTargetButtons = TARGET_LANGUAGES.slice(0, targetButtonCount);
|
||||||
|
|
||||||
|
const handleSaveCard = async () => {
|
||||||
|
if (!session) {
|
||||||
|
toast.error(t("pleaseLogin"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (decks.length === 0) {
|
||||||
|
toast.error(t("pleaseCreateDeck"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!lastTranslation?.sourceText || !translationResult?.translatedText) {
|
||||||
|
toast.error(t("noTranslationToSave"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deckSelect = document.getElementById("deck-select-translator") as HTMLSelectElement;
|
||||||
|
const deckId = deckSelect?.value ? Number(deckSelect.value) : decks[0]?.id;
|
||||||
|
|
||||||
|
if (!deckId) {
|
||||||
|
toast.error(t("noDeckSelected"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSaving(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const sourceText = lastTranslation.sourceText;
|
||||||
|
const hasSpaces = sourceText.includes(" ");
|
||||||
|
let cardType: CardType = "WORD";
|
||||||
|
if (!translationResult.sourceIpa) {
|
||||||
|
cardType = "SENTENCE";
|
||||||
|
} else if (hasSpaces) {
|
||||||
|
cardType = "PHRASE";
|
||||||
|
}
|
||||||
|
|
||||||
|
await actionCreateCard({
|
||||||
|
deckId,
|
||||||
|
word: sourceText,
|
||||||
|
ipa: translationResult.sourceIpa || null,
|
||||||
|
queryLang: lastTranslation.sourceLanguage,
|
||||||
|
cardType,
|
||||||
|
meanings: [{
|
||||||
|
partOfSpeech: null,
|
||||||
|
definition: translationResult.translatedText,
|
||||||
|
example: null,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
const deckName = decks.find((d) => d.id === deckId)?.name || "Unknown";
|
||||||
|
toast.success(t("savedToDeck", { deckName }));
|
||||||
|
setShowSaveModal(false);
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(t("saveFailed"));
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-white">
|
<div className="min-h-[calc(100vh-64px)] bg-white">
|
||||||
{/* TCard Component */}
|
{/* TCard Component */}
|
||||||
@@ -101,13 +265,13 @@ export default function TranslatorPage() {
|
|||||||
<div className="w-full md:w-1/2 flex flex-col-reverse gap-2">
|
<div className="w-full md:w-1/2 flex flex-col-reverse gap-2">
|
||||||
{/* ICard1 Component */}
|
{/* ICard1 Component */}
|
||||||
<div className="border border-gray-200 rounded-lg w-full h-64 p-2">
|
<div className="border border-gray-200 rounded-lg w-full h-64 p-2">
|
||||||
<textarea
|
<Textarea
|
||||||
className="resize-none h-8/12 w-full focus:outline-0"
|
className="resize-none h-8/12 w-full"
|
||||||
ref={taref}
|
ref={taref}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.ctrlKey && e.key === "Enter") translate();
|
if (e.ctrlKey && e.key === "Enter") translate();
|
||||||
}}
|
}}
|
||||||
></textarea>
|
/>
|
||||||
<div className="ipa w-full h-2/12 overflow-auto text-gray-600">
|
<div className="ipa w-full h-2/12 overflow-auto text-gray-600">
|
||||||
{translationResult?.sourceIpa || ""}
|
{translationResult?.sourceIpa || ""}
|
||||||
</div>
|
</div>
|
||||||
@@ -125,18 +289,41 @@ export default function TranslatorPage() {
|
|||||||
src={IMAGES.play_arrow}
|
src={IMAGES.play_arrow}
|
||||||
alt="play"
|
alt="play"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const t = taref.current?.value;
|
const text = taref.current?.value;
|
||||||
if (!t) return;
|
if (!text) return;
|
||||||
tts(t, translationResult?.sourceLanguage || "");
|
tts(text, translationResult?.sourceLanguage || "");
|
||||||
}}
|
}}
|
||||||
></IconClick>
|
></IconClick>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="option1 w-full flex flex-row justify-between items-center">
|
<div ref={sourceContainerRef} className="option1 w-full flex gap-1 items-center overflow-x-auto">
|
||||||
<span>{t("detectLanguage")}</span>
|
<span className="shrink-0">{t("sourceLanguage")}</span>
|
||||||
|
{visibleSourceButtons.map((lang) => (
|
||||||
|
<LightButton
|
||||||
|
key={lang.value}
|
||||||
|
selected={!customSourceLanguage && sourceLanguage === lang.value}
|
||||||
|
onClick={() => {
|
||||||
|
setSourceLanguage(lang.value);
|
||||||
|
setCustomSourceLanguage("");
|
||||||
|
}}
|
||||||
|
className="shrink-0"
|
||||||
|
>
|
||||||
|
{getLangLabel(t, lang.label)}
|
||||||
|
</LightButton>
|
||||||
|
))}
|
||||||
|
<Input
|
||||||
|
variant="bordered"
|
||||||
|
size="sm"
|
||||||
|
value={customSourceLanguage}
|
||||||
|
onChange={(e) => setCustomSourceLanguage(e.target.value)}
|
||||||
|
placeholder={t("customLanguage")}
|
||||||
|
className="w-auto min-w-[120px] shrink-0"
|
||||||
|
/>
|
||||||
|
<div className="flex-1"></div>
|
||||||
<LightButton
|
<LightButton
|
||||||
selected={needIpa}
|
selected={needIpa}
|
||||||
onClick={() => setNeedIpa((prev) => !prev)}
|
onClick={() => setNeedIpa((prev) => !prev)}
|
||||||
|
className="shrink-0"
|
||||||
>
|
>
|
||||||
{t("generateIPA")}
|
{t("generateIPA")}
|
||||||
</LightButton>
|
</LightButton>
|
||||||
@@ -172,43 +359,35 @@ export default function TranslatorPage() {
|
|||||||
></IconClick>
|
></IconClick>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="option2 w-full flex gap-1 items-center flex-wrap">
|
<div ref={targetContainerRef} className="option2 w-full flex gap-1 items-center overflow-x-auto">
|
||||||
<span>{t("translateInto")}</span>
|
<span className="shrink-0">{t("translateInto")}</span>
|
||||||
|
{visibleTargetButtons.map((lang) => (
|
||||||
<LightButton
|
<LightButton
|
||||||
selected={targetLanguage === "Chinese"}
|
key={lang.value}
|
||||||
onClick={() => setTargetLanguage("Chinese")}
|
selected={!customTargetLanguage && targetLanguage === lang.value}
|
||||||
>
|
|
||||||
{t("chinese")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={targetLanguage === "English"}
|
|
||||||
onClick={() => setTargetLanguage("English")}
|
|
||||||
>
|
|
||||||
{t("english")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={targetLanguage === "Italian"}
|
|
||||||
onClick={() => setTargetLanguage("Italian")}
|
|
||||||
>
|
|
||||||
{t("italian")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={!["Chinese", "English", "Italian"].includes(targetLanguage)}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newLang = prompt(t("enterLanguage"));
|
setTargetLanguage(lang.value);
|
||||||
if (newLang) {
|
setCustomTargetLanguage("");
|
||||||
setTargetLanguage(newLang);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
|
className="shrink-0"
|
||||||
>
|
>
|
||||||
{t("other")}
|
{getLangLabel(t, lang.label)}
|
||||||
</LightButton>
|
</LightButton>
|
||||||
|
))}
|
||||||
|
<Input
|
||||||
|
variant="bordered"
|
||||||
|
size="sm"
|
||||||
|
value={customTargetLanguage}
|
||||||
|
onChange={(e) => setCustomTargetLanguage(e.target.value)}
|
||||||
|
placeholder={t("customLanguage")}
|
||||||
|
className="w-auto min-w-[120px] shrink-0"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TranslateButton Component */}
|
{/* TranslateButton Component */}
|
||||||
<div className="w-screen flex justify-center items-center">
|
<div className="w-screen flex justify-center items-center gap-4">
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
onClick={translate}
|
onClick={translate}
|
||||||
disabled={processing}
|
disabled={processing}
|
||||||
@@ -217,7 +396,49 @@ export default function TranslatorPage() {
|
|||||||
>
|
>
|
||||||
{t("translate")}
|
{t("translate")}
|
||||||
</PrimaryButton>
|
</PrimaryButton>
|
||||||
|
{translationResult && session && decks.length > 0 && (
|
||||||
|
<CircleButton
|
||||||
|
onClick={() => setShowSaveModal(true)}
|
||||||
|
title={t("saveAsCard")}
|
||||||
|
>
|
||||||
|
<Plus size={20} />
|
||||||
|
</CircleButton>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{showSaveModal && (
|
||||||
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
||||||
|
<div className="bg-white rounded-lg p-6 w-full max-w-md mx-4">
|
||||||
|
<h2 className="text-xl font-semibold mb-4">{t("saveAsCard")}</h2>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{t("selectDeck")}
|
||||||
|
</label>
|
||||||
|
<Select id="deck-select-translator" className="w-full">
|
||||||
|
{decks.map((deck) => (
|
||||||
|
<option key={deck.id} value={deck.id}>
|
||||||
|
{deck.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className="mb-4 p-3 bg-gray-50 rounded text-sm">
|
||||||
|
<div className="font-medium mb-1">{t("front")}:</div>
|
||||||
|
<div className="text-gray-700 mb-2">{lastTranslation?.sourceText}</div>
|
||||||
|
<div className="font-medium mb-1">{t("back")}:</div>
|
||||||
|
<div className="text-gray-700">{translationResult?.translatedText}</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<LightButton onClick={() => setShowSaveModal(false)}>
|
||||||
|
{t("cancel")}
|
||||||
|
</LightButton>
|
||||||
|
<PrimaryButton onClick={handleSaveCard} loading={isSaving}>
|
||||||
|
{t("save")}
|
||||||
|
</PrimaryButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
Folder as Fd,
|
Layers,
|
||||||
FolderPen,
|
Pencil,
|
||||||
FolderPlus,
|
Plus,
|
||||||
Globe,
|
Globe,
|
||||||
Lock,
|
Lock,
|
||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { CircleButton, LightButton } from "@/design-system/base/button";
|
import { CircleButton, LightButton } from "@/design-system/base/button";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
|
import { VStack } from "@/design-system/layout/stack";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -18,30 +20,33 @@ import { PageLayout } from "@/components/ui/PageLayout";
|
|||||||
import { PageHeader } from "@/components/ui/PageHeader";
|
import { PageHeader } from "@/components/ui/PageHeader";
|
||||||
import { CardList } from "@/components/ui/CardList";
|
import { CardList } from "@/components/ui/CardList";
|
||||||
import {
|
import {
|
||||||
actionCreateFolder,
|
actionCreateDeck,
|
||||||
actionDeleteFolderById,
|
actionDeleteDeck,
|
||||||
actionGetFoldersWithTotalPairsByUserId,
|
actionGetDecksByUserId,
|
||||||
actionRenameFolderById,
|
actionUpdateDeck,
|
||||||
actionSetFolderVisibility,
|
actionGetDeckById,
|
||||||
} from "@/modules/folder/folder-action";
|
} from "@/modules/deck/deck-action";
|
||||||
import { TSharedFolderWithTotalPairs } from "@/shared/folder-type";
|
import type { ActionOutputDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
|
||||||
interface FolderCardProps {
|
interface DeckCardProps {
|
||||||
folder: TSharedFolderWithTotalPairs;
|
deck: ActionOutputDeck;
|
||||||
onUpdateFolder: (folderId: number, updates: Partial<TSharedFolderWithTotalPairs>) => void;
|
onUpdateDeck: (deckId: number, updates: Partial<ActionOutputDeck>) => void;
|
||||||
onDeleteFolder: (folderId: number) => void;
|
onDeleteDeck: (deckId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps) => {
|
const DeckCard = ({ deck, onUpdateDeck, onDeleteDeck }: DeckCardProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("folders");
|
const t = useTranslations("decks");
|
||||||
|
|
||||||
const handleToggleVisibility = async (e: React.MouseEvent) => {
|
const handleToggleVisibility = async (e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const newVisibility = folder.visibility === "PUBLIC" ? "PRIVATE" : "PUBLIC";
|
const newVisibility = deck.visibility === "PUBLIC" ? "PRIVATE" : "PUBLIC";
|
||||||
const result = await actionSetFolderVisibility(folder.id, newVisibility);
|
const result = await actionUpdateDeck({
|
||||||
|
deckId: deck.id,
|
||||||
|
visibility: newVisibility,
|
||||||
|
});
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
onUpdateFolder(folder.id, { visibility: newVisibility });
|
onUpdateDeck(deck.id, { visibility: newVisibility });
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -51,9 +56,12 @@ const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps)
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const newName = prompt(t("enterNewName"))?.trim();
|
const newName = prompt(t("enterNewName"))?.trim();
|
||||||
if (newName && newName.length > 0) {
|
if (newName && newName.length > 0) {
|
||||||
const result = await actionRenameFolderById(folder.id, newName);
|
const result = await actionUpdateDeck({
|
||||||
|
deckId: deck.id,
|
||||||
|
name: newName,
|
||||||
|
});
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
onUpdateFolder(folder.id, { name: newName });
|
onUpdateDeck(deck.id, { name: newName });
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -62,11 +70,11 @@ const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps)
|
|||||||
|
|
||||||
const handleDelete = async (e: React.MouseEvent) => {
|
const handleDelete = async (e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const confirm = prompt(t("confirmDelete", { name: folder.name }));
|
const confirm = prompt(t("confirmDelete", { name: deck.name }));
|
||||||
if (confirm === folder.name) {
|
if (confirm === deck.name) {
|
||||||
const result = await actionDeleteFolderById(folder.id);
|
const result = await actionDeleteDeck({ deckId: deck.id });
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
onDeleteFolder(folder.id);
|
onDeleteDeck(deck.id);
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -77,31 +85,31 @@ const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps)
|
|||||||
<div
|
<div
|
||||||
className="flex justify-between items-center group py-4 px-5 border-b border-gray-200 last:border-b-0 hover:bg-gray-50 cursor-pointer transition-colors"
|
className="flex justify-between items-center group py-4 px-5 border-b border-gray-200 last:border-b-0 hover:bg-gray-50 cursor-pointer transition-colors"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(`/folders/${folder.id}`);
|
router.push(`/decks/${deck.id}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-4 flex-1">
|
<div className="flex items-center gap-4 flex-1">
|
||||||
<div className="shrink-0 text-primary-500">
|
<div className="shrink-0 text-primary-500">
|
||||||
<Fd size={24} />
|
<Layers size={24} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<h3 className="font-semibold text-gray-900 truncate">{folder.name}</h3>
|
<h3 className="font-semibold text-gray-900 truncate">{deck.name}</h3>
|
||||||
<span className="flex items-center gap-1 text-xs text-gray-400">
|
<span className="flex items-center gap-1 text-xs text-gray-400">
|
||||||
{folder.visibility === "PUBLIC" ? (
|
{deck.visibility === "PUBLIC" ? (
|
||||||
<Globe size={12} />
|
<Globe size={12} />
|
||||||
) : (
|
) : (
|
||||||
<Lock size={12} />
|
<Lock size={12} />
|
||||||
)}
|
)}
|
||||||
{folder.visibility === "PUBLIC" ? t("public") : t("private")}
|
{deck.visibility === "PUBLIC" ? t("public") : t("private")}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-gray-500 mt-0.5">
|
<p className="text-sm text-gray-500 mt-0.5">
|
||||||
{t("folderInfo", {
|
{t("deckInfo", {
|
||||||
id: folder.id,
|
id: deck.id,
|
||||||
name: folder.name,
|
name: deck.name,
|
||||||
totalPairs: folder.total,
|
totalCards: deck.cardCount ?? 0,
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,16 +118,16 @@ const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps)
|
|||||||
<div className="flex items-center gap-1 ml-4">
|
<div className="flex items-center gap-1 ml-4">
|
||||||
<CircleButton
|
<CircleButton
|
||||||
onClick={handleToggleVisibility}
|
onClick={handleToggleVisibility}
|
||||||
title={folder.visibility === "PUBLIC" ? t("setPrivate") : t("setPublic")}
|
title={deck.visibility === "PUBLIC" ? t("setPrivate") : t("setPublic")}
|
||||||
>
|
>
|
||||||
{folder.visibility === "PUBLIC" ? (
|
{deck.visibility === "PUBLIC" ? (
|
||||||
<Lock size={18} />
|
<Lock size={18} />
|
||||||
) : (
|
) : (
|
||||||
<Globe size={18} />
|
<Globe size={18} />
|
||||||
)}
|
)}
|
||||||
</CircleButton>
|
</CircleButton>
|
||||||
<CircleButton onClick={handleRename}>
|
<CircleButton onClick={handleRename}>
|
||||||
<FolderPen size={18} />
|
<Pencil size={18} />
|
||||||
</CircleButton>
|
</CircleButton>
|
||||||
<CircleButton
|
<CircleButton
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
@@ -133,46 +141,49 @@ const FolderCard = ({ folder, onUpdateFolder, onDeleteFolder }: FolderCardProps)
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface FoldersClientProps {
|
interface DecksClientProps {
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FoldersClient({ userId }: FoldersClientProps) {
|
export function DecksClient({ userId }: DecksClientProps) {
|
||||||
const t = useTranslations("folders");
|
const t = useTranslations("decks");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [folders, setFolders] = useState<TSharedFolderWithTotalPairs[]>([]);
|
const [decks, setDecks] = useState<ActionOutputDeck[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const loadFolders = async () => {
|
const loadDecks = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const result = await actionGetFoldersWithTotalPairsByUserId(userId);
|
const result = await actionGetDecksByUserId(userId);
|
||||||
if (result.success && result.data) {
|
if (result.success && result.data) {
|
||||||
setFolders(result.data);
|
setDecks(result.data);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadFolders();
|
loadDecks();
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
|
|
||||||
const handleUpdateFolder = (folderId: number, updates: Partial<TSharedFolderWithTotalPairs>) => {
|
const handleUpdateDeck = (deckId: number, updates: Partial<ActionOutputDeck>) => {
|
||||||
setFolders((prev) =>
|
setDecks((prev) =>
|
||||||
prev.map((f) => (f.id === folderId ? { ...f, ...updates } : f))
|
prev.map((d) => (d.id === deckId ? { ...d, ...updates } : d))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteFolder = (folderId: number) => {
|
const handleDeleteDeck = (deckId: number) => {
|
||||||
setFolders((prev) => prev.filter((f) => f.id !== folderId));
|
setDecks((prev) => prev.filter((d) => d.id !== deckId));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateFolder = async () => {
|
const handleCreateDeck = async () => {
|
||||||
const folderName = prompt(t("enterFolderName"));
|
const deckName = prompt(t("enterDeckName"));
|
||||||
if (!folderName?.trim()) return;
|
if (!deckName?.trim()) return;
|
||||||
|
|
||||||
const result = await actionCreateFolder(userId, folderName.trim());
|
const result = await actionCreateDeck({ name: deckName.trim() });
|
||||||
if (result.success) {
|
if (result.success && result.deckId) {
|
||||||
loadFolders();
|
const deckResult = await actionGetDeckById({ deckId: result.deckId });
|
||||||
|
if (deckResult.success && deckResult.data) {
|
||||||
|
setDecks((prev) => [...prev, deckResult.data!]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.message);
|
toast.error(result.message);
|
||||||
}
|
}
|
||||||
@@ -182,33 +193,33 @@ export function FoldersClient({ userId }: FoldersClientProps) {
|
|||||||
<PageLayout>
|
<PageLayout>
|
||||||
<PageHeader title={t("title")} subtitle={t("subtitle")} />
|
<PageHeader title={t("title")} subtitle={t("subtitle")} />
|
||||||
|
|
||||||
<div className="mb-4">
|
<div className="mb-4 flex gap-2">
|
||||||
<LightButton onClick={handleCreateFolder}>
|
<LightButton onClick={handleCreateDeck}>
|
||||||
<FolderPlus size={18} />
|
<Plus size={18} />
|
||||||
{t("newFolder")}
|
{t("newDeck")}
|
||||||
</LightButton>
|
</LightButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CardList>
|
<CardList>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="p-8 text-center">
|
<VStack align="center" className="p-8">
|
||||||
<div className="w-8 h-8 border-2 border-gray-200 border-t-gray-400 rounded-full animate-spin mx-auto mb-3"></div>
|
<Skeleton variant="circular" className="w-8 h-8 mb-3" />
|
||||||
<p className="text-sm text-gray-500">{t("loading")}</p>
|
<p className="text-sm text-gray-500">{t("loading")}</p>
|
||||||
</div>
|
</VStack>
|
||||||
) : folders.length === 0 ? (
|
) : decks.length === 0 ? (
|
||||||
<div className="text-center py-12 text-gray-400">
|
<div className="text-center py-12 text-gray-400">
|
||||||
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
<div className="w-16 h-16 mx-auto mb-3 rounded-full bg-gray-100 flex items-center justify-center">
|
||||||
<Fd size={24} className="text-gray-400" />
|
<Layers size={24} className="text-gray-400" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm">{t("noFoldersYet")}</p>
|
<p className="text-sm">{t("noDecksYet")}</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
folders.map((folder) => (
|
decks.map((deck) => (
|
||||||
<FolderCard
|
<DeckCard
|
||||||
key={folder.id}
|
key={deck.id}
|
||||||
folder={folder}
|
deck={deck}
|
||||||
onUpdateFolder={handleUpdateFolder}
|
onUpdateDeck={handleUpdateDeck}
|
||||||
onDeleteFolder={handleDeleteFolder}
|
onDeleteDeck={handleDeleteDeck}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
285
src/app/decks/[deck_id]/AddCardModal.tsx
Normal file
285
src/app/decks/[deck_id]/AddCardModal.tsx
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { LightButton, PrimaryButton } from "@/design-system/base/button";
|
||||||
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Select } from "@/design-system/base/select";
|
||||||
|
import { Textarea } from "@/design-system/base/textarea";
|
||||||
|
import { Modal } from "@/design-system/overlay/modal";
|
||||||
|
import { VStack, HStack } from "@/design-system/layout/stack";
|
||||||
|
import { Plus, Trash2 } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { actionCreateCard } from "@/modules/card/card-action";
|
||||||
|
import type { CardType, CardMeaning } from "@/modules/card/card-action-dto";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
const QUERY_LANGUAGE_LABELS = {
|
||||||
|
english: "english",
|
||||||
|
chinese: "chinese",
|
||||||
|
japanese: "japanese",
|
||||||
|
korean: "korean",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const QUERY_LANGUAGES = [
|
||||||
|
{ value: "en", label: "english" as const },
|
||||||
|
{ value: "zh", label: "chinese" as const },
|
||||||
|
{ value: "ja", label: "japanese" as const },
|
||||||
|
{ value: "ko", label: "korean" as const },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
interface AddCardModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
deckId: number;
|
||||||
|
onAdded: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AddCardModal({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
deckId,
|
||||||
|
onAdded,
|
||||||
|
}: AddCardModalProps) {
|
||||||
|
const t = useTranslations("deck_id");
|
||||||
|
|
||||||
|
const [cardType, setCardType] = useState<CardType>("WORD");
|
||||||
|
const [word, setWord] = useState("");
|
||||||
|
const [ipa, setIpa] = useState("");
|
||||||
|
const [queryLang, setQueryLang] = useState("en");
|
||||||
|
const [customQueryLang, setCustomQueryLang] = useState("");
|
||||||
|
const [meanings, setMeanings] = useState<CardMeaning[]>([
|
||||||
|
{ partOfSpeech: null, definition: "", example: null }
|
||||||
|
]);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
const showIpa = cardType === "WORD" || cardType === "PHRASE";
|
||||||
|
|
||||||
|
const addMeaning = () => {
|
||||||
|
setMeanings([...meanings, { partOfSpeech: null, definition: "", example: null }]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeMeaning = (index: number) => {
|
||||||
|
if (meanings.length > 1) {
|
||||||
|
setMeanings(meanings.filter((_, i) => i !== index));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateMeaning = (
|
||||||
|
index: number,
|
||||||
|
field: "partOfSpeech" | "definition" | "example",
|
||||||
|
value: string
|
||||||
|
) => {
|
||||||
|
const updated = [...meanings];
|
||||||
|
updated[index] = {
|
||||||
|
...updated[index],
|
||||||
|
[field]: value || null
|
||||||
|
};
|
||||||
|
setMeanings(updated);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
setCardType("WORD");
|
||||||
|
setWord("");
|
||||||
|
setIpa("");
|
||||||
|
setQueryLang("en");
|
||||||
|
setCustomQueryLang("");
|
||||||
|
setMeanings([{ partOfSpeech: null, definition: "", example: null }]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAdd = async () => {
|
||||||
|
if (!word.trim()) {
|
||||||
|
toast.error(t("wordRequired"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validMeanings = meanings.filter(m => m.definition?.trim());
|
||||||
|
if (validMeanings.length === 0) {
|
||||||
|
toast.error(t("definitionRequired"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
const effectiveQueryLang = customQueryLang.trim() || queryLang;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cardResult = await actionCreateCard({
|
||||||
|
deckId,
|
||||||
|
word: word.trim(),
|
||||||
|
ipa: showIpa && ipa.trim() ? ipa.trim() : null,
|
||||||
|
queryLang: effectiveQueryLang,
|
||||||
|
cardType,
|
||||||
|
meanings: validMeanings.map(m => ({
|
||||||
|
partOfSpeech: cardType === "SENTENCE" ? null : (m.partOfSpeech?.trim() || null),
|
||||||
|
definition: m.definition!.trim(),
|
||||||
|
example: m.example?.trim() || null,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!cardResult.success) {
|
||||||
|
throw new Error(cardResult.message || "Failed to create card");
|
||||||
|
}
|
||||||
|
|
||||||
|
resetForm();
|
||||||
|
onAdded();
|
||||||
|
onClose();
|
||||||
|
toast.success(t("cardAdded") || "Card added successfully");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
resetForm();
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal open={isOpen} onClose={handleClose} size="md">
|
||||||
|
<Modal.Header>
|
||||||
|
<Modal.Title>{t("addNewCard")}</Modal.Title>
|
||||||
|
<Modal.CloseButton onClick={handleClose} />
|
||||||
|
</Modal.Header>
|
||||||
|
|
||||||
|
<Modal.Body className="space-y-4">
|
||||||
|
<HStack gap={3}>
|
||||||
|
<div className="flex-1">
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{t("cardType")}
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={cardType}
|
||||||
|
onChange={(e) => setCardType(e.target.value as CardType)}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
<option value="WORD">{t("wordCard")}</option>
|
||||||
|
<option value="PHRASE">{t("phraseCard")}</option>
|
||||||
|
<option value="SENTENCE">{t("sentenceCard")}</option>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{t("queryLang")}
|
||||||
|
</label>
|
||||||
|
<HStack gap={2} className="flex-wrap">
|
||||||
|
{QUERY_LANGUAGES.map((lang) => (
|
||||||
|
<LightButton
|
||||||
|
key={lang.value}
|
||||||
|
selected={!customQueryLang && queryLang === lang.value}
|
||||||
|
onClick={() => {
|
||||||
|
setQueryLang(lang.value);
|
||||||
|
setCustomQueryLang("");
|
||||||
|
}}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t(lang.label)}
|
||||||
|
</LightButton>
|
||||||
|
))}
|
||||||
|
<Input
|
||||||
|
value={customQueryLang}
|
||||||
|
onChange={(e) => setCustomQueryLang(e.target.value)}
|
||||||
|
placeholder={t("enterLanguageName")}
|
||||||
|
className="w-auto min-w-[100px] flex-1"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
</HStack>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{cardType === "SENTENCE" ? t("sentence") : t("word")} *
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
value={word}
|
||||||
|
onChange={(e) => setWord(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
placeholder={cardType === "SENTENCE" ? t("sentencePlaceholder") : t("wordPlaceholder")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{showIpa && (
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{t("ipa")}
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
value={ipa}
|
||||||
|
onChange={(e) => setIpa(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
placeholder={t("ipaPlaceholder")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<HStack justify="between" className="mb-2">
|
||||||
|
<label className="block text-sm font-medium text-gray-700">
|
||||||
|
{t("meanings")} *
|
||||||
|
</label>
|
||||||
|
<button
|
||||||
|
onClick={addMeaning}
|
||||||
|
className="text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1"
|
||||||
|
>
|
||||||
|
<Plus size={14} />
|
||||||
|
{t("addMeaning")}
|
||||||
|
</button>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
<VStack gap={4}>
|
||||||
|
{meanings.map((meaning, index) => (
|
||||||
|
<div key={index} className="p-3 bg-gray-50 rounded-lg space-y-2">
|
||||||
|
<HStack gap={2}>
|
||||||
|
{cardType !== "SENTENCE" && (
|
||||||
|
<div className="w-28 shrink-0">
|
||||||
|
<Input
|
||||||
|
value={meaning.partOfSpeech || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "partOfSpeech", e.target.value)}
|
||||||
|
placeholder={t("partOfSpeech")}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex-1">
|
||||||
|
<Input
|
||||||
|
value={meaning.definition || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "definition", e.target.value)}
|
||||||
|
placeholder={t("definition")}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{meanings.length > 1 && (
|
||||||
|
<button
|
||||||
|
onClick={() => removeMeaning(index)}
|
||||||
|
className="p-2 text-gray-400 hover:text-red-500"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</HStack>
|
||||||
|
<Textarea
|
||||||
|
value={meaning.example || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "example", e.target.value)}
|
||||||
|
placeholder={t("examplePlaceholder")}
|
||||||
|
className="w-full min-h-[40px] text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</VStack>
|
||||||
|
</div>
|
||||||
|
</Modal.Body>
|
||||||
|
|
||||||
|
<Modal.Footer>
|
||||||
|
<LightButton onClick={handleClose}>
|
||||||
|
{t("cancel")}
|
||||||
|
</LightButton>
|
||||||
|
<PrimaryButton onClick={handleAdd} loading={isSubmitting}>
|
||||||
|
{isSubmitting ? t("adding") : t("add")}
|
||||||
|
</PrimaryButton>
|
||||||
|
</Modal.Footer>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
133
src/app/decks/[deck_id]/CardItem.tsx
Normal file
133
src/app/decks/[deck_id]/CardItem.tsx
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
import { Trash2, Pencil } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { CircleButton } from "@/design-system/base/button";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import type { ActionOutputCard, CardType } from "@/modules/card/card-action-dto";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { actionDeleteCard } from "@/modules/card/card-action";
|
||||||
|
import { EditCardModal } from "./EditCardModal";
|
||||||
|
|
||||||
|
interface CardItemProps {
|
||||||
|
card: ActionOutputCard;
|
||||||
|
isReadOnly: boolean;
|
||||||
|
onDel: () => void;
|
||||||
|
onUpdated: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CARD_TYPE_LABELS: Record<CardType, string> = {
|
||||||
|
WORD: "Word",
|
||||||
|
PHRASE: "Phrase",
|
||||||
|
SENTENCE: "Sentence",
|
||||||
|
};
|
||||||
|
|
||||||
|
export function CardItem({
|
||||||
|
card,
|
||||||
|
isReadOnly,
|
||||||
|
onDel,
|
||||||
|
onUpdated,
|
||||||
|
}: CardItemProps) {
|
||||||
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
const [showEditModal, setShowEditModal] = useState(false);
|
||||||
|
const t = useTranslations("deck_id");
|
||||||
|
|
||||||
|
const frontText = card.word;
|
||||||
|
const backText = card.meanings.map((m) =>
|
||||||
|
m.partOfSpeech ? `${m.partOfSpeech}: ${m.definition}` : m.definition
|
||||||
|
).join("; ");
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
try {
|
||||||
|
const result = await actionDeleteCard({ cardId: card.id });
|
||||||
|
if (result.success) {
|
||||||
|
toast.success(t("cardDeleted"));
|
||||||
|
onDel();
|
||||||
|
} else {
|
||||||
|
toast.error(result.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
}
|
||||||
|
setShowDeleteConfirm(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="group border-b border-gray-100 hover:bg-gray-50 transition-colors">
|
||||||
|
<div className="p-4">
|
||||||
|
<div className="flex items-start justify-between mb-3">
|
||||||
|
<div className="flex items-center gap-2 text-xs text-gray-500">
|
||||||
|
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
||||||
|
{t("card")}
|
||||||
|
</span>
|
||||||
|
<span className="px-2 py-1 bg-blue-50 text-blue-600 rounded-md">
|
||||||
|
{CARD_TYPE_LABELS[card.cardType]}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-1 opacity-50 group-hover:opacity-100 transition-opacity">
|
||||||
|
{!isReadOnly && (
|
||||||
|
<>
|
||||||
|
<CircleButton
|
||||||
|
onClick={() => setShowEditModal(true)}
|
||||||
|
title={t("edit")}
|
||||||
|
className="text-gray-400 hover:text-blue-500 hover:bg-blue-50"
|
||||||
|
>
|
||||||
|
<Pencil size={14} />
|
||||||
|
</CircleButton>
|
||||||
|
<CircleButton
|
||||||
|
onClick={() => setShowDeleteConfirm(true)}
|
||||||
|
title={t("delete")}
|
||||||
|
className="text-gray-400 hover:text-red-500 hover:bg-red-50"
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
</CircleButton>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="text-gray-900 grid grid-cols-2 gap-4 w-3/4">
|
||||||
|
<div>
|
||||||
|
{frontText.length > 30
|
||||||
|
? frontText.substring(0, 30) + "..."
|
||||||
|
: frontText}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{backText.length > 30
|
||||||
|
? backText.substring(0, 30) + "..."
|
||||||
|
: backText}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{showDeleteConfirm && (
|
||||||
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
||||||
|
<div className="bg-white rounded-lg p-4 max-w-sm mx-4">
|
||||||
|
<p className="text-gray-700 mb-4">{t("deleteConfirm")}</p>
|
||||||
|
<div className="flex gap-2 justify-end">
|
||||||
|
<button
|
||||||
|
onClick={() => setShowDeleteConfirm(false)}
|
||||||
|
className="px-3 py-1 text-gray-600 hover:bg-gray-100 rounded"
|
||||||
|
>
|
||||||
|
{t("cancel")}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleDelete}
|
||||||
|
className="px-3 py-1 text-red-600 hover:bg-red-50 rounded"
|
||||||
|
>
|
||||||
|
{t("delete")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<EditCardModal
|
||||||
|
isOpen={showEditModal}
|
||||||
|
onClose={() => setShowEditModal(false)}
|
||||||
|
card={card}
|
||||||
|
onUpdated={onUpdated}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
229
src/app/decks/[deck_id]/EditCardModal.tsx
Normal file
229
src/app/decks/[deck_id]/EditCardModal.tsx
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { LightButton, PrimaryButton } from "@/design-system/base/button";
|
||||||
|
import { Input } from "@/design-system/base/input";
|
||||||
|
import { Textarea } from "@/design-system/base/textarea";
|
||||||
|
import { Modal } from "@/design-system/overlay/modal";
|
||||||
|
import { VStack, HStack } from "@/design-system/layout/stack";
|
||||||
|
import { Plus, Trash2 } from "lucide-react";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { actionUpdateCard } from "@/modules/card/card-action";
|
||||||
|
import type { ActionOutputCard, CardMeaning } from "@/modules/card/card-action-dto";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
interface EditCardModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
card: ActionOutputCard | null;
|
||||||
|
onUpdated: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EditCardModal({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
card,
|
||||||
|
onUpdated,
|
||||||
|
}: EditCardModalProps) {
|
||||||
|
const t = useTranslations("deck_id");
|
||||||
|
|
||||||
|
const [word, setWord] = useState("");
|
||||||
|
const [ipa, setIpa] = useState("");
|
||||||
|
const [meanings, setMeanings] = useState<CardMeaning[]>([
|
||||||
|
{ partOfSpeech: null, definition: "", example: null }
|
||||||
|
]);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
const showIpa = card?.cardType === "WORD" || card?.cardType === "PHRASE";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (card) {
|
||||||
|
setWord(card.word);
|
||||||
|
setIpa(card.ipa || "");
|
||||||
|
setMeanings(
|
||||||
|
card.meanings.length > 0
|
||||||
|
? card.meanings
|
||||||
|
: [{ partOfSpeech: null, definition: "", example: null }]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [card]);
|
||||||
|
|
||||||
|
const addMeaning = () => {
|
||||||
|
setMeanings([...meanings, { partOfSpeech: null, definition: "", example: null }]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeMeaning = (index: number) => {
|
||||||
|
if (meanings.length > 1) {
|
||||||
|
setMeanings(meanings.filter((_, i) => i !== index));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateMeaning = (index: number, field: keyof CardMeaning, value: string) => {
|
||||||
|
const updated = [...meanings];
|
||||||
|
updated[index] = { ...updated[index], [field]: value || null };
|
||||||
|
setMeanings(updated);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdate = async () => {
|
||||||
|
if (!card) return;
|
||||||
|
|
||||||
|
if (!word.trim()) {
|
||||||
|
toast.error(t("wordRequired"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validMeanings = meanings.filter(m => m.definition?.trim());
|
||||||
|
if (validMeanings.length === 0) {
|
||||||
|
toast.error(t("definitionRequired"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await actionUpdateCard({
|
||||||
|
cardId: card.id,
|
||||||
|
word: word.trim(),
|
||||||
|
ipa: showIpa && ipa.trim() ? ipa.trim() : null,
|
||||||
|
meanings: validMeanings.map(m => ({
|
||||||
|
partOfSpeech: card.cardType === "SENTENCE" ? null : (m.partOfSpeech?.trim() || null),
|
||||||
|
definition: m.definition!.trim(),
|
||||||
|
example: m.example?.trim() || null,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.success) {
|
||||||
|
throw new Error(result.message || "Failed to update card");
|
||||||
|
}
|
||||||
|
|
||||||
|
onUpdated();
|
||||||
|
onClose();
|
||||||
|
toast.success(t("cardUpdated") || "Card updated successfully");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!card) return null;
|
||||||
|
|
||||||
|
const cardTypeLabel = card.cardType === "WORD"
|
||||||
|
? t("wordCard")
|
||||||
|
: card.cardType === "PHRASE"
|
||||||
|
? t("phraseCard")
|
||||||
|
: t("sentenceCard");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal open={isOpen} onClose={onClose} size="md">
|
||||||
|
<Modal.Header>
|
||||||
|
<Modal.Title>{t("updateCard")}</Modal.Title>
|
||||||
|
<Modal.CloseButton onClick={onClose} />
|
||||||
|
</Modal.Header>
|
||||||
|
|
||||||
|
<Modal.Body className="space-y-4">
|
||||||
|
<HStack gap={2} className="text-sm text-gray-500">
|
||||||
|
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
||||||
|
{t("card")}
|
||||||
|
</span>
|
||||||
|
<span className="px-2 py-1 bg-blue-50 text-blue-600 rounded-md">
|
||||||
|
{cardTypeLabel}
|
||||||
|
</span>
|
||||||
|
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
||||||
|
{card.queryLang}
|
||||||
|
</span>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{card.cardType === "SENTENCE" ? t("sentence") : t("word")} *
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
value={word}
|
||||||
|
onChange={(e) => setWord(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{showIpa && (
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
{t("ipa")}
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
value={ipa}
|
||||||
|
onChange={(e) => setIpa(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
placeholder={t("ipaPlaceholder")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<HStack justify="between" className="mb-2">
|
||||||
|
<label className="block text-sm font-medium text-gray-700">
|
||||||
|
{t("meanings")} *
|
||||||
|
</label>
|
||||||
|
<button
|
||||||
|
onClick={addMeaning}
|
||||||
|
className="text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1"
|
||||||
|
>
|
||||||
|
<Plus size={14} />
|
||||||
|
{t("addMeaning")}
|
||||||
|
</button>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
<VStack gap={4}>
|
||||||
|
{meanings.map((meaning, index) => (
|
||||||
|
<div key={index} className="p-3 bg-gray-50 rounded-lg space-y-2">
|
||||||
|
<HStack gap={2}>
|
||||||
|
{card.cardType !== "SENTENCE" && (
|
||||||
|
<div className="w-28 shrink-0">
|
||||||
|
<Input
|
||||||
|
value={meaning.partOfSpeech || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "partOfSpeech", e.target.value)}
|
||||||
|
placeholder={t("partOfSpeech")}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex-1">
|
||||||
|
<Input
|
||||||
|
value={meaning.definition || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "definition", e.target.value)}
|
||||||
|
placeholder={t("definition")}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{meanings.length > 1 && (
|
||||||
|
<button
|
||||||
|
onClick={() => removeMeaning(index)}
|
||||||
|
className="p-2 text-gray-400 hover:text-red-500"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</HStack>
|
||||||
|
<Textarea
|
||||||
|
value={meaning.example || ""}
|
||||||
|
onChange={(e) => updateMeaning(index, "example", e.target.value)}
|
||||||
|
placeholder={t("examplePlaceholder")}
|
||||||
|
className="w-full min-h-[40px] text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</VStack>
|
||||||
|
</div>
|
||||||
|
</Modal.Body>
|
||||||
|
|
||||||
|
<Modal.Footer>
|
||||||
|
<LightButton onClick={onClose}>
|
||||||
|
{t("cancel")}
|
||||||
|
</LightButton>
|
||||||
|
<PrimaryButton onClick={handleUpdate} loading={isSubmitting}>
|
||||||
|
{isSubmitting ? t("updating") : t("update")}
|
||||||
|
</PrimaryButton>
|
||||||
|
</Modal.Footer>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
152
src/app/decks/[deck_id]/InDeck.tsx
Normal file
152
src/app/decks/[deck_id]/InDeck.tsx
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { ArrowLeft, Plus } from "lucide-react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { CardItem } from "./CardItem";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
|
import { PrimaryButton, CircleButton, LinkButton } from "@/design-system/base/button";
|
||||||
|
import { CardList } from "@/components/ui/CardList";
|
||||||
|
import { VStack } from "@/design-system/layout/stack";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
|
import { actionGetCardsByDeckId, actionDeleteCard } from "@/modules/card/card-action";
|
||||||
|
import { actionGetDeckById } from "@/modules/deck/deck-action";
|
||||||
|
import type { ActionOutputCard } from "@/modules/card/card-action-dto";
|
||||||
|
import type { ActionOutputDeck } from "@/modules/deck/deck-action-dto";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { AddCardModal } from "./AddCardModal";
|
||||||
|
|
||||||
|
export function InDeck({ deckId, isReadOnly }: { deckId: number; isReadOnly: boolean }) {
|
||||||
|
const [cards, setCards] = useState<ActionOutputCard[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [openAddModal, setAddModal] = useState(false);
|
||||||
|
const [deckInfo, setDeckInfo] = useState<ActionOutputDeck | null>(null);
|
||||||
|
const router = useRouter();
|
||||||
|
const t = useTranslations("deck_id");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchCards = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const [cardsResult, deckResult] = await Promise.all([
|
||||||
|
actionGetCardsByDeckId({ deckId }),
|
||||||
|
actionGetDeckById({ deckId }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!cardsResult.success || !cardsResult.data) {
|
||||||
|
throw new Error(cardsResult.message || "Failed to load cards");
|
||||||
|
}
|
||||||
|
setCards(cardsResult.data);
|
||||||
|
|
||||||
|
if (deckResult.success && deckResult.data) {
|
||||||
|
setDeckInfo(deckResult.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchCards();
|
||||||
|
}, [deckId]);
|
||||||
|
|
||||||
|
const refreshCards = async () => {
|
||||||
|
const result = await actionGetCardsByDeckId({ deckId });
|
||||||
|
if (result.success && result.data) {
|
||||||
|
setCards(result.data);
|
||||||
|
} else {
|
||||||
|
toast.error(result.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteCard = async (cardId: number) => {
|
||||||
|
try {
|
||||||
|
const result = await actionDeleteCard({ cardId });
|
||||||
|
if (result.success) {
|
||||||
|
toast.success(t("cardDeleted"));
|
||||||
|
await refreshCards();
|
||||||
|
} else {
|
||||||
|
toast.error(result.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<div className="mb-6">
|
||||||
|
<LinkButton
|
||||||
|
onClick={router.back}
|
||||||
|
className="flex items-center gap-2 mb-4"
|
||||||
|
>
|
||||||
|
<ArrowLeft size={16} />
|
||||||
|
<span className="text-sm">{t("back")}</span>
|
||||||
|
</LinkButton>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-1">
|
||||||
|
{deckInfo?.name || t("cards")}
|
||||||
|
</h1>
|
||||||
|
<p className="text-sm text-gray-500">
|
||||||
|
{t("itemsCount", { count: cards.length })}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<PrimaryButton
|
||||||
|
onClick={() => {
|
||||||
|
router.push(`/decks/${deckId}/learn`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("memorize")}
|
||||||
|
</PrimaryButton>
|
||||||
|
{!isReadOnly && (
|
||||||
|
<CircleButton
|
||||||
|
onClick={() => {
|
||||||
|
setAddModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Plus size={18} className="text-gray-700" />
|
||||||
|
</CircleButton>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CardList>
|
||||||
|
{loading ? (
|
||||||
|
<VStack align="center" className="p-8">
|
||||||
|
<Skeleton variant="circular" className="w-8 h-8" />
|
||||||
|
<p className="text-sm text-gray-500">{t("loadingCards")}</p>
|
||||||
|
</VStack>
|
||||||
|
) : cards.length === 0 ? (
|
||||||
|
<div className="p-12 text-center">
|
||||||
|
<p className="text-sm text-gray-500 mb-2">{t("noCards")}</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="divide-y divide-gray-100">
|
||||||
|
{cards.map((card) => (
|
||||||
|
<CardItem
|
||||||
|
key={card.id}
|
||||||
|
card={card}
|
||||||
|
isReadOnly={isReadOnly}
|
||||||
|
onDel={() => handleDeleteCard(card.id)}
|
||||||
|
onUpdated={refreshCards}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</CardList>
|
||||||
|
|
||||||
|
<AddCardModal
|
||||||
|
isOpen={openAddModal}
|
||||||
|
onClose={() => setAddModal(false)}
|
||||||
|
deckId={deckId}
|
||||||
|
onAdded={refreshCards}
|
||||||
|
/>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
466
src/app/decks/[deck_id]/learn/Memorize.tsx
Normal file
466
src/app/decks/[deck_id]/learn/Memorize.tsx
Normal file
@@ -0,0 +1,466 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useEffect, useTransition, useCallback, useRef } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import localFont from "next/font/local";
|
||||||
|
import { Layers, Check, RotateCcw, Volume2, Headphones, ChevronLeft, ChevronRight, Shuffle, List, Repeat, Infinity } from "lucide-react";
|
||||||
|
import { actionGetCardsByDeckId } from "@/modules/card/card-action";
|
||||||
|
import type { ActionOutputCard } from "@/modules/card/card-action-dto";
|
||||||
|
import { PageLayout } from "@/components/ui/PageLayout";
|
||||||
|
import { LightButton, CircleButton } from "@/design-system/base/button";
|
||||||
|
import { Progress } from "@/design-system/feedback/progress";
|
||||||
|
import { Skeleton } from "@/design-system/feedback/skeleton";
|
||||||
|
import { HStack, VStack } from "@/design-system/layout/stack";
|
||||||
|
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
||||||
|
import { getTTSUrl, type TTS_SUPPORTED_LANGUAGES } from "@/lib/bigmodel/tts";
|
||||||
|
|
||||||
|
const myFont = localFont({
|
||||||
|
src: "../../../../../public/fonts/NotoNaskhArabic-VariableFont_wght.ttf",
|
||||||
|
});
|
||||||
|
|
||||||
|
type StudyMode = "order-limited" | "order-infinite" | "random-limited" | "random-infinite";
|
||||||
|
|
||||||
|
interface MemorizeProps {
|
||||||
|
deckId: number;
|
||||||
|
deckName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Memorize: React.FC<MemorizeProps> = ({ deckId, deckName }) => {
|
||||||
|
const t = useTranslations("memorize.review");
|
||||||
|
const router = useRouter();
|
||||||
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
|
const [originalCards, setOriginalCards] = useState<ActionOutputCard[]>([]);
|
||||||
|
const [cards, setCards] = useState<ActionOutputCard[]>([]);
|
||||||
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
|
const [showAnswer, setShowAnswer] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [isReversed, setIsReversed] = useState(false);
|
||||||
|
const [isDictation, setIsDictation] = useState(false);
|
||||||
|
const [studyMode, setStudyMode] = useState<StudyMode>("order-limited");
|
||||||
|
const { play, stop, load } = useAudioPlayer();
|
||||||
|
const audioUrlRef = useRef<string | null>(null);
|
||||||
|
const [isAudioLoading, setIsAudioLoading] = useState(false);
|
||||||
|
|
||||||
|
const shuffleCards = useCallback((cardArray: ActionOutputCard[]): ActionOutputCard[] => {
|
||||||
|
const shuffled = [...cardArray];
|
||||||
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
||||||
|
}
|
||||||
|
return shuffled;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let ignore = false;
|
||||||
|
|
||||||
|
const loadCards = async () => {
|
||||||
|
setIsLoading(true);
|
||||||
|
setError(null);
|
||||||
|
startTransition(async () => {
|
||||||
|
const result = await actionGetCardsByDeckId({ deckId, limit: 100 });
|
||||||
|
if (!ignore) {
|
||||||
|
if (result.success && result.data) {
|
||||||
|
setOriginalCards(result.data);
|
||||||
|
setCards(result.data);
|
||||||
|
setCurrentIndex(0);
|
||||||
|
setShowAnswer(false);
|
||||||
|
setIsReversed(false);
|
||||||
|
setIsDictation(false);
|
||||||
|
} else {
|
||||||
|
setError(result.message);
|
||||||
|
}
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCards();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
ignore = true;
|
||||||
|
};
|
||||||
|
}, [deckId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (studyMode.startsWith("random")) {
|
||||||
|
setCards(shuffleCards(originalCards));
|
||||||
|
} else {
|
||||||
|
setCards(originalCards);
|
||||||
|
}
|
||||||
|
setCurrentIndex(0);
|
||||||
|
setShowAnswer(false);
|
||||||
|
}, [studyMode, originalCards, shuffleCards]);
|
||||||
|
|
||||||
|
const getCurrentCard = (): ActionOutputCard | null => {
|
||||||
|
return cards[currentIndex] ?? null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getFrontText = (card: ActionOutputCard): string => {
|
||||||
|
if (isReversed) {
|
||||||
|
return card.meanings.map((m) =>
|
||||||
|
m.partOfSpeech ? `${m.partOfSpeech}: ${m.definition}` : m.definition
|
||||||
|
).join("; ");
|
||||||
|
}
|
||||||
|
return card.word;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getBackContent = (card: ActionOutputCard): React.ReactNode => {
|
||||||
|
if (isReversed) {
|
||||||
|
return <span className="text-gray-900 text-xl md:text-2xl text-center">{card.word}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VStack align="stretch" gap={2} className="w-full max-w-lg">
|
||||||
|
{card.meanings.map((m, idx) => (
|
||||||
|
<div key={idx} className="flex gap-3 text-left">
|
||||||
|
{m.partOfSpeech && (
|
||||||
|
<span className="text-primary-600 text-sm font-medium min-w-[60px] shrink-0">
|
||||||
|
{m.partOfSpeech}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className="text-gray-800">{m.definition}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</VStack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleShowAnswer = useCallback(() => {
|
||||||
|
setShowAnswer(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const isInfinite = studyMode.endsWith("infinite");
|
||||||
|
|
||||||
|
const handleNextCard = useCallback(() => {
|
||||||
|
if (isInfinite) {
|
||||||
|
if (currentIndex >= cards.length - 1) {
|
||||||
|
if (studyMode.startsWith("random")) {
|
||||||
|
setCards(shuffleCards(originalCards));
|
||||||
|
}
|
||||||
|
setCurrentIndex(0);
|
||||||
|
} else {
|
||||||
|
setCurrentIndex(currentIndex + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentIndex < cards.length - 1) {
|
||||||
|
setCurrentIndex(currentIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setShowAnswer(false);
|
||||||
|
setIsReversed(false);
|
||||||
|
setIsDictation(false);
|
||||||
|
cleanupAudio();
|
||||||
|
}, [currentIndex, cards.length, isInfinite, studyMode, originalCards, shuffleCards]);
|
||||||
|
|
||||||
|
const handlePrevCard = useCallback(() => {
|
||||||
|
if (isInfinite) {
|
||||||
|
if (currentIndex <= 0) {
|
||||||
|
setCurrentIndex(cards.length - 1);
|
||||||
|
} else {
|
||||||
|
setCurrentIndex(currentIndex - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
setCurrentIndex(currentIndex - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setShowAnswer(false);
|
||||||
|
setIsReversed(false);
|
||||||
|
setIsDictation(false);
|
||||||
|
cleanupAudio();
|
||||||
|
}, [currentIndex, cards.length, isInfinite]);
|
||||||
|
|
||||||
|
const cleanupAudio = useCallback(() => {
|
||||||
|
if (audioUrlRef.current) {
|
||||||
|
URL.revokeObjectURL(audioUrlRef.current);
|
||||||
|
audioUrlRef.current = null;
|
||||||
|
}
|
||||||
|
stop();
|
||||||
|
}, [stop]);
|
||||||
|
|
||||||
|
const playTTS = useCallback(async (text: string) => {
|
||||||
|
if (isAudioLoading) return;
|
||||||
|
|
||||||
|
setIsAudioLoading(true);
|
||||||
|
try {
|
||||||
|
const hasChinese = /[\u4e00-\u9fff]/.test(text);
|
||||||
|
const hasJapanese = /[\u3040-\u309f\u30a0-\u30ff]/.test(text);
|
||||||
|
const hasKorean = /[\uac00-\ud7af]/.test(text);
|
||||||
|
|
||||||
|
let lang: TTS_SUPPORTED_LANGUAGES = "Auto";
|
||||||
|
if (hasChinese) lang = "Chinese";
|
||||||
|
else if (hasJapanese) lang = "Japanese";
|
||||||
|
else if (hasKorean) lang = "Korean";
|
||||||
|
else if (/^[a-zA-Z\s]/.test(text)) lang = "English";
|
||||||
|
|
||||||
|
const audioUrl = await getTTSUrl(text, lang);
|
||||||
|
|
||||||
|
if (audioUrl && audioUrl !== "error") {
|
||||||
|
audioUrlRef.current = audioUrl;
|
||||||
|
await load(audioUrl);
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("TTS playback failed", e);
|
||||||
|
} finally {
|
||||||
|
setIsAudioLoading(false);
|
||||||
|
}
|
||||||
|
}, [isAudioLoading, load, play]);
|
||||||
|
|
||||||
|
const playCurrentCard = useCallback(() => {
|
||||||
|
const currentCard = getCurrentCard();
|
||||||
|
if (!currentCard) return;
|
||||||
|
|
||||||
|
const text = isReversed
|
||||||
|
? currentCard.meanings.map((m) => m.definition).join("; ")
|
||||||
|
: currentCard.word;
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
playTTS(text);
|
||||||
|
}
|
||||||
|
}, [isReversed, playTTS]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!showAnswer) {
|
||||||
|
if (e.key === " " || e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleShowAnswer();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (e.key === "ArrowRight" || e.key === " " || e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleNextCard();
|
||||||
|
} else if (e.key === "ArrowLeft") {
|
||||||
|
e.preventDefault();
|
||||||
|
handlePrevCard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||||
|
}, [showAnswer, handleShowAnswer, handleNextCard, handlePrevCard]);
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<VStack align="center" className="py-12">
|
||||||
|
<Skeleton variant="circular" className="h-12 w-12 mb-4" />
|
||||||
|
<p className="text-gray-600">{t("loading")}</p>
|
||||||
|
</VStack>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<VStack align="center" className="py-12">
|
||||||
|
<div className="text-red-600 mb-4 px-4 py-3 bg-red-50 border border-red-200 rounded-lg max-w-md">
|
||||||
|
{error}
|
||||||
|
</div>
|
||||||
|
<LightButton onClick={() => router.push("/decks")} className="px-4 py-2">
|
||||||
|
{t("backToDecks")}
|
||||||
|
</LightButton>
|
||||||
|
</VStack>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cards.length === 0) {
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<VStack align="center" className="py-12">
|
||||||
|
<div className="text-green-500 mb-4">
|
||||||
|
<Check className="w-16 h-16 mx-auto" />
|
||||||
|
</div>
|
||||||
|
<h2 className="text-2xl font-bold text-gray-800 mb-2">{t("allDone")}</h2>
|
||||||
|
<p className="text-gray-600 mb-6">{t("allDoneDesc")}</p>
|
||||||
|
<LightButton onClick={() => router.push("/decks")} className="px-4 py-2">
|
||||||
|
{t("backToDecks")}
|
||||||
|
</LightButton>
|
||||||
|
</VStack>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentCard = getCurrentCard()!;
|
||||||
|
const displayFront = getFrontText(currentCard);
|
||||||
|
const isFinished = !isInfinite && currentIndex === cards.length - 1 && showAnswer;
|
||||||
|
|
||||||
|
const studyModeOptions: { value: StudyMode; label: string; icon: React.ReactNode }[] = [
|
||||||
|
{ value: "order-limited", label: t("orderLimited"), icon: <List className="w-4 h-4" /> },
|
||||||
|
{ value: "order-infinite", label: t("orderInfinite"), icon: <Repeat className="w-4 h-4" /> },
|
||||||
|
{ value: "random-limited", label: t("randomLimited"), icon: <Shuffle className="w-4 h-4" /> },
|
||||||
|
{ value: "random-infinite", label: t("randomInfinite"), icon: <Infinity className="w-4 h-4" /> },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageLayout>
|
||||||
|
<HStack justify="between" className="mb-4">
|
||||||
|
<HStack gap={2} className="text-gray-600">
|
||||||
|
<Layers className="w-5 h-5" />
|
||||||
|
<span className="font-medium">{deckName}</span>
|
||||||
|
</HStack>
|
||||||
|
{!isInfinite && (
|
||||||
|
<span className="text-sm text-gray-500">
|
||||||
|
{t("progress", { current: currentIndex + 1, total: cards.length })}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
{!isInfinite && (
|
||||||
|
<Progress
|
||||||
|
value={((currentIndex + 1) / cards.length) * 100}
|
||||||
|
showLabel={false}
|
||||||
|
animated={false}
|
||||||
|
className="mb-6"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<VStack gap={2} className="mb-4">
|
||||||
|
<HStack justify="center" gap={1} className="flex-wrap">
|
||||||
|
{studyModeOptions.map((option) => (
|
||||||
|
<LightButton
|
||||||
|
key={option.value}
|
||||||
|
onClick={() => setStudyMode(option.value)}
|
||||||
|
selected={studyMode === option.value}
|
||||||
|
leftIcon={option.icon}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{option.label}
|
||||||
|
</LightButton>
|
||||||
|
))}
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
<HStack justify="center" gap={2}>
|
||||||
|
<LightButton
|
||||||
|
onClick={() => {
|
||||||
|
setIsReversed(!isReversed);
|
||||||
|
setShowAnswer(false);
|
||||||
|
}}
|
||||||
|
selected={isReversed}
|
||||||
|
leftIcon={<RotateCcw className="w-4 h-4" />}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t("reverse")}
|
||||||
|
</LightButton>
|
||||||
|
<LightButton
|
||||||
|
onClick={() => {
|
||||||
|
setIsDictation(!isDictation);
|
||||||
|
}}
|
||||||
|
selected={isDictation}
|
||||||
|
leftIcon={<Headphones className="w-4 h-4" />}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t("dictation")}
|
||||||
|
</LightButton>
|
||||||
|
</HStack>
|
||||||
|
</VStack>
|
||||||
|
|
||||||
|
<div className={`bg-white border border-gray-200 rounded-xl shadow-sm mb-6 ${myFont.className}`}>
|
||||||
|
{isDictation ? (
|
||||||
|
<>
|
||||||
|
<VStack align="center" justify="center" gap={4} className="p-8 min-h-[20dvh]">
|
||||||
|
{currentCard.ipa ? (
|
||||||
|
<div className="text-gray-700 text-2xl text-center font-mono">
|
||||||
|
{currentCard.ipa}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="text-gray-400 text-lg">
|
||||||
|
{t("noIpa")}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</VStack>
|
||||||
|
|
||||||
|
{showAnswer && (
|
||||||
|
<>
|
||||||
|
<div className="border-t border-gray-200" />
|
||||||
|
<VStack align="center" justify="center" className="p-8 min-h-[20dvh] bg-gray-50 rounded-b-xl">
|
||||||
|
<div className="text-gray-900 text-xl md:text-2xl text-center whitespace-pre-line">
|
||||||
|
{displayFront}
|
||||||
|
</div>
|
||||||
|
{getBackContent(currentCard)}
|
||||||
|
</VStack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<HStack align="center" justify="center" className="p-8 min-h-[20dvh]">
|
||||||
|
<div className="text-gray-900 text-xl md:text-2xl text-center whitespace-pre-line">
|
||||||
|
{displayFront}
|
||||||
|
</div>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
|
{showAnswer && (
|
||||||
|
<>
|
||||||
|
<div className="border-t border-gray-200" />
|
||||||
|
<VStack align="center" justify="center" className="p-8 min-h-[20dvh] bg-gray-50 rounded-b-xl">
|
||||||
|
{getBackContent(currentCard)}
|
||||||
|
</VStack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<HStack justify="center">
|
||||||
|
{!showAnswer ? (
|
||||||
|
<LightButton
|
||||||
|
onClick={handleShowAnswer}
|
||||||
|
disabled={isPending}
|
||||||
|
className="px-8 py-3 text-lg rounded-full"
|
||||||
|
>
|
||||||
|
{t("showAnswer")}
|
||||||
|
<span className="ml-2 text-xs opacity-60">Space</span>
|
||||||
|
</LightButton>
|
||||||
|
) : isFinished ? (
|
||||||
|
<VStack align="center" gap={4}>
|
||||||
|
<div className="text-green-500">
|
||||||
|
<Check className="w-12 h-12" />
|
||||||
|
</div>
|
||||||
|
<p className="text-gray-600">{t("allDoneDesc")}</p>
|
||||||
|
<HStack gap={2}>
|
||||||
|
<LightButton onClick={() => router.push("/decks")} className="px-4 py-2">
|
||||||
|
{t("backToDecks")}
|
||||||
|
</LightButton>
|
||||||
|
<LightButton onClick={() => setCurrentIndex(0)} className="px-4 py-2">
|
||||||
|
{t("restart")}
|
||||||
|
</LightButton>
|
||||||
|
</HStack>
|
||||||
|
</VStack>
|
||||||
|
) : (
|
||||||
|
<HStack gap={4}>
|
||||||
|
<LightButton
|
||||||
|
onClick={handlePrevCard}
|
||||||
|
className="px-4 py-2"
|
||||||
|
>
|
||||||
|
<ChevronLeft className="w-5 h-5" />
|
||||||
|
</LightButton>
|
||||||
|
<span className="text-gray-500 text-sm">
|
||||||
|
{t("nextCard")}
|
||||||
|
<span className="ml-2 text-xs opacity-60">Space</span>
|
||||||
|
</span>
|
||||||
|
<LightButton
|
||||||
|
onClick={handleNextCard}
|
||||||
|
className="px-4 py-2"
|
||||||
|
>
|
||||||
|
<ChevronRight className="w-5 h-5" />
|
||||||
|
</LightButton>
|
||||||
|
</HStack>
|
||||||
|
)}
|
||||||
|
</HStack>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Memorize };
|
||||||
34
src/app/decks/[deck_id]/learn/page.tsx
Normal file
34
src/app/decks/[deck_id]/learn/page.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { auth } from "@/auth";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
import { actionGetDeckById } from "@/modules/deck/deck-action";
|
||||||
|
import { Memorize } from "./Memorize";
|
||||||
|
|
||||||
|
export default async function LearnPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ deck_id: string }>;
|
||||||
|
}) {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
const { deck_id } = await params;
|
||||||
|
const deckId = Number(deck_id);
|
||||||
|
|
||||||
|
if (!deckId) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
const deckInfo = (await actionGetDeckById({ deckId })).data;
|
||||||
|
|
||||||
|
if (!deckInfo) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
const isOwner = session?.user?.id === deckInfo.userId;
|
||||||
|
const isPublic = deckInfo.visibility === "PUBLIC";
|
||||||
|
|
||||||
|
if (!isOwner && !isPublic) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Memorize deckId={deckId} deckName={deckInfo.name} />;
|
||||||
|
}
|
||||||
37
src/app/decks/[deck_id]/page.tsx
Normal file
37
src/app/decks/[deck_id]/page.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import { InDeck } from "./InDeck";
|
||||||
|
import { auth } from "@/auth";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
import { actionGetDeckById } from "@/modules/deck/deck-action";
|
||||||
|
|
||||||
|
export default async function DecksPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ deck_id: number; }>;
|
||||||
|
}) {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
const { deck_id } = await params;
|
||||||
|
const t = await getTranslations("deck_id");
|
||||||
|
|
||||||
|
if (!deck_id) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
const deckInfo = (await actionGetDeckById({ deckId: Number(deck_id) })).data;
|
||||||
|
|
||||||
|
if (!deckInfo) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
const isOwner = session?.user?.id === deckInfo.userId;
|
||||||
|
const isPublic = deckInfo.visibility === "PUBLIC";
|
||||||
|
|
||||||
|
if (!isOwner && !isPublic) {
|
||||||
|
redirect("/decks");
|
||||||
|
}
|
||||||
|
|
||||||
|
const isReadOnly = !isOwner;
|
||||||
|
|
||||||
|
return <InDeck deckId={Number(deck_id)} isReadOnly={isReadOnly} />;
|
||||||
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { FoldersClient } from "./FoldersClient";
|
import { DecksClient } from "./DecksClient";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function FoldersPage() {
|
export default async function DecksPage() {
|
||||||
const session = await auth.api.getSession(
|
const session = await auth.api.getSession(
|
||||||
{ headers: await headers() }
|
{ headers: await headers() }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
redirect("/login?redirect=/folders");
|
redirect("/login?redirect=/decks");
|
||||||
}
|
}
|
||||||
|
|
||||||
return <FoldersClient userId={session.user.id} />;
|
return <DecksClient userId={session.user.id} />;
|
||||||
}
|
}
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
import { LightButton } from "@/design-system/base/button";
|
|
||||||
import { Input } from "@/design-system/base/input";
|
|
||||||
import { LocaleSelector } from "@/components/ui/LocaleSelector";
|
|
||||||
import { X } from "lucide-react";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
|
|
||||||
interface AddTextPairModalProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
onAdd: (
|
|
||||||
text1: string,
|
|
||||||
text2: string,
|
|
||||||
language1: string,
|
|
||||||
language2: string,
|
|
||||||
) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AddTextPairModal({
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
onAdd,
|
|
||||||
}: AddTextPairModalProps) {
|
|
||||||
const t = useTranslations("folder_id");
|
|
||||||
const input1Ref = useRef<HTMLInputElement>(null);
|
|
||||||
const input2Ref = useRef<HTMLInputElement>(null);
|
|
||||||
const [language1, setLanguage1] = useState("english");
|
|
||||||
const [language2, setLanguage2] = useState("chinese");
|
|
||||||
|
|
||||||
if (!isOpen) return null;
|
|
||||||
|
|
||||||
const handleAdd = () => {
|
|
||||||
if (
|
|
||||||
!input1Ref.current?.value ||
|
|
||||||
!input2Ref.current?.value ||
|
|
||||||
!language1 ||
|
|
||||||
!language2
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const text1 = input1Ref.current.value;
|
|
||||||
const text2 = input2Ref.current.value;
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof text1 === "string" &&
|
|
||||||
typeof text2 === "string" &&
|
|
||||||
typeof language1 === "string" &&
|
|
||||||
typeof language2 === "string" &&
|
|
||||||
text1.trim() !== "" &&
|
|
||||||
text2.trim() !== "" &&
|
|
||||||
language1.trim() !== "" &&
|
|
||||||
language2.trim() !== ""
|
|
||||||
) {
|
|
||||||
onAdd(text1, text2, language1, language2);
|
|
||||||
input1Ref.current.value = "";
|
|
||||||
input2Ref.current.value = "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="fixed inset-0 bg-black/50 backdrop-blur flex items-center justify-center z-50"
|
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
handleAdd();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="bg-white rounded-md p-6 w-full max-w-md mx-4">
|
|
||||||
<div className="flex">
|
|
||||||
<h2 className="flex-1 text-xl font-light mb-4 text-center">
|
|
||||||
{t("addNewTextPair")}
|
|
||||||
</h2>
|
|
||||||
<X onClick={onClose} className="hover:cursor-pointer"></X>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
{t("text1")}
|
|
||||||
<Input ref={input1Ref} className="w-full"></Input>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("text2")}
|
|
||||||
<Input ref={input2Ref} className="w-full"></Input>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("language1")}
|
|
||||||
<LocaleSelector value={language1} onChange={setLanguage1} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("language2")}
|
|
||||||
<LocaleSelector value={language2} onChange={setLanguage2} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<LightButton onClick={handleAdd}>{t("add")}</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { ArrowLeft, Plus } from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { redirect, useRouter } from "next/navigation";
|
|
||||||
import { AddTextPairModal } from "./AddTextPairModal";
|
|
||||||
import { TextPairCard } from "./TextPairCard";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { PageLayout } from "@/components/ui/PageLayout";
|
|
||||||
import { PrimaryButton, CircleButton, LinkButton } from "@/design-system/base/button";
|
|
||||||
import { CardList } from "@/components/ui/CardList";
|
|
||||||
import { actionCreatePair, actionDeletePairById, actionGetPairsByFolderId } from "@/modules/folder/folder-action";
|
|
||||||
import { TSharedPair } from "@/shared/folder-type";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
|
|
||||||
export function InFolder({ folderId, isReadOnly }: { folderId: number; isReadOnly: boolean; }) {
|
|
||||||
const [textPairs, setTextPairs] = useState<TSharedPair[]>([]);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const [openAddModal, setAddModal] = useState(false);
|
|
||||||
const router = useRouter();
|
|
||||||
const t = useTranslations("folder_id");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchTextPairs = async () => {
|
|
||||||
setLoading(true);
|
|
||||||
await actionGetPairsByFolderId(folderId)
|
|
||||||
.then(result => {
|
|
||||||
if (!result.success || !result.data) {
|
|
||||||
throw new Error(result.message || "Failed to load text pairs");
|
|
||||||
}
|
|
||||||
return result.data;
|
|
||||||
}).then(setTextPairs)
|
|
||||||
.catch((error) => {
|
|
||||||
toast.error(error instanceof Error ? error.message : "Unknown error");
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
fetchTextPairs();
|
|
||||||
}, [folderId]);
|
|
||||||
|
|
||||||
const refreshTextPairs = async () => {
|
|
||||||
await actionGetPairsByFolderId(folderId)
|
|
||||||
.then(result => {
|
|
||||||
if (!result.success || !result.data) {
|
|
||||||
throw new Error(result.message || "Failed to refresh text pairs");
|
|
||||||
}
|
|
||||||
return result.data;
|
|
||||||
}).then(setTextPairs)
|
|
||||||
.catch((error) => {
|
|
||||||
toast.error(error instanceof Error ? error.message : "Unknown error");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageLayout>
|
|
||||||
{/* 顶部导航和标题栏 */}
|
|
||||||
<div className="mb-6">
|
|
||||||
{/* 返回按钮 */}
|
|
||||||
<LinkButton
|
|
||||||
onClick={router.back}
|
|
||||||
className="flex items-center gap-2 mb-4"
|
|
||||||
>
|
|
||||||
<ArrowLeft size={16} />
|
|
||||||
<span className="text-sm">{t("back")}</span>
|
|
||||||
</LinkButton>
|
|
||||||
|
|
||||||
{/* 页面标题和操作按钮 */}
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
{/* 标题区域 */}
|
|
||||||
<div>
|
|
||||||
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-1">
|
|
||||||
{t("textPairs")}
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-gray-500">
|
|
||||||
{t("itemsCount", { count: textPairs.length })}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 操作按钮区域 */}
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<PrimaryButton
|
|
||||||
onClick={() => {
|
|
||||||
redirect(`/memorize?folder_id=${folderId}`);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("memorize")}
|
|
||||||
</PrimaryButton>
|
|
||||||
{!isReadOnly && (
|
|
||||||
<CircleButton
|
|
||||||
onClick={() => {
|
|
||||||
setAddModal(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Plus size={18} className="text-gray-700" />
|
|
||||||
</CircleButton>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 文本对列表 */}
|
|
||||||
<CardList>
|
|
||||||
{loading ? (
|
|
||||||
// 加载状态
|
|
||||||
<div className="p-8 text-center">
|
|
||||||
<div className="w-8 h-8 border-2 border-gray-200 border-t-gray-400 rounded-full animate-spin mx-auto mb-3"></div>
|
|
||||||
<p className="text-sm text-gray-500">{t("loadingTextPairs")}</p>
|
|
||||||
</div>
|
|
||||||
) : textPairs.length === 0 ? (
|
|
||||||
// 空状态
|
|
||||||
<div className="p-12 text-center">
|
|
||||||
<p className="text-sm text-gray-500 mb-2">{t("noTextPairs")}</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
// 文本对卡片列表
|
|
||||||
<div className="divide-y divide-gray-100">
|
|
||||||
{textPairs
|
|
||||||
.toSorted((a, b) => a.id - b.id)
|
|
||||||
.map((textPair) => (
|
|
||||||
<TextPairCard
|
|
||||||
key={textPair.id}
|
|
||||||
textPair={textPair}
|
|
||||||
isReadOnly={isReadOnly}
|
|
||||||
onDel={() => {
|
|
||||||
actionDeletePairById(textPair.id)
|
|
||||||
.then(result => {
|
|
||||||
if (!result.success) throw new Error(result.message || "Delete failed");
|
|
||||||
}).then(refreshTextPairs)
|
|
||||||
.catch((error) => {
|
|
||||||
toast.error(error instanceof Error ? error.message : "Unknown error");
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
refreshTextPairs={refreshTextPairs}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</CardList>
|
|
||||||
|
|
||||||
{/* 添加文本对模态框 */}
|
|
||||||
<AddTextPairModal
|
|
||||||
isOpen={openAddModal}
|
|
||||||
onClose={() => setAddModal(false)}
|
|
||||||
onAdd={async (
|
|
||||||
text1: string,
|
|
||||||
text2: string,
|
|
||||||
language1: string,
|
|
||||||
language2: string,
|
|
||||||
) => {
|
|
||||||
await actionCreatePair({
|
|
||||||
text1: text1,
|
|
||||||
text2: text2,
|
|
||||||
language1: language1,
|
|
||||||
language2: language2,
|
|
||||||
folderId: folderId,
|
|
||||||
});
|
|
||||||
refreshTextPairs();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</PageLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
import { Edit, Trash2 } from "lucide-react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { CircleButton } from "@/design-system/base/button";
|
|
||||||
import { UpdateTextPairModal } from "./UpdateTextPairModal";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { TSharedPair } from "@/shared/folder-type";
|
|
||||||
import { actionUpdatePairById } from "@/modules/folder/folder-action";
|
|
||||||
import { ActionInputUpdatePairById } from "@/modules/folder/folder-action-dto";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
interface TextPairCardProps {
|
|
||||||
textPair: TSharedPair;
|
|
||||||
isReadOnly: boolean;
|
|
||||||
onDel: () => void;
|
|
||||||
refreshTextPairs: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TextPairCard({
|
|
||||||
textPair,
|
|
||||||
isReadOnly,
|
|
||||||
onDel,
|
|
||||||
refreshTextPairs,
|
|
||||||
}: TextPairCardProps) {
|
|
||||||
const [openUpdateModal, setOpenUpdateModal] = useState(false);
|
|
||||||
const t = useTranslations("folder_id");
|
|
||||||
return (
|
|
||||||
<div className="group border-b border-gray-100 hover:bg-gray-50 transition-colors">
|
|
||||||
<div className="p-4">
|
|
||||||
<div className="flex items-start justify-between mb-3">
|
|
||||||
<div className="flex items-center gap-2 text-xs text-gray-500">
|
|
||||||
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
|
||||||
{textPair.language1.toUpperCase()}
|
|
||||||
</span>
|
|
||||||
<span>→</span>
|
|
||||||
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
|
||||||
{textPair.language2.toUpperCase()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-1 opacity-50 group-hover:opacity-100 transition-opacity">
|
|
||||||
{!isReadOnly && (
|
|
||||||
<>
|
|
||||||
<CircleButton
|
|
||||||
onClick={() => setOpenUpdateModal(true)}
|
|
||||||
title={t("edit")}
|
|
||||||
className="text-gray-400 hover:text-gray-600"
|
|
||||||
>
|
|
||||||
<Edit size={14} />
|
|
||||||
</CircleButton>
|
|
||||||
<CircleButton
|
|
||||||
onClick={onDel}
|
|
||||||
title={t("delete")}
|
|
||||||
className="text-gray-400 hover:text-red-500 hover:bg-red-50"
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</CircleButton>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="text-gray-900 grid grid-cols-2 gap-4 w-3/4">
|
|
||||||
<div>
|
|
||||||
{textPair.text1.length > 30
|
|
||||||
? textPair.text1.substring(0, 30) + "..."
|
|
||||||
: textPair.text1}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{textPair.text2.length > 30
|
|
||||||
? textPair.text2.substring(0, 30) + "..."
|
|
||||||
: textPair.text2}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<UpdateTextPairModal
|
|
||||||
isOpen={openUpdateModal}
|
|
||||||
onClose={() => setOpenUpdateModal(false)}
|
|
||||||
onUpdate={async (id: number, data: ActionInputUpdatePairById) => {
|
|
||||||
await actionUpdatePairById(id, data).then(result => result.success ? toast.success(result.message) : toast.error(result.message));
|
|
||||||
setOpenUpdateModal(false);
|
|
||||||
refreshTextPairs();
|
|
||||||
}}
|
|
||||||
textPair={textPair}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
import { LightButton } from "@/design-system/base/button";
|
|
||||||
import { Input } from "@/design-system/base/input";
|
|
||||||
import { LocaleSelector } from "@/components/ui/LocaleSelector";
|
|
||||||
import { X } from "lucide-react";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { TSharedPair } from "@/shared/folder-type";
|
|
||||||
import { ActionInputUpdatePairById } from "@/modules/folder/folder-action-dto";
|
|
||||||
|
|
||||||
interface UpdateTextPairModalProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
textPair: TSharedPair;
|
|
||||||
onUpdate: (id: number, tp: ActionInputUpdatePairById) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function UpdateTextPairModal({
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
onUpdate,
|
|
||||||
textPair,
|
|
||||||
}: UpdateTextPairModalProps) {
|
|
||||||
const t = useTranslations("folder_id");
|
|
||||||
const input1Ref = useRef<HTMLInputElement>(null);
|
|
||||||
const input2Ref = useRef<HTMLInputElement>(null);
|
|
||||||
const [language1, setLanguage1] = useState(textPair.language1);
|
|
||||||
const [language2, setLanguage2] = useState(textPair.language2);
|
|
||||||
|
|
||||||
if (!isOpen) return null;
|
|
||||||
|
|
||||||
const handleUpdate = () => {
|
|
||||||
if (
|
|
||||||
!input1Ref.current?.value ||
|
|
||||||
!input2Ref.current?.value ||
|
|
||||||
!language1 ||
|
|
||||||
!language2
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const text1 = input1Ref.current.value;
|
|
||||||
const text2 = input2Ref.current.value;
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof text1 === "string" &&
|
|
||||||
typeof text2 === "string" &&
|
|
||||||
typeof language1 === "string" &&
|
|
||||||
typeof language2 === "string" &&
|
|
||||||
text1.trim() !== "" &&
|
|
||||||
text2.trim() !== "" &&
|
|
||||||
language1.trim() !== "" &&
|
|
||||||
language2.trim() !== ""
|
|
||||||
) {
|
|
||||||
onUpdate(textPair.id, { text1, text2, language1, language2 });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="fixed inset-0 bg-black/50 backdrop-blur flex items-center justify-center z-50"
|
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
handleUpdate();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="bg-white rounded-md p-6 w-full max-w-md mx-4">
|
|
||||||
<div className="flex">
|
|
||||||
<h2 className="flex-1 text-xl font-light mb-4 text-center">
|
|
||||||
{t("updateTextPair")}
|
|
||||||
</h2>
|
|
||||||
<X onClick={onClose} className="hover:cursor-pointer"></X>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
{t("text1")}
|
|
||||||
<Input
|
|
||||||
defaultValue={textPair.text1}
|
|
||||||
ref={input1Ref}
|
|
||||||
className="w-full"
|
|
||||||
></Input>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("text2")}
|
|
||||||
<Input
|
|
||||||
defaultValue={textPair.text2}
|
|
||||||
ref={input2Ref}
|
|
||||||
className="w-full"
|
|
||||||
></Input>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("language1")}
|
|
||||||
<LocaleSelector value={language1} onChange={setLanguage1} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{t("language2")}
|
|
||||||
<LocaleSelector value={language2} onChange={setLanguage2} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<LightButton onClick={handleUpdate}>{t("update")}</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import { redirect } from "next/navigation";
|
|
||||||
import { getTranslations } from "next-intl/server";
|
|
||||||
import { InFolder } from "./InFolder";
|
|
||||||
import { auth } from "@/auth";
|
|
||||||
import { headers } from "next/headers";
|
|
||||||
import { actionGetFolderVisibility } from "@/modules/folder/folder-action";
|
|
||||||
|
|
||||||
export default async function FoldersPage({
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
params: Promise<{ folder_id: number; }>;
|
|
||||||
}) {
|
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
|
||||||
const { folder_id } = await params;
|
|
||||||
const t = await getTranslations("folder_id");
|
|
||||||
|
|
||||||
if (!folder_id) {
|
|
||||||
redirect("/folders");
|
|
||||||
}
|
|
||||||
|
|
||||||
const folderInfo = (await actionGetFolderVisibility(Number(folder_id))).data;
|
|
||||||
|
|
||||||
if (!folderInfo) {
|
|
||||||
redirect("/folders");
|
|
||||||
}
|
|
||||||
|
|
||||||
const isOwner = session?.user?.id === folderInfo.userId;
|
|
||||||
const isPublic = folderInfo.visibility === "PUBLIC";
|
|
||||||
|
|
||||||
if (!isOwner && !isPublic) {
|
|
||||||
redirect("/folders");
|
|
||||||
}
|
|
||||||
|
|
||||||
const isReadOnly = !isOwner;
|
|
||||||
|
|
||||||
return <InFolder folderId={Number(folder_id)} isReadOnly={isReadOnly} />;
|
|
||||||
}
|
|
||||||
@@ -5,18 +5,17 @@
|
|||||||
* 使用 @theme 指令定义主题变量
|
* 使用 @theme 指令定义主题变量
|
||||||
*/
|
*/
|
||||||
@theme {
|
@theme {
|
||||||
/* 主色 - Teal */
|
--color-primary-50: var(--primary-50);
|
||||||
--color-primary-50: #f0f9f8;
|
--color-primary-100: var(--primary-100);
|
||||||
--color-primary-100: #e0f2f0;
|
--color-primary-200: var(--primary-200);
|
||||||
--color-primary-200: #bce6e1;
|
--color-primary-300: var(--primary-300);
|
||||||
--color-primary-300: #8dd4cc;
|
--color-primary-400: var(--primary-400);
|
||||||
--color-primary-400: #5ec2b7;
|
--color-primary-500: var(--primary-500);
|
||||||
--color-primary-500: #35786f;
|
--color-primary-600: var(--primary-600);
|
||||||
--color-primary-600: #2a605b;
|
--color-primary-700: var(--primary-700);
|
||||||
--color-primary-700: #1f4844;
|
--color-primary-800: var(--primary-800);
|
||||||
--color-primary-800: #183835;
|
--color-primary-900: var(--primary-900);
|
||||||
--color-primary-900: #122826;
|
--color-primary-950: var(--primary-950);
|
||||||
--color-primary-950: #0a1413;
|
|
||||||
|
|
||||||
/* 中性色 */
|
/* 中性色 */
|
||||||
--color-gray-50: #f9fafb;
|
--color-gray-50: #f9fafb;
|
||||||
@@ -100,6 +99,19 @@
|
|||||||
* 定义全局 CSS 变量用于主题切换和动态样式
|
* 定义全局 CSS 变量用于主题切换和动态样式
|
||||||
*/
|
*/
|
||||||
:root {
|
:root {
|
||||||
|
/* 主题色 - 默认 Mist */
|
||||||
|
--primary-50: #f7f8fa;
|
||||||
|
--primary-100: #eef1f5;
|
||||||
|
--primary-200: #dce2eb;
|
||||||
|
--primary-300: #c4cdd9;
|
||||||
|
--primary-400: #a3b0c1;
|
||||||
|
--primary-500: #8594a8;
|
||||||
|
--primary-600: #6b7a8d;
|
||||||
|
--primary-700: #596474;
|
||||||
|
--primary-800: #4b5360;
|
||||||
|
--primary-900: #414850;
|
||||||
|
--primary-950: #22262b;
|
||||||
|
|
||||||
/* 基础颜色 */
|
/* 基础颜色 */
|
||||||
--background: #ffffff;
|
--background: #ffffff;
|
||||||
--foreground: #111827;
|
--foreground: #111827;
|
||||||
@@ -114,7 +126,7 @@
|
|||||||
/* 边框 */
|
/* 边框 */
|
||||||
--border: #d1d5db;
|
--border: #d1d5db;
|
||||||
--border-secondary: #e5e7eb;
|
--border-secondary: #e5e7eb;
|
||||||
--border-focus: #35786f;
|
--border-focus: #8594a8;
|
||||||
|
|
||||||
/* 圆角 - 更小的圆角 */
|
/* 圆角 - 更小的圆角 */
|
||||||
--radius-xs: 0.125rem;
|
--radius-xs: 0.125rem;
|
||||||
@@ -132,7 +144,7 @@
|
|||||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
||||||
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
||||||
--shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
--shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
||||||
--shadow-primary: 0 4px 14px 0 rgba(53, 120, 111, 0.39);
|
--shadow-primary: 0 4px 14px 0 rgba(133, 148, 168, 0.39);
|
||||||
|
|
||||||
/* 间距 */
|
/* 间距 */
|
||||||
--spacing-xs: 0.25rem;
|
--spacing-xs: 0.25rem;
|
||||||
@@ -165,7 +177,7 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: var(--background);
|
background: var(--primary-50);
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
font-family: var(--font-geist-sans), -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
|
font-family: var(--font-geist-sans), -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { NextIntlClientProvider } from "next-intl";
|
|||||||
import { Navbar } from "@/components/layout/Navbar";
|
import { Navbar } from "@/components/layout/Navbar";
|
||||||
import { Toaster } from "sonner";
|
import { Toaster } from "sonner";
|
||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
|
import { ThemeProvider } from "@/components/theme-provider";
|
||||||
|
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
width: "device-width",
|
width: "device-width",
|
||||||
@@ -25,11 +26,13 @@ export default async function RootLayout({
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body className={`antialiased`}>
|
<body className={`antialiased`}>
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
<ThemeProvider>
|
||||||
<NextIntlClientProvider>
|
<NextIntlClientProvider>
|
||||||
<Navbar></Navbar>
|
<Navbar></Navbar>
|
||||||
{children}
|
{children}
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</NextIntlClientProvider>
|
</NextIntlClientProvider>
|
||||||
|
</ThemeProvider>
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default async function HomePage() {
|
|||||||
color="#dd7486"
|
color="#dd7486"
|
||||||
></LinkArea>
|
></LinkArea>
|
||||||
<LinkArea
|
<LinkArea
|
||||||
href="/memorize"
|
href="/decks"
|
||||||
name={t("memorize.name")}
|
name={t("memorize.name")}
|
||||||
description={t("memorize.description")}
|
description={t("memorize.description")}
|
||||||
color="#cc9988"
|
color="#cc9988"
|
||||||
|
|||||||
57
src/app/settings/page.tsx
Normal file
57
src/app/settings/page.tsx
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useTheme } from "@/components/theme-provider";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { cn } from "@/utils/cn";
|
||||||
|
|
||||||
|
export default function SettingsPage() {
|
||||||
|
const t = useTranslations("settings");
|
||||||
|
const { currentTheme, setTheme, availableThemes } = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-[calc(100vh-64px)] bg-white p-4 md:p-8">
|
||||||
|
<div className="max-w-2xl mx-auto">
|
||||||
|
<h1 className="text-2xl font-bold text-gray-900 mb-6">
|
||||||
|
{t("title")}
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div className="space-y-6">
|
||||||
|
<div>
|
||||||
|
<h2 className="text-lg font-semibold text-gray-800 mb-3">
|
||||||
|
{t("themeColor")}
|
||||||
|
</h2>
|
||||||
|
<p className="text-sm text-gray-600 mb-4">
|
||||||
|
{t("themeColorDescription")}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-4 sm:grid-cols-8 gap-3">
|
||||||
|
{availableThemes.map((theme) => (
|
||||||
|
<button
|
||||||
|
key={theme.id}
|
||||||
|
onClick={() => setTheme(theme.id)}
|
||||||
|
className={cn(
|
||||||
|
"group relative flex flex-col items-center gap-2 p-2 rounded-lg transition-all",
|
||||||
|
currentTheme === theme.id
|
||||||
|
? "ring-2 ring-offset-2"
|
||||||
|
: "hover:bg-gray-50"
|
||||||
|
)}
|
||||||
|
style={{
|
||||||
|
["--tw-ring-color" as string]: theme.colors[500],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="w-8 h-8 rounded-full shadow-md ring-1 ring-black/10"
|
||||||
|
style={{ backgroundColor: theme.colors[500] }}
|
||||||
|
/>
|
||||||
|
<span className="text-xs text-gray-600 group-hover:text-gray-900">
|
||||||
|
{theme.name}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
40
src/auth.ts
40
src/auth.ts
@@ -4,6 +4,10 @@ import { nextCookies } from "better-auth/next-js";
|
|||||||
import { username } from "better-auth/plugins";
|
import { username } from "better-auth/plugins";
|
||||||
import { createAuthMiddleware, APIError } from "better-auth/api";
|
import { createAuthMiddleware, APIError } from "better-auth/api";
|
||||||
import { prisma } from "./lib/db";
|
import { prisma } from "./lib/db";
|
||||||
|
import { createLogger } from "./lib/logger";
|
||||||
|
|
||||||
|
const log = createLogger("auth");
|
||||||
|
|
||||||
import {
|
import {
|
||||||
sendEmail,
|
sendEmail,
|
||||||
generateVerificationEmailHtml,
|
generateVerificationEmailHtml,
|
||||||
@@ -18,21 +22,28 @@ export const auth = betterAuth({
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
requireEmailVerification: true,
|
requireEmailVerification: true,
|
||||||
sendResetPassword: async ({ user, url }) => {
|
sendResetPassword: async ({ user, url }) => {
|
||||||
void sendEmail({
|
const result = await sendEmail({
|
||||||
to: user.email,
|
to: user.email,
|
||||||
subject: "重置您的密码 - Learn Languages",
|
subject: "重置您的密码 - Learn Languages",
|
||||||
html: generateResetPasswordEmailHtml(url, user.name || "用户"),
|
html: generateResetPasswordEmailHtml(url, user.name || "用户"),
|
||||||
});
|
});
|
||||||
|
if (!result.success) {
|
||||||
|
log.error("Failed to send reset password email", { error: result.error });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emailVerification: {
|
emailVerification: {
|
||||||
sendOnSignUp: true,
|
sendOnSignUp: true,
|
||||||
|
sendOnSignIn: true,
|
||||||
sendVerificationEmail: async ({ user, url }) => {
|
sendVerificationEmail: async ({ user, url }) => {
|
||||||
void sendEmail({
|
const result = await sendEmail({
|
||||||
to: user.email,
|
to: user.email,
|
||||||
subject: "验证您的邮箱 - Learn Languages",
|
subject: "验证您的邮箱 - Learn Languages",
|
||||||
html: generateVerificationEmailHtml(url, user.name || "用户"),
|
html: generateVerificationEmailHtml(url, user.name || "用户"),
|
||||||
});
|
});
|
||||||
|
if (!result.success) {
|
||||||
|
log.error("Failed to send verification email", { error: result.error });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
socialProviders: {
|
socialProviders: {
|
||||||
@@ -44,14 +55,35 @@ export const auth = betterAuth({
|
|||||||
plugins: [nextCookies(), username()],
|
plugins: [nextCookies(), username()],
|
||||||
hooks: {
|
hooks: {
|
||||||
before: createAuthMiddleware(async (ctx) => {
|
before: createAuthMiddleware(async (ctx) => {
|
||||||
if (ctx.path !== "/sign-up/email" && ctx.path !== "/update-user") return;
|
if (ctx.path === "/sign-up/email" || ctx.path === "/update-user") {
|
||||||
|
|
||||||
const body = ctx.body as { username?: string };
|
const body = ctx.body as { username?: string };
|
||||||
if (!body.username || body.username.trim() === "") {
|
if (!body.username || body.username.trim() === "") {
|
||||||
throw new APIError("BAD_REQUEST", {
|
throw new APIError("BAD_REQUEST", {
|
||||||
message: "Username is required",
|
message: "Username is required",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx.path === "/sign-in/username") {
|
||||||
|
const body = ctx.body as { username?: string };
|
||||||
|
if (body.username) {
|
||||||
|
const user = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ username: body.username },
|
||||||
|
{ email: body.username },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
select: { emailVerified: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (user && !user.emailVerified) {
|
||||||
|
throw new APIError("FORBIDDEN", {
|
||||||
|
message: "Please verify your email address before signing in",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
47
src/components/follow/FollowButton.tsx
Normal file
47
src/components/follow/FollowButton.tsx
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useTransition } from "react";
|
||||||
|
import { PrimaryButton, LightButton } from "@/design-system/base/button";
|
||||||
|
import { actionToggleFollow } from "@/modules/follow/follow-action";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
interface FollowButtonProps {
|
||||||
|
targetUserId: string;
|
||||||
|
initialIsFollowing: boolean;
|
||||||
|
onFollowChange?: (isFollowing: boolean, followersCount: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FollowButton({
|
||||||
|
targetUserId,
|
||||||
|
initialIsFollowing,
|
||||||
|
onFollowChange,
|
||||||
|
}: FollowButtonProps) {
|
||||||
|
const [isFollowing, setIsFollowing] = useState(initialIsFollowing);
|
||||||
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
|
const handleToggleFollow = () => {
|
||||||
|
startTransition(async () => {
|
||||||
|
const result = await actionToggleFollow({ targetUserId });
|
||||||
|
if (result.success && result.data) {
|
||||||
|
setIsFollowing(result.data.isFollowing);
|
||||||
|
onFollowChange?.(result.data.isFollowing, result.data.followersCount);
|
||||||
|
} else {
|
||||||
|
toast.error(result.message || "Failed to update follow status");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isFollowing) {
|
||||||
|
return (
|
||||||
|
<LightButton onClick={handleToggleFollow} disabled={isPending}>
|
||||||
|
{isPending ? "..." : "Following"}
|
||||||
|
</LightButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PrimaryButton onClick={handleToggleFollow} disabled={isPending}>
|
||||||
|
{isPending ? "..." : "Follow"}
|
||||||
|
</PrimaryButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
54
src/components/follow/FollowStats.tsx
Normal file
54
src/components/follow/FollowStats.tsx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { FollowButton } from "./FollowButton";
|
||||||
|
|
||||||
|
interface FollowStatsProps {
|
||||||
|
userId: string;
|
||||||
|
initialFollowersCount: number;
|
||||||
|
initialFollowingCount: number;
|
||||||
|
initialIsFollowing: boolean;
|
||||||
|
currentUserId?: string;
|
||||||
|
isOwnProfile: boolean;
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FollowStats({
|
||||||
|
userId,
|
||||||
|
initialFollowersCount,
|
||||||
|
initialFollowingCount,
|
||||||
|
initialIsFollowing,
|
||||||
|
currentUserId,
|
||||||
|
isOwnProfile,
|
||||||
|
username,
|
||||||
|
}: FollowStatsProps) {
|
||||||
|
const [followersCount, setFollowersCount] = useState(initialFollowersCount);
|
||||||
|
|
||||||
|
const handleFollowChange = (isFollowing: boolean, count: number) => {
|
||||||
|
setFollowersCount(count);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<a
|
||||||
|
href={`/users/${username}/followers`}
|
||||||
|
className="text-sm text-gray-600 hover:text-primary-500 transition-colors"
|
||||||
|
>
|
||||||
|
<span className="font-semibold text-gray-900">{followersCount}</span> followers
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
href={`/users/${username}/following`}
|
||||||
|
className="text-sm text-gray-600 hover:text-primary-500 transition-colors"
|
||||||
|
>
|
||||||
|
<span className="font-semibold text-gray-900">{initialFollowingCount}</span> following
|
||||||
|
</a>
|
||||||
|
{currentUserId && !isOwnProfile && (
|
||||||
|
<FollowButton
|
||||||
|
targetUserId={userId}
|
||||||
|
initialIsFollowing={initialIsFollowing}
|
||||||
|
onFollowChange={handleFollowChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
68
src/components/follow/UserList.tsx
Normal file
68
src/components/follow/UserList.tsx
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import Image from "next/image";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
interface UserItem {
|
||||||
|
id: string;
|
||||||
|
username: string | null;
|
||||||
|
displayUsername: string | null;
|
||||||
|
image: string | null;
|
||||||
|
bio: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserListProps {
|
||||||
|
users: UserItem[];
|
||||||
|
emptyMessage: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserList({ users, emptyMessage }: UserListProps) {
|
||||||
|
if (users.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="text-center py-12 text-gray-500">
|
||||||
|
{emptyMessage}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{users.map((user) => (
|
||||||
|
<Link
|
||||||
|
key={user.id}
|
||||||
|
href={`/users/${user.username || user.id}`}
|
||||||
|
className="flex items-center gap-4 p-4 bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow"
|
||||||
|
>
|
||||||
|
{user.image ? (
|
||||||
|
<div className="relative w-12 h-12 rounded-full overflow-hidden flex-shrink-0">
|
||||||
|
<Image
|
||||||
|
src={user.image}
|
||||||
|
alt={user.displayUsername || user.username || "User"}
|
||||||
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
unoptimized
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="w-12 h-12 rounded-full bg-primary-500 flex items-center justify-center flex-shrink-0">
|
||||||
|
<span className="text-lg font-bold text-white">
|
||||||
|
{(user.displayUsername || user.username || "U")[0].toUpperCase()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="font-semibold text-gray-900 truncate">
|
||||||
|
{user.displayUsername || user.username || "Anonymous"}
|
||||||
|
</div>
|
||||||
|
{user.username && (
|
||||||
|
<div className="text-sm text-gray-500">@{user.username}</div>
|
||||||
|
)}
|
||||||
|
{user.bio && (
|
||||||
|
<div className="text-sm text-gray-600 truncate mt-1">
|
||||||
|
{user.bio}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,81 +1,104 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { GhostLightButton } from "@/design-system/base/button";
|
import { useState, useEffect, useRef, useCallback } from "react";
|
||||||
import { useState } from "react";
|
|
||||||
import { Languages } from "lucide-react";
|
import { Languages } from "lucide-react";
|
||||||
|
import { cn } from "@/utils/cn";
|
||||||
|
|
||||||
|
const languages = [
|
||||||
|
{ code: "en-US", label: "English" },
|
||||||
|
{ code: "zh-CN", label: "中文" },
|
||||||
|
{ code: "ja-JP", label: "日本語" },
|
||||||
|
{ code: "ko-KR", label: "한국어" },
|
||||||
|
{ code: "de-DE", label: "Deutsch" },
|
||||||
|
{ code: "fr-FR", label: "Français" },
|
||||||
|
{ code: "it-IT", label: "Italiano" },
|
||||||
|
{ code: "ug-CN", label: "ئۇيغۇرچە" },
|
||||||
|
];
|
||||||
|
|
||||||
export function LanguageSettings() {
|
export function LanguageSettings() {
|
||||||
const [showLanguageMenu, setShowLanguageMenu] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const handleLanguageClick = () => {
|
const [pendingLocale, setPendingLocale] = useState<string | null>(null);
|
||||||
setShowLanguageMenu((prev) => !prev);
|
const menuRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
||||||
|
setIsOpen(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const setLocale = async (locale: string) => {
|
|
||||||
document.cookie = `locale=${locale}`;
|
if (isOpen) {
|
||||||
|
document.addEventListener("mousedown", handleClickOutside);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("mousedown", handleClickOutside);
|
||||||
|
};
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleEscape = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") setIsOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
document.addEventListener("keydown", handleEscape);
|
||||||
|
return () => document.removeEventListener("keydown", handleEscape);
|
||||||
|
}
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (pendingLocale) {
|
||||||
|
document.cookie = `locale=${pendingLocale}; path=/`;
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
}
|
||||||
|
}, [pendingLocale]);
|
||||||
|
|
||||||
|
const setLocale = useCallback((locale: string) => {
|
||||||
|
setPendingLocale(locale);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="relative" ref={menuRef}>
|
||||||
<GhostLightButton
|
<button
|
||||||
size="md"
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
onClick={handleLanguageClick}
|
className="flex items-center justify-center p-2 rounded-md text-white hover:bg-white/10 transition-colors"
|
||||||
|
aria-label="切换语言"
|
||||||
|
aria-expanded={isOpen}
|
||||||
>
|
>
|
||||||
<Languages size={20} />
|
<Languages size={20} />
|
||||||
</GhostLightButton>
|
</button>
|
||||||
<div className="relative">
|
|
||||||
{showLanguageMenu && (
|
<div
|
||||||
<div>
|
className={cn(
|
||||||
<div className="absolute top-10 right-0 rounded-md shadow-md flex flex-col gap-2">
|
"absolute right-0 top-full mt-2 w-40 rounded-lg bg-white shadow-lg ring-1 ring-black/5 overflow-hidden transition-all duration-200 origin-top-right z-50",
|
||||||
<GhostLightButton
|
isOpen
|
||||||
className="w-full bg-primary-500"
|
? "opacity-100 scale-100"
|
||||||
onClick={() => setLocale("en-US")}
|
: "opacity-0 scale-95 pointer-events-none"
|
||||||
>
|
|
||||||
English
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("zh-CN")}
|
|
||||||
>
|
|
||||||
中文
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("ja-JP")}
|
|
||||||
>
|
|
||||||
日本語
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("ko-KR")}
|
|
||||||
>
|
|
||||||
한국어
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("de-DE")}
|
|
||||||
>
|
|
||||||
Deutsch
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("fr-FR")}
|
|
||||||
>
|
|
||||||
Français
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("it-IT")}
|
|
||||||
>
|
|
||||||
Italiano
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton
|
|
||||||
className="w-full bg-primary-500"
|
|
||||||
onClick={() => setLocale("ug-CN")}
|
|
||||||
>
|
|
||||||
ئۇيغۇرچە
|
|
||||||
</GhostLightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div></>
|
role="menu"
|
||||||
|
>
|
||||||
|
<div className="py-1">
|
||||||
|
{languages.map((lang) => (
|
||||||
|
<button
|
||||||
|
key={lang.code}
|
||||||
|
onClick={() => setLocale(lang.code)}
|
||||||
|
className="w-full flex items-center px-4 py-2.5 text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors text-left"
|
||||||
|
role="menuitem"
|
||||||
|
>
|
||||||
|
{lang.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isOpen && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-40"
|
||||||
|
onClick={() => setIsOpen(false)}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
92
src/components/layout/MobileMenu.tsx
Normal file
92
src/components/layout/MobileMenu.tsx
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useEffect, useRef } from "react";
|
||||||
|
import { Menu, X } from "lucide-react";
|
||||||
|
import { cn } from "@/utils/cn";
|
||||||
|
import type { NavigationItem } from "./Navbar";
|
||||||
|
|
||||||
|
interface MobileMenuProps {
|
||||||
|
items: NavigationItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MobileMenu({ items }: MobileMenuProps) {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const menuRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
||||||
|
setIsOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
document.addEventListener("mousedown", handleClickOutside);
|
||||||
|
document.body.style.overflow = "hidden";
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("mousedown", handleClickOutside);
|
||||||
|
document.body.style.overflow = "";
|
||||||
|
};
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleEscape = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") setIsOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
document.addEventListener("keydown", handleEscape);
|
||||||
|
return () => document.removeEventListener("keydown", handleEscape);
|
||||||
|
}
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative" ref={menuRef}>
|
||||||
|
<button
|
||||||
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
|
className="flex items-center justify-center p-2 rounded-md text-white hover:bg-white/10 transition-colors"
|
||||||
|
aria-label={isOpen ? "关闭菜单" : "打开菜单"}
|
||||||
|
aria-expanded={isOpen}
|
||||||
|
>
|
||||||
|
{isOpen ? <X size={24} /> : <Menu size={24} />}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"absolute right-0 top-full mt-2 w-56 rounded-lg bg-white shadow-lg ring-1 ring-black/5 overflow-hidden transition-all duration-200 origin-top-right z-50",
|
||||||
|
isOpen
|
||||||
|
? "opacity-100 scale-100"
|
||||||
|
: "opacity-0 scale-95 pointer-events-none"
|
||||||
|
)}
|
||||||
|
role="menu"
|
||||||
|
>
|
||||||
|
<div className="py-1">
|
||||||
|
{items.map((item, index) => (
|
||||||
|
<a
|
||||||
|
key={index}
|
||||||
|
href={item.href}
|
||||||
|
className="flex items-center gap-3 px-4 py-3 text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors"
|
||||||
|
role="menuitem"
|
||||||
|
onClick={() => setIsOpen(false)}
|
||||||
|
target={item.external ? "_blank" : undefined}
|
||||||
|
rel={item.external ? "noopener noreferrer" : undefined}
|
||||||
|
>
|
||||||
|
{item.icon && <span className="shrink-0 text-gray-500">{item.icon}</span>}
|
||||||
|
<span>{item.label}</span>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isOpen && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-40"
|
||||||
|
onClick={() => setIsOpen(false)}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
import Image from "next/image";
|
import { Compass, Folder, Heart, Home, Settings, User, Github } from "lucide-react";
|
||||||
import { IMAGES } from "@/config/images";
|
|
||||||
import { Compass, Folder, Heart, Home, User } from "lucide-react";
|
|
||||||
import { LanguageSettings } from "./LanguageSettings";
|
import { LanguageSettings } from "./LanguageSettings";
|
||||||
|
import { MobileMenu } from "./MobileMenu";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { GhostLightButton } from "@/design-system/base/button";
|
import { GhostLightButton } from "@/design-system/base/button";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export interface NavigationItem {
|
||||||
|
label: string;
|
||||||
|
href: string;
|
||||||
|
icon?: ReactNode;
|
||||||
|
external?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export async function Navbar() {
|
export async function Navbar() {
|
||||||
const t = await getTranslations("navbar");
|
const t = await getTranslations("navbar");
|
||||||
@@ -13,49 +20,38 @@ export async function Navbar() {
|
|||||||
headers: await headers()
|
headers: await headers()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mobileMenuItems: NavigationItem[] = [
|
||||||
|
{ label: t("folders"), href: "/decks", icon: <Folder size={18} /> },
|
||||||
|
{ label: t("explore"), href: "/explore", icon: <Compass size={18} /> },
|
||||||
|
...(session ? [{ label: t("favorites"), href: "/favorites", icon: <Heart size={18} /> }] : []),
|
||||||
|
{ label: t("sourceCode"), href: "https://github.com/GoddoNebianU/learn-languages", icon: <Github size={18} />, external: true },
|
||||||
|
{ label: t("settings"), href: "/settings", icon: <Settings size={18} /> },
|
||||||
|
...(session
|
||||||
|
? [{ label: t("profile"), href: "/profile", icon: <User size={18} /> }]
|
||||||
|
: [{ label: t("sign_in"), href: "/login", icon: <User size={18} /> }]
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-between items-center w-full h-16 px-4 md:px-8 bg-primary-500 text-white">
|
<div className="flex justify-between items-center w-full h-16 px-4 md:px-8 bg-primary-500 text-white">
|
||||||
<GhostLightButton href="/" className="border-b hidden! md:block!" size="md">
|
<GhostLightButton href="/" className="border-b hidden! md:block!" size="md">
|
||||||
{t("title")}
|
{t("title")}
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
<GhostLightButton className="block! md:hidden!" size="md" href={"/"}>
|
<GhostLightButton className="block! md:hidden!" size="md" href="/">
|
||||||
<Home size={20} />
|
<Home size={20} />
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
<div className="flex gap-0.5 justify-center items-center">
|
<div className="flex gap-0.5 justify-center items-center">
|
||||||
<LanguageSettings />
|
<LanguageSettings />
|
||||||
<GhostLightButton
|
<GhostLightButton href="/decks" className="md:block! hidden!" size="md">
|
||||||
className="md:hidden! block!"
|
|
||||||
size="md"
|
|
||||||
href="https://github.com/GoddoNebianU/learn-languages"
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
src={IMAGES.github_mark_white}
|
|
||||||
alt="GitHub"
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
/>
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton href="/folders" className="md:block! hidden!" size="md">
|
|
||||||
{t("folders")}
|
{t("folders")}
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
<GhostLightButton href="/folders" className="md:hidden! block!" size="md">
|
|
||||||
<Folder size={20} />
|
|
||||||
</GhostLightButton>
|
|
||||||
<GhostLightButton href="/explore" className="md:block! hidden!" size="md">
|
<GhostLightButton href="/explore" className="md:block! hidden!" size="md">
|
||||||
{t("explore")}
|
{t("explore")}
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
<GhostLightButton href="/explore" className="md:hidden! block!" size="md">
|
|
||||||
<Compass size={20} />
|
|
||||||
</GhostLightButton>
|
|
||||||
{session && (
|
{session && (
|
||||||
<>
|
|
||||||
<GhostLightButton href="/favorites" className="md:block! hidden!" size="md">
|
<GhostLightButton href="/favorites" className="md:block! hidden!" size="md">
|
||||||
{t("favorites")}
|
{t("favorites")}
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
<GhostLightButton href="/favorites" className="md:hidden! block!" size="md">
|
|
||||||
<Heart size={20} />
|
|
||||||
</GhostLightButton>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
<GhostLightButton
|
<GhostLightButton
|
||||||
className="hidden! md:block!"
|
className="hidden! md:block!"
|
||||||
@@ -64,23 +60,21 @@ export async function Navbar() {
|
|||||||
>
|
>
|
||||||
{t("sourceCode")}
|
{t("sourceCode")}
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
{
|
<GhostLightButton href="/settings" className="hidden! md:block!" size="md">
|
||||||
(() => {
|
{t("settings")}
|
||||||
return session &&
|
|
||||||
<>
|
|
||||||
<GhostLightButton href="/profile" className="hidden! md:block!" size="md">{t("profile")}</GhostLightButton>
|
|
||||||
<GhostLightButton href="/profile" className="md:hidden! block!" size="md">
|
|
||||||
<User size={20} />
|
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
</>
|
{session ? (
|
||||||
|| <>
|
<GhostLightButton href="/profile" className="hidden! md:block!" size="md">
|
||||||
<GhostLightButton href="/login" className="hidden! md:block!" size="md">{t("sign_in")}</GhostLightButton>
|
{t("profile")}
|
||||||
<GhostLightButton href="/login" className="md:hidden! block!" size="md">
|
|
||||||
<User size={20} />
|
|
||||||
</GhostLightButton>
|
</GhostLightButton>
|
||||||
</>;
|
) : (
|
||||||
})()
|
<GhostLightButton href="/login" className="hidden! md:block!" size="md">
|
||||||
}
|
{t("sign_in")}
|
||||||
|
</GhostLightButton>
|
||||||
|
)}
|
||||||
|
<div className="md:hidden!">
|
||||||
|
<MobileMenu items={mobileMenuItems} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
79
src/components/theme-provider.tsx
Normal file
79
src/components/theme-provider.tsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { createContext, useContext, useEffect, useState, useMemo } from "react";
|
||||||
|
import {
|
||||||
|
THEME_PRESETS,
|
||||||
|
DEFAULT_THEME,
|
||||||
|
getThemePreset,
|
||||||
|
applyThemeColors,
|
||||||
|
type ThemePreset,
|
||||||
|
} from "@/shared/theme-presets";
|
||||||
|
|
||||||
|
type ThemeContextType = {
|
||||||
|
currentTheme: string;
|
||||||
|
themePreset: ThemePreset;
|
||||||
|
setTheme: (themeId: string) => void;
|
||||||
|
availableThemes: ThemePreset[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const ThemeContext = createContext<ThemeContextType | null>(null);
|
||||||
|
|
||||||
|
const STORAGE_KEY = "theme-preset";
|
||||||
|
|
||||||
|
function getInitialTheme(): string {
|
||||||
|
if (typeof window === "undefined") return DEFAULT_THEME;
|
||||||
|
const saved = localStorage.getItem(STORAGE_KEY);
|
||||||
|
return saved && getThemePreset(saved) ? saved : DEFAULT_THEME;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const [currentTheme, setCurrentTheme] = useState<string>(DEFAULT_THEME);
|
||||||
|
const [hydrated, setHydrated] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const savedTheme = getInitialTheme();
|
||||||
|
if (savedTheme !== currentTheme) {
|
||||||
|
setCurrentTheme(savedTheme);
|
||||||
|
}
|
||||||
|
setHydrated(true);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!hydrated) return;
|
||||||
|
const preset = getThemePreset(currentTheme);
|
||||||
|
if (preset) {
|
||||||
|
applyThemeColors(preset);
|
||||||
|
localStorage.setItem(STORAGE_KEY, currentTheme);
|
||||||
|
}
|
||||||
|
}, [currentTheme, hydrated]);
|
||||||
|
|
||||||
|
const setTheme = (themeId: string) => {
|
||||||
|
if (getThemePreset(themeId)) {
|
||||||
|
setCurrentTheme(themeId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const themePreset = useMemo(() => getThemePreset(currentTheme) || THEME_PRESETS[0], [currentTheme]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ThemeContext.Provider
|
||||||
|
value={{
|
||||||
|
currentTheme,
|
||||||
|
themePreset,
|
||||||
|
setTheme,
|
||||||
|
availableThemes: THEME_PRESETS,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useTheme() {
|
||||||
|
const context = useContext(ThemeContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useTheme must be used within a ThemeProvider");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
@@ -21,7 +21,25 @@ const COMMON_LANGUAGES = [
|
|||||||
{ label: "portuguese", value: "portuguese" },
|
{ label: "portuguese", value: "portuguese" },
|
||||||
{ label: "russian", value: "russian" },
|
{ label: "russian", value: "russian" },
|
||||||
{ label: "other", value: "other" },
|
{ label: "other", value: "other" },
|
||||||
];
|
] as const;
|
||||||
|
|
||||||
|
type LocaleLabel = typeof COMMON_LANGUAGES[number]["label"];
|
||||||
|
|
||||||
|
function getLocaleLabel(t: (key: string) => string, label: LocaleLabel): string {
|
||||||
|
switch (label) {
|
||||||
|
case "chinese": return t("translator.chinese");
|
||||||
|
case "english": return t("translator.english");
|
||||||
|
case "italian": return t("translator.italian");
|
||||||
|
case "japanese": return t("translator.japanese");
|
||||||
|
case "korean": return t("translator.korean");
|
||||||
|
case "french": return t("translator.french");
|
||||||
|
case "german": return t("translator.german");
|
||||||
|
case "spanish": return t("translator.spanish");
|
||||||
|
case "portuguese": return t("translator.portuguese");
|
||||||
|
case "russian": return t("translator.russian");
|
||||||
|
case "other": return t("translator.other");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface LocaleSelectorProps {
|
interface LocaleSelectorProps {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -62,7 +80,7 @@ export function LocaleSelector({ value, onChange }: LocaleSelectorProps) {
|
|||||||
>
|
>
|
||||||
{COMMON_LANGUAGES.map((lang) => (
|
{COMMON_LANGUAGES.map((lang) => (
|
||||||
<option key={lang.value} value={lang.value}>
|
<option key={lang.value} value={lang.value}>
|
||||||
{t(`translator.${lang.label}`)}
|
{getLocaleLabel(t, lang.label)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const selectVariants = cva(
|
|||||||
default: "border-b-2 border-gray-300 bg-transparent rounded-t-md",
|
default: "border-b-2 border-gray-300 bg-transparent rounded-t-md",
|
||||||
bordered: "border-gray-300 bg-white",
|
bordered: "border-gray-300 bg-white",
|
||||||
filled: "border-transparent bg-gray-100",
|
filled: "border-transparent bg-gray-100",
|
||||||
|
light: "border-transparent bg-gray-100 shadow-sm hover:bg-gray-200 font-semibold cursor-pointer",
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
sm: "h-9 px-3 text-sm",
|
sm: "h-9 px-3 text-sm",
|
||||||
@@ -48,6 +49,11 @@ const selectVariants = cva(
|
|||||||
error: true,
|
error: true,
|
||||||
className: "bg-error-50",
|
className: "bg-error-50",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
variant: "light",
|
||||||
|
error: true,
|
||||||
|
className: "bg-error-50 hover:bg-error-100",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
variant: "default",
|
variant: "default",
|
||||||
|
|||||||
@@ -14,17 +14,31 @@ export async function generateEntries(
|
|||||||
const isWord = inputType === "word";
|
const isWord = inputType === "word";
|
||||||
|
|
||||||
const prompt = `
|
const prompt = `
|
||||||
生成词典条目。词语:"${standardForm}"(${queryLang})。用${definitionLang}释义。
|
你是专业词典编纂专家。为词条"${standardForm}"(${queryLang})生成${definitionLang}释义。
|
||||||
|
|
||||||
返回 JSON:
|
【核心要求】
|
||||||
${isWord ? `{"entries":[{"ipa":"音标","partOfSpeech":"词性","definition":"释义","example":"例句"}]}` : `{"entries":[{"definition":"释义","example":"例句"}]}`}
|
生成尽可能完整、全面的词典条目,包括:
|
||||||
|
${isWord ? `- 所有常见词性(名词、动词、形容词、副词等)
|
||||||
|
- 每个词性下的所有常用义项
|
||||||
|
- 专业领域含义、口语含义、习语用法` : `- 所有常见含义和用法
|
||||||
|
- 字面义和引申义
|
||||||
|
- 不同语境下的解释`}
|
||||||
|
|
||||||
只返回 JSON。
|
【JSON格式】
|
||||||
|
${isWord ? `{"entries":[{"ipa":"国际音标","partOfSpeech":"词性","definition":"详细释义","example":"自然例句"}]}` : `{"entries":[{"definition":"详细释义","example":"自然例句"}]}`}
|
||||||
|
|
||||||
|
【质量标准】
|
||||||
|
- 条目数量:尽可能多,不要遗漏常用义项
|
||||||
|
- 释义:准确、完整、符合母语者习惯
|
||||||
|
- 例句:自然、地道、展示实际用法
|
||||||
|
- IPA:使用标准国际音标(单词/短语必填)
|
||||||
|
|
||||||
|
只返回JSON,不要其他内容。
|
||||||
`.trim();
|
`.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await getAnswer([
|
const result = await getAnswer([
|
||||||
{ role: "system", content: "词典条目生成器,只返回 JSON。" },
|
{ role: "system", content: "专业词典编纂专家,返回完整JSON词典数据。" },
|
||||||
{ role: "user", content: prompt },
|
{ role: "user", content: prompt },
|
||||||
]).then(parseAIGeneratedJSON<EntriesGenerationResult>);
|
]).then(parseAIGeneratedJSON<EntriesGenerationResult>);
|
||||||
|
|
||||||
@@ -47,6 +61,7 @@ ${isWord ? `{"entries":[{"ipa":"音标","partOfSpeech":"词性","definition":"
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Generated dictionary entries", { count: result.entries.length });
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Entries generation failed", { error: error instanceof Error ? error.message : String(error) });
|
log.error("Entries generation failed", { error: error instanceof Error ? error.message : String(error) });
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import OpenAI from "openai";
|
|
||||||
|
|
||||||
const openai = new OpenAI({
|
|
||||||
apiKey: process.env.ZHIPU_API_KEY,
|
|
||||||
baseURL: "https://open.bigmodel.cn/api/paas/v4",
|
|
||||||
});
|
|
||||||
|
|
||||||
type Messages = Array<
|
type Messages = Array<
|
||||||
| { role: "system"; content: string }
|
| { role: "system"; content: string }
|
||||||
| { role: "user"; content: string }
|
| { role: "user"; content: string }
|
||||||
@@ -20,13 +13,29 @@ async function getAnswer(prompt: string | Messages): Promise<string> {
|
|||||||
? [{ role: "user", content: prompt }]
|
? [{ role: "user", content: prompt }]
|
||||||
: prompt;
|
: prompt;
|
||||||
|
|
||||||
const response = await openai.chat.completions.create({
|
const response = await fetch("https://open.bigmodel.cn/api/paas/v4/chat/completions", {
|
||||||
model: process.env.ZHIPU_MODEL_NAME || "glm-4",
|
method: "POST",
|
||||||
messages: messages as OpenAI.Chat.Completions.ChatCompletionMessageParam[],
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": `Bearer ${process.env.ZHIPU_API_KEY}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
model: process.env.ZHIPU_MODEL_NAME || "glm-4.6",
|
||||||
|
messages,
|
||||||
temperature: 0.2,
|
temperature: 0.2,
|
||||||
|
thinking: {
|
||||||
|
type: "disabled"
|
||||||
|
}
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const content = response.choices[0]?.message?.content;
|
if (!response.ok) {
|
||||||
|
throw new Error(`AI API 请求失败: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json() as { choices?: Array<{ message?: { content?: string } }> };
|
||||||
|
const content = data.choices?.[0]?.message?.content;
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
throw new Error("AI API 返回空响应");
|
throw new Error("AI API 返回空响应");
|
||||||
}
|
}
|
||||||
|
|||||||
152
src/lib/bigmodel/ocr/orchestrator.ts
Normal file
152
src/lib/bigmodel/ocr/orchestrator.ts
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import OpenAI from "openai";
|
||||||
|
import { parseAIGeneratedJSON } from "@/utils/json";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import { OCRInput, OCROutput, OCRRawResponse } from "./types";
|
||||||
|
|
||||||
|
const log = createLogger("ocr-orchestrator");
|
||||||
|
|
||||||
|
const openai = new OpenAI({
|
||||||
|
apiKey: process.env.ZHIPU_API_KEY,
|
||||||
|
baseURL: "https://open.bigmodel.cn/api/paas/v4",
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes OCR on an image to extract vocabulary word-definition pairs.
|
||||||
|
*
|
||||||
|
* Uses GLM-4.6V vision model to analyze vocabulary table images and
|
||||||
|
* extract structured word-definition pairs.
|
||||||
|
*
|
||||||
|
* @param input - OCR input containing base64 image and optional language hints
|
||||||
|
* @returns Structured output with extracted pairs and detected languages
|
||||||
|
* @throws Error if OCR fails or response is malformed
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const result = await executeOCR({
|
||||||
|
* imageBase64: "iVBORw0KGgo...",
|
||||||
|
* sourceLanguage: "English",
|
||||||
|
* targetLanguage: "Chinese"
|
||||||
|
* });
|
||||||
|
* // result.pairs: [{ word: "hello", definition: "你好" }, ...]
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export async function executeOCR(input: OCRInput): Promise<OCROutput> {
|
||||||
|
const { imageBase64, sourceLanguage, targetLanguage } = input;
|
||||||
|
|
||||||
|
log.debug("Starting OCR", {
|
||||||
|
hasSourceHint: !!sourceLanguage,
|
||||||
|
hasTargetHint: !!targetLanguage,
|
||||||
|
imageLength: imageBase64.length,
|
||||||
|
});
|
||||||
|
|
||||||
|
const languageHints: string[] = [];
|
||||||
|
if (sourceLanguage) {
|
||||||
|
languageHints.push(`源语言提示: ${sourceLanguage}`);
|
||||||
|
}
|
||||||
|
if (targetLanguage) {
|
||||||
|
languageHints.push(`目标语言提示: ${targetLanguage}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const prompt = `
|
||||||
|
你是一个专业的OCR识别助手,专门从词汇表截图中提取单词和释义。
|
||||||
|
|
||||||
|
${languageHints.length > 0 ? `语言提示:\n${languageHints.join("\n")}\n` : ""}
|
||||||
|
|
||||||
|
你的任务是分析图片中的词汇表,提取所有单词-释义对。
|
||||||
|
|
||||||
|
要求:
|
||||||
|
1. 识别图片中的词汇表结构(可能是两列或多列)
|
||||||
|
2. 提取每一行的单词和对应的释义/翻译
|
||||||
|
3. 自动检测源语言和目标语言
|
||||||
|
4. 保持原始大小写和拼写
|
||||||
|
5. 如果图片模糊或不清晰,尽力识别并标注置信度较低的项目
|
||||||
|
6. 忽略表头、页码等非词汇内容
|
||||||
|
|
||||||
|
返回 JSON 格式:
|
||||||
|
{
|
||||||
|
"pairs": [
|
||||||
|
{ "word": "单词1", "definition": "释义1" },
|
||||||
|
{ "word": "单词2", "definition": "释义2" }
|
||||||
|
],
|
||||||
|
"detectedSourceLanguage": "检测到的源语言",
|
||||||
|
"detectedTargetLanguage": "检测到的目标语言"
|
||||||
|
}
|
||||||
|
|
||||||
|
只返回 JSON,不要任何其他文字。
|
||||||
|
`.trim();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await openai.chat.completions.create({
|
||||||
|
model: "glm-4.6v",
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "image_url",
|
||||||
|
image_url: {
|
||||||
|
url: imageBase64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: prompt,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
temperature: 0.1,
|
||||||
|
});
|
||||||
|
|
||||||
|
const content = response.choices[0]?.message?.content;
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
log.error("OCR returned empty response");
|
||||||
|
throw new Error("OCR 返回空响应");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("Received OCR response", { contentLength: content.length });
|
||||||
|
|
||||||
|
const parsed = parseAIGeneratedJSON<OCRRawResponse>(content);
|
||||||
|
|
||||||
|
if (!parsed.pairs || !Array.isArray(parsed.pairs)) {
|
||||||
|
log.error("Invalid OCR response: missing or invalid pairs array", { parsed });
|
||||||
|
throw new Error("OCR 响应格式无效:缺少 pairs 数组");
|
||||||
|
}
|
||||||
|
|
||||||
|
const validPairs = parsed.pairs.filter((pair) => {
|
||||||
|
const isValid = typeof pair.word === "string" && typeof pair.definition === "string";
|
||||||
|
if (!isValid) {
|
||||||
|
log.warn("Skipping invalid pair", { pair });
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (validPairs.length === 0) {
|
||||||
|
log.error("No valid pairs extracted from image");
|
||||||
|
throw new Error("未能从图片中提取有效的词汇对");
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: OCROutput = {
|
||||||
|
pairs: validPairs,
|
||||||
|
detectedSourceLanguage: parsed.detectedSourceLanguage,
|
||||||
|
detectedTargetLanguage: parsed.detectedTargetLanguage,
|
||||||
|
};
|
||||||
|
|
||||||
|
log.info("OCR completed successfully", {
|
||||||
|
pairCount: result.pairs.length,
|
||||||
|
sourceLanguage: result.detectedSourceLanguage,
|
||||||
|
targetLanguage: result.detectedTargetLanguage,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error && error.message.startsWith("OCR")) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("OCR failed", { error });
|
||||||
|
const errorMessage = error instanceof Error ? error.message : "未知错误";
|
||||||
|
throw new Error(`OCR 处理失败: ${errorMessage}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/lib/bigmodel/ocr/types.ts
Normal file
44
src/lib/bigmodel/ocr/types.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Input for OCR pipeline
|
||||||
|
*/
|
||||||
|
export interface OCRInput {
|
||||||
|
/** Base64 encoded image (without data URL prefix) */
|
||||||
|
imageBase64: string;
|
||||||
|
/** Optional: hint about source language */
|
||||||
|
sourceLanguage?: string;
|
||||||
|
/** Optional: hint about target/translation language */
|
||||||
|
targetLanguage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single word-definition pair extracted from image
|
||||||
|
*/
|
||||||
|
export interface VocabularyPair {
|
||||||
|
/** The original word */
|
||||||
|
word: string;
|
||||||
|
/** The translation/definition */
|
||||||
|
definition: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output from OCR pipeline
|
||||||
|
*/
|
||||||
|
export interface OCROutput {
|
||||||
|
/** Extracted word-definition pairs */
|
||||||
|
pairs: VocabularyPair[];
|
||||||
|
/** Detected source language */
|
||||||
|
detectedSourceLanguage?: string;
|
||||||
|
/** Detected target/translation language */
|
||||||
|
detectedTargetLanguage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal structure for AI response parsing
|
||||||
|
*/
|
||||||
|
interface OCRRawResponse {
|
||||||
|
pairs: Array<{ word: string; definition: string }>;
|
||||||
|
detectedSourceLanguage?: string;
|
||||||
|
detectedTargetLanguage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { OCRRawResponse };
|
||||||
@@ -132,19 +132,28 @@ async function generateIPA(
|
|||||||
export async function executeTranslation(
|
export async function executeTranslation(
|
||||||
sourceText: string,
|
sourceText: string,
|
||||||
targetLanguage: string,
|
targetLanguage: string,
|
||||||
needIpa: boolean
|
needIpa: boolean,
|
||||||
|
sourceLanguage?: string
|
||||||
): Promise<TranslationLLMResponse> {
|
): Promise<TranslationLLMResponse> {
|
||||||
try {
|
try {
|
||||||
log.debug("Starting translation", { sourceText, targetLanguage, needIpa });
|
log.debug("Starting translation", { sourceText, targetLanguage, needIpa, sourceLanguage });
|
||||||
|
|
||||||
|
let detectedLanguage: string;
|
||||||
|
|
||||||
|
if (sourceLanguage) {
|
||||||
|
log.debug("[Stage 1] Using provided source language", { sourceLanguage });
|
||||||
|
detectedLanguage = sourceLanguage;
|
||||||
|
} else {
|
||||||
log.debug("[Stage 1] Detecting source language");
|
log.debug("[Stage 1] Detecting source language");
|
||||||
const detectionResult = await detectLanguage(sourceText);
|
const detectionResult = await detectLanguage(sourceText);
|
||||||
log.debug("[Stage 1] Detection result", { detectionResult });
|
log.debug("[Stage 1] Detection result", { detectionResult });
|
||||||
|
detectedLanguage = detectionResult.sourceLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("[Stage 2] Performing translation");
|
log.debug("[Stage 2] Performing translation");
|
||||||
const translatedText = await performTranslation(
|
const translatedText = await performTranslation(
|
||||||
sourceText,
|
sourceText,
|
||||||
detectionResult.sourceLanguage,
|
detectedLanguage,
|
||||||
targetLanguage
|
targetLanguage
|
||||||
);
|
);
|
||||||
log.debug("[Stage 2] Translation complete", { translatedText });
|
log.debug("[Stage 2] Translation complete", { translatedText });
|
||||||
@@ -159,19 +168,19 @@ export async function executeTranslation(
|
|||||||
let targetIpa: string | undefined;
|
let targetIpa: string | undefined;
|
||||||
|
|
||||||
if (needIpa) {
|
if (needIpa) {
|
||||||
log.debug("[Stage 3] Generating IPA");
|
log.debug("[Stage 3] Generating IPA in parallel");
|
||||||
sourceIpa = await generateIPA(sourceText, detectionResult.sourceLanguage);
|
[sourceIpa, targetIpa] = await Promise.all([
|
||||||
log.debug("[Stage 3] Source IPA", { sourceIpa });
|
generateIPA(sourceText, detectedLanguage),
|
||||||
|
generateIPA(translatedText, targetLanguage),
|
||||||
targetIpa = await generateIPA(translatedText, targetLanguage);
|
]);
|
||||||
log.debug("[Stage 3] Target IPA", { targetIpa });
|
log.debug("[Stage 3] IPA complete", { sourceIpa, targetIpa });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assemble final result
|
// Assemble final result
|
||||||
const finalResult: TranslationLLMResponse = {
|
const finalResult: TranslationLLMResponse = {
|
||||||
sourceText,
|
sourceText,
|
||||||
translatedText,
|
translatedText,
|
||||||
sourceLanguage: detectionResult.sourceLanguage,
|
sourceLanguage: detectedLanguage,
|
||||||
targetLanguage,
|
targetLanguage,
|
||||||
sourceIpa,
|
sourceIpa,
|
||||||
targetIpa,
|
targetIpa,
|
||||||
|
|||||||
@@ -56,7 +56,13 @@ export type ActionOutputUserProfile = {
|
|||||||
username: string | null;
|
username: string | null;
|
||||||
displayUsername: string | null;
|
displayUsername: string | null;
|
||||||
image: string | null;
|
image: string | null;
|
||||||
|
bio: string | null;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ActionOutputDeleteAccount = {
|
||||||
|
success: boolean;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
ActionInputSignIn,
|
ActionInputSignIn,
|
||||||
ActionInputSignUp,
|
ActionInputSignUp,
|
||||||
ActionOutputAuth,
|
ActionOutputAuth,
|
||||||
|
ActionOutputDeleteAccount,
|
||||||
ActionOutputUserProfile,
|
ActionOutputUserProfile,
|
||||||
validateActionInputGetUserProfileByUsername,
|
validateActionInputGetUserProfileByUsername,
|
||||||
validateActionInputSignIn,
|
validateActionInputSignIn,
|
||||||
@@ -18,7 +19,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
serviceGetUserProfileByUsername,
|
serviceGetUserProfileByUsername,
|
||||||
serviceSignIn,
|
serviceSignIn,
|
||||||
serviceSignUp
|
serviceSignUp,
|
||||||
|
serviceDeleteAccount
|
||||||
} from "./auth-service";
|
} from "./auth-service";
|
||||||
|
|
||||||
// Re-export types for use in components
|
// Re-export types for use in components
|
||||||
@@ -180,3 +182,27 @@ export async function actionGetUserProfileByUsername(dto: ActionInputGetUserProf
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete account action
|
||||||
|
* Permanently deletes the current user and all associated data
|
||||||
|
*/
|
||||||
|
export async function actionDeleteAccount(): Promise<ActionOutputDeleteAccount> {
|
||||||
|
try {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await serviceDeleteAccount({ userId: session.user.id });
|
||||||
|
|
||||||
|
if (!result.success) {
|
||||||
|
return { success: false, message: "Failed to delete account" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, message: "Account deleted successfully" };
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Delete account failed", { error: e });
|
||||||
|
return { success: false, message: "Failed to delete account" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export type RepoOutputUserProfile = {
|
|||||||
username: string | null;
|
username: string | null;
|
||||||
displayUsername: string | null;
|
displayUsername: string | null;
|
||||||
image: string | null;
|
image: string | null;
|
||||||
|
bio: string | null;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
} | null;
|
} | null;
|
||||||
@@ -24,3 +25,12 @@ export type RepoInputFindUserById = {
|
|||||||
export type RepoInputFindUserByEmail = {
|
export type RepoInputFindUserByEmail = {
|
||||||
email: string;
|
email: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Delete user cascade types
|
||||||
|
export type RepoInputDeleteUserCascade = {
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RepoOutputDeleteUserCascade = {
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import { prisma } from "@/lib/db";
|
import { prisma } from "@/lib/db";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
import {
|
import {
|
||||||
RepoInputFindUserByEmail,
|
RepoInputFindUserByEmail,
|
||||||
RepoInputFindUserById,
|
RepoInputFindUserById,
|
||||||
RepoInputFindUserByUsername,
|
RepoInputFindUserByUsername,
|
||||||
RepoOutputUserProfile
|
RepoInputDeleteUserCascade,
|
||||||
|
RepoOutputUserProfile,
|
||||||
|
RepoOutputDeleteUserCascade
|
||||||
} from "./auth-repository-dto";
|
} from "./auth-repository-dto";
|
||||||
|
|
||||||
/**
|
const log = createLogger("auth-repository");
|
||||||
* Find user by username
|
|
||||||
*/
|
|
||||||
export async function repoFindUserByUsername(dto: RepoInputFindUserByUsername): Promise<RepoOutputUserProfile> {
|
export async function repoFindUserByUsername(dto: RepoInputFindUserByUsername): Promise<RepoOutputUserProfile> {
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: { username: dto.username },
|
where: { username: dto.username },
|
||||||
@@ -19,6 +21,7 @@ export async function repoFindUserByUsername(dto: RepoInputFindUserByUsername):
|
|||||||
username: true,
|
username: true,
|
||||||
displayUsername: true,
|
displayUsername: true,
|
||||||
image: true,
|
image: true,
|
||||||
|
bio: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
}
|
}
|
||||||
@@ -27,9 +30,6 @@ export async function repoFindUserByUsername(dto: RepoInputFindUserByUsername):
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find user by ID
|
|
||||||
*/
|
|
||||||
export async function repoFindUserById(dto: RepoInputFindUserById): Promise<RepoOutputUserProfile> {
|
export async function repoFindUserById(dto: RepoInputFindUserById): Promise<RepoOutputUserProfile> {
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: { id: dto.id },
|
where: { id: dto.id },
|
||||||
@@ -40,6 +40,7 @@ export async function repoFindUserById(dto: RepoInputFindUserById): Promise<Repo
|
|||||||
username: true,
|
username: true,
|
||||||
displayUsername: true,
|
displayUsername: true,
|
||||||
image: true,
|
image: true,
|
||||||
|
bio: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
}
|
}
|
||||||
@@ -48,9 +49,6 @@ export async function repoFindUserById(dto: RepoInputFindUserById): Promise<Repo
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find user by email
|
|
||||||
*/
|
|
||||||
export async function repoFindUserByEmail(dto: RepoInputFindUserByEmail): Promise<RepoOutputUserProfile> {
|
export async function repoFindUserByEmail(dto: RepoInputFindUserByEmail): Promise<RepoOutputUserProfile> {
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: { email: dto.email },
|
where: { email: dto.email },
|
||||||
@@ -61,6 +59,7 @@ export async function repoFindUserByEmail(dto: RepoInputFindUserByEmail): Promis
|
|||||||
username: true,
|
username: true,
|
||||||
displayUsername: true,
|
displayUsername: true,
|
||||||
image: true,
|
image: true,
|
||||||
|
bio: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
}
|
}
|
||||||
@@ -68,3 +67,48 @@ export async function repoFindUserByEmail(dto: RepoInputFindUserByEmail): Promis
|
|||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function repoDeleteUserCascade(dto: RepoInputDeleteUserCascade): Promise<RepoOutputDeleteUserCascade> {
|
||||||
|
const { userId } = dto;
|
||||||
|
|
||||||
|
log.info("Starting cascade delete for user", { userId });
|
||||||
|
|
||||||
|
await prisma.$transaction(async (tx) => {
|
||||||
|
await tx.card.deleteMany({
|
||||||
|
where: { deck: { userId } }
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.deckFavorite.deleteMany({
|
||||||
|
where: { userId }
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.deck.deleteMany({
|
||||||
|
where: { userId }
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.follow.deleteMany({
|
||||||
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ followerId: userId },
|
||||||
|
{ followingId: userId }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.session.deleteMany({
|
||||||
|
where: { userId }
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.account.deleteMany({
|
||||||
|
where: { userId }
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.user.delete({
|
||||||
|
where: { id: userId }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
log.info("Cascade delete completed for user", { userId });
|
||||||
|
|
||||||
|
return { success: true };
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,15 @@ export type ServiceOutputUserProfile = {
|
|||||||
username: string | null;
|
username: string | null;
|
||||||
displayUsername: string | null;
|
displayUsername: string | null;
|
||||||
image: string | null;
|
image: string | null;
|
||||||
|
bio: string | null;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
|
export type ServiceInputDeleteAccount = {
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputDeleteAccount = {
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import {
|
import {
|
||||||
repoFindUserByUsername,
|
repoFindUserByUsername,
|
||||||
repoFindUserById
|
repoFindUserById,
|
||||||
|
repoDeleteUserCascade
|
||||||
} from "./auth-repository";
|
} from "./auth-repository";
|
||||||
import {
|
import {
|
||||||
ServiceInputGetUserProfileByUsername,
|
ServiceInputGetUserProfileByUsername,
|
||||||
ServiceInputGetUserProfileById,
|
ServiceInputGetUserProfileById,
|
||||||
ServiceInputSignIn,
|
ServiceInputSignIn,
|
||||||
ServiceInputSignUp,
|
ServiceInputSignUp,
|
||||||
|
ServiceInputDeleteAccount,
|
||||||
ServiceOutputAuth,
|
ServiceOutputAuth,
|
||||||
ServiceOutputUserProfile
|
ServiceOutputUserProfile,
|
||||||
|
ServiceOutputDeleteAccount
|
||||||
} from "./auth-service-dto";
|
} from "./auth-service-dto";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,3 +95,7 @@ export async function serviceGetUserProfileByUsername(dto: ServiceInputGetUserPr
|
|||||||
export async function serviceGetUserProfileById(dto: ServiceInputGetUserProfileById): Promise<ServiceOutputUserProfile> {
|
export async function serviceGetUserProfileById(dto: ServiceInputGetUserProfileById): Promise<ServiceOutputUserProfile> {
|
||||||
return await repoFindUserById(dto);
|
return await repoFindUserById(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function serviceDeleteAccount(dto: ServiceInputDeleteAccount): Promise<ServiceOutputDeleteAccount> {
|
||||||
|
return await repoDeleteUserCascade({ userId: dto.userId });
|
||||||
|
}
|
||||||
|
|||||||
12
src/modules/auth/forgot-password-action-dto.ts
Normal file
12
src/modules/auth/forgot-password-action-dto.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const schemaActionInputForgotPassword = z.object({
|
||||||
|
email: z.string().email("请输入有效的邮箱地址"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ActionInputForgotPassword = z.infer<typeof schemaActionInputForgotPassword>;
|
||||||
|
|
||||||
|
export interface ActionOutputForgotPassword {
|
||||||
|
success: boolean;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
35
src/modules/auth/forgot-password-action.ts
Normal file
35
src/modules/auth/forgot-password-action.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import { validate } from "@/utils/validate";
|
||||||
|
import { ValidateError } from "@/lib/errors";
|
||||||
|
import {
|
||||||
|
schemaActionInputForgotPassword,
|
||||||
|
type ActionInputForgotPassword,
|
||||||
|
type ActionOutputForgotPassword,
|
||||||
|
} from "./forgot-password-action-dto";
|
||||||
|
import { serviceRequestPasswordReset } from "./forgot-password-service";
|
||||||
|
|
||||||
|
const log = createLogger("forgot-password-action");
|
||||||
|
|
||||||
|
export async function actionRequestPasswordReset(
|
||||||
|
input: unknown
|
||||||
|
): Promise<ActionOutputForgotPassword> {
|
||||||
|
try {
|
||||||
|
const dto = validate(input, schemaActionInputForgotPassword) as ActionInputForgotPassword;
|
||||||
|
|
||||||
|
return await serviceRequestPasswordReset({ email: dto.email });
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: e.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
log.error("Password reset request failed", { error: e });
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "发送重置邮件失败,请稍后重试",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/modules/auth/forgot-password-repository-dto.ts
Normal file
7
src/modules/auth/forgot-password-repository-dto.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export type RepoInputFindUserByEmail = {
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RepoOutputFindUserByEmail = {
|
||||||
|
id: string;
|
||||||
|
} | null;
|
||||||
19
src/modules/auth/forgot-password-repository.ts
Normal file
19
src/modules/auth/forgot-password-repository.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { prisma } from "@/lib/db";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import {
|
||||||
|
RepoInputFindUserByEmail,
|
||||||
|
RepoOutputFindUserByEmail
|
||||||
|
} from "./forgot-password-repository-dto";
|
||||||
|
|
||||||
|
const log = createLogger("forgot-password-repository");
|
||||||
|
|
||||||
|
export async function repoFindUserByEmail(dto: RepoInputFindUserByEmail): Promise<RepoOutputFindUserByEmail> {
|
||||||
|
log.debug("Finding user by email", { email: dto.email });
|
||||||
|
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: { email: dto.email },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
8
src/modules/auth/forgot-password-service-dto.ts
Normal file
8
src/modules/auth/forgot-password-service-dto.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export type ServiceInputRequestPasswordReset = {
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputRequestPasswordReset = {
|
||||||
|
success: boolean;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
34
src/modules/auth/forgot-password-service.ts
Normal file
34
src/modules/auth/forgot-password-service.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { auth } from "@/auth";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import { repoFindUserByEmail } from "./forgot-password-repository";
|
||||||
|
import {
|
||||||
|
ServiceInputRequestPasswordReset,
|
||||||
|
ServiceOutputRequestPasswordReset
|
||||||
|
} from "./forgot-password-service-dto";
|
||||||
|
|
||||||
|
const log = createLogger("forgot-password-service");
|
||||||
|
|
||||||
|
export async function serviceRequestPasswordReset(dto: ServiceInputRequestPasswordReset): Promise<ServiceOutputRequestPasswordReset> {
|
||||||
|
log.info("Processing password reset request", { email: dto.email });
|
||||||
|
|
||||||
|
const user = await repoFindUserByEmail({ email: dto.email });
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "该邮箱未注册",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
await auth.api.requestPasswordReset({
|
||||||
|
body: {
|
||||||
|
email: dto.email,
|
||||||
|
redirectTo: "/reset-password",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "重置密码邮件已发送,请检查您的邮箱",
|
||||||
|
};
|
||||||
|
}
|
||||||
54
src/modules/card/card-action-dto.ts
Normal file
54
src/modules/card/card-action-dto.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import z from "zod";
|
||||||
|
import { generateValidator } from "@/utils/validate";
|
||||||
|
import type { RepoOutputCard, RepoOutputCardStats, CardMeaning, CardType } from "./card-repository-dto";
|
||||||
|
|
||||||
|
export type ActionOutputCard = RepoOutputCard;
|
||||||
|
export type ActionOutputCardStats = RepoOutputCardStats;
|
||||||
|
export type { CardMeaning, CardType };
|
||||||
|
|
||||||
|
const CardMeaningSchema = z.object({
|
||||||
|
partOfSpeech: z.string().nullable(),
|
||||||
|
definition: z.string(),
|
||||||
|
example: z.string().optional().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const schemaActionInputCreateCard = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
word: z.string().min(1),
|
||||||
|
ipa: z.string().optional().nullable(),
|
||||||
|
queryLang: z.string().min(1),
|
||||||
|
cardType: z.enum(["WORD", "PHRASE", "SENTENCE"]),
|
||||||
|
meanings: z.array(CardMeaningSchema).min(1),
|
||||||
|
});
|
||||||
|
export type ActionInputCreateCard = z.infer<typeof schemaActionInputCreateCard>;
|
||||||
|
export const validateActionInputCreateCard = generateValidator(schemaActionInputCreateCard);
|
||||||
|
|
||||||
|
export const schemaActionInputUpdateCard = z.object({
|
||||||
|
cardId: z.number().int().positive(),
|
||||||
|
word: z.string().min(1).optional(),
|
||||||
|
ipa: z.string().optional().nullable(),
|
||||||
|
meanings: z.array(CardMeaningSchema).min(1).optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputUpdateCard = z.infer<typeof schemaActionInputUpdateCard>;
|
||||||
|
export const validateActionInputUpdateCard = generateValidator(schemaActionInputUpdateCard);
|
||||||
|
|
||||||
|
export const schemaActionInputDeleteCard = z.object({
|
||||||
|
cardId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputDeleteCard = z.infer<typeof schemaActionInputDeleteCard>;
|
||||||
|
export const validateActionInputDeleteCard = generateValidator(schemaActionInputDeleteCard);
|
||||||
|
|
||||||
|
export const schemaActionInputGetCardsByDeckId = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
limit: z.number().int().min(1).max(100).optional(),
|
||||||
|
offset: z.number().int().min(0).optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputGetCardsByDeckId = z.infer<typeof schemaActionInputGetCardsByDeckId>;
|
||||||
|
export const validateActionInputGetCardsByDeckId = generateValidator(schemaActionInputGetCardsByDeckId);
|
||||||
|
|
||||||
|
export const schemaActionInputGetRandomCard = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
excludeIds: z.array(z.number().int().positive()).optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputGetRandomCard = z.infer<typeof schemaActionInputGetRandomCard>;
|
||||||
|
export const validateActionInputGetRandomCard = generateValidator(schemaActionInputGetRandomCard);
|
||||||
220
src/modules/card/card-action.ts
Normal file
220
src/modules/card/card-action.ts
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { auth } from "@/auth";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import { ValidateError } from "@/lib/errors";
|
||||||
|
import {
|
||||||
|
serviceCreateCard,
|
||||||
|
serviceUpdateCard,
|
||||||
|
serviceDeleteCard,
|
||||||
|
serviceGetCardById,
|
||||||
|
serviceGetCardsByDeckId,
|
||||||
|
serviceGetRandomCard,
|
||||||
|
serviceGetCardStats,
|
||||||
|
serviceCheckDeckOwnership,
|
||||||
|
} from "./card-service";
|
||||||
|
import type { ActionOutputCard, ActionOutputCardStats } from "./card-action-dto";
|
||||||
|
import type { CardMeaning, CardType } from "./card-repository-dto";
|
||||||
|
import {
|
||||||
|
validateActionInputCreateCard,
|
||||||
|
validateActionInputUpdateCard,
|
||||||
|
validateActionInputDeleteCard,
|
||||||
|
validateActionInputGetCardsByDeckId,
|
||||||
|
validateActionInputGetRandomCard,
|
||||||
|
} from "./card-action-dto";
|
||||||
|
|
||||||
|
const log = createLogger("card-action");
|
||||||
|
|
||||||
|
function mapCardToOutput(card: any): ActionOutputCard {
|
||||||
|
return {
|
||||||
|
id: card.id,
|
||||||
|
deckId: card.deckId,
|
||||||
|
word: card.word,
|
||||||
|
ipa: card.ipa,
|
||||||
|
queryLang: card.queryLang,
|
||||||
|
cardType: card.cardType,
|
||||||
|
meanings: card.meanings,
|
||||||
|
createdAt: card.createdAt,
|
||||||
|
updatedAt: card.updatedAt,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCurrentUserId(): Promise<string | null> {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
return session?.user?.id ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkDeckOwnership(deckId: number): Promise<boolean> {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) return false;
|
||||||
|
return serviceCheckDeckOwnership({ deckId, userId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionCreateCard(input: unknown) {
|
||||||
|
try {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
const validated = validateActionInputCreateCard(input);
|
||||||
|
const isOwner = await checkDeckOwnership(validated.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to add cards to this deck" };
|
||||||
|
}
|
||||||
|
const result = await serviceCreateCard(validated);
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to create card", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to create card" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionUpdateCard(input: unknown) {
|
||||||
|
try {
|
||||||
|
const validated = validateActionInputUpdateCard(input);
|
||||||
|
const card = await serviceGetCardById(validated.cardId);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "Card not found" };
|
||||||
|
}
|
||||||
|
const isOwner = await checkDeckOwnership(card.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to update this card" };
|
||||||
|
}
|
||||||
|
const result = await serviceUpdateCard(validated);
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to update card", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to update card" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionDeleteCard(input: unknown) {
|
||||||
|
try {
|
||||||
|
const validated = validateActionInputDeleteCard(input);
|
||||||
|
const card = await serviceGetCardById(validated.cardId);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "Card not found" };
|
||||||
|
}
|
||||||
|
const isOwner = await checkDeckOwnership(card.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to delete this card" };
|
||||||
|
}
|
||||||
|
const result = await serviceDeleteCard(validated);
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to delete card", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to delete card" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetCardsByDeckId(input: unknown) {
|
||||||
|
try {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
const validated = validateActionInputGetCardsByDeckId(input);
|
||||||
|
const isOwner = await checkDeckOwnership(validated.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to view cards in this deck" };
|
||||||
|
}
|
||||||
|
const cards = await serviceGetCardsByDeckId(validated);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Cards fetched successfully",
|
||||||
|
data: cards.map(mapCardToOutput),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to get cards", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to get cards" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetCardById(cardId: number) {
|
||||||
|
try {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
const card = await serviceGetCardById(cardId);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "Card not found" };
|
||||||
|
}
|
||||||
|
const isOwner = await checkDeckOwnership(card.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to view this card" };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Card fetched successfully",
|
||||||
|
data: mapCardToOutput(card),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Failed to get card", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to get card" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetRandomCard(input: unknown) {
|
||||||
|
try {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
const validated = validateActionInputGetRandomCard(input);
|
||||||
|
const isOwner = await checkDeckOwnership(validated.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to view cards in this deck" };
|
||||||
|
}
|
||||||
|
const card = await serviceGetRandomCard(validated);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "No cards available" };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Random card fetched successfully",
|
||||||
|
data: mapCardToOutput(card),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to get random card", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to get random card" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetCardStats(deckId: number) {
|
||||||
|
try {
|
||||||
|
const userId = await getCurrentUserId();
|
||||||
|
if (!userId) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
const isOwner = await checkDeckOwnership(deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to view stats for this deck" };
|
||||||
|
}
|
||||||
|
const stats = await serviceGetCardStats(deckId);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Card stats fetched successfully",
|
||||||
|
data: stats,
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Failed to get card stats", { error: e instanceof Error ? e.message : String(e) });
|
||||||
|
return { success: false, message: "Failed to get card stats" };
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/modules/card/card-repository-dto.ts
Normal file
65
src/modules/card/card-repository-dto.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
export type CardMeaning = {
|
||||||
|
partOfSpeech: string | null;
|
||||||
|
definition: string;
|
||||||
|
example?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CardTypeEnum = {
|
||||||
|
WORD: "WORD",
|
||||||
|
PHRASE: "PHRASE",
|
||||||
|
SENTENCE: "SENTENCE",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type CardType = keyof typeof CardTypeEnum;
|
||||||
|
|
||||||
|
export interface RepoInputCreateCard {
|
||||||
|
deckId: number;
|
||||||
|
word: string;
|
||||||
|
ipa?: string | null;
|
||||||
|
queryLang: string;
|
||||||
|
cardType: CardType;
|
||||||
|
meanings: CardMeaning[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RepoInputUpdateCard {
|
||||||
|
cardId: number;
|
||||||
|
word?: string;
|
||||||
|
ipa?: string | null;
|
||||||
|
meanings?: CardMeaning[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RepoInputDeleteCard {
|
||||||
|
cardId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RepoInputGetCardsByDeckId {
|
||||||
|
deckId: number;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RepoInputGetRandomCard {
|
||||||
|
deckId: number;
|
||||||
|
excludeIds?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RepoInputCheckCardOwnership {
|
||||||
|
cardId: number;
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RepoOutputCard = {
|
||||||
|
id: number;
|
||||||
|
deckId: number;
|
||||||
|
word: string;
|
||||||
|
ipa: string | null;
|
||||||
|
queryLang: string;
|
||||||
|
cardType: CardType;
|
||||||
|
meanings: CardMeaning[];
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RepoOutputCardStats = {
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
148
src/modules/card/card-repository.ts
Normal file
148
src/modules/card/card-repository.ts
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
import {
|
||||||
|
RepoInputCreateCard,
|
||||||
|
RepoInputUpdateCard,
|
||||||
|
RepoInputDeleteCard,
|
||||||
|
RepoInputGetCardsByDeckId,
|
||||||
|
RepoInputGetRandomCard,
|
||||||
|
RepoInputCheckCardOwnership,
|
||||||
|
RepoOutputCard,
|
||||||
|
RepoOutputCardStats,
|
||||||
|
CardMeaning,
|
||||||
|
} from "./card-repository-dto";
|
||||||
|
import { prisma } from "@/lib/db";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
|
||||||
|
const log = createLogger("card-repository");
|
||||||
|
|
||||||
|
export async function repoCreateCard(input: RepoInputCreateCard): Promise<number> {
|
||||||
|
log.debug("Creating card", { deckId: input.deckId, word: input.word });
|
||||||
|
const card = await prisma.card.create({
|
||||||
|
data: {
|
||||||
|
deckId: input.deckId,
|
||||||
|
word: input.word,
|
||||||
|
ipa: input.ipa,
|
||||||
|
queryLang: input.queryLang,
|
||||||
|
cardType: input.cardType,
|
||||||
|
meanings: {
|
||||||
|
create: input.meanings.map((m: CardMeaning) => ({
|
||||||
|
partOfSpeech: m.partOfSpeech,
|
||||||
|
definition: m.definition,
|
||||||
|
example: m.example,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
log.info("Card created", { cardId: card.id });
|
||||||
|
return card.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoUpdateCard(input: RepoInputUpdateCard): Promise<void> {
|
||||||
|
log.debug("Updating card", { cardId: input.cardId });
|
||||||
|
await prisma.$transaction(async (tx) => {
|
||||||
|
if (input.word !== undefined) {
|
||||||
|
await tx.card.update({
|
||||||
|
where: { id: input.cardId },
|
||||||
|
data: { word: input.word },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (input.ipa !== undefined) {
|
||||||
|
await tx.card.update({
|
||||||
|
where: { id: input.cardId },
|
||||||
|
data: { ipa: input.ipa },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (input.meanings !== undefined) {
|
||||||
|
await tx.cardMeaning.deleteMany({
|
||||||
|
where: { cardId: input.cardId },
|
||||||
|
});
|
||||||
|
await tx.cardMeaning.createMany({
|
||||||
|
data: input.meanings.map((m: CardMeaning) => ({
|
||||||
|
cardId: input.cardId,
|
||||||
|
partOfSpeech: m.partOfSpeech,
|
||||||
|
definition: m.definition,
|
||||||
|
example: m.example,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await tx.card.update({
|
||||||
|
where: { id: input.cardId },
|
||||||
|
data: { updatedAt: new Date() },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
log.info("Card updated", { cardId: input.cardId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoDeleteCard(input: RepoInputDeleteCard): Promise<void> {
|
||||||
|
log.debug("Deleting card", { cardId: input.cardId });
|
||||||
|
await prisma.card.delete({
|
||||||
|
where: { id: input.cardId },
|
||||||
|
});
|
||||||
|
log.info("Card deleted", { cardId: input.cardId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetCardById(cardId: number): Promise<RepoOutputCard | null> {
|
||||||
|
const card = await prisma.card.findUnique({
|
||||||
|
where: { id: cardId },
|
||||||
|
include: { meanings: { orderBy: { createdAt: "asc" } } },
|
||||||
|
});
|
||||||
|
return card as RepoOutputCard | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetCardsByDeckId(input: RepoInputGetCardsByDeckId): Promise<RepoOutputCard[]> {
|
||||||
|
const { deckId, limit = 50, offset = 0 } = input;
|
||||||
|
const cards = await prisma.card.findMany({
|
||||||
|
where: { deckId },
|
||||||
|
include: { meanings: { orderBy: { createdAt: "asc" } } },
|
||||||
|
orderBy: { createdAt: "desc" },
|
||||||
|
take: limit,
|
||||||
|
skip: offset,
|
||||||
|
});
|
||||||
|
log.debug("Fetched cards by deck", { deckId, count: cards.length });
|
||||||
|
return cards as RepoOutputCard[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetRandomCard(input: RepoInputGetRandomCard): Promise<RepoOutputCard | null> {
|
||||||
|
const { deckId, excludeIds = [] } = input;
|
||||||
|
const whereClause = excludeIds.length > 0
|
||||||
|
? { deckId, id: { notIn: excludeIds } }
|
||||||
|
: { deckId };
|
||||||
|
const count = await prisma.card.count({ where: whereClause });
|
||||||
|
if (count === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const skip = Math.floor(Math.random() * count);
|
||||||
|
const cards = await prisma.card.findMany({
|
||||||
|
where: whereClause,
|
||||||
|
include: { meanings: { orderBy: { createdAt: "asc" } } },
|
||||||
|
skip,
|
||||||
|
take: 1,
|
||||||
|
});
|
||||||
|
const card = cards[0];
|
||||||
|
if (!card) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
log.debug("Got random card", { cardId: card.id, deckId });
|
||||||
|
return card as RepoOutputCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetCardDeckOwnerId(cardId: number): Promise<string | null> {
|
||||||
|
const card = await prisma.card.findUnique({
|
||||||
|
where: { id: cardId },
|
||||||
|
include: {
|
||||||
|
deck: {
|
||||||
|
select: { userId: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return card?.deck.userId ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoCheckCardOwnership(input: RepoInputCheckCardOwnership): Promise<boolean> {
|
||||||
|
const ownerId = await repoGetCardDeckOwnerId(input.cardId);
|
||||||
|
return ownerId === input.userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetCardStats(deckId: number): Promise<RepoOutputCardStats> {
|
||||||
|
const total = await prisma.card.count({ where: { deckId } });
|
||||||
|
return { total };
|
||||||
|
}
|
||||||
4
src/modules/card/card-service-dto.ts
Normal file
4
src/modules/card/card-service-dto.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import type { RepoOutputCard, RepoOutputCardStats } from "./card-repository-dto";
|
||||||
|
|
||||||
|
export type ServiceOutputCard = RepoOutputCard;
|
||||||
|
export type ServiceOutputCardStats = RepoOutputCardStats;
|
||||||
104
src/modules/card/card-service.ts
Normal file
104
src/modules/card/card-service.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import type {
|
||||||
|
RepoOutputCard,
|
||||||
|
RepoOutputCardStats,
|
||||||
|
CardMeaning,
|
||||||
|
CardType,
|
||||||
|
} from "./card-repository-dto";
|
||||||
|
import type {
|
||||||
|
RepoInputCreateCard,
|
||||||
|
RepoInputUpdateCard,
|
||||||
|
RepoInputDeleteCard,
|
||||||
|
RepoInputGetCardsByDeckId,
|
||||||
|
RepoInputGetRandomCard,
|
||||||
|
RepoInputCheckCardOwnership,
|
||||||
|
} from "./card-repository-dto";
|
||||||
|
import { repoGetUserIdByDeckId } from "@/modules/deck/deck-repository";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import {
|
||||||
|
repoCreateCard,
|
||||||
|
repoUpdateCard,
|
||||||
|
repoDeleteCard,
|
||||||
|
repoGetCardById,
|
||||||
|
repoGetCardsByDeckId,
|
||||||
|
repoGetRandomCard,
|
||||||
|
repoGetCardStats,
|
||||||
|
repoCheckCardOwnership,
|
||||||
|
} from "./card-repository";
|
||||||
|
|
||||||
|
const log = createLogger("card-service");
|
||||||
|
|
||||||
|
export type { CardMeaning as ServiceCardMeaning, CardType as ServiceCardType };
|
||||||
|
|
||||||
|
export type ServiceInputCreateCard = RepoInputCreateCard;
|
||||||
|
export type ServiceInputUpdateCard = RepoInputUpdateCard;
|
||||||
|
export type ServiceInputDeleteCard = RepoInputDeleteCard;
|
||||||
|
export type ServiceInputGetCardsByDeckId = RepoInputGetCardsByDeckId;
|
||||||
|
export type ServiceInputGetRandomCard = RepoInputGetRandomCard;
|
||||||
|
export type ServiceInputCheckCardOwnership = RepoInputCheckCardOwnership;
|
||||||
|
|
||||||
|
export type ServiceInputCheckDeckOwnership = {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputCard = RepoOutputCard;
|
||||||
|
export type ServiceOutputCardStats = RepoOutputCardStats;
|
||||||
|
|
||||||
|
export async function serviceCreateCard(input: ServiceInputCreateCard): Promise<{ success: boolean; cardId?: number; message: string }> {
|
||||||
|
log.info("Creating card", { deckId: input.deckId, word: input.word });
|
||||||
|
const cardId = await repoCreateCard(input);
|
||||||
|
log.info("Card created", { cardId });
|
||||||
|
return { success: true, cardId, message: "Card created successfully" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceUpdateCard(input: ServiceInputUpdateCard): Promise<{ success: boolean; message: string }> {
|
||||||
|
log.info("Updating card", { cardId: input.cardId });
|
||||||
|
const card = await repoGetCardById(input.cardId);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "Card not found" };
|
||||||
|
}
|
||||||
|
await repoUpdateCard(input);
|
||||||
|
log.info("Card updated", { cardId: input.cardId });
|
||||||
|
return { success: true, message: "Card updated successfully" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceDeleteCard(input: ServiceInputDeleteCard): Promise<{ success: boolean; message: string }> {
|
||||||
|
log.info("Deleting card", { cardId: input.cardId });
|
||||||
|
const card = await repoGetCardById(input.cardId);
|
||||||
|
if (!card) {
|
||||||
|
return { success: false, message: "Card not found" };
|
||||||
|
}
|
||||||
|
await repoDeleteCard(input);
|
||||||
|
log.info("Card deleted", { cardId: input.cardId });
|
||||||
|
return { success: true, message: "Card deleted successfully" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetCardById(cardId: number): Promise<ServiceOutputCard | null> {
|
||||||
|
return repoGetCardById(cardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetCardsByDeckId(input: ServiceInputGetCardsByDeckId): Promise<ServiceOutputCard[]> {
|
||||||
|
log.debug("Getting cards by deck", { deckId: input.deckId });
|
||||||
|
return repoGetCardsByDeckId(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetRandomCard(input: ServiceInputGetRandomCard): Promise<ServiceOutputCard | null> {
|
||||||
|
log.debug("Getting random card", { deckId: input.deckId });
|
||||||
|
return repoGetRandomCard(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetCardStats(deckId: number): Promise<ServiceOutputCardStats> {
|
||||||
|
log.debug("Getting card stats", { deckId });
|
||||||
|
return repoGetCardStats(deckId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceCheckCardOwnership(input: ServiceInputCheckCardOwnership): Promise<boolean> {
|
||||||
|
log.debug("Checking card ownership", { cardId: input.cardId });
|
||||||
|
return repoCheckCardOwnership(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceCheckDeckOwnership(input: ServiceInputCheckDeckOwnership): Promise<boolean> {
|
||||||
|
log.debug("Checking deck ownership", { deckId: input.deckId });
|
||||||
|
const ownerId = await repoGetUserIdByDeckId(input.deckId);
|
||||||
|
return ownerId === input.userId;
|
||||||
|
}
|
||||||
154
src/modules/deck/deck-action-dto.ts
Normal file
154
src/modules/deck/deck-action-dto.ts
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
import { generateValidator } from "@/utils/validate";
|
||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
export const schemaActionInputCreateDeck = z.object({
|
||||||
|
name: z.string().min(1).max(100),
|
||||||
|
desc: z.string().max(500).optional(),
|
||||||
|
visibility: z.enum(["PRIVATE", "PUBLIC"]).optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputCreateDeck = z.infer<typeof schemaActionInputCreateDeck>;
|
||||||
|
export const validateActionInputCreateDeck = generateValidator(schemaActionInputCreateDeck);
|
||||||
|
|
||||||
|
export const schemaActionInputUpdateDeck = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
name: z.string().min(1).max(100).optional(),
|
||||||
|
desc: z.string().max(500).optional(),
|
||||||
|
visibility: z.enum(["PRIVATE", "PUBLIC"]).optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputUpdateDeck = z.infer<typeof schemaActionInputUpdateDeck>;
|
||||||
|
export const validateActionInputUpdateDeck = generateValidator(schemaActionInputUpdateDeck);
|
||||||
|
|
||||||
|
export const schemaActionInputDeleteDeck = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputDeleteDeck = z.infer<typeof schemaActionInputDeleteDeck>;
|
||||||
|
export const validateActionInputDeleteDeck = generateValidator(schemaActionInputDeleteDeck);
|
||||||
|
|
||||||
|
export const schemaActionInputGetDeckById = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputGetDeckById = z.infer<typeof schemaActionInputGetDeckById>;
|
||||||
|
export const validateActionInputGetDeckById = generateValidator(schemaActionInputGetDeckById);
|
||||||
|
|
||||||
|
export const schemaActionInputGetPublicDecks = z.object({
|
||||||
|
limit: z.number().int().positive().optional(),
|
||||||
|
offset: z.number().int().nonnegative().optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputGetPublicDecks = z.infer<typeof schemaActionInputGetPublicDecks>;
|
||||||
|
export const validateActionInputGetPublicDecks = generateValidator(schemaActionInputGetPublicDecks);
|
||||||
|
|
||||||
|
export type ActionOutputDeck = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
desc: string;
|
||||||
|
userId: string;
|
||||||
|
visibility: "PRIVATE" | "PUBLIC";
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
cardCount?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputPublicDeck = ActionOutputDeck & {
|
||||||
|
userName: string | null;
|
||||||
|
userUsername: string | null;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputCreateDeck = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
deckId?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputUpdateDeck = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputDeleteDeck = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputGetDeckById = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputDeck;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputGetDecksByUserId = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputDeck[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputGetPublicDecks = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputPublicDeck[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const schemaActionInputSearchPublicDecks = z.object({
|
||||||
|
query: z.string().min(1),
|
||||||
|
limit: z.number().int().positive().optional(),
|
||||||
|
offset: z.number().int().nonnegative().optional(),
|
||||||
|
});
|
||||||
|
export type ActionInputSearchPublicDecks = z.infer<typeof schemaActionInputSearchPublicDecks>;
|
||||||
|
export const validateActionInputSearchPublicDecks = generateValidator(schemaActionInputSearchPublicDecks);
|
||||||
|
|
||||||
|
export const schemaActionInputGetPublicDeckById = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputGetPublicDeckById = z.infer<typeof schemaActionInputGetPublicDeckById>;
|
||||||
|
export const validateActionInputGetPublicDeckById = generateValidator(schemaActionInputGetPublicDeckById);
|
||||||
|
|
||||||
|
export const schemaActionInputToggleDeckFavorite = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputToggleDeckFavorite = z.infer<typeof schemaActionInputToggleDeckFavorite>;
|
||||||
|
export const validateActionInputToggleDeckFavorite = generateValidator(schemaActionInputToggleDeckFavorite);
|
||||||
|
|
||||||
|
export const schemaActionInputCheckDeckFavorite = z.object({
|
||||||
|
deckId: z.number().int().positive(),
|
||||||
|
});
|
||||||
|
export type ActionInputCheckDeckFavorite = z.infer<typeof schemaActionInputCheckDeckFavorite>;
|
||||||
|
export const validateActionInputCheckDeckFavorite = generateValidator(schemaActionInputCheckDeckFavorite);
|
||||||
|
|
||||||
|
export type ActionOutputDeckFavorite = {
|
||||||
|
isFavorited: boolean;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputSearchPublicDecks = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputPublicDeck[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputGetPublicDeckById = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputPublicDeck;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputToggleDeckFavorite = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputDeckFavorite;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputCheckDeckFavorite = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputDeckFavorite;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputUserFavoriteDeck = ActionOutputPublicDeck & {
|
||||||
|
favoritedAt: Date;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ActionOutputGetUserFavoriteDecks = {
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
data?: ActionOutputUserFavoriteDeck[];
|
||||||
|
};
|
||||||
326
src/modules/deck/deck-action.ts
Normal file
326
src/modules/deck/deck-action.ts
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { auth } from "@/auth";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import { ValidateError } from "@/lib/errors";
|
||||||
|
import { Visibility } from "../../../generated/prisma/enums";
|
||||||
|
import {
|
||||||
|
ActionInputCreateDeck,
|
||||||
|
ActionInputUpdateDeck,
|
||||||
|
ActionInputDeleteDeck,
|
||||||
|
ActionInputGetDeckById,
|
||||||
|
ActionInputGetPublicDecks,
|
||||||
|
ActionInputSearchPublicDecks,
|
||||||
|
ActionInputGetPublicDeckById,
|
||||||
|
ActionInputToggleDeckFavorite,
|
||||||
|
ActionInputCheckDeckFavorite,
|
||||||
|
ActionOutputCreateDeck,
|
||||||
|
ActionOutputUpdateDeck,
|
||||||
|
ActionOutputDeleteDeck,
|
||||||
|
ActionOutputGetDeckById,
|
||||||
|
ActionOutputGetDecksByUserId,
|
||||||
|
ActionOutputGetPublicDecks,
|
||||||
|
ActionOutputDeck,
|
||||||
|
ActionOutputPublicDeck,
|
||||||
|
ActionOutputSearchPublicDecks,
|
||||||
|
ActionOutputGetPublicDeckById,
|
||||||
|
ActionOutputToggleDeckFavorite,
|
||||||
|
ActionOutputCheckDeckFavorite,
|
||||||
|
ActionOutputGetUserFavoriteDecks,
|
||||||
|
validateActionInputCreateDeck,
|
||||||
|
validateActionInputUpdateDeck,
|
||||||
|
validateActionInputDeleteDeck,
|
||||||
|
validateActionInputGetDeckById,
|
||||||
|
validateActionInputGetPublicDecks,
|
||||||
|
validateActionInputSearchPublicDecks,
|
||||||
|
validateActionInputGetPublicDeckById,
|
||||||
|
validateActionInputToggleDeckFavorite,
|
||||||
|
validateActionInputCheckDeckFavorite,
|
||||||
|
} from "./deck-action-dto";
|
||||||
|
import {
|
||||||
|
serviceCreateDeck,
|
||||||
|
serviceUpdateDeck,
|
||||||
|
serviceDeleteDeck,
|
||||||
|
serviceGetDeckById,
|
||||||
|
serviceGetDecksByUserId,
|
||||||
|
serviceGetPublicDecks,
|
||||||
|
serviceCheckOwnership,
|
||||||
|
serviceSearchPublicDecks,
|
||||||
|
serviceGetPublicDeckById,
|
||||||
|
serviceToggleDeckFavorite,
|
||||||
|
serviceCheckDeckFavorite,
|
||||||
|
serviceGetUserFavoriteDecks,
|
||||||
|
} from "./deck-service";
|
||||||
|
|
||||||
|
const log = createLogger("deck-action");
|
||||||
|
|
||||||
|
async function checkDeckOwnership(deckId: number): Promise<boolean> {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) return false;
|
||||||
|
return serviceCheckOwnership({ deckId, userId: session.user.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionCreateDeck(input: ActionInputCreateDeck): Promise<ActionOutputCreateDeck> {
|
||||||
|
try {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
|
||||||
|
const validatedInput = validateActionInputCreateDeck(input);
|
||||||
|
const result = await serviceCreateDeck({
|
||||||
|
name: validatedInput.name,
|
||||||
|
desc: validatedInput.desc,
|
||||||
|
userId: session.user.id,
|
||||||
|
visibility: validatedInput.visibility as Visibility | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to create deck", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionUpdateDeck(input: ActionInputUpdateDeck): Promise<ActionOutputUpdateDeck> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputUpdateDeck(input);
|
||||||
|
|
||||||
|
const isOwner = await checkDeckOwnership(validatedInput.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to update this deck" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return serviceUpdateDeck({
|
||||||
|
deckId: validatedInput.deckId,
|
||||||
|
name: validatedInput.name,
|
||||||
|
desc: validatedInput.desc,
|
||||||
|
visibility: validatedInput.visibility as Visibility | undefined,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to update deck", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionDeleteDeck(input: ActionInputDeleteDeck): Promise<ActionOutputDeleteDeck> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputDeleteDeck(input);
|
||||||
|
|
||||||
|
const isOwner = await checkDeckOwnership(validatedInput.deckId);
|
||||||
|
if (!isOwner) {
|
||||||
|
return { success: false, message: "You do not have permission to delete this deck" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return serviceDeleteDeck({ deckId: validatedInput.deckId });
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to delete deck", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetDeckById(input: ActionInputGetDeckById): Promise<ActionOutputGetDeckById> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputGetDeckById(input);
|
||||||
|
const result = await serviceGetDeckById({ deckId: validatedInput.deckId });
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: {
|
||||||
|
...result.data,
|
||||||
|
visibility: result.data.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Failed to get deck", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetDecksByUserId(userId: string): Promise<ActionOutputGetDecksByUserId> {
|
||||||
|
try {
|
||||||
|
const result = await serviceGetDecksByUserId({ userId });
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: result.data.map((deck) => ({
|
||||||
|
...deck,
|
||||||
|
visibility: deck.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Failed to get decks", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetPublicDecks(input: ActionInputGetPublicDecks = {}): Promise<ActionOutputGetPublicDecks> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputGetPublicDecks(input);
|
||||||
|
const result = await serviceGetPublicDecks(validatedInput);
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: result.data.map((deck) => ({
|
||||||
|
...deck,
|
||||||
|
visibility: deck.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to get public decks", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetPublicDeckById(input: ActionInputGetPublicDeckById): Promise<ActionOutputGetPublicDeckById> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputGetPublicDeckById(input);
|
||||||
|
const result = await serviceGetPublicDeckById(validatedInput);
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: {
|
||||||
|
...result.data,
|
||||||
|
visibility: result.data.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to get public deck", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionSearchPublicDecks(input: ActionInputSearchPublicDecks): Promise<ActionOutputSearchPublicDecks> {
|
||||||
|
try {
|
||||||
|
const validatedInput = validateActionInputSearchPublicDecks(input);
|
||||||
|
const result = await serviceSearchPublicDecks(validatedInput);
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: result.data.map((deck) => ({
|
||||||
|
...deck,
|
||||||
|
visibility: deck.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to search public decks", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionToggleDeckFavorite(input: ActionInputToggleDeckFavorite): Promise<ActionOutputToggleDeckFavorite> {
|
||||||
|
try {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
|
||||||
|
const validatedInput = validateActionInputToggleDeckFavorite(input);
|
||||||
|
const result = await serviceToggleDeckFavorite({
|
||||||
|
deckId: validatedInput.deckId,
|
||||||
|
userId: session.user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to toggle deck favorite", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionCheckDeckFavorite(input: ActionInputCheckDeckFavorite): Promise<ActionOutputCheckDeckFavorite> {
|
||||||
|
try {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return { success: true, message: "Not logged in", data: { isFavorited: false, favoriteCount: 0 } };
|
||||||
|
}
|
||||||
|
|
||||||
|
const validatedInput = validateActionInputCheckDeckFavorite(input);
|
||||||
|
const result = await serviceCheckDeckFavorite({
|
||||||
|
deckId: validatedInput.deckId,
|
||||||
|
userId: session.user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidateError) {
|
||||||
|
return { success: false, message: e.message };
|
||||||
|
}
|
||||||
|
log.error("Failed to check deck favorite", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function actionGetUserFavoriteDecks(): Promise<ActionOutputGetUserFavoriteDecks> {
|
||||||
|
try {
|
||||||
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return { success: false, message: "Unauthorized" };
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await serviceGetUserFavoriteDecks(session.user.id);
|
||||||
|
|
||||||
|
if (!result.success || !result.data) {
|
||||||
|
return { success: false, message: result.message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: result.message,
|
||||||
|
data: result.data.map((deck) => ({
|
||||||
|
...deck,
|
||||||
|
visibility: deck.visibility as "PRIVATE" | "PUBLIC",
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Failed to get user favorite decks", { error: e });
|
||||||
|
return { success: false, message: "Unknown error occurred" };
|
||||||
|
}
|
||||||
|
}
|
||||||
74
src/modules/deck/deck-repository-dto.ts
Normal file
74
src/modules/deck/deck-repository-dto.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { Visibility } from "../../../generated/prisma/enums";
|
||||||
|
|
||||||
|
import type { DictionaryItemWithEntries } from "@/shared/card-type";
|
||||||
|
|
||||||
|
export interface RepoInputCreateDeck {
|
||||||
|
name: string;
|
||||||
|
desc?: string;
|
||||||
|
userId: string;
|
||||||
|
visibility?: Visibility;
|
||||||
|
}
|
||||||
|
export interface RepoInputUpdateDeck {
|
||||||
|
id: number;
|
||||||
|
name?: string;
|
||||||
|
desc?: string;
|
||||||
|
visibility?: Visibility;
|
||||||
|
}
|
||||||
|
export interface RepoInputGetDeckById {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
export interface RepoInputGetDecksByUserId {
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
export interface RepoInputGetPublicDecks {
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
orderBy?: "createdAt" | "name";
|
||||||
|
}
|
||||||
|
export interface RepoInputDeleteDeck {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
export type RepoOutputDeck = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
desc: string;
|
||||||
|
userId: string;
|
||||||
|
visibility: Visibility;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
cardCount?: number;
|
||||||
|
};
|
||||||
|
export type RepoOutputPublicDeck = RepoOutputDeck & {
|
||||||
|
userName: string | null;
|
||||||
|
userUsername: string | null;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
export type RepoOutputDeckOwnership = {
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
export interface RepoInputToggleDeckFavorite {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
export interface RepoInputCheckDeckFavorite {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
export interface RepoInputSearchPublicDecks {
|
||||||
|
query: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
}
|
||||||
|
export interface RepoInputGetPublicDeckById {
|
||||||
|
deckId: number;
|
||||||
|
}
|
||||||
|
export type RepoOutputDeckFavorite = {
|
||||||
|
isFavorited: boolean;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
export interface RepoInputGetUserFavoriteDecks {
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
export type RepoOutputUserFavoriteDeck = RepoOutputPublicDeck & {
|
||||||
|
favoritedAt: Date;
|
||||||
|
};
|
||||||
315
src/modules/deck/deck-repository.ts
Normal file
315
src/modules/deck/deck-repository.ts
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
import { prisma } from "@/lib/db";
|
||||||
|
import {
|
||||||
|
RepoInputCreateDeck,
|
||||||
|
RepoInputUpdateDeck,
|
||||||
|
RepoInputGetDeckById,
|
||||||
|
RepoInputGetDecksByUserId,
|
||||||
|
RepoInputGetPublicDecks,
|
||||||
|
RepoInputDeleteDeck,
|
||||||
|
RepoOutputDeck,
|
||||||
|
RepoOutputPublicDeck,
|
||||||
|
RepoOutputDeckOwnership,
|
||||||
|
RepoInputToggleDeckFavorite,
|
||||||
|
RepoInputCheckDeckFavorite,
|
||||||
|
RepoInputSearchPublicDecks,
|
||||||
|
RepoInputGetPublicDeckById,
|
||||||
|
RepoOutputDeckFavorite,
|
||||||
|
RepoInputGetUserFavoriteDecks,
|
||||||
|
RepoOutputUserFavoriteDeck,
|
||||||
|
} from "./deck-repository-dto";
|
||||||
|
import { Visibility } from "../../../generated/prisma/enums";
|
||||||
|
|
||||||
|
export async function repoCreateDeck(data: RepoInputCreateDeck): Promise<number> {
|
||||||
|
const deck = await prisma.deck.create({
|
||||||
|
data: {
|
||||||
|
name: data.name,
|
||||||
|
desc: data.desc ?? "",
|
||||||
|
userId: data.userId,
|
||||||
|
visibility: data.visibility ?? Visibility.PRIVATE,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return deck.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoUpdateDeck(input: RepoInputUpdateDeck): Promise<void> {
|
||||||
|
const { id, ...updateData } = input;
|
||||||
|
await prisma.deck.update({
|
||||||
|
where: { id },
|
||||||
|
data: updateData,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetDeckById(input: RepoInputGetDeckById): Promise<RepoOutputDeck | null> {
|
||||||
|
const deck = await prisma.deck.findUnique({
|
||||||
|
where: { id: input.id },
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deck) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: deck.id,
|
||||||
|
name: deck.name,
|
||||||
|
desc: deck.desc,
|
||||||
|
userId: deck.userId,
|
||||||
|
visibility: deck.visibility,
|
||||||
|
createdAt: deck.createdAt,
|
||||||
|
updatedAt: deck.updatedAt,
|
||||||
|
cardCount: deck._count?.cards ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetDecksByUserId(input: RepoInputGetDecksByUserId): Promise<RepoOutputDeck[]> {
|
||||||
|
const decks = await prisma.deck.findMany({
|
||||||
|
where: { userId: input.userId },
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return decks.map((deck) => ({
|
||||||
|
id: deck.id,
|
||||||
|
name: deck.name,
|
||||||
|
desc: deck.desc,
|
||||||
|
userId: deck.userId,
|
||||||
|
visibility: deck.visibility,
|
||||||
|
createdAt: deck.createdAt,
|
||||||
|
updatedAt: deck.updatedAt,
|
||||||
|
cardCount: deck._count?.cards ?? 0,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetPublicDecks(input: RepoInputGetPublicDecks = {}): Promise<RepoOutputPublicDeck[]> {
|
||||||
|
const { limit = 50, offset = 0, orderBy = "createdAt" } = input;
|
||||||
|
|
||||||
|
const decks = await prisma.deck.findMany({
|
||||||
|
where: { visibility: Visibility.PUBLIC },
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true, favorites: true },
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
select: { name: true, username: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: { [orderBy]: "desc" },
|
||||||
|
take: limit,
|
||||||
|
skip: offset,
|
||||||
|
});
|
||||||
|
|
||||||
|
return decks.map((deck) => ({
|
||||||
|
id: deck.id,
|
||||||
|
name: deck.name,
|
||||||
|
desc: deck.desc,
|
||||||
|
userId: deck.userId,
|
||||||
|
visibility: deck.visibility,
|
||||||
|
createdAt: deck.createdAt,
|
||||||
|
updatedAt: deck.updatedAt,
|
||||||
|
cardCount: deck._count?.cards ?? 0,
|
||||||
|
userName: deck.user?.name ?? null,
|
||||||
|
userUsername: deck.user?.username ?? null,
|
||||||
|
favoriteCount: deck._count?.favorites ?? 0,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoDeleteDeck(input: RepoInputDeleteDeck): Promise<void> {
|
||||||
|
await prisma.deck.delete({
|
||||||
|
where: { id: input.id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetUserIdByDeckId(deckId: number): Promise<string | null> {
|
||||||
|
const deck = await prisma.deck.findUnique({
|
||||||
|
where: { id: deckId },
|
||||||
|
select: { userId: true },
|
||||||
|
});
|
||||||
|
return deck?.userId ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetDeckOwnership(deckId: number): Promise<RepoOutputDeckOwnership | null> {
|
||||||
|
const deck = await prisma.deck.findUnique({
|
||||||
|
where: { id: deckId },
|
||||||
|
select: { userId: true },
|
||||||
|
});
|
||||||
|
return deck;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetPublicDeckById(input: RepoInputGetPublicDeckById): Promise<RepoOutputPublicDeck | null> {
|
||||||
|
const deck = await prisma.deck.findFirst({
|
||||||
|
where: {
|
||||||
|
id: input.deckId,
|
||||||
|
visibility: Visibility.PUBLIC,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true, favorites: true },
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
select: { name: true, username: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deck) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: deck.id,
|
||||||
|
name: deck.name,
|
||||||
|
desc: deck.desc,
|
||||||
|
userId: deck.userId,
|
||||||
|
visibility: deck.visibility,
|
||||||
|
createdAt: deck.createdAt,
|
||||||
|
updatedAt: deck.updatedAt,
|
||||||
|
cardCount: deck._count?.cards ?? 0,
|
||||||
|
userName: deck.user?.name ?? null,
|
||||||
|
userUsername: deck.user?.username ?? null,
|
||||||
|
favoriteCount: deck._count?.favorites ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoToggleDeckFavorite(input: RepoInputToggleDeckFavorite): Promise<RepoOutputDeckFavorite> {
|
||||||
|
const existing = await prisma.deckFavorite.findUnique({
|
||||||
|
where: {
|
||||||
|
userId_deckId: {
|
||||||
|
userId: input.userId,
|
||||||
|
deckId: input.deckId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
await prisma.deckFavorite.delete({
|
||||||
|
where: { id: existing.id },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await prisma.deckFavorite.create({
|
||||||
|
data: {
|
||||||
|
userId: input.userId,
|
||||||
|
deckId: input.deckId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const deck = await prisma.deck.findUnique({
|
||||||
|
where: { id: input.deckId },
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { favorites: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
isFavorited: !existing,
|
||||||
|
favoriteCount: deck?._count?.favorites ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoCheckDeckFavorite(input: RepoInputCheckDeckFavorite): Promise<RepoOutputDeckFavorite> {
|
||||||
|
const favorite = await prisma.deckFavorite.findUnique({
|
||||||
|
where: {
|
||||||
|
userId_deckId: {
|
||||||
|
userId: input.userId,
|
||||||
|
deckId: input.deckId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const deck = await prisma.deck.findUnique({
|
||||||
|
where: { id: input.deckId },
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { favorites: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
isFavorited: !!favorite,
|
||||||
|
favoriteCount: deck?._count?.favorites ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoSearchPublicDecks(input: RepoInputSearchPublicDecks): Promise<RepoOutputPublicDeck[]> {
|
||||||
|
const { query, limit = 50, offset = 0 } = input;
|
||||||
|
|
||||||
|
const decks = await prisma.deck.findMany({
|
||||||
|
where: {
|
||||||
|
visibility: Visibility.PUBLIC,
|
||||||
|
OR: [
|
||||||
|
{ name: { contains: query, mode: "insensitive" } },
|
||||||
|
{ desc: { contains: query, mode: "insensitive" } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true, favorites: true },
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
select: { name: true, username: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: { createdAt: "desc" },
|
||||||
|
take: limit,
|
||||||
|
skip: offset,
|
||||||
|
});
|
||||||
|
|
||||||
|
return decks.map((deck) => ({
|
||||||
|
id: deck.id,
|
||||||
|
name: deck.name,
|
||||||
|
desc: deck.desc,
|
||||||
|
userId: deck.userId,
|
||||||
|
visibility: deck.visibility,
|
||||||
|
createdAt: deck.createdAt,
|
||||||
|
updatedAt: deck.updatedAt,
|
||||||
|
cardCount: deck._count?.cards ?? 0,
|
||||||
|
userName: deck.user?.name ?? null,
|
||||||
|
userUsername: deck.user?.username ?? null,
|
||||||
|
favoriteCount: deck._count?.favorites ?? 0,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function repoGetUserFavoriteDecks(
|
||||||
|
input: RepoInputGetUserFavoriteDecks,
|
||||||
|
): Promise<RepoOutputUserFavoriteDeck[]> {
|
||||||
|
const favorites = await prisma.deckFavorite.findMany({
|
||||||
|
where: { userId: input.userId },
|
||||||
|
include: {
|
||||||
|
deck: {
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: { cards: true, favorites: true },
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
select: { name: true, username: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: { createdAt: "desc" },
|
||||||
|
});
|
||||||
|
|
||||||
|
return favorites.map((fav) => ({
|
||||||
|
id: fav.deck.id,
|
||||||
|
name: fav.deck.name,
|
||||||
|
desc: fav.deck.desc,
|
||||||
|
userId: fav.deck.userId,
|
||||||
|
visibility: fav.deck.visibility,
|
||||||
|
createdAt: fav.deck.createdAt,
|
||||||
|
updatedAt: fav.deck.updatedAt,
|
||||||
|
cardCount: fav.deck._count?.cards ?? 0,
|
||||||
|
userName: fav.deck.user?.name ?? null,
|
||||||
|
userUsername: fav.deck.user?.username ?? null,
|
||||||
|
favoriteCount: fav.deck._count?.favorites ?? 0,
|
||||||
|
favoritedAt: fav.createdAt,
|
||||||
|
}));
|
||||||
|
}
|
||||||
83
src/modules/deck/deck-service-dto.ts
Normal file
83
src/modules/deck/deck-service-dto.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import { Visibility } from "../../../generated/prisma/enums";
|
||||||
|
|
||||||
|
export type ServiceInputCreateDeck = {
|
||||||
|
name: string;
|
||||||
|
desc?: string;
|
||||||
|
userId: string;
|
||||||
|
visibility?: Visibility;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputUpdateDeck = {
|
||||||
|
deckId: number;
|
||||||
|
name?: string;
|
||||||
|
desc?: string;
|
||||||
|
visibility?: Visibility;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputDeleteDeck = {
|
||||||
|
deckId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputGetDeckById = {
|
||||||
|
deckId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputGetDecksByUserId = {
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputGetPublicDecks = {
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputCheckOwnership = {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputDeck = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
desc: string;
|
||||||
|
userId: string;
|
||||||
|
visibility: Visibility;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
cardCount?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputPublicDeck = ServiceOutputDeck & {
|
||||||
|
userName: string | null;
|
||||||
|
userUsername: string | null;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputToggleDeckFavorite = {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputCheckDeckFavorite = {
|
||||||
|
deckId: number;
|
||||||
|
userId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputSearchPublicDecks = {
|
||||||
|
query: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceInputGetPublicDeckById = {
|
||||||
|
deckId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputDeckFavorite = {
|
||||||
|
isFavorited: boolean;
|
||||||
|
favoriteCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ServiceOutputUserFavoriteDeck = ServiceOutputPublicDeck & {
|
||||||
|
favoritedAt: Date;
|
||||||
|
};
|
||||||
166
src/modules/deck/deck-service.ts
Normal file
166
src/modules/deck/deck-service.ts
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
import { createLogger } from "@/lib/logger";
|
||||||
|
import {
|
||||||
|
ServiceInputCreateDeck,
|
||||||
|
ServiceInputUpdateDeck,
|
||||||
|
ServiceInputDeleteDeck,
|
||||||
|
ServiceInputGetDeckById,
|
||||||
|
ServiceInputGetDecksByUserId,
|
||||||
|
ServiceInputGetPublicDecks,
|
||||||
|
ServiceInputCheckOwnership,
|
||||||
|
ServiceOutputDeck,
|
||||||
|
ServiceOutputPublicDeck,
|
||||||
|
ServiceInputToggleDeckFavorite,
|
||||||
|
ServiceInputCheckDeckFavorite,
|
||||||
|
ServiceInputSearchPublicDecks,
|
||||||
|
ServiceInputGetPublicDeckById,
|
||||||
|
ServiceOutputDeckFavorite,
|
||||||
|
ServiceOutputUserFavoriteDeck,
|
||||||
|
} from "./deck-service-dto";
|
||||||
|
import {
|
||||||
|
repoCreateDeck,
|
||||||
|
repoUpdateDeck,
|
||||||
|
repoGetDeckById,
|
||||||
|
repoGetDecksByUserId,
|
||||||
|
repoGetPublicDecks,
|
||||||
|
repoDeleteDeck,
|
||||||
|
repoGetUserIdByDeckId,
|
||||||
|
repoToggleDeckFavorite,
|
||||||
|
repoCheckDeckFavorite,
|
||||||
|
repoSearchPublicDecks,
|
||||||
|
repoGetPublicDeckById,
|
||||||
|
repoGetUserFavoriteDecks,
|
||||||
|
} from "./deck-repository";
|
||||||
|
|
||||||
|
const log = createLogger("deck-service");
|
||||||
|
|
||||||
|
export async function serviceCheckOwnership(input: ServiceInputCheckOwnership): Promise<boolean> {
|
||||||
|
const ownerId = await repoGetUserIdByDeckId(input.deckId);
|
||||||
|
return ownerId === input.userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceCreateDeck(input: ServiceInputCreateDeck): Promise<{ success: boolean; deckId?: number; message: string }> {
|
||||||
|
try {
|
||||||
|
log.info("Creating deck", { name: input.name, userId: input.userId });
|
||||||
|
const deckId = await repoCreateDeck(input);
|
||||||
|
log.info("Deck created successfully", { deckId });
|
||||||
|
return { success: true, deckId, message: "Deck created successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to create deck", { error });
|
||||||
|
return { success: false, message: "Failed to create deck" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceUpdateDeck(input: ServiceInputUpdateDeck): Promise<{ success: boolean; message: string }> {
|
||||||
|
try {
|
||||||
|
log.info("Updating deck", { deckId: input.deckId });
|
||||||
|
await repoUpdateDeck({
|
||||||
|
id: input.deckId,
|
||||||
|
name: input.name,
|
||||||
|
desc: input.desc,
|
||||||
|
visibility: input.visibility,
|
||||||
|
});
|
||||||
|
log.info("Deck updated successfully", { deckId: input.deckId });
|
||||||
|
return { success: true, message: "Deck updated successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to update deck", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to update deck" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceDeleteDeck(input: ServiceInputDeleteDeck): Promise<{ success: boolean; message: string }> {
|
||||||
|
try {
|
||||||
|
log.info("Deleting deck", { deckId: input.deckId });
|
||||||
|
await repoDeleteDeck({ id: input.deckId });
|
||||||
|
log.info("Deck deleted successfully", { deckId: input.deckId });
|
||||||
|
return { success: true, message: "Deck deleted successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to delete deck", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to delete deck" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetDeckById(input: ServiceInputGetDeckById): Promise<{ success: boolean; data?: ServiceOutputDeck; message: string }> {
|
||||||
|
try {
|
||||||
|
const deck = await repoGetDeckById({ id: input.deckId });
|
||||||
|
if (!deck) {
|
||||||
|
return { success: false, message: "Deck not found" };
|
||||||
|
}
|
||||||
|
return { success: true, data: deck, message: "Deck retrieved successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to get deck", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to get deck" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetDecksByUserId(input: ServiceInputGetDecksByUserId): Promise<{ success: boolean; data?: ServiceOutputDeck[]; message: string }> {
|
||||||
|
try {
|
||||||
|
const decks = await repoGetDecksByUserId(input);
|
||||||
|
return { success: true, data: decks, message: "Decks retrieved successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to get decks", { error, userId: input.userId });
|
||||||
|
return { success: false, message: "Failed to get decks" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetPublicDecks(input: ServiceInputGetPublicDecks = {}): Promise<{ success: boolean; data?: ServiceOutputPublicDeck[]; message: string }> {
|
||||||
|
try {
|
||||||
|
const decks = await repoGetPublicDecks(input);
|
||||||
|
return { success: true, data: decks, message: "Public decks retrieved successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to get public decks", { error });
|
||||||
|
return { success: false, message: "Failed to get public decks" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetPublicDeckById(input: ServiceInputGetPublicDeckById): Promise<{ success: boolean; data?: ServiceOutputPublicDeck; message: string }> {
|
||||||
|
try {
|
||||||
|
const deck = await repoGetPublicDeckById(input);
|
||||||
|
if (!deck) {
|
||||||
|
return { success: false, message: "Deck not found or not public" };
|
||||||
|
}
|
||||||
|
return { success: true, data: deck, message: "Deck retrieved successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to get public deck", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to get deck" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceToggleDeckFavorite(input: ServiceInputToggleDeckFavorite): Promise<{ success: boolean; data?: ServiceOutputDeckFavorite; message: string }> {
|
||||||
|
try {
|
||||||
|
const result = await repoToggleDeckFavorite(input);
|
||||||
|
return { success: true, data: result, message: "Favorite toggled successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to toggle deck favorite", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to toggle favorite" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceCheckDeckFavorite(input: ServiceInputCheckDeckFavorite): Promise<{ success: boolean; data?: ServiceOutputDeckFavorite; message: string }> {
|
||||||
|
try {
|
||||||
|
const result = await repoCheckDeckFavorite(input);
|
||||||
|
return { success: true, data: result, message: "Favorite status retrieved" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to check deck favorite", { error, deckId: input.deckId });
|
||||||
|
return { success: false, message: "Failed to check favorite status" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceSearchPublicDecks(input: ServiceInputSearchPublicDecks): Promise<{ success: boolean; data?: ServiceOutputPublicDeck[]; message: string }> {
|
||||||
|
try {
|
||||||
|
const decks = await repoSearchPublicDecks(input);
|
||||||
|
return { success: true, data: decks, message: "Search completed successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to search public decks", { error, query: input.query });
|
||||||
|
return { success: false, message: "Search failed" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function serviceGetUserFavoriteDecks(userId: string): Promise<{ success: boolean; data?: ServiceOutputUserFavoriteDeck[]; message: string }> {
|
||||||
|
try {
|
||||||
|
const favorites = await repoGetUserFavoriteDecks({ userId });
|
||||||
|
return { success: true, data: favorites, message: "Favorite decks retrieved successfully" };
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to get user favorite decks", { error, userId });
|
||||||
|
return { success: false, message: "Failed to get favorite decks" };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
import { TSharedItem } from "@/shared/dictionary-type";
|
|
||||||
import { LENGTH_MAX_DICTIONARY_TEXT, LENGTH_MAX_LANGUAGE, LENGTH_MIN_DICTIONARY_TEXT, LENGTH_MIN_LANGUAGE } from "@/shared/constant";
|
|
||||||
import { generateValidator } from "@/utils/validate";
|
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
|
import { generateValidator } from "@/utils/validate";
|
||||||
|
|
||||||
const schemaActionInputLookUpDictionary = z.object({
|
export const schemaActionLookUpDictionary = z.object({
|
||||||
text: z.string().min(LENGTH_MIN_DICTIONARY_TEXT).max(LENGTH_MAX_DICTIONARY_TEXT),
|
text: z.string().min(1),
|
||||||
queryLang: z.string().min(LENGTH_MIN_LANGUAGE).max(LENGTH_MAX_LANGUAGE),
|
queryLang: z.string().min(1),
|
||||||
forceRelook: z.boolean(),
|
definitionLang: z.string().min(1),
|
||||||
definitionLang: z.string().min(LENGTH_MIN_LANGUAGE).max(LENGTH_MAX_LANGUAGE),
|
|
||||||
userId: z.string().optional()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ActionInputLookUpDictionary = z.infer<typeof schemaActionInputLookUpDictionary>;
|
export type ActionInputLookUpDictionary = z.infer<typeof schemaActionLookUpDictionary>;
|
||||||
|
export const validateActionInputLookUpDictionary = generateValidator(schemaActionLookUpDictionary);
|
||||||
export const validateActionInputLookUpDictionary = generateValidator(schemaActionInputLookUpDictionary);
|
|
||||||
|
|
||||||
export type ActionOutputLookUpDictionary = {
|
export type ActionOutputLookUpDictionary = {
|
||||||
message: string,
|
|
||||||
success: boolean;
|
success: boolean;
|
||||||
data?: TSharedItem;
|
message: string;
|
||||||
|
data?: {
|
||||||
|
standardForm: string;
|
||||||
|
entries: Array<{
|
||||||
|
ipa?: string;
|
||||||
|
definition: string;
|
||||||
|
partOfSpeech?: string;
|
||||||
|
example: string;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,38 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import { ActionInputLookUpDictionary, ActionOutputLookUpDictionary, validateActionInputLookUpDictionary } from "./dictionary-action-dto";
|
import { executeDictionaryLookup } from "@/lib/bigmodel/dictionary/orchestrator";
|
||||||
import { ValidateError } from "@/lib/errors";
|
|
||||||
import { createLogger } from "@/lib/logger";
|
import { createLogger } from "@/lib/logger";
|
||||||
import { serviceLookUp } from "./dictionary-service";
|
import { LookUpError } from "@/lib/errors";
|
||||||
|
import {
|
||||||
|
ActionInputLookUpDictionary,
|
||||||
|
ActionOutputLookUpDictionary,
|
||||||
|
validateActionInputLookUpDictionary,
|
||||||
|
} from "./dictionary-action-dto";
|
||||||
|
|
||||||
const log = createLogger("dictionary-action");
|
const log = createLogger("dictionary-action");
|
||||||
|
|
||||||
export const actionLookUpDictionary = async (dto: ActionInputLookUpDictionary): Promise<ActionOutputLookUpDictionary> => {
|
export async function actionLookUpDictionary(
|
||||||
|
input: unknown,
|
||||||
|
): Promise<ActionOutputLookUpDictionary> {
|
||||||
try {
|
try {
|
||||||
|
const validated = validateActionInputLookUpDictionary(input);
|
||||||
|
|
||||||
|
const result = await executeDictionaryLookup(
|
||||||
|
validated.text,
|
||||||
|
validated.queryLang,
|
||||||
|
validated.definitionLang
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: 'success',
|
|
||||||
success: true,
|
success: true,
|
||||||
data: await serviceLookUp(validateActionInputLookUpDictionary(dto))
|
message: "Lookup successful",
|
||||||
|
data: result,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ValidateError) {
|
if (e instanceof LookUpError) {
|
||||||
return {
|
return { success: false, message: e.message };
|
||||||
success: false,
|
|
||||||
message: e.message
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
log.error("Dictionary lookup failed", { error: e instanceof Error ? e.message : String(e) });
|
log.error("Dictionary lookup failed", { error: e instanceof Error ? e.message : String(e) });
|
||||||
return {
|
return { success: false, message: "Lookup failed" };
|
||||||
success: false,
|
}
|
||||||
message: 'Unknown error occured.'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { TSharedItem } from "@/shared/dictionary-type";
|
|
||||||
|
|
||||||
export type RepoInputCreateDictionaryLookUp = {
|
|
||||||
userId?: string;
|
|
||||||
text: string;
|
|
||||||
queryLang: string;
|
|
||||||
definitionLang: string;
|
|
||||||
dictionaryItemId?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RepoOutputSelectLastLookUpResult = TSharedItem & {id: number} | null;
|
|
||||||
|
|
||||||
export type RepoInputCreateDictionaryItem = {
|
|
||||||
standardForm: string;
|
|
||||||
queryLang: string;
|
|
||||||
definitionLang: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RepoInputCreateDictionaryEntry = {
|
|
||||||
itemId: number;
|
|
||||||
ipa?: string;
|
|
||||||
definition: string;
|
|
||||||
partOfSpeech?: string;
|
|
||||||
example: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RepoInputCreateDictionaryEntryWithoutItemId = {
|
|
||||||
ipa?: string;
|
|
||||||
definition: string;
|
|
||||||
partOfSpeech?: string;
|
|
||||||
example: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RepoInputSelectLastLookUpResult = {
|
|
||||||
text: string,
|
|
||||||
queryLang: string,
|
|
||||||
definitionLang: string;
|
|
||||||
};
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
import { stringNormalize } from "@/utils/string";
|
|
||||||
import {
|
|
||||||
RepoInputCreateDictionaryEntry,
|
|
||||||
RepoInputCreateDictionaryEntryWithoutItemId,
|
|
||||||
RepoInputCreateDictionaryItem,
|
|
||||||
RepoInputCreateDictionaryLookUp,
|
|
||||||
RepoInputSelectLastLookUpResult,
|
|
||||||
RepoOutputSelectLastLookUpResult,
|
|
||||||
} from "./dictionary-repository-dto";
|
|
||||||
import { prisma } from "@/lib/db";
|
|
||||||
|
|
||||||
export async function repoSelectLastLookUpResult(dto: RepoInputSelectLastLookUpResult): Promise<RepoOutputSelectLastLookUpResult> {
|
|
||||||
const result = await prisma.dictionaryLookUp.findFirst({
|
|
||||||
where: {
|
|
||||||
normalizedText: stringNormalize(dto.text),
|
|
||||||
queryLang: dto.queryLang,
|
|
||||||
definitionLang: dto.definitionLang,
|
|
||||||
dictionaryItemId: {
|
|
||||||
not: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
include: {
|
|
||||||
dictionaryItem: {
|
|
||||||
include: {
|
|
||||||
entries: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
orderBy: {
|
|
||||||
createdAt: 'desc'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (result && result.dictionaryItem) {
|
|
||||||
const item = result.dictionaryItem;
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
standardForm: item.standardForm,
|
|
||||||
entries: item.entries.filter(v => !!v).map(v => {
|
|
||||||
return {
|
|
||||||
ipa: v.ipa || undefined,
|
|
||||||
definition: v.definition,
|
|
||||||
partOfSpeech: v.partOfSpeech || undefined,
|
|
||||||
example: v.example
|
|
||||||
};
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function repoCreateLookUp(content: RepoInputCreateDictionaryLookUp) {
|
|
||||||
return (await prisma.dictionaryLookUp.create({
|
|
||||||
data: { ...content, normalizedText: stringNormalize(content.text) }
|
|
||||||
})).id;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function repoCreateLookUpWithItemAndEntries(
|
|
||||||
itemData: RepoInputCreateDictionaryItem,
|
|
||||||
lookUpData: RepoInputCreateDictionaryLookUp,
|
|
||||||
entries: RepoInputCreateDictionaryEntryWithoutItemId[]
|
|
||||||
) {
|
|
||||||
return await prisma.$transaction(async (tx) => {
|
|
||||||
const item = await tx.dictionaryItem.create({
|
|
||||||
data: itemData
|
|
||||||
});
|
|
||||||
|
|
||||||
await tx.dictionaryLookUp.create({
|
|
||||||
data: {
|
|
||||||
...lookUpData,
|
|
||||||
normalizedText: stringNormalize(lookUpData.text),
|
|
||||||
dictionaryItemId: item.id
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const entry of entries) {
|
|
||||||
await tx.dictionaryEntry.create({
|
|
||||||
data: {
|
|
||||||
...entry,
|
|
||||||
itemId: item.id
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return item.id;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user