Vue3 Frontend Development And Integration
Page Guide
1. Directory Structure
| Directory | Purpose |
|---|---|
vue3/src/views | Page entries, organized by business module |
vue3/src/api | API request wrappers |
vue3/src/router | Routes, fixed pages, and basic dynamic-route logic |
vue3/src/mocks | Stable Mock data |
vue3/e2e | Playwright E2E test cases |
vue3/scripts | Scripts for OpenAPI, integration checks, and more |
vue3/src/api/schema.d.ts | Type definitions generated from OpenAPI |
2. Local Development
cd vue3
npm install
npm run devCommon modes:
| Command | Purpose |
|---|---|
npm run dev | Local frontend connected to a local backend |
npm run dev:mock | Local frontend connected to the Mock service |
npm run dev:test | Local frontend connected to the shared test backend |
npm run build | Production build |
npm run preview | Preview the build output |
The browser request prefix is always /dev-api; switch between environments through environment variables and proxy targets.
3. API Contract
The backend OpenAPI is the source of the frontend-backend API contract.
Default generation:
cd vue3
npm run openapiCheck whether the schema is outdated:
cd vue3
npm run openapi:checkSpecify an OpenAPI address:
cd vue3
$env:FASTBEE_OPENAPI_URL="http://test-api.fastbee.cn/v3/api-docs"
npm run openapiFor every backend API change, confirm the URL, method, request parameters, response structure, pagination structure, upload/download behavior, and error codes.
4. Mock And Integration
Recommended flow:
- When the backend API is not ready, develop pages with
npm run dev:mock. - Maintain success, empty-data, business-failure, and 401/403 examples in Apifox.
- Maintain stable Mocks in
vue3/src/mocksfor key flows. - Run integration checks after the page is complete.
- After connecting to the real backend, rerun the E2E tests and Apifox collections.
Aggregate check:
cd vue3
npm run verify:integrationThis command runs integration static checks and Playwright integration test cases.
5. Request Tracing
Vue3 Axios requests carry an X-Request-Id. Backend responses and logs should echo the same requestId.
When an API fails during integration, record:
- The requestId.
- The request URL and method.
- The request parameters.
- The response body.
- The current login user and roles.
- The page and steps to reproduce.
This lets the backend locate the issue quickly in the logs.
6. Steps For Integrating A New Module
- Add a page directory under
vue3/src/views. - Add an API file under
vue3/src/api. - Confirm that the backend OpenAPI already includes the target API.
- Run
npm run openapito update the types. - Add Mock examples.
- Integrate menu and button permissions.
- Add stable Playwright test cases.
- Run
npm run verify:integration.
7. FAQ
Page request returns 404
Check whether the API path carries the /dev-api prefix, whether the proxy target is correct, and whether the backend API is registered.
The page has permission but buttons are not displayed
Check menu permissions, button permission identifiers, role authorization, and frontend permission directives.
openapi:check fails
This means schema.d.ts was not updated after the backend contract changed. Run npm run openapi, then check whether the type changes are expected.
E2E fails but the page works manually
Check whether the Mock data changed, whether the locators are stable, whether asynchronous waits are sufficient, and whether the test environment polluted the local cache.

