cool-admin-vue
repository·8.x·Indexed 25 days ago
https://github.com/cool-team-official/cool-admin-vueA modular, plugin-based administrative permission management system built with Vue 3, TypeScript, and Vite. Designed for rapid CRUD development, it features AI-assisted coding, drag-and-drop workflow orchestration, and a comprehensive set of components including cl-crud for data management, cl-dialog for modal interactions, and a programmatic ContextMenu.
What's inside cool-admin-vue
- cool-admin for vue is an open-source administration framework built on Vue.js. It is designed for rapid development and follows the MIT license, allowing free use in commercial products (provided they are not used for illegal activities like gambling or violence).
Technology stack of cool-admin for vue
8.xThe project is built using the following modern web technologies:
- Vue.js: Core framework
- VueRouter: Official Vue.js routing
- Pinia: Lightweight state management
- ElementPlus: Desktop component library
- Vite: Build tool
Run the cool-admin application
8.xAfter installing the dependencies, you can start the development server by running the following command. Once started, you can preview the application in your browser at http://localhost:9000.
pnpm devClone the cool-admin-vue repository
8.xTo start working with the project locally, clone the official repository from GitHub.
git clone https://github.com/cool-team-official/cool-admin-vue.gitInstall project dependencies
8.xTo install the necessary dependencies for the
cool-admin-vueproject, it is recommended to usepnpm.pnpm iUnderstand the EPS (Electronic Product Service) concept
8.xEPS is a mechanism used to synchronize backend API definitions with the frontend. It provides a type-safe way to interact with backend services by automatically generating TypeScript interfaces and service objects based on the actual API structure.
Key Components:
- Entities (
Eps.Entity): Represent backend data models, including their columns, search configurations, and API endpoints. - Service Tree: A hierarchical object that mirrors the API's namespace structure (e.g.,
/admin/user/infobecomesservice.user.info). - Type Definitions: Automatically generated
.d.tsor.tsfiles that provide autocomplete and type checking for API requests, parameters, and responses. - Platform Specifics: The plugin adjusts output based on
config.type. Foruniapp-x, it usesexport interfaceand flattens types, whereas foradminorapp, it usesdeclare namespace Eps.
- Entities (
Understand the cl-crud reactive state structure
8.xThe
crudobject is the central source of truth for a CRUD instance. Its structure includes:id: The unique identifier (provided vianameprop or instance UID).routePath: The current URL path (defaults tolocation.pathname).loading: Boolean indicating if a data request is in progress.selection: Array of currently selected items.params: Pagination and query parameters (e.g.,{ page: 1, size: 20 }).service: Configuration for the backend service/API.dict: Dictionary/lookup data.permission: Permission settings merged from global config.mitt: An event emitter instance for component communication.config: Local configuration object.
How cl-select handles tree selection and IDs
8.xWhen using
cl-selectin tree mode, you can control how values are returned using two specific props:allLevelsId: When enabled, selecting a node will return an array containing the ID of the selected node AND the IDs of all its ancestors. This is useful for maintaining path information in hierarchical data.checkStrictly: When enabled, it decouples the selection state of parent and child nodes. This is passed down to the underlyingel-tree-selectcomponent.
If
allLevelsIdis false, the component returns only the specific value of the selected node.How module structure and discovery works
8.xThe system automatically discovers modules and plugins by scanning specific directory patterns within
/src. A module is defined by its location in eithersrc/modules/orsrc/plugins/.To define a module, you can provide the following files/folders:
config.ts: Defines the module's configuration, value, and metadata (likeorder,enable, orignore).service/**: Contains service classes. Each service class should have anamespaceproperty which is used as the registration path.directives/**: Contains Vue directives. The filename (without extension) is used as the directive name.
Module Metadata Properties:
name: Unique identifier for the module.type: Indicates if it is a 'module' or 'plugin'.value: The core configuration or a function that returns configuration.order: Determines the initialization sequence (higher numbers are processed first).enable: Boolean to toggle the module (defaults totrue).install: A function called during bootstrapping:(app: App, options: any) => void.components: An array of components to register (can be a component or a function returning a component).directives: An array of objects containing{ name, value }for Vue directive registration.ignore: An array of paths/values to be merged into the globalconfig.ignorelist.onLoad: An async lifecycle hook:(events: any) => Promise<any>used to register events.
Use cl-view-group for split-pane layouts
8.xThe
cl-view-groupcomponent is used to create layouts with multiple sections, typically a#leftand a#rightslot. This is useful for master-detail views, such as showing a list of departments on the left and a list of users on the right.<cl-view-group> <template #left> <!-- Left side content (e.g., a list) --> </template> <template #right> <!-- Right side content (e.g., a CRUD table) --> </template> </cl-view-group>How form hooks work (bind vs submit)
8.xForm hooks operate in two modes to manage the data flow between your API and the UI components:
bindmode: Triggered when data is being loaded from the server into the form. The hook transforms the raw API data into a format suitable for form inputs (e.g., converting a JSON string into an object).submitmode: Triggered when the form is being submitted. The hook transforms the form input values back into the format expected by the API (e.g., converting an object into a JSON string).
When using complex hooks like
splitJoinorjson, the logic automatically switches behavior based on the currentmethod.Configure cl-form items and data structure
8.xThe
cl-formcomponent uses a configuration-driven approach to define fields. Fields are passed via theitemsproperty in theopen()method.Field Configuration (
ClForm.Item)Each item in the
itemsarray defines a form field. Key properties include:prop: The key in the form data object. Supports dot notation (e.g.,user.name), which the component automatically converts to a hyphenated key (e.g.,user-name) for internal flat state management.type: The type of field (e.g.,'tabs'for tabbed groups).label: The display label for the field.required: Boolean to trigger validation.rules: Validation rules object.children: Nested items for grouping or hierarchical structures.hidden: A boolean or a function(scope) => booleanto determine if the field should be hidden.span: Grid span for the layout (defaulting tostyle.form.span).hook: A submission hook that runs during thesubmit()process.
Data Transformation
When submitting, the component performs
invokeData(d). This transforms keys containing hyphens back into nested objects. For example, a keyuser-namein the flat form state is converted to{ user: { name: ... } }in the final submitted object.