### Install Dependencies and Login Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/README.md Installs project dependencies, the CloudBase CLI globally, and logs in to your Tencent Cloud account. Ensure you have Node.js installed. ```bash npm install npm install -g @cloudbase/cli tcb login ``` -------------------------------- ### Invoke Custom Action with Parameters Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Example of passing parameters to the showToast action within the platform configuration. ```json // 使用示例(在微搭低代码平台配置) // 调用 showToast 动作时传入参数: { "title": "保存成功", "icon": "success", "duration": 2000 } ``` -------------------------------- ### Debug Local Components Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/README.md Starts a local debugging server to test custom components within the Weda editor. This command allows for rapid iteration during development. ```bash tcb lowcode debug ``` -------------------------------- ### Gantt Chart Component Example Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Demonstrates how to use the Gantt component for project management and task scheduling visualization. Supports task dragging and progress updates. Requires React. ```jsx import React from 'react'; import { Gantt } from './web/components'; // 完整甘特图示例 const GanttExample = () => { // 任务数据定义 const tasks = [ { start: '2023-04-01', end: '2023-04-15', name: '项目', id: 'ProjectSample', progress: 25, type: 'project', // 项目类型 hideChildren: false, displayOrder: 1, }, { start: '2023-04-01', end: '2023-04-02', name: '计划', id: 'Task 0', progress: 45, type: 'task', // 任务类型 project: 'ProjectSample', // 所属项目 displayOrder: 2, }, { start: '2023-04-02', end: '2023-04-04', name: '调研', id: 'Task 1', progress: 25, dependencies: ['Task 0'], // 依赖关系 type: 'task', project: 'ProjectSample', displayOrder: 3, }, { start: '2023-04-04', end: '2023-04-08', name: '研发', id: 'Task 3', progress: 2, dependencies: ['Task 1'], type: 'task', project: 'ProjectSample', displayOrder: 4, }, { start: '2023-04-15', end: '2023-04-15', name: '发布', id: 'Task 6', progress: 25, type: 'milestone', // 里程碑类型 dependencies: ['Task 3'], project: 'ProjectSample', displayOrder: 5, }, { start: '2023-04-18', end: '2023-04-19', name: '团建', id: 'Task 9', progress: 0, isDisabled: true, // 禁用任务(不可拖拽) type: 'task', }, ]; // 样式配置 const stylingOption = { listCellWidth: '155px', // 任务列表单元格宽度 columnWidth: '65', // 列宽 }; // 显示配置 const displayOption = { viewMode: 'Day', // 视图模式:'Day' | 'Week' | 'Month' locale: 'zh', // 语言:中文 }; // 事件处理器 const events = { onClick: ({ task }) => { console.log('任务点击:', task); }, onSelect: ({ task, isSelected }) => { console.log('任务选择:', task, isSelected); }, onDoubleClick: ({ task }) => { console.log('任务双击:', task); }, onDelete: ({ task, callback }) => { console.log('任务删除:', task); // 调用 callback 确认删除 callback(); }, onDateChange: ({ task, children }) => { console.log('日期变更:', task, children); }, onProgressChange: ({ task, children }) => { console.log('进度变更:', task, children); }, onExpanderClick: ({ task }) => { console.log('展开/收起:', task); }, }; return ( ); }; export default GanttExample; ``` -------------------------------- ### Configure ECharts Chart Options Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Example configurations for line and pie charts to be passed to the ECharts component. ```javascript // 配置示例:折线图 const lineChartOption = { xAxis: { type: 'category', data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] }, yAxis: { type: 'value' }, series: [{ data: [150, 230, 224, 218, 135, 147, 260], type: 'line', smooth: true }] }; // 配置示例:饼状图 const pieChartOption = { series: [{ type: 'pie', radius: '50%', data: [ { value: 1048, name: '搜索引擎' }, { value: 735, name: '直接访问' }, { value: 580, name: '邮件营销' }, { value: 484, name: '联盟广告' }, ] }] }; ``` -------------------------------- ### Create a New Component Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/README.md Generates the initial configuration and file structure for a new custom component. You will be prompted to enter the component name. ```bash npm run new ``` -------------------------------- ### Register Components and Actions Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Centralized registration file for components and actions. ```javascript // 组件注册入口 - src/configs/index.js import Button from './components/button'; import Gantt from './components/gantt.json'; import Chart from './components/echart.json'; import Slider from './components/slider.json'; import showToast from './actions/showToast'; export const components = { Button, Gantt, Chart, Slider, }; export const actions = { showToast, }; export default { components, actions }; ``` -------------------------------- ### 运行组件测试 Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/src/stories/Introduction.stories.mdx 执行项目配置的测试脚本以验证组件功能。 ```bash npm test ``` -------------------------------- ### Run Storybook for Gantt Chart Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/src/web/components/gantt/README.md Execute this command to view the component storybook locally. ```bash npm run storybook ``` -------------------------------- ### 调试与发布组件 Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/src/stories/Introduction.stories.mdx 使用云开发命令行工具进行组件的本地调试与线上发布。 ```bash tcb lowcode debug ``` ```bash tcb lowcode publish ``` -------------------------------- ### Implement Custom showToast Action Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Cross-platform action implementation for displaying toast notifications. ```javascript // 小程序端实现 - src/mp/actions/showToast/index.js export default function showToast({ data }) { wx.showToast(data); } // Web 端实现 - src/web/actions/showToast/index.js export default function showToast({ data }) { alert(data?.title); // 可替换为自定义 Toast 组件 } ``` -------------------------------- ### Scaffold New Component Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Command to generate the boilerplate structure for a new component. ```bash # 创建新组件 npm run new # 输入组件名称(如:Image) # 自动生成以下文件结构: # src/ # configs/ # components/ # image.json # 组件配置文件 # index.js # 自动更新组件注册 # web/ # components/ # image/ # index.jsx # Web 端组件实现 ``` -------------------------------- ### Define Action Configuration Schema Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt JSON Schema definition for the showToast action parameters and metadata. ```json // Action 配置文件 - src/configs/actions/showToast.json { "data": { "type": "object", "properties": { "title": { "title": "标题", "type": "string", "default": "提示的内容" }, "icon": { "title": "图标", "type": "string", "default": "success", "enum": [ { "label": "success", "value": "success" }, { "label": "loading", "value": "loading" }, { "label": "none", "value": "none" } ] }, "duration": { "title": "提示的延迟时间", "type": "number", "default": 1500 } } }, "meta": { "title": "自定义提示", "description": "自定义提示" } } ``` -------------------------------- ### 初始化与发布自定义组件 Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt 使用 tcb-cli 工具进行项目依赖安装、登录、本地调试及组件发布。 ```bash # 克隆项目并安装依赖 git clone cd weda_custom_components npm install # 安装腾讯云 CLI 工具并登录 npm install -g @cloudbase/cli tcb login # 启动本地调试(连接微搭编辑器) tcb lowcode debug # 发布组件到微搭平台 tcb lowcode publish # 本地 Storybook 开发调试 npm run storybook ``` -------------------------------- ### 实现 Web 端 Button 组件 Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt 基于 React 实现的 Web 端按钮组件,支持多种类型、尺寸及事件处理配置。 ```jsx // Web 端使用示例 - src/web/components/button/index.jsx import * as React from 'react'; import { Button } from './web/components'; // 基础用法 - 主要按钮 Component({ properties: { text: { type: String, value: '按钮' }, size: { type: String, value: 'default' }, // 'default' | 'mini' type: { type: String, value: 'primary' }, // 'primary' | 'default' | 'warn' plain: { type: Boolean, value: false }, loading: { type: Boolean, value: false }, disabled: { type: Boolean, value: false }, }, methods: { triggerCustomEvent(e) { this.triggerEvent('customevent', e); }, }, }); ``` -------------------------------- ### Define Component Configuration Schema Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt JSON Schema for defining component properties, events, and metadata. ```json // 组件配置示例 - src/configs/components/button.json { "$schema": "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/schema/lcds_component.json", "data": { "type": "object", "properties": { "text": { "title": "按钮文字", "default": "按钮", "type": "string" }, "size": { "title": "按钮大小", "type": "string", "default": "default", "x-component": "radio", "enum": [ { "label": "default", "value": "default" }, { "label": "mini", "value": "mini" } ] }, "type": { "title": "按钮类型", "type": "string", "default": "primary", "x-component": "radio", "enum": [ { "label": "default", "value": "default" }, { "label": "primary", "value": "primary" }, { "label": "warn", "value": "warn" } ] }, "loading": { "title": "加载中", "type": "boolean", "default": false }, "disabled": { "title": "禁用", "type": "boolean", "default": false } } }, "events": [ { "name": "customevent", "title": "自定义事件" } ], "meta": { "title": "按钮", "description": "按钮组件,兼容小程序和H5平台", "icon": "../icons/button.svg", "category": "表单", "componentOrder": 1 } } ``` -------------------------------- ### Publish Custom Component Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/README.md Uploads your custom component code to your Tencent Cloud account. After uploading, you can publish the component library in the Weda platform for use in applications. ```bash tcb lowcode publish ``` -------------------------------- ### Check Code Style Source: https://github.com/tencentcloudbase/weda-custom-components/blob/main/README.md Performs a code style check on your project files to ensure consistency and adherence to project standards. ```bash npm run lint ``` -------------------------------- ### Integrate Chart Component in Page Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Usage of the chart component within a WXML template and the corresponding Page logic. ```javascript // 小程序页面中使用 // WXML: // // JS: Page({ data: { chartOption: lineChartOption }, onChartReady({ detail }) { const { echartsInstance, echarts } = detail; console.log('图表初始化完成', echartsInstance); } }); ``` -------------------------------- ### Implement ECharts Component for Mini Program Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Defines a custom component using ECharts with support for dark mode and dynamic option configuration. ```javascript // 小程序端使用示例 - src/mp/components/chart/echart/index.js Component({ properties: { option: { type: Object, value: {}, // ECharts 配置项 }, dark: { type: Boolean, value: false, // 深色模式 }, }, methods: { async initChart(canvas, width, height, dpr) { const theme = this.data.dark ? 'dark' : null; const objEchart = echarts.init(canvas, theme, { width, height, devicePixelRatio: dpr, }); objEchart.setOption(this.data.option, true); this._chart = objEchart; // 触发 onReady 事件,返回 ECharts 实例 this.triggerEvent('onReady', { echartsInstance: objEchart, echarts }); return objEchart; }, }, }); ``` -------------------------------- ### Slider in Weda Form Integration Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Shows how to integrate the Slider component into a Weda form using the `useFormInputTrait` hook for controlled and uncontrolled value management and form validation. ```jsx import { useFormInputTrait } from '@cloudbase/weda-ui'; const FormSlider = React.forwardRef(function FormSlider(props, inputRef) { const { value, // 兼容受控与非受控的 value disabled, // 禁用状态 readOnly, // 只读状态 onChange, // 封装后的 onChange } = useFormInputTrait({ $widget: props.$widget, // runtime 传入的 widget 实例 inputRef, name: props.name, value: props.value, disabled: props.disabled, onChange: props.onChange, }); const handleChange = React.useCallback((value) => { onChange?.(value); props.events?.change?.({ value }); }, [props.events, onChange]); return ( ); }); ``` -------------------------------- ### Basic Slider Component Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt A basic slider component for web applications, supporting min, max, step, and value configurations. It includes an optional change event handler. ```jsx console.log('值变更:', value) }} /> ``` -------------------------------- ### Slider with Stepped Marks Source: https://context7.com/tencentcloudbase/weda-custom-components/llms.txt Configures a slider to only allow selection at specific step values, useful for ratings or discrete selections. Includes a custom change handler. ```jsx handleRatingChange(value) }} /> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.