### Install PlusProComponents with yarn Source: https://plus-pro-components.com/guide/installation Use this command to install the library with yarn. Ensure you have yarn installed. ```sh yarn add plus-pro-components ``` -------------------------------- ### Install PlusProComponents with npm Source: https://plus-pro-components.com/guide/installation Use this command to install the library with npm. Ensure you have npm installed. ```sh npm install plus-pro-components --save ``` -------------------------------- ### Install PlusProComponents with pnpm Source: https://plus-pro-components.com/guide/installation Use this command to install the library with pnpm. Ensure you have pnpm installed. ```sh pnpm install plus-pro-components ``` -------------------------------- ### Install @plus-pro-components/utils with npm Source: https://plus-pro-components.com/api/utils Use this command to install the utility package using npm. ```sh npm install @plus-pro-components/utils --save ``` -------------------------------- ### Install @plus-pro-components/utils with yarn Source: https://plus-pro-components.com/api/utils Use this command to install the utility package using yarn. ```sh yarn add @plus-pro-components/utils ``` -------------------------------- ### Install @plus-pro-components/utils with pnpm Source: https://plus-pro-components.com/api/utils Use this command to install the utility package using pnpm. ```sh pnpm install @plus-pro-components/utils ``` -------------------------------- ### DatePicker Basic Usage Source: https://plus-pro-components.com/components/date-picker Demonstrates the basic integration of the DatePicker component. No specific setup or imports are shown in this example. ```vue ``` -------------------------------- ### Layout Event Handling Example Source: https://plus-pro-components.com/components/layout Shows how to handle events emitted by the PlusSidebar and PlusHeader components within the PlusLayout. Ensure the corresponding handler functions are defined in your setup. ```html ``` ```typescript const handleClickDropdownItem = (dropdownItem: { label: string; value: string }) => { console.log(dropdownItem) } const handleToggleCollapse = (collapse: boolean) => { console.log(collapse) } ``` -------------------------------- ### Install @plus-pro-components/resolver Source: https://plus-pro-components.com/ecosystem/resolver Install the resolver package using pnpm. This is the first step to enable automatic component imports. ```sh pnpm i @plus-pro-components/resolver ``` -------------------------------- ### Basic InputTag Usage Source: https://plus-pro-components.com/components/input-tag Demonstrates the fundamental usage of the InputTag component. No specific setup or constraints are mentioned for this basic example. ```vue ``` -------------------------------- ### Advanced Table Example Source: https://plus-pro-components.com/components/table Demonstrates an advanced usage example of the PlusTable component, combining various customization options. ```APIDOC ## Advanced Table :::demo table/advanced ::: ``` -------------------------------- ### Implement a Basic PlusForm Source: https://plus-pro-components.com/components/form.html A comprehensive example showing form state management, column definitions with various value types, and event handling. ```vue ``` -------------------------------- ### Overall Render Function Example Source: https://plus-pro-components.com/components/rule Demonstrates using an overall render function to apply the same rendering logic to all items in a loop. The `allRender` function is used to generate the VNode for each item. ```html ``` -------------------------------- ### Layout Basic Usage Source: https://plus-pro-components.com/components/layout Demonstrates the basic integration of the PlusLayout component. This snippet is intended for initial setup and understanding of the component's structure. ```html ``` -------------------------------- ### Individual Render Function Example Source: https://plus-pro-components.com/components/rule Illustrates using individual render functions for each item in a loop, allowing for different rendering logic per item. Each item in the `list` has a `render` property that defines its specific VNode. ```html ``` -------------------------------- ### Basic Radio Usage Source: https://plus-pro-components.com/components/radio Demonstrates the fundamental usage of the PlusRadio component. No specific setup is required beyond importing the component. ```vue ``` -------------------------------- ### Use AES Encryption Source: https://plus-pro-components.com/api/utils/encrypt Example usage of the encrypt function. ```typescript import { encrypt } from '@plus-pro-components/utils' encrypt('key', 'message') // U2FsdGVkX19GcnbMMQplTX7ZrBomhN24tzbA5Nlc1dw= ``` -------------------------------- ### DisplayItem Basic Usage Source: https://plus-pro-components.com/components/display-item Demonstrates the basic rendering of the DisplayItem component. No specific setup is required beyond its inclusion in a PlusTable. ```vue ``` -------------------------------- ### Format Money Utility Source: https://plus-pro-components.com/api/utils Import and use the formatMoney function to format currency values. Ensure the package is installed and imported correctly. ```ts import { formatMoney } from '@plus-pro-components/utils' formatMoney('100') // ¥100.00 ``` -------------------------------- ### Storage Utility Functions Source: https://plus-pro-components.com/api/utils/storage Functions for setting, getting, and removing data from localStorage. ```APIDOC ## setStorage ### Description Sets a value in localStorage. ### Parameters - **key** (string) - Required - The storage key. - **value** (any) - Required - The data to store. ## getStorage ### Description Retrieves a value from localStorage. ### Parameters - **key** (string) - Required - The storage key. ## removeStorage ### Description Removes an item from localStorage. ### Parameters - **key** (string) - Required - The storage key to remove. ``` -------------------------------- ### Basic StepsForm Usage Source: https://plus-pro-components.com/components/steps-form Demonstrates the fundamental usage of the StepsForm component. Set the 'active' prop to control the current step (starting from 1) and provide 'data' for the form fields. ```vue ``` -------------------------------- ### ElTable Attributes Example Source: https://plus-pro-components.com/components/table Demonstrates how to use common ElTable attributes like stripe, border, and fit with the PlusTable component. These attributes control the visual appearance and behavior of the table. ```html ``` -------------------------------- ### Basic Header Usage Source: https://plus-pro-components.com/components/header Demonstrates the basic implementation of the PlusHeader component. ```vue ``` -------------------------------- ### Disable Start Date Logic Source: https://plus-pro-components.com/components/date-picker Use this function to determine if a start date should be disabled. It returns true if the start time is after the provided end value. ```javascript const startDisabledDate = (startTime, endValue) => { if (!endValue) return false return startTime.getTime() > new Date(endValue).getTime() } ``` -------------------------------- ### 项目目录结构 Source: https://plus-pro-components.com/guide/dev 展示了 PlusProComponents 项目的根目录结构及各文件夹的功能说明。 ```sh ├── CHANGELOG.md #changelog文件 ├── commitlint.config.js #commitlint配置 ├── docs #文档所在目录 | ├── .vitepress #vitepress配置 | ├── components #组件文档 | ├── examples #组件文档对应的vue示例 | ├── deploy.sh #文档部署脚本 | ├── guide #快速开始文档 | ├── index.md #文档首页 | ├── package.json | ├── public | └── utils ├── global.d.ts #全局组件ts提示 ├── LICENSE #LICENSE 文件 ├── package.json ├── packages #包文件夹 | ├── components #主组件 | ├── constants #固定变量 | ├── eslint-config #eslint配置独立 | ├── hooks #hooks | ├── locale #国际化 | ├── play #组件实时预览 | ├── plus-pro-components #主包入口 | ├── utils #工具 | ├── theme-chalk #样式 | └── types #公共TS类型 ├── pnpm-lock.yaml ├── pnpm-workspace.yaml #工作空间配置 ├── README.md #项目介绍 ├── scripts #脚本 | ├── build #主包打包 | ├── changelog #changelog | ├── create-component #新增组件 | ├── release #整包release | ├── utils #公共打包工具 | ├── commit.sh #代码提交 | └── publish.sh #整包发布 ├── tsconfig.base.json #tsconfig配置 ├── tsconfig.json ├── tsconfig.node.json ├── tsconfig.vitest.json ├── tsconfig.web.json ├── typings #全局d.ts | └── env.d.ts └── vitest.config.ts #vitest配置 ``` -------------------------------- ### Get Decrypted Token Source: https://plus-pro-components.com/api/utils/storage Retrieves and decrypts a token from localStorage using AES. Provide the key to get the decrypted token string. ```typescript /** * 获取token 带AES解密 * @returns token */ declare function getToken(key: string): string ``` ```typescript import { getToken } from '@plus-pro-components/utils' getToken('tokenKey') // 'token' ``` -------------------------------- ### openExe Source: https://plus-pro-components.com/api/utils/other Opens a local application on the computer using a specified protocol. ```APIDOC ## openExe ### Description Opens a local application on the computer by invoking its protocol handler. ### Method POST (conceptual, as it triggers an action) ### Endpoint N/A (Client-side function) ### Parameters - **protocol** (string) - Required - The protocol of the local application (e.g., `vscode://`). - **event** (Event) - Required - The click event from an element (e.g., `el-button` or native `button`). - **timeout** (number) - Optional - The timeout in milliseconds to consider the open action failed if no response is received. Defaults to 1000ms. ### Request Example ```html ``` ```javascript import { openExe } from '@plus-pro-components/utils'; const url = 'vscode://'; const handleClick = async (event) => { try { await openExe(url, event, 2000); // 2 second timeout console.log('Application opened successfully.'); } catch (error) { console.error('Failed to open application:', error); } }; ``` ### Response #### Success Response (200) - **FocusEvent** - A FocusEvent object if the application is successfully launched or focused. #### Response Example (This is a conceptual example as the actual response is an event object) ```json { "type": "focus", "target": " ``` ```ts import { openExe } from '@plus-pro-components/utils' const url = 'vscode://' const handleClick = async (event: MouseEvent) => { await openExe(url, event) } ``` -------------------------------- ### Get localStorage Item Source: https://plus-pro-components.com/api/utils/storage Use this function to retrieve an item from localStorage by its key. The retrieved value is returned. ```typescript /** * 获取 localStorage * @returns storage */ declare function getToken(key: string): string ``` ```typescript import { getStorage } from '@plus-pro-components/utils' getStorage('key') // { data: { username: "name" } } ``` -------------------------------- ### Exposes Source: https://plus-pro-components.com/components/date-picker The PlusDatePicker component exposes instances of the start and end el-date-picker components, allowing for direct manipulation or access to their methods. ```APIDOC ## Exposes ### Description The PlusDatePicker component exposes instances of the start and end el-date-picker components, allowing for direct manipulation or access to their methods. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **startPickerInstance** (object) - The instance of the start el-date-picker. - **endPickerInstance** (object) - The instance of the end el-date-picker. #### Response Example None ``` -------------------------------- ### Implement basic sidebar Source: https://plus-pro-components.com/components/sidebar Displays the standard sidebar configuration based on provided route information. ```vue sidebar/basic ``` -------------------------------- ### Basic DrawerForm Usage Source: https://plus-pro-components.com/components/drawer-form Demonstrates the basic implementation of the DrawerForm component. Ensure v-model values are defined using ref to prevent potential reactivity loss. ```vue ``` -------------------------------- ### Include PlusProComponents via unpkg CDN Source: https://plus-pro-components.com/guide/installation Include these script and link tags in your HTML's head section to use PlusProComponents directly from the unpkg CDN. This method makes the library available globally as `PlusProComponents`. ```html ``` -------------------------------- ### DrawerForm Exposes Source: https://plus-pro-components.com/components/drawer-form Exposed instances from the DrawerForm component. ```APIDOC ## DrawerForm Exposes ### Description Exposed instances from the DrawerForm component for programmatic access. ### Exposes - **`formInstance`** - Instance of the `el-form` component. Type: `object`. - **`drawerInstance`** - Instance of the `el-drawer` component. Type: `object`. ``` -------------------------------- ### 项目启动与开发命令 Source: https://plus-pro-components.com/guide/dev 用于安装依赖、启动开发环境及预览文档的常用命令。 ```sh pnpm i ``` ```sh pnpm docs:dev ``` ```sh pnpm dev ``` -------------------------------- ### Basic Page Usage Source: https://plus-pro-components.com/components/page Demonstrates the fundamental integration of the Page component. ```html ``` -------------------------------- ### 单行可编辑表格示例 Source: https://plus-pro-components.com/components/table 通过调用 formRefs 的 startCellEdit 方法实现单行编辑与校验。 ```text table/row-edit ``` -------------------------------- ### Disable End Date Logic Source: https://plus-pro-components.com/components/date-picker Use this function to determine if an end date should be disabled. It returns true if the end time is before the provided start value. ```javascript const endDisabledDate = (endTime, startValue) => { if (!startValue) return false return endTime.getTime() < new Date(startValue).getTime() } ``` -------------------------------- ### Customize Tooltip Icon with 'tooltip-icon' Slot Source: https://plus-pro-components.com/components/form.html Use the 'tooltip-icon' slot to provide a custom tooltip icon. This example replaces the default icon with an ElIcon Warning component. ```vue ``` -------------------------------- ### 配置 SCSS 命名空间变量 Source: https://plus-pro-components.com/guide/namespace 在样式文件中通过 @forward 覆盖 Element Plus 和 plus-pro-components 的命名空间变量。 ```scss @forward 'element-plus/theme-chalk/src/mixins/config.scss' with ( $namespace: 'ep' ); @forward 'plus-pro-components/theme-chalk/src/mixins/config.scss' with ( $el-namespace: 'ep' ); ``` -------------------------------- ### Form Event Handlers Source: https://plus-pro-components.com/components/form.html Provides example functions for handling form events such as changes, submissions, submission errors, and resets. These functions log the relevant data to the console. ```javascript const handleChange = (values: FieldValues, prop: PlusColumn) => { console.log(values, prop, 'change') } ``` ```javascript const handleSubmit = (values: FieldValues) => { console.log(values, 'Submit') } ``` ```javascript const handleSubmitError = (err: any) => { console.log(err, 'err') } ``` ```javascript const handleReset = () => { console.log('handleReset') } ``` -------------------------------- ### 配置 ElConfigProvider 命名空间 Source: https://plus-pro-components.com/guide/namespace 在根组件中使用 ElConfigProvider 并设置 namespace 属性。 ```html ``` -------------------------------- ### StepsForm Header Slot Rendering Source: https://plus-pro-components.com/components/steps-form Allows custom rendering of the StepsForm header using slots. This example shows how to use slots for header customization, similar to the simple style. ```vue ``` -------------------------------- ### 克隆仓库 Source: https://plus-pro-components.com/guide/dev 从 GitHub 或 Gitee 镜像克隆项目仓库。 ```sh git clone https://github.com/plus-pro-components/plus-pro-components.git ``` ```bash git clone https://gitee.com/plus-pro-components/plus-pro-components.git ``` -------------------------------- ### 完整引入 PlusProComponents Source: https://plus-pro-components.com/guide/quickstart 在 main.ts 中全局注册 PlusProComponents 及其样式。 ```typescript import { createApp } from 'vue' // 导入element-plus 及其样式 import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' // 导入plus-pro-components 及其样式 import PlusProComponents from 'plus-pro-components' import 'plus-pro-components/index.css' import App from './App.vue' const app = createApp(App) app.use(ElementPlus) // 使用 app.use(PlusProComponents) app.mount('#app') ``` -------------------------------- ### Handle Form Validation Event Source: https://plus-pro-components.com/components/form.html This example shows how to handle the 'validate' event emitted by the PlusForm component when form validation is performed. The handler receives the property name, validity status, and error message. ```html ``` ```typescript const handleValidate = (prop: FormItemProp, isValid: boolean, message: string) => { console.log(dropdownItem) } ``` -------------------------------- ### 恢复 PlusSearch 按钮布局 Source: https://plus-pro-components.com/guide/upgrade 通过 CSS 覆盖默认样式,使搜索按钮恢复到旧版本的布局。 ```css .plus-search .plus-search__button__wrapper.el-form-item { flex: none; } ``` -------------------------------- ### 新增组件流程 Source: https://plus-pro-components.com/guide/dev 创建新组件、配置导出、注册类型及预览组件的步骤。 ```sh pnpm run new table ``` ```text Confirm create table component? yes ``` ```sh ├── index.ts #主文件 ├── src | └── index.vue #组件实际代码 ├── style | ├── index.ts #组件按需加载 scss 样式,包含自身样式和外部样式 | └── css.ts #组件按需加载 css 样式,包含自身样式和外部样式 └── __tests__ └── table.test.tsx #单元测试代码 主要测试组件中的 props、event、slots、样式、CSS class 名、生命周期钩子,和其他相关的问题。 ``` ```ts export * from './table' ``` ```js import { PlusTable } from '@plus-pro-components/components/table' const plugins: Component[] = [PlusDialog, PlusPagination, PlusTable] ``` ```ts declare module '@vue/runtime-core' { export interface GlobalComponents { PlusTable: typeof import('plus-pro-components')['PlusTable'] } } ``` ```html ```