提交 a847f5f0 编写于 作者: W WOSHIMAHAIFENG

Merge branch 'dev' of https://gitcode.net/dcloud/hello-uni-app-x into dev-payment

此差异已折叠。
describe('component-native-list-view-refresh', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
//打开list-view测试页
page = await program.reLaunch('/pages/component/list-view/list-view-refresh')
await page.waitFor(600)
})
it('check_list_view_refresh', async () => {
await page.waitFor(async () => {
return await page.data('refresherTriggered') === false;
});
//等待下拉刷新结束
await page.waitFor(500)
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
})
})
<template>
<list-view v-if="list_show" id="listview" style="flex: 1;" show-scrollbar=false :refresher-enabled="true"
:refresher-triggered="refresherTriggered" @refresherrefresh="onRefresherrefresh">
<list-item class="item">
<text>向下滑动触发下拉刷新</text>
</list-item>
<list-item v-for="index in item_count" class="item">
<text>item-------{{index}}</text>
</list-item>
</list-view>
</template>
<script>
export default {
data() {
return {
item_count: 20,
list_show: false,
refresherTriggered: true
}
},
onLoad() {
//延迟显示list-view
setTimeout(() => {
this.list_show = true;
}, 500)
},
methods: {
onRefresherrefresh() {
this.refresherTriggered = true;
setTimeout(() => {
this.refresherTriggered = false;
}, 1000)
}
}
}
</script>
<style>
.item {
padding: 15px;
margin: 0 0 5px 0;
background-color: #fff;
border-radius: 5px;
}
.button_item {
width: 200px;
}
</style>
......@@ -182,7 +182,11 @@
@confirm="confirm_refresher_background_input"></input-data>
<enum-data :items="size_enum" title="通过id位置跳转" @change="item_change_size_enum"></enum-data>
<navigator url="/pages/component/list-view/list-view-refresh" hover-class="none">
<button type="primary" class="button">
list-view 下拉刷新
</button>
</navigator>
<navigator url="/pages/component/list-view/list-view-multiplex" hover-class="none">
<button type="primary" class="button">
list-view 对list-item复用测试
......
......@@ -20,4 +20,12 @@ describe('text-props', () => {
expect(height).toBe(0)
}
})
it('text nested', async () => {
page.callMethod("setTextNested")
const element = await page.$('#text-nested')
if (element != null) {
expect(await element.text()).toBe("二级节点文字红色且背景色黄色")
}
})
})
......@@ -78,7 +78,7 @@
<view class="text-box">
<text
>一级节点黑色
<text style="color: red;background-color: yellow;"
<text id="text-nested" ref="text-nested" style="color: red;background-color: yellow;"
>二级节点红色且背景色黄色
<text>三级节点不继承二级的颜色</text>
</text>
......@@ -114,7 +114,12 @@ export default {
singleLineText: 'uni-app x,终极跨平台方案',
}
},
methods: {},
methods: {
// 自动化测试
setTextNested() {
(this.$refs["text-nested"] as UniTextElement).value = "二级节点文字红色且背景色黄色";
}
}
}
</script>
......
......@@ -54,8 +54,7 @@
export default {
data() {
return {
list: [
// #ifdef APP
list: [
{
id: 'long-list',
url: 'long-list',
......@@ -72,8 +71,7 @@
url: 'long-list2'
},
] as Page[],
},
// #endif
},
{
id: 'list-news',
url: 'list-news',
......
......@@ -7,7 +7,7 @@
<view class="swiper-list">
<scroll-view ref="tabScroll" class="swiper-tabs" direction="horizontal" :show-scrollbar="false">
<view class="flex-row" style="align-self: flex-start;">
<text ref="swipertab" class="swiper-tabs-item" :class="swiperIndex==index ? 'swiper-tabs-item-active' : ''"
<text ref="swipertab" space="nbsp" class="swiper-tabs-item" :class="swiperIndex==index ? 'swiper-tabs-item-active' : ''"
v-for="(item, index) in swiperList" :key="index" @click="onTabClick(index)">
{{item.name}}
</text>
......@@ -209,7 +209,7 @@
// 滚动到水平中心位置
const scroll_x = x - this.swiperWidth / 2
if(this.tabScrollView !== null){
if(this.tabScrollView != null){
this.tabScrollView!.scrollLeft = scroll_x
}
},
......@@ -238,6 +238,9 @@
.swiper-list {
height: 100%;
/* #ifdef WEB */
flex: 1;
/* #endif */
}
.swiper-tabs {
......@@ -249,6 +252,7 @@
color: #555;
font-size: 16px;
padding: 12px 25px;
white-space: nowrap;
}
.swiper-tabs-item-active {
......
......@@ -165,7 +165,9 @@
const percentage = Math.abs(current_offset_x) / this.swiperWidth
// 通知更新指示线
this.updateTabIndicator(current_index, move_to_index, percentage)
if (current_index != move_to_index) {
this.updateTabIndicator(current_index, move_to_index, percentage)
}
// 首次可见时初始化数据
this.initSwiperItemData(move_to_index)
......@@ -242,6 +244,9 @@
.swiper-list {
height: 100%;
/* #ifdef WEB */
flex: 1;
/* #endif */
}
.swiper-tabs {
......@@ -253,6 +258,7 @@
color: #555;
font-size: 16px;
padding: 12px 25px;
white-space: nowrap;
}
.swiper-tabs-item-active {
......
......@@ -191,6 +191,7 @@
color: #555;
font-size: 16px;
padding: 12px 25px;
white-space: nowrap;
}
.swiper-tabs-item-active {
......
......@@ -143,6 +143,7 @@
color: #555;
font-size: 16px;
margin: 15px 25px 5px 25px;
white-space: nowrap;
}
.swiper-tabs-item-active {
......
## 1.0.6(2024-02-28)
- 更新 Circle 组件名称,防止与内置组件名冲突
## 1.0.5(2024-01-12)
- 优化 删除组件内无用日志输出
## 1.0.4(2024-01-10)
......
<template>
<view :ref="elId" class="block" :style="{width:size+'px',height:size+'px'}"></view>
</template>
<script>
import { hexToRgba } from './util'
export default {
name: "uni-snow",
props: {
speed: {
type: Number,
default: 16,
},
size: {
type: Number,
default: 20,
},
color: {
type: String,
default: '',
}
},
data() {
const elId = `Uni_${(Math.random() * 10e5).toInt().toString(36)}`
return {
elId: elId,
timer: 0,
};
},
mounted() {
const refs = this.$refs[this.elId] as UniElement
let ctx = refs.getDrawableContext()!
this.spinner(ctx)
},
unmounted() {
clearInterval(this.timer)
},
methods: {
spinner(ctx : DrawableContext) {
const steps = 12;
let step = 0;
const width = this.size;
const lineWidth = width / 12;
// 线长度和距离圆心距离
const length = width / 4 - lineWidth;
const offset = width / 4;
function draw() {
ctx.reset();
for (let i = 0; i < steps; i++) {
const stepAngle = 360 / steps;
const angle = stepAngle * i;
// 计算透明度
const opacity = ((steps - (step % steps)) * stepAngle + angle) % 360 + 30;
// 计算正余弦值
const sin = Math.sin((angle / 180) * Math.PI);
const cos = Math.cos((angle / 180) * Math.PI);
// 开始绘制线条
ctx.lineWidth = lineWidth;
ctx.lineCap = 'round';
ctx.beginPath();
ctx.moveTo(width / 2 + offset * cos, width / 2 + offset * sin);
ctx.lineTo(
width / 2 + (offset + length) * cos,
width / 2 + (offset + length) * sin
);
// 获取填充颜色
const fillColor = this.color !== '' ? this.color : '#333333';
// 转换透明度并设置颜色
ctx.strokeStyle = hexToRgba(fillColor, Math.round((opacity / 360) * 255));
ctx.stroke();
}
step += 1;
ctx.update();
}
draw()
// 每隔一段时间执行绘制函数
this.timer = setInterval(() => draw(), this.speed + 76);
}
}
}
</script>
<style scoped>
.block {
width: 50px;
height: 50px;
}
</style>
......@@ -4,12 +4,12 @@
<template v-if="loading">
<slot></slot>
<template v-if="$slots['default'] == null">
<Circle :speed="16" :size="loadWidth" :color="color"></Circle>
<LoadingCircle :speed="16" :size="loadWidth" :color="color"></LoadingCircle>
<text v-if="text" class="inline-text" :style=" { color: color }">{{text}}</text>
</template>
<template v-else>
<view class="uni-loading-mask" :style="{backgroundColor:background}">
<Circle :speed="16" :size="loadWidth" :color="color"></Circle>
<LoadingCircle :speed="16" :size="loadWidth" :color="color"></LoadingCircle>
<text v-if="text" class="block-text" :style=" { color: color }">{{text}}</text>
</view>
</template>
......@@ -20,7 +20,7 @@
</view>
</template>
<script>
import Circle from './circle.uvue'
import LoadingCircle from './loading-circle.uvue'
// TODO 性能问题,其他类型暂时不对外开放
// import Icon from './icon.uvue'
// import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue'
......@@ -45,7 +45,7 @@
export default {
name: "uni-loading",
components: { Circle },
components: { LoadingCircle },
props: {
loading: {
type: Boolean,
......
{
"id": "uni-loading",
"displayName": "uni-loading",
"version": "1.0.5",
"version": "1.0.6",
"description": "加载动画组件多用在页面内数据加载时,提供一个loading动画,列表的上拉加载,下拉刷新等都需要加载动画",
"keywords": [
"loading",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册