Workbench Summary
Core Architecture Design
The Workbench (Admin) is an advanced feature module of TechUI that adopts a Data-Driven + Global Interception design pattern.
- Entry Control: You must configure
features: { admin: true }inTechUIInitto activate the$ADMINglobal service. - State Management: Core state is mounted under
$tState.ADMIN, includinguserInfo(user information),menu(menu tree),componentRegister(component registry), etc. - Persistence: The system automatically syncs sensitive data (Token) to Session/LocalStorage and large data volumes (Menu) to IndexedDB to prevent data loss upon page refresh.
Key Module Mechanisms
A. Dynamic Router
The system does not use a static routing table; instead, it generates routes dynamically based on menu data returned by the backend.
- Loading Timing: Triggered within the global route guard
router.beforeEach. - Generation Logic:
- Check the
$ARouterInitedstatus. - If not initialized, read
$AMenu(or restore from IndexedDB). - Traverse the menu and match components via
register.js. - Mount sub-routes using
router.addRoute('layout', ...).
- Error Handling: Encountering a 404 or route not found usually indicates missing configuration in
register.jsor that the IndexedDB cache has not been updated.
B. Component Register
To resolve path limitations imposed by build tools (Vite/Webpack) on dynamic imports, a "Pre-registration" mode is adopted.
- File Location: Usually located at
src/navigation/register.js. - Mapping Rule:
Key(Route Identifier) ->Value(() => import('path')). - Global Injection: Must be assigned to
$ADMIN.value.componentRegisterinmain.jsorApp.vue.
C. Layout System
The standard layout is provided by <TuiAdminLayout>, usually wrapped inside <TuiAdaptive>.
- Structure: Logo Area + Sidebar Menu + Top Tab + Content Area + Bottom Assist Bar (Assist).
- Assist Bar:
assist.vueis the functional area at the bottom of the sidebar, responsible for avatar display, message notifications, settings, and logout logic. - Caching: Built-in
KeepAlive, automatically managing the$AKeepAlivelist via routemeta.keepAlive.
D. Login Authentication
- Component:
<TuiLogin>provides a standard UI, supporting vector/image backgrounds and form validation. - Flow:
- Call API to get Token and UserID.
- Write to
$ADMIN.value.userInfo. - (Optional) Fetch menu and write to
$ADMIN.value.menu. - Jump using
routerTransition.
Quick Start Test Cases
Find reading the documentation too tedious?
I feel the same way. You can directly download the test cases and the minimal starter project to dive straight into development. Once you understand the concepts in the previous chapters, you can get started immediately.
Test Cases & Quick Start