PartnerUp is a UniApp (Vue 3) client targeting mini-program platforms. The architecture is layered:
- UI: pages and components (
src/pages,src/components). - Business: domain models + API logic (
src/business). - State: Pinia stores with persistence (
src/store). - Infrastructure: utilities, i18n, styling, libs (
src/utils,src/locale,src/styles,src/libs).
src/main.tscreates the SSR app, installs i18n and Pinia, and enablespinia-plugin-unistorage.src/App.vueregisters lifecycle handlers and triggersAccount.login(false)at launch.- Pages and tabbar are declared in
src/pages.json. A custom tabbar is implemented insrc/custom-tab-bar.
Page / Component
-> Business model (V.class / V.formClass)
-> HTTPApiClient (uni-network) OR DBApiClient (PostgREST)
-> Response Body (lazy Valibot parsing)
-> Store (Pinia) for cached or shared state
- Model system:
src/business/index.tsprovidesV.class,V.formClass,nullable(),instance(),limit_string()to create Valibot-backed classes. - HTTP:
src/business/http-api.tswraps@uni-helper/uni-networkwith auth headers, custom success code handling, 401 retry, and error reporting. - DB:
src/business/db-api.tswraps PostgREST (src/libs/postgrest-js) with per-call auth headers. - Domain modules:
account,partner_request,communication,base,oss.
- Pinia stores live under
src/store. - Persistence is via
pinia-plugin-unistorage(enabled insrc/main.ts).
PAGE_IDandPAGE_PATHare defined insrc/data/enum.tsandsrc/data/mapper.ts.navigate()insrc/utils/vendor.tsroutes viauni.navigateTooruni.switchTab(tabbar pages).src/utils/tabbar.tssyncs selection and avatar state with the custom tabbar.
src/locale/index.tsconfiguresvue-i18nwith JSONC aggregates fromsrc/locale/{locale}/*.jsonc.- Use
useTranslate()fromsrc/localefor domain/global keys. Prefer component/page-local messages withuseI18n({ inheritLocale: true, messages: localMessages })(alias the returnedttolt). Shared/global keys can use the exportedtfromsrc/locale. Text should never be hard-coded.
- UnoCSS is configured in
uno.config.tswith a custom design preset (src/styles/presets/design.ts). - SCSS design tokens and mixins (
sys-var(),pu-font,pu-elevation,pu-icon) are injected via Vite for components/pages.
- UniApp templates use
<view>,<text>,<image>(not HTML tags like<div>). - Conditional compilation (
#ifdef) is present and a custom Vite plugin processes it for tests (vite-plugins/vite-plugin-uni-conditional-compile.ts). - Safe-area handling is done via components such as
src/components/common/safeAreaInset.vue.
- Tests run with Vitest (
vitest.config.ts). - Global Uni API mocks and DOM adapters are in
tests/setup.ts. - Component tests live under
tests/components/.