# CutThink Lite - UI 框架文档 ## 概述 CutThink Lite 的 UI 框架提供了一套完整的 CSS 变量系统和可复用的 JavaScript 组件。 ## CSS 变量系统 ### 颜色变量 ```css /* 品牌色 */ --primary: #8B6914; --primary-hover: #A67C00; --primary-light: #F5E6C8; --primary-dark: #6B520F; /* 功能色 */ --danger: #EF4444; --success: #10B981; --warning: #F59E0B; --info: #3B82F6; /* 背景色 */ --bg-primary: #FFFFFF; --bg-secondary: #F8F9FA; --bg-tertiary: #E5E7EB; --bg-sidebar: #FFFFFF; /* 文本色 */ --text-primary: #1F2937; --text-secondary: #6B7280; --text-muted: #9CA3AF; ``` ### 间距系统 ```css --spacing-xs: 4px; --spacing-sm: 8px; --spacing-md: 12px; --spacing-lg: 16px; --spacing-xl: 20px; --spacing-2xl: 24px; --spacing-3xl: 32px; --spacing-4xl: 40px; ``` ### 圆角 ```css --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-full: 9999px; ``` ### 阴影 ```css --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05); --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1); --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1); ``` ## JavaScript 组件 ### 1. Layout 布局组件 ```javascript import { Layout } from '@/components/shared/Layout.js' const layout = new Layout({ header: true, sidebar: true, headerOptions: { title: 'CutThink Lite', version: 'v0.1.0', searchable: true, actions: [ { icon: '⚙️', title: '设置', onClick: () => {} } ] }, sidebarOptions: { sections: [ { title: '主要功能', items: [ { id: 'screenshot', icon: '📷', label: '截图', active: true }, { id: 'gallery', icon: '🖼️', label: '图库' } ] } ] } }) document.getElementById('app').appendChild(layout.render()) ``` ### 2. Button 按钮组件 ```javascript import { Button } from '@/components/shared/Button.js' const button = new Button({ text: '点击我', icon: '✓', variant: 'primary', // primary, secondary, danger, success, ghost size: 'md', // sm, md, lg onClick: () => console.log('Clicked!') }) document.body.appendChild(button.render()) ``` ### 3. Input 输入框组件 ```javascript import { Input } from '@/components/shared/Input.js' const input = new Input({ label: '用户名', placeholder: '请输入用户名', required: true, hint: '用户名长度为 4-20 个字符', onChange: (value) => console.log(value) }) document.body.appendChild(input.render()) ``` ### 4. Card 卡片组件 ```javascript import { Card } from '@/components/shared/Card.js' const card = new Card({ title: '卡片标题', icon: '📝', content: '
这是卡片内容
', actions: [ { text: '编辑', onClick: () => {} }, { text: '删除', onClick: () => {} } ] }) document.body.appendChild(card.render()) ``` ### 5. Toast 通知组件 ```javascript import { Toast } from '@/components/shared/Toast.js' // 显示不同类型的通知 Toast.success('成功', '操作已完成!') Toast.danger('错误', '操作失败,请重试。') Toast.warning('警告', '请注意检查输入。') Toast.info('信息', '这是一条通知。') // 自定义配置 Toast.show({ type: 'success', title: '自定义标题', message: '自定义消息', duration: 5000 }) ``` ### 6. Modal 模态框组件 ```javascript import { Modal } from '@/components/shared/Modal.js' // 创建模态框 const modal = new Modal({ title: '确认操作', content: '确定要执行此操作吗?
', onConfirm: () => console.log('Confirmed'), onCancel: () => console.log('Cancelled') }) // 静态方法 Modal.confirm({ title: '删除确认', content: '确定要删除这条记录吗?' }).then(result => { if (result) { // 用户点击了确定 } }) ``` ## CSS 类名 ### 布局类 ```html