diff --git a/frontend/.env b/frontend/.env new file mode 100644 index 0000000..5aee63b --- /dev/null +++ b/frontend/.env @@ -0,0 +1,3 @@ +VITE_APP_API='http://localhost:8000/api' +VITE_APP_THEMES='@/themes' +VITE_APP_PLUGINS='@/plugins' diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js new file mode 100644 index 0000000..092408a --- /dev/null +++ b/frontend/eslint.config.js @@ -0,0 +1,28 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/frontend/services/dependency-checker.ts b/frontend/services/dependency-checker.ts deleted file mode 100644 index cb8758e..0000000 --- a/frontend/services/dependency-checker.ts +++ /dev/null @@ -1,29 +0,0 @@ -// services/dependency-checker.ts - -import { Dependency } from "../types/common"; - -/** - * 依赖检查器服务 - */ -export class DependencyChecker { - /** - * 检查依赖项是否满足要求 - * @param dependencies 需要检查的依赖项列表 - * @returns 是否所有依赖都满足要求 - */ - static async checkDependencies(dependencies: Dependency[]): Promise { - for (const dep of dependencies) { - const response = await fetch(`/api/dependencies/check`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(dep) - }); - - if (!response.ok) { - console.error(`依赖检查失败: ${dep.id}`); - return false; - } - } - return true; - } - } \ No newline at end of file diff --git a/frontend/src/env.d.ts b/frontend/src/env.d.ts new file mode 100644 index 0000000..4efdf44 --- /dev/null +++ b/frontend/src/env.d.ts @@ -0,0 +1,11 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_API: string + readonly VITE_APP_THEMES: string + readonly VITE_APP_PLUGINS: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 6a26a99..8cbabd3 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -8,6 +8,8 @@ import {createContext} from "react"; export const serverAddressContext=createContext("localhost:8080") // 动态路由 const RouterListener: React.FC = () => { + const a=import.meta.env.VITE_APP_THEMES; + console.log(a) const pathname = location.pathname.split("/"); console.log(pathname) return ( diff --git a/frontend/src/page/page.tsx b/frontend/src/page/page.tsx index 51852de..781b5d4 100644 --- a/frontend/src/page/page.tsx +++ b/frontend/src/page/page.tsx @@ -1,7 +1,8 @@ // page/page.tsx import React from "react"; -const THEMEPATH= "../../themes" +const THEMEPATH= "@/themes" import {serverAddressContext} from "../main.tsx"; + // 动态获取当前主题 const getCurrentTheme = async (): Promise => { return new Promise((resolve) => { diff --git a/frontend/tsconfig.app.json b/frontend/tsconfig.app.json new file mode 100644 index 0000000..992a3e9 --- /dev/null +++ b/frontend/tsconfig.app.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + "paths": { + "@/*": ["./*"] + } + }, + "include": ["src","utils","themes","public"] +} diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json new file mode 100644 index 0000000..1ffef60 --- /dev/null +++ b/frontend/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/frontend/tsconfig.node.json b/frontend/tsconfig.node.json new file mode 100644 index 0000000..0b3139d --- /dev/null +++ b/frontend/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + }, + "include": ["vite.config.ts"] +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts new file mode 100644 index 0000000..ae34513 --- /dev/null +++ b/frontend/vite.config.ts @@ -0,0 +1,12 @@ +import {defineConfig} from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], + resolve: { + alias: { + '@': __dirname, + } + } +}) diff --git a/package.json b/package.json new file mode 100644 index 0000000..dc218ac --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "react-helmet": "^6.1.0" + } +}