跳到主要内容
Skip to content

For detailed structure, path aliases, and env config, see frontend/web/README.md.

Technology Stack

CategoryChoice
FrameworkVue 3 (Composition API / <script setup>)
BuildVite 7
LanguageTypeScript
UIElement Plus
RouterVue Router 4 (Hash mode)
StatePinia + pinia-plugin-persistedstate
StylesTailwind CSS 4, SCSS
HTTPAxios

Project Structure

frontend/web/src/
├── api/              # API modules by business domain
├── assets/           # Images, fonts, global styles
├── components/       # Shared & business components
├── config/           # App configuration
├── enums/            # Enumerations
├── hooks/            # Composable functions
├── layouts/          # Layout system (left, top, mixed)
├── locales/          # i18n
├── plugins/          # Vue plugin registration
├── router/           # Static routes, dynamic routes, guards
├── store/            # Pinia modules
├── styles/           # Style system (including dark theme)
├── types/            # TypeScript types
├── utils/            # Utilities
├── views/            # Page views
├── App.vue
└── main.ts           # Entry

Path Aliases

AliasPoints to
@src/
@viewssrc/views
@storessrc/store
@utilssrc/utils

Environment Variables

Only variables prefixed with VITE_ are injected into frontend code:

VariablePurpose
VITE_PORTDev server port
VITE_API_BASE_URLProxy target: backend HTTP address
VITE_APP_BASE_APIAPI path prefix
VITE_APP_WS_ENDPOINTWebSocket endpoint
VITE_APP_TITLEPage title
VITE_BASE_URLDeployment base path
VITE_ACCESS_MODEMenu source (frontend / backend / mixed)

Restart pnpm dev after changing env files.

Scripts

bash
cd frontend/web
pnpm install
pnpm dev              # Dev server (default 5173)

# Other scripts
pnpm build            # Production build
pnpm type-check       # TypeScript check
pnpm lint             # ESLint + Prettier + Stylelint
pnpm clean:cache      # Clean cache

Routes & Menus

FileResponsibility
src/router/staticRoutes.tsStatic routes, shell layout
src/router/dynamicRoutes.tsMenu-driven dynamic routes
src/router/beforeEach.tsAuth guard, dynamic mounting
src/router/MenuProcessor.tsBackend menu → frontend routes

Routes use Hash mode. Static routes (Layout/Login/404) register on load. Business routes are lazy addRoute by guard based on menu permissions.

App Startup Flow

main.ts → initPlugins(app) → mount("#app")
  → App.vue → onBeforeMount: theme init
  → onMounted: bootstrap() → storage check/upgrade/site config
  → route guard beforeEach
    → storage invalidation check
    → auth check
    → dynamic route registration (menu → addRoute)
    → tab/title sync

Adding a New Page

  1. Create API file in src/api/
  2. Create page component in src/views/
  3. Register route (static or dynamic) + backend menu config
  4. Keep path and name consistent across all three

Common Issues

SymptomSuggestion
ECONNREFUSEDBackend not running or wrong port
401 / frequent login redirectsToken expired, clear local storage and re-login
.env changes not taking effectMust restart pnpm dev
Dependency issuesTry pnpm clean:cache && pnpm dev
Type errorsRun pnpm type-check

Build & Deploy

  • Output directory: dist/
  • For sub-path deployment, set VITE_BASE_URL
  • Production build may strip console (see vite.config.ts)