# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview uni-halo v3.0 is a multi-platform blog client built on the **Halo 2.x** headless CMS API. It targets WeChat mini-program (primary), H5, Alipay, and native apps. Built on the **unibest** scaffold with Vue 3 + TypeScript + Vite + UnoCSS. ## Commands | Task | Command | |------|---------| | Install dependencies | `pnpm install` | | Dev (H5) | `pnpm dev` or `pnpm dev:h5` | | Dev (WeChat mini-program) | `pnpm dev:mp` or `pnpm dev:mp-weixin` | | Dev (Alipay mini-program) | `pnpm dev:mp-alipay` | | Dev (native app) | `pnpm dev:app` | | Build (H5) | `pnpm build` or `pnpm build:h5` | | Build (WeChat) | `pnpm build:mp` | | Build (app) | `pnpm build:app` | | Lint | `pnpm lint` | | Lint + auto-fix | `pnpm lint:fix` | | Type check | `pnpm type-check` | | Run tests (watch) | `pnpm test` | | Run tests (single) | `pnpm test:run` | | Generate API client from OpenAPI | `pnpm openapi` | | Upload to WeChat platform | `pnpm upload:mp` | ## Architecture ### Entry Flow `src/main.ts` → creates Vue app → installs Pinia → route interceptor → request interceptor → i18n. On launch, `src/App.vue` fetches the uni-halo plugin configuration from the Halo server and stores it in the `uniHaloConfig` Pinia store. ### Routing (Convention-Based) Pages in `src/pages/` are auto-registered by `@uni-helper/vite-plugin-uni-pages`. Use the `definePage()` macro at the top of page files to set metadata (navigation style, title, etc.). Sub-packages live in `src/subpkg-blog/` and `src/subpkg-demo/`. Route guards in `src/router/interceptor.ts` intercept `navigateTo`, `reLaunch`, `redirectTo`, `switchTab`. Supports whitelist (default: login required) and blacklist strategies, configured in `src/router/config.ts`. ### HTTP Layer — Three Coexisting Strategies 1. **Custom `uni.request` wrapper** (`src/http/http.ts`) — GET/POST/PUT/DELETE helpers with transparent 401 token refresh (queues pending requests during refresh). Used by `src/api/login.ts`. 2. **Alova** (`src/http/alova.ts`) — Alova 3.3+ with `@alova/adapter-uniapp`, Halo-specific response handling. Used by `src/api/halo-base/*` and `src/api/halo-plugin/*`. 3. **vue-query** (`src/http/vue-query.ts`) — skeleton/option, not actively used. Request interceptor (`src/http/interceptor.ts`) attaches `Authorization: Bearer ` to all requests. ### Authentication Dual token mode support (single access token OR access+refresh pair), controlled by `VITE_AUTH_MODE` env var. Token store (`src/store/token.ts`) handles login (standard + WeChat mini-program), logout, and automatic refresh with computed expiry checks. ### API Layer - `src/api/halo-base/` — Core Halo APIs: posts, categories, tags, comments, stats, trackers - `src/api/halo-plugin/` — uni-halo plugin APIs: plugin config, moments, links, gallery, votes, douban, muyin, data stats - `src/api/login.ts` — Auth APIs (login, register, WeChat login, token refresh) - `src/api/types/` — TypeScript interfaces for API responses - Types from `@halo-dev/api-client` (e.g., `ListedPostVo`, `PostVo`) ### State Management Pinia with `pinia-plugin-persistedstate` using `uni.getStorageSync`/`uni.setStorageSync`. All stores use Composition API style (`defineStore` with setup function): - `src/store/token.ts` — Authentication - `src/store/user.ts` — User profile - `src/store/config.ts` — uni-halo plugin configuration ### Custom Tabbar Fully custom tabbar in `src/tabbar/` with its own Pinia store. Configurable strategy: no tabbar, native tabbar, or custom tabbar. Currently set to `CUSTOM_TABBAR` with 5 tabs. ## Coding Conventions ### Vue Components - Use `