Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto eol=lf
* text=auto eol=lf

*.png binary
*.jpg binary
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: false
contact_links:
- name: 安全漏洞报告
url: https://github.com/hacksynth/ose/security/advisories/new
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 本地运行时产物(包括 .env.local、storage/、备份目录)一律不要提交。
# 本地运行时产物(包括 .env.local、storage/、备份目录)一律不要提交。

node_modules
.next
Expand Down
2 changes: 1 addition & 1 deletion SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 支持说明
# 支持说明

如果你在使用 OSE 时遇到问题:

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FlatCompat } from "@eslint/eslintrc";
import { FlatCompat } from "@eslint/eslintrc";

const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
Expand Down
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
/** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.TAURI_BUILD || process.env.DOCKER_BUILD ? "standalone" : undefined,
images: {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@
"tauri:icons": "tauri icon src-tauri/icons/app-icon.png",
"verify:portable": "node scripts/verify-portable.js",
"screenshots": "node scripts/capture-screenshots.mjs",
"check:bom": "node scripts/check-no-bom.js",
"prepare": "husky && npx prisma generate --schema src/prisma/schema.prisma"
},
"prisma": {
"schema": "src/prisma/schema.prisma",
"seed": "tsx src/prisma/seed.ts"
},
"lint-staged": {
"*.{ts,tsx,mjs,cjs,js,json,css,md,yml,yaml,d.ts}": [
"node scripts/check-no-bom.js"
],
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
Expand Down
51 changes: 51 additions & 0 deletions scripts/check-no-bom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const BOM = Buffer.from([0xef, 0xbb, 0xbf]);
const fixMode = process.argv.includes('--fix');
const explicitFiles = process.argv.slice(2).filter(a => !a.startsWith('--'));

function getTrackedFiles() {
return execSync('git ls-files', { encoding: 'utf8' })
.trim()
.split('\n')
.filter(Boolean);
}

function hasBom(filePath) {
try {
const buf = fs.readFileSync(filePath);
return buf.length >= 3 && buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf;
} catch {
return false;
}
}

function stripBom(filePath) {
const buf = fs.readFileSync(filePath);
fs.writeFileSync(filePath, buf.slice(3));
}

const files = explicitFiles.length > 0 ? explicitFiles : getTrackedFiles();
const bomFiles = files.filter(f => fs.existsSync(f) && hasBom(f));

if (bomFiles.length === 0) {
console.log('No BOM found.');
process.exit(0);
}

if (fixMode) {
bomFiles.forEach(f => {
stripBom(f);
console.log('Fixed:', f);
});
console.log(`Removed BOM from ${bomFiles.length} file(s).`);
process.exit(0);
} else {
bomFiles.forEach(f => console.error('BOM detected:', f));
console.error(`\n${bomFiles.length} file(s) contain UTF-8 BOM. Run with --fix to remove them.`);
process.exit(1);
}
2 changes: 1 addition & 1 deletion src/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense } from "react";
import { Suspense } from "react";
import { DecorativeBackground } from "@/components/decorative-background";
import { LoginForm } from "@/components/login-form";

Expand Down
2 changes: 1 addition & 1 deletion src/app/(auth)/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DecorativeBackground } from "@/components/decorative-background";
import { DecorativeBackground } from "@/components/decorative-background";
import { RegisterForm } from "@/components/register-form";

export default function RegisterPage() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/analysis/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from 'next/link';
import Link from 'next/link';
import { redirect } from 'next/navigation';
import { auth } from '@/lib/auth';
import { getUserAnalysis } from '@/lib/analysis';
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/exam/[attemptId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound, redirect } from "next/navigation";
import { notFound, redirect } from "next/navigation";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { ExamAttemptClient } from "@/components/exam-attempt-client";
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/exam/[attemptId]/result/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from 'next/link';
import Link from 'next/link';
import { notFound, redirect } from 'next/navigation';
import { CheckCircle2, XCircle } from 'lucide-react';
import { auth } from '@/lib/auth';
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "next/navigation";
import { redirect } from "next/navigation";
import { auth } from "@/lib/auth";
import { MainNav } from "@/components/main-nav";
import { DecorativeBackground } from "@/components/decorative-background";
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Loader2 } from "lucide-react";
import { Loader2 } from "lucide-react";
import { Card } from "@/components/ui/card";

export default function Loading() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/plan/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound, redirect } from 'next/navigation';
import { notFound, redirect } from 'next/navigation';
import { auth } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import { Card } from '@/components/ui/card';
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/practice/case/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound } from "next/navigation";
import { prisma } from "@/lib/prisma";
import { CaseAnswerClient } from "@/components/case-answer-client";

Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/practice/random/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "next/navigation";
import { redirect } from "next/navigation";

export default function RandomPracticePage() {
redirect("/practice");
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/practice/session/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense } from "react";
import { Suspense } from "react";
import { PracticeSession } from "@/components/practice-session";

export default function PracticeSessionPage() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from 'next/navigation';
import { redirect } from 'next/navigation';
import { auth } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import { getChoiceAnswerEvents } from '@/lib/knowledge-stats';
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/wrong-notes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WrongNotesClient } from "@/components/wrong-notes-client";
import { WrongNotesClient } from "@/components/wrong-notes-client";

export default function WrongNotesPage() {
return <WrongNotesClient />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/ai/diagnosis/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { getAIProvider, isAIConfigured } from "@/lib/ai";
import { checkAIRateLimit } from "@/lib/ai/rate-limit";
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/ai/explain/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { buildAIProvider, isAIConfigured, resolveAIConfig } from "@/lib/ai";
import { checkAIRateLimit } from "@/lib/ai/rate-limit";
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/ai/status/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { getAIStatus } from "@/lib/ai";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/analysis/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { getUserAnalysis } from "@/lib/analysis";
import { prisma } from "@/lib/prisma";
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { handlers } from "@/lib/auth";
import { handlers } from "@/lib/auth";

export const { GET, POST } = handlers;
2 changes: 1 addition & 1 deletion src/app/api/exam/[id]/result/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/knowledge/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from 'next/server';
import { NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/knowledge/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from 'next/server';
import { NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import { getChoiceAnswerEvents } from '@/lib/knowledge-stats';
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/practice/cases/[id]/result/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/practice/cases/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/practice/summary/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/profile/heatmap/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { getChinaDateKey, getRecentDateKeys } from "@/lib/stats";
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/profile/knowledge-stats/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from 'next/server';
import { NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import { getChoiceAnswerEvents } from '@/lib/knowledge-stats';
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/profile/stats/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { getContinuousDays, getLongestStreak } from "@/lib/stats";
Expand Down
2 changes: 1 addition & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@tailwind base;
@tailwind base;
@tailwind components;
@tailwind utilities;

Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Metadata } from 'next';
import type { Metadata } from 'next';
import { Nunito } from 'next/font/google';
import type { Viewport } from 'next';
import './globals.css';
Expand Down
2 changes: 1 addition & 1 deletion src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from 'next/link';
import Link from 'next/link';
import { Button } from '@/components/ui/button';
import { DecorativeBackground } from '@/components/decorative-background';

Expand Down
2 changes: 1 addition & 1 deletion src/components/decorative-background.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function DecorativeBackground() {
export function DecorativeBackground() {
return (
<div aria-hidden="true" className="absolute inset-0 overflow-hidden">
<div className="ose-orb -left-24 top-20 h-72 w-72 bg-softYellow" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/practice-session.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client';
'use client';

import { useEffect, useMemo, useState } from 'react';
import Link from 'next/link';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as AvatarPrimitive from "@radix-ui/react-avatar";
import * as AvatarPrimitive from "@radix-ui/react-avatar";
import { cn } from "@/lib/utils";

const Avatar = ({ className, ...props }: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import * as React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import * as React from "react";
import { cn } from "@/lib/utils";

const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client";
"use client";

import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { cn } from "@/lib/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import * as React from "react";
import { cn } from "@/lib/utils";

const Input = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(({ className, type, ...props }, ref) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import { cn } from "@/lib/utils";

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client';
'use client';

import * as ToastPrimitives from '@radix-ui/react-toast';
import { cn } from '@/lib/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ai/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const EXPLAIN_SYSTEM_PROMPT = `你是一位经验丰富的软件设计师考试辅导老师,擅长用通俗易懂的语言讲解计算机专业知识。
export const EXPLAIN_SYSTEM_PROMPT = `你是一位经验丰富的软件设计师考试辅导老师,擅长用通俗易懂的语言讲解计算机专业知识。

请针对以下选择题进行详细讲解,要求:
1. 先分析题目考查的知识点
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ai/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AIMessage = {
export type AIMessage = {
role: "user" | "assistant";
content: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };

Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ClassValue, clsx } from "clsx";
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextRequest, NextResponse } from 'next/server';
import { NextRequest, NextResponse } from 'next/server';
import { getToken } from 'next-auth/jwt';

const protectedRoutes = [
Expand Down
2 changes: 1 addition & 1 deletion src/types-next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "next-auth";
import "next-auth";

declare module "next-auth" {
interface Session {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"compilerOptions": {
"target": "es2017",
"lib": [
Expand Down
Loading