feat: 调整项目结构

This commit is contained in:
duanshuwen
2025-09-21 17:25:09 +08:00
parent 0b66462d16
commit 9f23854ad5
410 changed files with 3806 additions and 1668 deletions

View File

@@ -0,0 +1,72 @@
# Stepper 数字步进器组件
一个简洁易用的数字步进器组件,支持增减操作和数值范围限制。
## 功能特性
-**双向数据绑定**:支持 v-model 语法糖
- 🔢 **数值范围控制**:可设置最小值和最大值
- 🎯 **响应式更新**:实时响应外部数值变化
- 🎨 **简洁UI设计**:使用 uni-icons 图标,界面清爽
- 📱 **移动端适配**:完美适配各种屏幕尺寸
## 使用方法
### 基础用法
```vue
<template>
<Stepper v-model="quantity" />
</template>
<script setup>
import { ref } from 'vue'
import Stepper from '@/components/Stepper/index.vue'
const quantity = ref(1)
</script>
```
### 设置数值范围
```vue
<template>
<Stepper
v-model="quantity"
:min="1"
:max="10"
/>
</template>
```
## API
### Props
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| modelValue | Number | 1 | 当前数值,支持 v-model |
| min | Number | 1 | 最小值 |
| max | Number | 100 | 最大值 |
### Events
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| update:modelValue | 数值变化时触发 | (value: number) |
## 更新日志
### v1.1.0 (2024-12-19)
**修复响应性问题**
- 🐛 修复组件不响应外部 modelValue 变化的问题
- 🔄 添加 watch 监听器,确保实时同步外部值变化
- ✨ 提升组件响应性和数据同步准确性
- 🎯 完善与父组件的双向数据绑定
### v1.0.0
**初始版本**
- ✨ 基础数字步进器功能
- 🔢 支持数值范围控制
- 🎨 简洁的UI设计
- 📱 移动端适配

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,63 @@
<template>
<view class="stepper-wrapper">
<uni-icons type="minus" size="24" color="#999" @click="decrease" />
<text class="stepper-text">{{ value }}</text>
<uni-icons type="plus" size="24" color="#999" @click="increase" />
</view>
</template>
<script setup>
import { ref, defineProps, defineEmits, watch } from "vue";
// Props
const props = defineProps({
modelValue: {
type: Number,
default: 1,
},
min: {
type: Number,
default: 1,
},
max: {
type: Number,
default: 100,
},
});
// Emit
const emit = defineEmits(["update:modelValue"]);
// Local state
const value = ref(props.modelValue);
// 监听外部值变化,同步更新本地状态
watch(
() => props.modelValue,
(newValue) => {
value.value = newValue;
},
{ immediate: true }
);
// Methods
const decrease = () => {
if (value.value === 1) return;
if (value.value > props.min) {
value.value--;
emit("update:modelValue", value.value);
}
};
const increase = () => {
if (value.value < props.max) {
value.value++;
emit("update:modelValue", value.value);
}
};
</script>
<style scoped lang="scss">
@use "./styles/index.scss";
</style>

View File

@@ -0,0 +1,12 @@
## 步进器组件
## 提示词:
使用 uniapp + vue3 组合式 api 开发微信小程序,要求如下:
1、参考图片高度还原交互设计完成组件封装
2、要求布局样式结构简洁明了class 命名请按照模块名称来命名,例如:.stepper-wrapper
3、可以使用 uniapp 内置的组件
## 备注
仅供学习、交流使用,请勿用于商业用途。

View File

@@ -0,0 +1,11 @@
.stepper-wrapper {
display: flex;
align-items: center;
}
.stepper-text {
width: 40px;
font-size: 16px;
color: #333;
text-align: center;
}