diff --git a/WOT-COMPONENTS.md b/WOT-COMPONENTS.md deleted file mode 100644 index 57c1ec9..0000000 --- a/WOT-COMPONENTS.md +++ /dev/null @@ -1,1458 +0,0 @@ -# Wot Design Uni 组件使用文档 - -> 本项目使用 [wot-design-uni](https://wot-design-uni.cn/) 作为 UI 组件库 - -## 目录 - -- [安装配置](#安装配置) -- [基础组件](#基础组件) -- [表单组件](#表单组件) -- [反馈组件](#反馈组件) -- [展示组件](#展示组件) -- [导航组件](#导航组件) -- [业务场景](#业务场景) - ---- - -## 安装配置 - -### 1. 安装依赖 - -```bash -pnpm add wot-design-uni -``` - -### 2. 配置自动导入 - -```typescript -// vite.config.ts -import { defineConfig } from 'vite' -import uni from '@dcloudio/vite-plugin-uni' -import Components from '@uni-helper/vite-plugin-uni-components' -import { WotResolver } from '@uni-helper/vite-plugin-uni-components/resolvers' - -export default defineConfig({ - plugins: [ - uni(), - Components({ - resolvers: [WotResolver()] - }) - ] -}) -``` - -### 3. 引入样式 - -```typescript -// main.ts -import 'wot-design-uni/components/common/abstracts/variable.scss' -``` - -### 4. TypeScript 支持 - -```json -// tsconfig.json -{ - "compilerOptions": { - "types": ["wot-design-uni/global.d.ts"] - } -} -``` - ---- - -## 基础组件 - -### Button 按钮 - -```vue - -``` - -### Icon 图标 - -```vue - -``` - -### Image 图片 - -```vue - -``` - ---- - -## 表单组件 - -### Input 输入框 - -```vue - - - -``` - -### Textarea 文本域 - -```vue - - - -``` - -### Search 搜索框 - -```vue - - - -``` - -### Form 表单 - -```vue - - - -``` - -### Picker 选择器 - -```vue - - - -``` - -### Switch 开关 - -```vue - - - -``` - -### Checkbox 复选框 - -```vue - - - -``` - -### Radio 单选框 - -```vue - - - -``` - ---- - -## 反馈组件 - -### Toast 轻提示 - -```typescript -// 使用方式 -import { useToast } from 'wot-design-uni' - -const toast = useToast() - -// 文字提示 -toast.show('提示内容') - -// 成功 -toast.success('操作成功') - -// 失败 -toast.error('操作失败') - -// 警告 -toast.warning('警告信息') - -// 加载中 -toast.loading('加载中...') - -// 关闭 -toast.close() - -// 带配置 -toast.show({ - msg: '提示内容', - duration: 3000, - iconName: 'check', - position: 'middle' -}) -``` - -```vue - - - -``` - -### Message 消息提示 - -```typescript -import { useMessage } from 'wot-design-uni' - -const message = useMessage() - -// 基础使用 -message.show('这是一条消息') - -// 类型 -message.success('成功消息') -message.error('错误消息') -message.warning('警告消息') -message.info('信息提示') - -// 配置 -message.show({ - msg: '消息内容', - type: 'success', - duration: 3000, - closable: true -}) -``` - -### Dialog 对话框 - -```vue - - - -``` - -### ActionSheet 动作面板 - -```vue - - - -``` - -### Popup 弹出层 - -```vue - - - -``` - -### Loading 加载 - -```vue - -``` - -### Notify 消息通知 - -```typescript -import { useNotify } from 'wot-design-uni' - -const notify = useNotify() - -// 基础使用 -notify.show('消息内容') - -// 类型 -notify.primary('主要通知') -notify.success('成功通知') -notify.warning('警告通知') -notify.danger('危险通知') - -// 配置 -notify.show({ - message: '通知内容', - type: 'success', - duration: 3000, - position: 'top' -}) -``` - ---- - -## 展示组件 - -### Cell 单元格 - -```vue - -``` - -### Badge 徽标 - -```vue - -``` - -### Tag 标签 - -```vue - -``` - -### Empty 空状态 - -```vue - -``` - -### Collapse 折叠面板 - -```vue - - - -``` - -### Progress 进度条 - -```vue - -``` - -### Skeleton 骨架屏 - -```vue - - - -``` - -### Swiper 轮播 - -```vue - - - -``` - ---- - -## 导航组件 - -### Navbar 导航栏 - -```vue - - - -``` - -### Tabbar 标签栏 - -```vue - - - -``` - -### Tabs 标签页 - -```vue - - - -``` - -### IndexBar 索引栏 - -```vue - - - -``` - -### SwipeAction 滑动操作 - -```vue - - - -``` - -### PullRefresh 下拉刷新 - -```vue - - - -``` - -### Loadmore 加载更多 - -```vue - - - -``` - ---- - -## 业务场景 - -### 场景1:会话列表项 - -```vue - -``` - -### 场景2:聊天消息输入 - -```vue - -``` - -### 场景3:好友申请列表 - -```vue - -``` - -### 场景4:朋友圈动态卡片 - -```vue - -``` - -### 场景5:设置页面 - -```vue - -``` - ---- - -## 主题定制 - -### 修改主题色 - -```scss -// uni.scss -@import 'wot-design-uni/components/common/abstracts/_variable.scss'; - -// 覆盖变量 -$-color-theme: #07c160; -$-color-success: #07c160; -$-color-danger: #ee0a24; -$-color-warning: #ff976a; -``` - -### 暗色模式适配 - -```scss -// 暗色模式下的组件样式覆盖 -page.dark { - // Cell - --wot-cell-bg-color: var(--bg-content); - --wot-cell-title-color: var(--text-primary); - --wot-cell-label-color: var(--text-secondary); - --wot-cell-value-color: var(--text-tertiary); - - // Button - --wot-button-normal-bg-color: var(--bg-content); - --wot-button-normal-color: var(--text-primary); - - // Input - --wot-input-bg-color: var(--bg-content); - --wot-input-color: var(--text-primary); - --wot-input-placeholder-color: var(--text-placeholder); -} -``` - ---- - -## 常见问题 - -### 1. 组件样式不生效 - -确保在 `main.ts` 中引入了样式文件: - -```typescript -import 'wot-design-uni/components/common/abstracts/variable.scss' -``` - -### 2. TypeScript 类型报错 - -在 `tsconfig.json` 中添加类型声明: - -```json -{ - "compilerOptions": { - "types": ["wot-design-uni/global.d.ts"] - } -} -``` - -### 3. 自动导入不生效 - -检查 `vite.config.ts` 配置是否正确,确保安装了 `@uni-helper/vite-plugin-uni-components`。 - -### 4. 小程序端组件不显示 - -某些组件在小程序端需要在 `pages.json` 中配置: - -```json -{ - "usingComponents": { - "wd-button": "wot-design-uni/components/wd-button/wd-button" - } -} -``` - ---- - -## 参考链接 - -- [wot-design-uni 官方文档](https://wot-design-uni.cn/) -- [组件列表](https://wot-design-uni.cn/component/button.html) -- [主题定制](https://wot-design-uni.cn/guide/custom-theme.html) -- [GitHub 仓库](https://github.com/Moonofweisheng/wot-design-uni)