Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
61481937
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
61481937
编写于
1月 10, 2024
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unicloud-db-contacts: 简化变量命名, 更新 uni-loading 组件
上级
d619a122
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
224 addition
and
148 deletion
+224
-148
pages/component/mixin-datacom/datacom.uvue
pages/component/mixin-datacom/datacom.uvue
+1
-1
pages/component/unicloud-db-contacts/add.uvue
pages/component/unicloud-db-contacts/add.uvue
+4
-3
pages/component/unicloud-db-contacts/detail.uvue
pages/component/unicloud-db-contacts/detail.uvue
+7
-7
pages/component/unicloud-db-contacts/edit.uvue
pages/component/unicloud-db-contacts/edit.uvue
+10
-10
pages/component/unicloud-db-contacts/list.uvue
pages/component/unicloud-db-contacts/list.uvue
+11
-6
uni_modules/uni-loading/changelog.md
uni_modules/uni-loading/changelog.md
+6
-0
uni_modules/uni-loading/components/uni-loading/circle.uvue
uni_modules/uni-loading/components/uni-loading/circle.uvue
+180
-106
uni_modules/uni-loading/components/uni-loading/icon.uvue
uni_modules/uni-loading/components/uni-loading/icon.uvue
+2
-12
uni_modules/uni-loading/components/uni-loading/uni-loading.uvue
...dules/uni-loading/components/uni-loading/uni-loading.uvue
+2
-2
uni_modules/uni-loading/package.json
uni_modules/uni-loading/package.json
+1
-1
未找到文件。
pages/component/mixin-datacom/datacom.uvue
浏览文件 @
61481937
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
const data = res.data
const data = res.data
// const count = res.count
// const count = res.count
this.mixinDatacomResData = data
this.mixinDatacomResData = data
}).catch((err) => {
}).catch((err
: any | null
) => {
this.mixinDatacomError = err as UniCloudError
this.mixinDatacomError = err as UniCloudError
}).finally(() => {
}).finally(() => {
this.mixinDatacomLoading = false
this.mixinDatacomLoading = false
...
...
pages/component/unicloud-db-contacts/add.uvue
浏览文件 @
61481937
...
@@ -40,18 +40,19 @@
...
@@ -40,18 +40,19 @@
return {
return {
collection: COLLECTION_NAME,
collection: COLLECTION_NAME,
genderList: GenderList as GenderType[],
genderList: GenderList as GenderType[],
$
uniCloudElement: null as UniCloudDBElement | null
uniCloudElement: null as UniCloudDBElement | null
}
}
},
},
onReady() {
onReady() {
this.
$
uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
},
methods: {
methods: {
onFormSubmit: function (e : FormSubmitEvent) {
onFormSubmit: function (e : FormSubmitEvent) {
const formData = e.detail.value
const formData = e.detail.value
const genderString = formData['gender'] as string
const genderString = formData['gender'] as string
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
this.$uniCloudElement!.add(formData, {
console.log('formData', formData)
this.uniCloudElement!.add(formData, {
showToast: false,
showToast: false,
needLoading: true,
needLoading: true,
loadingTitle: "正在保存...",
loadingTitle: "正在保存...",
...
...
pages/component/unicloud-db-contacts/detail.uvue
浏览文件 @
61481937
...
@@ -39,14 +39,14 @@
...
@@ -39,14 +39,14 @@
return {
return {
collection: '',
collection: '',
where: '',
where: '',
$
whereID: '',
whereID: '',
$
uniCloudElement: null as UniCloudDBElement | null
uniCloudElement: null as UniCloudDBElement | null
}
}
},
},
onLoad(options
: Map<string, string>
) {
onLoad(options) {
this.collection = COLLECTION_NAME;
this.collection = COLLECTION_NAME;
this.
$whereID = options.get('id')
as string;
this.
whereID = options['id']
as string;
this.where = `_id=='${this.
$
whereID}'`;
this.where = `_id=='${this.whereID}'`;
},
},
onShow() {
onShow() {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
},
},
onReady() {
onReady() {
this.
$
uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
},
methods: {
methods: {
displayGender(value : number | null) : string {
displayGender(value : number | null) : string {
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
})
})
},
},
onDataChange(_ : string) {
onDataChange(_ : string) {
this.
$
uniCloudElement!.loadData()
this.uniCloudElement!.loadData()
}
}
}
}
}
}
...
...
pages/component/unicloud-db-contacts/edit.uvue
浏览文件 @
61481937
...
@@ -49,31 +49,31 @@
...
@@ -49,31 +49,31 @@
collection: '',
collection: '',
where: '',
where: '',
genderList: GenderList as GenderType[],
genderList: GenderList as GenderType[],
$
whereID: '',
whereID: '',
$
uniCloudElement: null as UniCloudDBElement | null
uniCloudElement: null as UniCloudDBElement | null
}
}
},
},
onLoad(options
: Map<string, string>
) {
onLoad(options) {
this.collection = COLLECTION_NAME;
this.collection = COLLECTION_NAME;
this.
$whereID = options.get('id')
as string;
this.
whereID = options['id']
as string;
this.where = `_id=='${this.
$
whereID}'`;
this.where = `_id=='${this.whereID}'`;
},
},
onReady() {
onReady() {
this.
$
uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
},
methods: {
methods: {
onFormSubmit: function (e : FormSubmitEvent) {
onFormSubmit: function (e : FormSubmitEvent) {
const formData = e.detail.value
const formData = e.detail.value
const genderString = formData['gender'] as string
const genderString = formData['gender'] as string
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
this.
$uniCloudElement!.update(this.$
whereID, formData, {
this.
uniCloudElement!.update(this.
whereID, formData, {
showToast: false,
showToast: false,
needLoading: true,
needLoading: true,
needConfirm: false,
needConfirm: false,
loadingTitle: "正在保存...",
loadingTitle: "正在保存...",
success: (_ : UniCloudDBUpdateResult) => {
success: (_ : UniCloudDBUpdateResult) => {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
uni.$emit(UNICLOUD_DB_CONTACTS_UPDATE, this.
$
whereID)
uni.$emit(UNICLOUD_DB_CONTACTS_UPDATE, this.whereID)
setTimeout(() => {
setTimeout(() => {
uni.navigateBack()
uni.navigateBack()
}, 500)
}, 500)
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
})
})
},
},
remove(id : string | null, name : string | null) {
remove(id : string | null, name : string | null) {
this.
$
uniCloudElement!.remove(id!, {
this.uniCloudElement!.remove(id!, {
needConfirm: true,
needConfirm: true,
needLoading: true,
needLoading: true,
loadingTitle: "正在删除...",
loadingTitle: "正在删除...",
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
confirmContent: name,
confirmContent: name,
success: (_ : UniCloudDBRemoveResult) => {
success: (_ : UniCloudDBRemoveResult) => {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
uni.$emit(UNICLOUD_DB_CONTACTS_DELETE, this.
$
whereID)
uni.$emit(UNICLOUD_DB_CONTACTS_DELETE, this.whereID)
setTimeout(() => {
setTimeout(() => {
uni.navigateBack({
uni.navigateBack({
delta: 2
delta: 2
...
...
pages/component/unicloud-db-contacts/list.uvue
浏览文件 @
61481937
...
@@ -29,14 +29,14 @@
...
@@ -29,14 +29,14 @@
data() {
data() {
return {
return {
collection: COLLECTION_NAME,
collection: COLLECTION_NAME,
$
uniCloudElement: null as UniCloudDBElement | null
uniCloudElement: null as UniCloudDBElement | null
}
}
},
},
onReady() {
onReady() {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
uni.$on(UNICLOUD_DB_CONTACTS_DELETE, this.onDataChange);
uni.$on(UNICLOUD_DB_CONTACTS_DELETE, this.onDataChange);
this.
$
uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.
$
uniCloudElement!.loadData()
this.uniCloudElement!.loadData()
},
},
onUnload() {
onUnload() {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
},
},
onPullDownRefresh() {
onPullDownRefresh() {
this.
$
uniCloudElement!.loadData({
this.uniCloudElement!.loadData({
clear: true,
clear: true,
success: (_ : UniCloudDBGetResult) => {
success: (_ : UniCloudDBGetResult) => {
uni.stopPullDownRefresh()
uni.stopPullDownRefresh()
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
},
},
methods: {
methods: {
loadMore() {
loadMore() {
this.
$
uniCloudElement!.loadMore()
this.uniCloudElement!.loadMore()
},
},
gotoAddPage() {
gotoAddPage() {
// TODO 后续通过 EventChannel 实现
// TODO 后续通过 EventChannel 实现
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
})
})
},
},
onDataChange(_ : string) {
onDataChange(_ : string) {
this.
$
uniCloudElement!.loadData({
this.uniCloudElement!.loadData({
clear: true
clear: true
})
})
}
}
...
@@ -97,6 +97,11 @@
...
@@ -97,6 +97,11 @@
.udb {
.udb {
flex: 1;
flex: 1;
/* TODO */
/* #ifdef WEB */
display: flex;
/* #endif */
flex-direction: column;
}
}
.list-view {
.list-view {
...
...
uni_modules/uni-loading/changelog.md
浏览文件 @
61481937
## 1.0.4(2024-01-10)
-
优化 兼容 uvue h5 项目
## 1.0.3(2023-12-22)
-
更新 示例项目
## 1.0.2(2023-12-22)
-
优化 circle 部分动画逻辑,使动画更顺滑
## 1.0.1(2023-12-20)
## 1.0.1(2023-12-20)
-
修复 组件在高版本HBuilderX中运行出错的bug
-
修复 组件在高版本HBuilderX中运行出错的bug
## 1.0.0(2023-12-19)
## 1.0.0(2023-12-19)
...
...
uni_modules/uni-loading/components/uni-loading/circle.uvue
浏览文件 @
61481937
<template>
<template>
<view :ref="elId" class="block" :style="{width:size+'px',height:size+'px'}"></view>
<!-- #ifdef APP -->
<view :ref="elId" class="block" :style="{width:size+'px',height:size+'px'}"></view>
<!-- #endif -->
<!-- #ifdef WEB -->
<svg :width="size" :height="size" viewBox="25 25 50 50" :style="{width:size+'px',height:size+'px'}" class="uni-load__img uni-load__img--android-H5">
<circle cx="50" cy="50" r="20" fill="none" :style="{color:color}" :stroke-width="iconsSize"></circle>
</svg>
<!-- #endif -->
</template>
</template>
<script>
<script>
import { easeInOutCubic } from './util'
import { easeInOutCubic } from './util'
export default {
let elId = 0
name: "uni-loading",
export default {
props: {
name: "circle",
props: {
speed: {
speed: {
type: Number,
type: Number,
default: 16,
default: 16,
},
},
size: {
size: {
type: Number,
type: Number,
default: 20,
default: 20,
},
},
color: {
color: {
type: String,
type: String,
default: '',
default: '#666',
}
}
},
},
data() {
data() {
const elId = `Uni_${(Math.random() * 10e5).toInt().toString(36)}`
// 防止多调用,随机元素id
return {
elId += 1
elId: elId,
const elID = `Uni_Load_Circle_${elId}`
timer: 0,
return {
};
elId: elID,
},
timer: 0,
mounted() {
};
this.init()
},
},
computed: {
unmounted() {
iconsSize() : number {
clearInterval(this.timer)
console.log(this.size / 10);
},
return (this.size / 10) +1
methods: {
}
init() {
},
const refs = this.$refs[this.elId] as Element
mounted() {
let ctx = refs.getDrawableContext()!
// #ifdef APP
this.circular(ctx)
this.init()
},
// #endif
circular(ctx : DrawableContext) {
},
let startAngle = 0;
unmounted() {
let rotate = 0;
// 组件卸载时,需要卸载定时器,优化性能,防止页面卡死
const ARC_LENGTH = 359;
clearInterval(this.timer)
const center = this.size / 2;
},
const lineWidth = this.size / 10;
methods: {
const duration = 1200; // 动画持续时间
/**
const interval = this.speed; // 定时器间隔(大约 60 帧每秒)
* 初始化圆环
*/
init() {
const ARC_MAX = 358
const refs = this.$refs[this.elId] as Element
let startTime = 0;
let ctx = refs.getDrawableContext()!
let foreward_end = 0 // 正传
this.build_circular(ctx)
let reversal_end = ARC_MAX // 反转
},
function pogress_time() : number {
const currentTime = Date.now();
/**
const elapsedTime = currentTime - startTime;
* 构建圆环动画
const progress = elapsedTime / duration;
*/
const easedProgress = easeInOutCubic(progress);
build_circular(ctx : DrawableContext) {
return easedProgress
let startAngle = 0;
}
let rotate = 0;
const draw = () => {
const ARC_LENGTH = 359;
const center = this.size / 2; // 圆心
ctx.reset();
const lineWidth = this.size / 10; // 圆环宽度
ctx.beginPath();
const duration = 1200; // 动画持续时间
const interval = this.speed; // 定时器间隔(大约 60 帧每秒)
if (reversal_end == ARC_MAX) {
foreward_end = Math.min(pogress_time() * ARC_LENGTH, ARC_LENGTH); // 限制 end 的最大值为 ARC_LENGTH
// 使圆环过度更自然,不必运动到底
if (foreward_end >= ARC_MAX) {
const ARC_MAX = 358
reversal_end = 0
let startTime = 0;
foreward_end = ARC_MAX
let foreward_end = 0 // 正传
startTime = Date.now();
let reversal_end = ARC_MAX // 反转
}
function pogress_time() : number {
}
const currentTime = Date.now();
// 运动时间计算
if (foreward_end == ARC_MAX) {
const elapsedTime = currentTime - startTime;
reversal_end = Math.min(pogress_time() * ARC_LENGTH, ARC_LENGTH);
const progress = elapsedTime / duration;
if (reversal_end >= ARC_MAX) {
// 动画缓动
reversal_end = ARC_MAX
const easedProgress = easeInOutCubic(progress);
foreward_end = 0
return easedProgress
startTime = Date.now();
}
}
const draw = () => {
}
ctx.reset();
ctx.arc(
ctx.beginPath();
center,
center,
if (reversal_end == ARC_MAX) {
center - lineWidth,
foreward_end = Math.min(pogress_time() * ARC_LENGTH, ARC_LENGTH); // 限制 end 的最大值为 ARC_LENGTH
startAngle + rotate + (reversal_end * Math.PI / 180),
if (foreward_end >= ARC_MAX) {
startAngle + rotate + (foreward_end * Math.PI / 180)
reversal_end = 0
);
foreward_end = ARC_MAX
ctx.lineWidth = lineWidth;
startTime = Date.now();
const fillColor = (this.color !== '' ? this.color : '#666').toString();
}
ctx.strokeStyle = fillColor;
}
ctx.stroke();
ctx.update();
if (foreward_end == ARC_MAX) {
rotate += 0.05; // 旋转速度
reversal_end = Math.min(pogress_time() * ARC_LENGTH, ARC_LENGTH);
}
if (reversal_end >= ARC_MAX) {
reversal_end = ARC_MAX
this.timer = setInterval(() => draw(), interval);
foreward_end = 0
}
startTime = Date.now();
}
}
}
}
ctx.arc(
center,
center,
center - lineWidth,
startAngle + rotate + (reversal_end * Math.PI / 180),
startAngle + rotate + (foreward_end * Math.PI / 180)
);
ctx.lineWidth = lineWidth;
const fillColor = (this.color !== '' ? this.color : '#666').toString();
ctx.strokeStyle = fillColor;
ctx.stroke();
ctx.update();
rotate += 0.05; // 旋转速度
}
this.timer = setInterval(() => draw(), interval);
}
}
}
</script>
</script>
<style scoped>
<style scoped>
.block {
.block {
width: 50px;
width: 50px;
height: 50px;
height: 50px;
}
}
/* #ifdef WEB */
.uni-load__img {
width: 24px;
height: 24px;
}
.uni-load__img--android-H5 {
animation: loading-android-H5-rotate 2s linear infinite;
transform-origin: center center;
}
.uni-load__img--android-H5 circle {
display: inline-block;
animation: loading-android-H5-dash 1.5s ease-in-out infinite;
stroke: currentColor;
stroke-linecap: round;
}
@keyframes loading-android-H5-rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes loading-android-H5-dash {
0% {
stroke-dasharray: 1, 200;
/* stroke-dashoffset: 0; */
}
50% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -20;
}
100% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -120;
}
}
/* #endif */
</style>
</style>
uni_modules/uni-loading/components/uni-loading/icon.uvue
浏览文件 @
61481937
<template>
<template>
<uni-icons :id="elId" class='load-ani' :style="aniStyle" @transitionend="onEnd" :type="iconType" :size="size" :color="color"></uni-icons>
<uni-icons :id="elId" class='load-ani' :style="aniStyle" @transitionend="onEnd" :type="iconType" :size="size" :color="color"></uni-icons>
<!-- return h(UniIcons, {
id: this.elId,
class: 'load-ani',
style: this.aniStyle,
onTransitionend: this.onEnd,
id: this.elId,
type: this.iconType,
color: this.color,
// TODO +2 是为了大小与自绘元素保持大小一致
size: this.loadWidth + 2,
}) -->
</template>
</template>
<script>
<script>
export default {
export default {
name:'icon',
props: {
props: {
iconType: {
iconType: {
type: String,
type: String,
...
@@ -77,4 +67,4 @@
...
@@ -77,4 +67,4 @@
transition-timing-function: linear;
transition-timing-function: linear;
transform: rotate(0deg);
transform: rotate(0deg);
}
}
</style>
</style>
\ No newline at end of file
uni_modules/uni-loading/components/uni-loading/uni-loading.uvue
浏览文件 @
61481937
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
</template>
</template>
<script>
<script>
import Circle from './circle.uvue'
import Circle from './circle.uvue'
// import Snow from './snow.uvue'
// TODO 性能问题,其他类型暂时不对外开放
// import Icon from './icon.uvue'
// import Icon from './icon.uvue'
// import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue'
// import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue'
...
@@ -161,4 +161,4 @@
...
@@ -161,4 +161,4 @@
transform: rotate(0deg);
transform: rotate(0deg);
}
}
</style>
</style>
\ No newline at end of file
uni_modules/uni-loading/package.json
浏览文件 @
61481937
{
{
"id"
:
"uni-loading"
,
"id"
:
"uni-loading"
,
"displayName"
:
"uni-loading"
,
"displayName"
:
"uni-loading"
,
"version"
:
"1.0.
1
"
,
"version"
:
"1.0.
4
"
,
"description"
:
"加载动画组件多用在页面内数据加载时,提供一个loading动画,列表的上拉加载,下拉刷新等都需要加载动画"
,
"description"
:
"加载动画组件多用在页面内数据加载时,提供一个loading动画,列表的上拉加载,下拉刷新等都需要加载动画"
,
"keywords"
:
[
"keywords"
:
[
"loading"
,
"loading"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录