diff --git a/scripts/verify-password.ts b/scripts/verify-password.ts deleted file mode 100644 index ee8509c3..00000000 --- a/scripts/verify-password.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from "@prisma/client" -import { compare } from "bcryptjs" - -const prisma = new PrismaClient() - -async function main() { - const user = await prisma.user.findUnique({ - where: { email: 'admin@localhost' }, - }) - - if (!user) { - console.log("User not found") - return - } - - const isValid = await compare("123456", user.password) - console.log("Password '123456' is valid:", isValid) -} - -main() - .catch((e) => { - console.error(e) - process.exit(1) - }) - .finally(async () => { - await prisma.$disconnect() - }) diff --git a/src/app/tags/page.tsx b/src/app/tags/page.tsx index c39a96e9..3e98db59 100644 --- a/src/app/tags/page.tsx +++ b/src/app/tags/page.tsx @@ -8,7 +8,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { STANDARD_TAGS } from "@/lib/knowledge-tags"; import { getCustomTags, addCustomTag, removeCustomTag, type CustomTagsData } from "@/lib/custom-tags"; import Link from "next/link"; -import { ArrowLeft, TrendingUp, Plus, Trash2 } from "lucide-react"; +import { ArrowLeft, TrendingUp, Plus, Trash2, ChevronDown, ChevronRight } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; @@ -24,9 +24,10 @@ export default function TagsPage() { const [loading, setLoading] = useState(true); // 自定义标签状态 - const [customTags, setCustomTags] = useState({ math: [], physics: [], chemistry: [], other: [] }); + const [customTags, setCustomTags] = useState({ math: [], physics: [], chemistry: [], english: [], other: [] }); const [newTagSubject, setNewTagSubject] = useState("math"); const [newTagName, setNewTagName] = useState(""); + const [expandedSubjects, setExpandedSubjects] = useState>({}); useEffect(() => { fetchStats(); @@ -78,42 +79,65 @@ export default function TagsPage() { // 渲染标准标签库 const renderStandardTags = () => { const subjects = Object.entries(STANDARD_TAGS); + + const toggleSubject = (subjectKey: string) => { + setExpandedSubjects(prev => ({ + ...prev, + [subjectKey]: !prev[subjectKey] + })); + }; + return subjects.map(([subjectKey, subjectData]) => { // @ts-ignore const subjectName = t.tags?.subjects?.[subjectKey] || subjectKey; const categories = Object.entries(subjectData); + const isExpanded = expandedSubjects[subjectKey]; + return ( - {subjectName} - - {categories.map(([categoryKey, categoryData]) => { - const tags: string[] = []; - const extractTags = (data: any) => { - if (Array.isArray(data)) tags.push(...data); - else if (typeof data === 'object') Object.values(data).forEach(extractTags); - }; - extractTags(categoryData); - if (tags.length === 0) return null; - // @ts-ignore - const categoryName = t.tags?.categories?.[categoryKey] || categoryKey; - return ( -
-

{categoryName} ({tags.length})

-
- {tags.map((tag) => { - const stat = stats.find((s) => s.tag === tag); - return ( - - {tag} - {stat && ({stat.count})} - - ); - })} + toggleSubject(subjectKey)} + > + + {isExpanded ? : } + {subjectName} + + + {isExpanded ? (language === 'zh' ? '收起' : 'Collapse') : (language === 'zh' ? '展开' : 'Expand')} + + + {isExpanded && ( + + {categories.map(([categoryKey, categoryData]) => { + const tags: string[] = []; + const extractTags = (data: any) => { + if (Array.isArray(data)) tags.push(...data); + else if (typeof data === 'object') Object.values(data).forEach(extractTags); + }; + extractTags(categoryData); + if (tags.length === 0) return null; + // @ts-ignore + const categoryName = t.tags?.categories?.[categoryKey] || categoryKey; + return ( +
+

{categoryName} ({tags.length})

+
+ {tags.map((tag) => { + const stat = stats.find((s) => s.tag === tag); + return ( + + {tag} + {stat && ({stat.count})} + + ); + })} +
-
- ); - })} - + ); + })} + + )} ); }); @@ -123,12 +147,13 @@ export default function TagsPage() { const renderCustomTags = () => { const subjects = [ { key: 'math' as const, name: t.tags?.subjects?.math || 'Math' }, + { key: 'english' as const, name: t.tags?.subjects?.english || 'English' }, { key: 'physics' as const, name: t.tags?.subjects?.physics || 'Physics' }, { key: 'chemistry' as const, name: t.tags?.subjects?.chemistry || 'Chemistry' }, { key: 'other' as const, name: t.tags?.subjects?.other || 'Other' }, ]; - const totalCount = customTags.math.length + customTags.physics.length + customTags.chemistry.length + customTags.other.length; + const totalCount = customTags.math.length + customTags.physics.length + customTags.chemistry.length + customTags.english.length + customTags.other.length; return (
@@ -140,6 +165,7 @@ export default function TagsPage() { {t.tags?.subjects?.math || "Math"} + {t.tags?.subjects?.english || "English"} {t.tags?.subjects?.physics || "Physics"} {t.tags?.subjects?.chemistry || "Chemistry"} {t.tags?.subjects?.other || "Other"} diff --git a/src/lib/custom-tags.ts b/src/lib/custom-tags.ts index 76d802ce..561147fa 100644 --- a/src/lib/custom-tags.ts +++ b/src/lib/custom-tags.ts @@ -6,6 +6,7 @@ const CUSTOM_TAGS_KEY = 'wrongnotebook_custom_tags'; export interface CustomTagsData { math: string[]; + english: string[]; physics: string[]; chemistry: string[]; other: string[]; @@ -16,18 +17,18 @@ export interface CustomTagsData { */ export function getCustomTags(): CustomTagsData { if (typeof window === 'undefined') { - return { math: [], physics: [], chemistry: [], other: [] }; + return { math: [], english: [], physics: [], chemistry: [], other: [] }; } try { const stored = localStorage.getItem(CUSTOM_TAGS_KEY); if (!stored) { - return { math: [], physics: [], chemistry: [], other: [] }; + return { math: [], english: [], physics: [], chemistry: [], other: [] }; } return JSON.parse(stored); } catch (error) { console.error('Failed to load custom tags:', error); - return { math: [], physics: [], chemistry: [], other: [] }; + return { math: [], english: [], physics: [], chemistry: [], other: [] }; } } @@ -84,6 +85,7 @@ export function getAllCustomTagsFlat(): string[] { const tags = getCustomTags(); return [ ...tags.math, + ...tags.english, ...tags.physics, ...tags.chemistry, ...tags.other, @@ -114,7 +116,7 @@ export function importCustomTags(jsonString: string): boolean { const tags = JSON.parse(jsonString); // 验证格式 - if (!tags.math || !tags.physics || !tags.chemistry || !tags.other) { + if (!tags.math || !tags.english || !tags.physics || !tags.chemistry || !tags.other) { throw new Error('Invalid format'); } @@ -141,9 +143,10 @@ export function getCustomTagsStats(): Record { const tags = getCustomTags(); return { math: tags.math.length, + english: tags.english.length, physics: tags.physics.length, chemistry: tags.chemistry.length, other: tags.other.length, - total: tags.math.length + tags.physics.length + tags.chemistry.length + tags.other.length, + total: tags.math.length + tags.english.length + tags.physics.length + tags.chemistry.length + tags.other.length, }; } diff --git a/src/lib/knowledge-tags.ts b/src/lib/knowledge-tags.ts index 25d4c38b..a605cda5 100644 --- a/src/lib/knowledge-tags.ts +++ b/src/lib/knowledge-tags.ts @@ -190,6 +190,69 @@ export const STANDARD_TAGS = { ], }, + // ==================== 英语 ==================== + english: { + grammar: [ + "名词", + "代词", + "冠词", + "数词", + "形容词", + "副词", + "介词", + "连词", + "动词", + "动词时态", + "一般现在时", + "一般过去时", + "一般将来时", + "现在进行时", + "过去进行时", + "现在完成时", + "过去完成时", + "被动语态", + "非谓语动词", + "动词不定式", + "动名词", + "分词", + "主谓一致", + ], + sentence: [ + "句子成分", + "主语", + "谓语", + "宾语", + "定语", + "状语", + "补语", + "简单句", + "并列句", + "复合句", + "宾语从句", + "定语从句", + "状语从句", + "主语从句", + "表语从句", + "同位语从句", + "倒装句", + "强调句", + "虚拟语气", + ], + reading: [ + "阅读理解", + "完形填空", + "七选五", + "任务型阅读", + ], + writing: [ + "书面表达", + "应用文", + "记叙文", + "议论文", + "说明文", + ], + }, + // ==================== 物理 ==================== physics: { // 力学 @@ -436,6 +499,7 @@ export const STANDARD_TAGS = { "溶质质量分数", ], }, + }; // 标签别名映射表 - 将AI可能生成的不同表达映射到标准标签 @@ -535,6 +599,22 @@ export const TAG_ALIASES: Record = { "一次函数性质": "一次函数的性质", "函数": "函数的概念", + // ========== 英语相关 ========== + "时态": "动词时态", + "语态": "被动语态", + "从句": "复合句", + "定从": "定语从句", + "宾从": "宾语从句", + "状从": "状语从句", + "虚拟": "虚拟语气", + "倒装": "倒装句", + "非谓语": "非谓语动词", + "不定式": "动词不定式", + "ing": "动名词", + "阅读": "阅读理解", + "完形": "完形填空", + "作文": "书面表达", + // ========== 代数相关 ========== "因式": "因式分解", "分解因式": "因式分解", diff --git a/src/lib/translations.ts b/src/lib/translations.ts index 6050ed1f..49eb159c 100644 --- a/src/lib/translations.ts +++ b/src/lib/translations.ts @@ -165,6 +165,7 @@ export const translations = { }, subjects: { math: "Math", + english: "English", physics: "Physics", chemistry: "Chemistry", other: "Other", @@ -184,6 +185,10 @@ export const translations = { compounds: "Compounds", reactions: "Reactions", calculation: "Calculation", + grammar: "Grammar", + sentence: "Sentence", + reading: "Reading", + writing: "Writing", }, custom: { addTitle: "Add Custom Tag", @@ -430,6 +435,7 @@ export const translations = { }, subjects: { math: "数学", + english: "英语", physics: "物理", chemistry: "化学", other: "其他", @@ -449,6 +455,10 @@ export const translations = { compounds: "化合物", reactions: "反应", calculation: "计算", + grammar: "语法", + sentence: "句法", + reading: "阅读", + writing: "写作", }, custom: { addTitle: "添加自定义标签",