### Clone Repository and Setup
Source: https://github.com/devcloudfe/vue-devui/blob/dev/CONTRIBUTING.md
Clone the Vue DevUI repository, install dependencies, and start the development server. Ensure you are using pnpm 6.x.
```bash
# username 为用户名,执行前请替换
git clone git@github.com:username/vue-devui.git
cd vue-devui
git remote add upstream git@github.com:DevCloudFE/vue-devui.git
pnpm i
pnpm dev
```
--------------------------------
### Vue Script Setup
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Provides the necessary Vue script setup for the pagination examples, including ref declarations for managing pagination state and event handler functions.
```javascript
import { ref } from 'vue';
const currentPage = ref(1);
const total = ref(200);
const pageSize = ref(10);
const page1 = ref(1);
const size1 = ref(10);
const page2 = ref(1);
const page3 = ref(1);
const page4 = ref(1);
const page5 = ref(1);
const page6 = ref(1);
const fullPage = ref(1);
const fullSize = ref(25);
const onPageChange = (page: number) => {
console.log('Page changed to:', page);
};
const onPageSizeChange = (size: number) => {
console.log('Page size changed to:', size);
};
```
--------------------------------
### Responsive Parameters Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/menu/index.md
Example demonstrating the use of responsive parameters like 'width', 'open-keys', and 'default-select-keys' in the d-menu component.
```APIDOC
## Responsive Parameters Example
### Description
This example demonstrates how to use responsive parameters such as `width`, `open-keys`, and `default-select-keys` with the `d-menu` component. These parameters allow for dynamic adjustments to the menu's appearance and behavior.
### Method
N/A (This is a component usage example)
### Endpoint
N/A (This is a component usage example)
### Request Example
```vue
changeDisabled
change select
Home
System item
Setting item
```
### Response
N/A (This is a component usage example)
```
--------------------------------
### Start Development Server
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/quick-start/index.md
Run the development server to start building and debugging your Vue.js application with DevUI.
```shell
yarn dev
```
--------------------------------
### Install Vue DevUI with yarn
Source: https://github.com/devcloudfe/vue-devui/blob/dev/README.md
Use this command to install the Vue DevUI library using yarn.
```sh
yarn add vue-devui
```
--------------------------------
### Basic Upload Component Setup
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Demonstrates the basic setup for the d-upload component, including model binding, upload options, and event handlers for success and error.
```vue
Click to Upload
```
--------------------------------
### Start Development Server
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/quick-start/index.md
Run the development server to see your Vue DevUI application in action. This command starts a local development environment.
```shell
npm run dev
```
--------------------------------
### Clone and run Vue DevUI development environment
Source: https://github.com/devcloudfe/vue-devui/blob/dev/README.md
Commands to clone the Vue DevUI repository, install dependencies, and start the development server.
```sh
git clone git@github.com:DevCloudFE/vue-devui.git
cd vue-devui
pnpm install
pnpm dev
```
--------------------------------
### Install Vue DevUI with pnpm
Source: https://github.com/devcloudfe/vue-devui/blob/dev/README.md
Use this command to install the Vue DevUI library using pnpm.
```sh
pnpm add vue-devui
```
--------------------------------
### Install DevUI and Icon Library
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/quick-start/index.md
Install the core vue-devui package using yarn. Optionally, install the font icon library if your demos rely on it.
```shell
yarn add vue-devui
# Optional, font icon library, some demos rely on this font library
# yarn add @devui-design/icons
# main.ts file introduction
# import '@devui-design/icons/icomoon/devui-icon.css'
```
--------------------------------
### Install Vue DevUI with npm
Source: https://github.com/devcloudfe/vue-devui/blob/dev/README.md
Use this command to install the Vue DevUI library using npm.
```sh
npm install vue-devui --save
```
--------------------------------
### Vue Button Group Examples
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/button/index.md
Demonstrates various configurations of the d-button-group component, including different sizes (sm, default, lg) and integration with d-dropdown menus. The setup function returns a ref for dropdown positioning.
```vue
Button Name
Size:sm
Shanghai
Beijing
Shenzhen
Size:default
Shanghai
Beijing
Shenzhen
Size:lg
Shanghai
Beijing
Shenzhen
Use with dropdown menu
Click Me 1
Shanghai
Click Me 2
Beijing
Click Me 3
```
--------------------------------
### Install and Import Vue DevUI
Source: https://github.com/devcloudfe/vue-devui/wiki/Vue-DevUI-公开测试参考指南
Install the vue-devui library and its icons, then import the plugin and necessary CSS styles to use the components in your Vue application.
```bash
# Install vue-devui
npm i vue-devui @devui-design/icons
```
```javascript
# Import component library plugin
import DevUI from 'vue-devui';
import 'vue-devui/style.css';
import '@devui-design/icons/icomoon/devui-icon.css';
createApp(App).use(DevUI).mount('#app');
```
```html
# Usage
确定
```
--------------------------------
### Install devui-theme
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/design-animation/index.md
Install the devui-theme package using npm. This package provides the necessary styles and variables for DevUI components.
```bash
npm install devui-theme
```
--------------------------------
### Install and Import Vue DevUI
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Demonstrates how to install the vue-devui package and import it globally or using on-demand imports. On-demand import is recommended for production to optimize bundle size.
```typescript
// Install via npm, yarn, or pnpm
// npm install vue-devui --save
// yarn add vue-devui
// pnpm add vue-devui
// main.ts - Full import
import { createApp } from 'vue';
import App from './App.vue';
import DevUI from 'vue-devui';
import 'vue-devui/style.css';
const app = createApp(App);
app.use(DevUI);
app.mount('#app');
// On-demand import (recommended for production)
import { createApp } from 'vue';
import App from './App.vue';
import { Button, Input, Modal, Table } from 'vue-devui';
const app = createApp(App);
app.use(Button);
app.use(Input);
app.use(Modal);
app.use(Table);
app.mount('#app');
```
--------------------------------
### Install Vue DevUI and Dependencies
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/quick-start/index.md
Install the Vue DevUI library, its icon set, and the theme package using NPM. Ensure you are in your project directory.
```shell
npm i vue-devui @devui-design/icons devui-theme
```
--------------------------------
### Basic DataGrid Usage
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/data-grid/index.md
Configure the DataGrid with `data` for table content and `columns` for header and field mapping. Set `fix-header` to true and provide a `max-height` for a scrollable header. This example demonstrates basic setup.
```vue
```
--------------------------------
### Basic Usage Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/virtual-list/index.md
Demonstrates the fundamental implementation of the VirtualList component for rendering a large dataset with scroll-to functionality.
```APIDOC
## Basic Usage Example
### Description
This example showcases how to use the `d-virtual-list` component to render a large list of 100,000 items and includes functionality to scroll to a specific item by its index.
### Component Usage
```vue
Scroll to
children{{ value }}
```
### Key Features Demonstrated
- **Data Binding**: The `data` prop is bound to a large array of objects.
- **Scroll To Functionality**: The `scrollTo` method is used to navigate to a specific item based on user input.
- **Custom Item Template**: The `#item` slot is used to define how each item in the list is rendered.
```
--------------------------------
### Popover Positioning Examples
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/popover/index.md
Demonstrates the various supported positions for the DevUI popover component. Ensure the 'controlled' prop is set to true for these examples.
```vue
left
left
left-top
left-top
left-top
left-bottom
left-bottom
left-bottom
top
top
top-left
top-left
top-right
top-right
right
right
right-top
right-top
right-top
right-bottom
right-bottom
right-bottom
bottom
bottom
bottom-left
bottom-left
bottom-right
bottom-right
```
--------------------------------
### Basic Usage of AutoComplete
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/auto-complete/index.md
Demonstrates the fundamental setup of the AutoComplete component, including setting the data source and handling user input.
```vue
```
--------------------------------
### Upload Component Script Setup
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Provides the script setup for the Vue component, including ref declarations, upload options configuration, and event handler functions.
```javascript
import { ref } from 'vue';
const manualUploadRef = ref();
const uploadOptions = {
uri: '/api/upload',
method: 'POST',
maximumSize: 5 * 1024 * 1024, // 5MB
headers: {
'Authorization': 'Bearer token123'
},
additionalParameter: {
folder: 'uploads'
},
fileFieldName: 'file',
withCredentials: true
};
const fileList = ref([]);
const dragFileList = ref([]);
const multipleFiles = ref([]);
const validatedFiles = ref([]);
const manualFiles = ref([]);
const customRequestFiles = ref([]);
const directoryFiles = ref([]);
const onUploadSuccess = (response: { file: File; response: any }[]) => {
console.log('Upload successful:', response);
};
const onUploadError = (error: { file: File; response: any }) => {
console.error('Upload failed:', error);
};
const onExceed = (files: File[], uploadFiles: File[]) => {
console.log('File limit exceeded. Trying to upload:', files.length, 'Current:', uploadFiles.length);
};
const beforeUpload = async (files: any[]) => {
const maxSize = 2 * 1024 * 1024; // 2MB
const validFiles = files.filter(f => f.file.size <= maxSize);
if (validFiles.length !== files.length) {
console.warn('Some files exceeded 2MB limit');
return false;
}
return true;
};
const submitUpload = () => {
manualUploadRef.value?.submit();
};
const customHttpRequest = async (files: File[]) => {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
try {
const response = await fetch('/api/custom-upload', {
method: 'POST',
body: formData
});
const result = await response.json();
console.log('Custom upload result:', result);
} catch (error) {
console.error('Custom upload error:', error);
}
};
```
--------------------------------
### Mermaid State Diagram Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/editor-md/index.md
Demonstrates the syntax for creating a state diagram using Mermaid. This is useful for visualizing the states and transitions of a system.
```mermaid
stateDiagram-v2
[*] --> Still
Still --> [*]
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
```
--------------------------------
### Mermaid Sequence Diagram Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/editor-md/index.md
Provides an example of a sequence diagram created with Mermaid. This is helpful for visualizing interactions between different components over time.
```mermaid
sequenceDiagram
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
```
--------------------------------
### Vue Component Setup with Props and Composables
Source: https://github.com/devcloudfe/vue-devui/wiki/Vue-DevUI-组件库规范文档
Standard Vue 3 component setup using `defineComponent`. Imports should follow a specific order: Vue core, types, sub-components, composables, and styles. Props are defined and destructured using `toRefs`.
```typescript
import { defineComponent, toRefs } from 'vue';
import type { SetupContext } from 'vue';
import { myComponentProps, MyComponentProps } from './my-component-types';
import useMyComponent from './use-button';
import './my-component.scss';
export default defineComponent({
name: 'DMyComponent',
props: myComponentProps,
emits: ['update:modelValue'],
setup(props: MyComponentProps, ctx: SetupContext) {
const { myProp } = toRefs(props);
const { myUseVar, myUseMethod } = useMyComponent(myUseParam);
return () => {
return (
{ myProp.value }
);
};
},
});
```
--------------------------------
### Directory Upload Setup
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Enables uploading entire folders using the webkitdirectory attribute, allowing for hierarchical file uploads.
```vue
Upload Folder
```
--------------------------------
### Dynamic Mode Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/rate/index.md
Shows the d-rate component in dynamic mode, allowing user interaction.
```APIDOC
## Dynamic Mode Example
### Description
Shows the d-rate component in dynamic mode, allowing user interaction.
### Method
N/A (Component Usage)
### Endpoint
N/A (Component Usage)
### Request Example
```vue
```
```
--------------------------------
### Create a New Vue Project with Vite
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/quick-start/index.md
Use Vite to scaffold a new Vue.js project with TypeScript support. This is the recommended way to start.
```shell
# npm 6.x
npm create vite my-vue-app --template vue-ts
# npm 7+
npm create vite my-vue-app -- --template vue-ts
```
--------------------------------
### Basic Usage of Notification Service
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/notification/index.md
Use the service method to open a notification. This example shows the default configuration with only content.
```vue
基本用法
```
--------------------------------
### Half Star Mode Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/rate/index.md
Enables half-star selection in the d-rate component and demonstrates the change event.
```APIDOC
## Half Star Mode Example
### Description
Enables half-star selection in the d-rate component and demonstrates the change event.
### Method
N/A (Component Usage)
### Endpoint
N/A (Component Usage)
### Request Example
```vue
{{ value }}
```
```
--------------------------------
### Create Vue Project with Vite
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/quick-start/index.md
Use @vite/cli to create a new Vue.js project with TypeScript support. This is the recommended starting point.
```shell
yarn create vite my-vue-app --template vue-ts
```
--------------------------------
### Mermaid Pie Chart Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/editor-md/index.md
Illustrates how to generate a pie chart using Mermaid syntax. This is suitable for displaying proportional data.
```mermaid
pie
"Dogs" : 386
"Cats" : 85
"Rats" : 15
```
--------------------------------
### Use the type parameter Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/rate/index.md
Illustrates using the 'type' parameter to set different rating styles (success, warning, error).
```APIDOC
## Use the type parameter Example
### Description
Illustrates using the 'type' parameter to set different rating styles (success, warning, error).
### Method
N/A (Component Usage)
### Endpoint
N/A (Component Usage)
### Request Example
```vue
```
```
--------------------------------
### Basic Form Structure with Input Fields
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/en-US/components/form/index.md
A simple form structure with input fields for name and age. This serves as a basic example for form setup.
```vue
Name
Age
```
--------------------------------
### Initialize and Apply Custom Theme with ThemeService
Source: https://context7.com/devcloudfe/vue-devui/llms.txt
Demonstrates how to initialize the ThemeService, define a custom theme with CSS variables, apply it, and manage theme lifecycle events like registration and unloading.
```typescript
import { ThemeService, Theme } from 'devui-theme';
// Initialize theme service
const themeService = new ThemeService();
// Initialize with specific theme or use stored preference
themeService.initializeTheme('infinity-theme');
// Apply a theme
const customTheme: Theme = {
id: 'my-custom-theme',
name: 'My Custom Theme',
data: {
'devui-brand': '#6366f1',
'devui-brand-foil': '#818cf8',
'devui-brand-hover': '#4f46e5',
'devui-brand-active': '#4338ca',
'devui-brand-active-focus': '#3730a3',
'devui-text': '#1e293b',
'devui-text-weak': '#64748b',
'devui-aide-text': '#94a3b8',
'devui-disabled-text': '#cbd5e1',
'devui-base-bg': '#ffffff',
'devui-global-bg': '#f8fafc',
'devui-float-block-shadow': '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
'devui-connected-overlay-shadow': '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
'devui-border-radius': '6px',
'devui-border-radius-card': '12px',
'devui-font-size': '14px',
'devui-font-size-card-title': '16px',
'devui-line-height-base': '1.5',
}
};
themeService.applyTheme(customTheme);
// Register for system color scheme changes (light/dark mode)
themeService.registerMediaQuery();
// Listen for theme changes
themeService.eventBus.on('themeChanged', (theme: Theme) => {
console.log('Theme changed to:', theme.id);
});
// Unload theme
themeService.unloadTheme();
// Unregister media query
themeService.unregisterMediaQuery();
```
--------------------------------
### Basic StepsGuide Usage
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/steps-guide/index.md
Demonstrates how to use the StepsGuide component with basic step configurations. It includes buttons to trigger different steps and handles step changes and guide closing.
```vue
Step 1
Step 2
Step 3
```
--------------------------------
### Install unplugin-vue-components
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/on-demand/index.md
Install the unplugin-vue-components plugin to enable automatic component imports. This is a development dependency.
```shell
npm i -D unplugin-vue-components
```
--------------------------------
### Vue Tree Search and Filter Example
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/tree/index.md
This example shows how to use the `d-search` component to search and filter nodes in a `d-tree`. It includes examples for basic search, filtering, filtering by a custom key, and filtering using a regular expression.
```vue
```
--------------------------------
### Implement Quick Hints with d-editor-md in Vue
Source: https://github.com/devcloudfe/vue-devui/blob/dev/packages/devui-vue/docs/components/editor-md/index.md
This example illustrates how to set up quick hint functionality (e.g., for @ mentions or # order numbers) using the hintConfig prop and a custom template slot. It includes logic for filtering suggestions and handling selections.
```vue
```