How arco-design/arco-design-pro-vue works
Project type and purpose
• This repository is a CLI tool plus a Vue 3/Vite-based starter template (“arco‑design‑pro‑vite”) for enterprise applications.
• The CLI (in .arco-cli/ and scripts/) bootstraps new projects; the template folder contains a fully configured frontend project using TypeScript, Vue3, Pinia, Arco Design Vue, ECharts, mock APIs, and i18n.
High‑level components
a. CLI Layer
• .arco-cli/init.js & scripts/*.js: orchestrate project creation, copying the template, customizing .env files, running install hooks.
• scripts/install.js, postpublish.js, etc.: lifecycle scripts for installing/deploying.
b. Template Project (“arco‑design‑pro‑vite”)
• Build & Config
– Vite configs (config/vite.config.*.ts), Babel, ESLint/Stylelint, Prettier, CommitLint, Husky.
– Vite plugins (config/plugin/*.ts): ArcoResolver, style importer, image minifier, visualizer, compressor.
• Source Code
– Entry point: src/main.ts → App.vue
– Routing: src/router with guards, dynamic routes, external modules.
– State Management: Pinia stores under src/store/modules/*.
– API Layer & Mock: src/api/*.ts + src/mock/*.ts + src/utils/setup-mock.ts.
– Internationalization: src/locale/* & component‑level locale.
– Utilities & Hooks: src/utils/*, src/hooks/*.
• Assets & Styles: src/assets/images, .less styles, global variables.
c. External Dependencies & Services
• Arco Design Vue component library
• ECharts for charts
• Browser (runtime)
• Optional real API backend (mocked in dev)
Relationships & Data Flows
• Developer invokes arco init (CLI Layer) → CLI reads init.js, runs hooks, copies template → NPM/PNPM installs dependencies (install scripts run).
• At build time, Vite loads vite.config.*, applies plugins → bundles source code → outputs static assets.
• At runtime in the browser:
• main.ts mounts Vue app → initializes router and store → user navigates to a view → view component dispatches store actions or calls API functions in src/api.
• In development, setup-mock intercepts requests and returns mock data; in production, calls go to real backend endpoints.
• Components render data, use ECharts or Arco components, dispatch state updates (Pinia).
• I18n hooks switch locales.
Architectural patterns & principles
• Modular by feature (views, components, store modules)
• Clear separation of concerns: UI, state, routing, API, build config, mocks, scripts
• Plugin‑based build pipeline: each plugin in Vite handles one responsibility (style import, asset compression, bundle visualization).
• Convention over configuration: standardized folder names, file patterns.
1. Build & Scaffold Layer
• CLI tool → Template + Scripts → Vite & plugins → Bundled Output
2. Runtime Application Layer
• Browser/Client → Vue App (main.ts)
• Inside Vue App: Router, Store (Pinia), API/Mock layer, UI Components, Hooks, i18n
3. External Integration
• Arco Design Vue & ECharts (external libraries)