Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
1992f23f
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看板
提交
1992f23f
编写于
9月 25, 2023
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 引崩溃问题移除自动化测试期间的弹框
上级
cfea7098
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
98 addition
and
115 deletion
+98
-115
pages/API/unicloud-call-function/unicloud-call-function.test.js
...API/unicloud-call-function/unicloud-call-function.test.js
+3
-0
pages/API/unicloud-call-function/unicloud-call-function.uvue
pages/API/unicloud-call-function/unicloud-call-function.uvue
+21
-15
pages/API/unicloud-database/unicloud-database.test.js
pages/API/unicloud-database/unicloud-database.test.js
+3
-0
pages/API/unicloud-database/unicloud-database.uvue
pages/API/unicloud-database/unicloud-database.uvue
+31
-72
pages/API/unicloud-file-api/unicloud-file-api.uvue
pages/API/unicloud-file-api/unicloud-file-api.uvue
+4
-4
pages/API/unicloud-import-object/unicloud-import-object.test.js
...API/unicloud-import-object/unicloud-import-object.test.js
+3
-0
pages/API/unicloud-import-object/unicloud-import-object.uvue
pages/API/unicloud-import-object/unicloud-import-object.uvue
+33
-24
未找到文件。
pages/API/unicloud-call-function/unicloud-call-function.test.js
浏览文件 @
1992f23f
...
...
@@ -5,6 +5,9 @@ describe('unicloud-call-function', () => {
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
setData
({
isUniTest
:
true
})
})
it
(
'
callFunction
'
,
async
()
=>
{
...
...
pages/API/unicloud-call-function/unicloud-call-function.uvue
浏览文件 @
1992f23f
...
...
@@ -20,7 +20,8 @@
return {
title: '请求云函数',
callFunctionResult: {},
callFunctionError: {}
callFunctionError: {},
isUniTest: false
}
},
onLoad() {
...
...
@@ -28,6 +29,19 @@
onUnload() {
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
uni.showToast({
title: content
})
}
},
callFunction: function () {
uni.showLoading({
title: '加载中...'
...
...
@@ -43,23 +57,15 @@
this.callFunctionResult = result
console.log(JSON.stringify(result))
uni.hideLoading()
uni.showModal({
title: '提示',
content: result['showMessage'] as string,
showCancel: false
})
}).catch<void>((err: any | null) => {
this.notify(result['showMessage'] as string, '提示')
}).catch<void>((err : any | null) => {
const error = err as UniCloudError
this.callFunctionError = {
errCode: error.errCode,
errMsg: error.errMsg
}
uni.hideLoading()
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
}
}
...
...
pages/API/unicloud-database/unicloud-database.test.js
浏览文件 @
1992f23f
...
...
@@ -5,6 +5,9 @@ describe('unicloud-database', () => {
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
setData
({
isUniTest
:
true
})
})
it
(
'
databaseBasic
'
,
async
()
=>
{
await
page
.
callMethod
(
'
dbRemove
'
)
...
...
pages/API/unicloud-database/unicloud-database.uvue
浏览文件 @
1992f23f
...
...
@@ -34,6 +34,7 @@
getWithCommandData: [] as Array<UTSJSONObject>,
removeDeleted: 0,
lookupData: [] as Array<UTSJSONObject>,
isUniTest: false
}
},
onLoad() {
...
...
@@ -41,6 +42,19 @@
onUnload() {
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
uni.showToast({
title: content
})
}
},
dbAdd: function () {
uni.showLoading({
title: '加载中...'
...
...
@@ -57,19 +71,12 @@
uni.hideLoading()
console.log(res)
this.addId = res.id
uni.showModal({
content: `新增成功,id: ${res.id}`,
showCancel: false
})
this.notify(`新增成功,id: ${res.id}`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbBatchAdd() {
...
...
@@ -88,21 +95,15 @@
.then<void>((res) => {
uni.hideLoading()
console.log(res)
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
this.batchAddIds = res.ids
this.batchAddinserted = res.inserted
uni.showModal({
content: `新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`,
showCancel: false
})
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbGet() {
...
...
@@ -123,19 +124,12 @@
uni.hideLoading()
console.log(res)
this.getData = res.data
uni.showModal({
content: `获取成功,取到了${res.data.length}条数据`,
showCancel: false
})
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbGetWithCommand() {
...
...
@@ -156,19 +150,12 @@
uni.hideLoading()
console.log(res)
this.getWithCommandData = res.data
uni.showModal({
content: `获取成功,取到了${res.data.length}条数据`,
showCancel: false
})
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbUpdate() {
...
...
@@ -187,19 +174,12 @@
uni.hideLoading()
console.log(res)
this.updateUpdated = res.updated
uni.showModal({
content: `更新成功,更新了${res.updated}条数据`,
showCancel: false
})
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbRemove() {
...
...
@@ -216,19 +196,12 @@
uni.hideLoading()
console.log(res)
this.removeDeleted = res.deleted
uni.showModal({
content: `删除成功,删掉了${res.deleted}条数据`,
showCancel: false
})
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbLookupInit() {
...
...
@@ -272,20 +245,13 @@
})
.then<void>((_) : void => {
uni.hideLoading()
uni.showModal({
content: '数据初始化成功',
showCancel: false
})
this.notify('数据初始化成功', '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
console.error(err)
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
},
dbLookup() {
...
...
@@ -305,19 +271,12 @@
uni.hideLoading()
console.log(res)
this.lookupData = res.data
uni.showModal({
content: `联表查询成功,取到了${res.data.length}条数据`,
showCancel: false
})
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
this.notify(error.errMsg, '错误')
})
}
}
...
...
pages/API/unicloud-file-api/unicloud-file-api.uvue
浏览文件 @
1992f23f
pages/API/unicloud-import-object/unicloud-import-object.test.js
浏览文件 @
1992f23f
...
...
@@ -5,6 +5,9 @@ describe('unicloud-import-object', () => {
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
setData
({
isUniTest
:
true
})
})
it
(
'
importObject
'
,
async
()
=>
{
await
page
.
callMethod
(
'
addTodo
'
)
...
...
pages/API/unicloud-import-object/unicloud-import-object.uvue
浏览文件 @
1992f23f
...
...
@@ -34,22 +34,34 @@
returnTodoTitle: '',
returnTodoContent: '',
failErrCode: '',
successErrCode: -1
successErrCode: -1,
isUniTest: false
}
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
uni.showToast({
title: content
})
}
},
addTodo() {
const todo = uniCloud.importObject('todo')
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
const title = this.todoTitle
const content = this.todoContent
todo.add(title, content).then<void>((res : UTSJSONObject) : void => {
this.returnTodoTitle = res['title'] as string
this.returnTodoContent = res['content'] as string
uni.showModal({
title: '提示',
content: res['showMessage'] as string,
showCancel: false
})
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
...
...
@@ -62,40 +74,37 @@
}
})
todoObj.randomFail().then<void>((res : UTSJSONObject) : void => {
uni.showModal({
title: '提示',
content: res['showMessage'] as string,
showCancel: false
})
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
})
},
fail() {
const todo = uniCloud.importObject('todo')
todo.fail().then<void>((res : UTSJSONObject) : void => {
uni.showModal({
title: '提示',
content: 'todo.fail应调用失败,此处错误的触发了成功回调',
showCancel: false
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.fail().then<void>((res : UTSJSONObject) : void => {
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
console.log('todo.fail: ', res);
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
this.failErrCode = error.errCode as string
console.error(error)
if (this.isUniTest) {
uni.showToast({
title: err.errMsg
})
}
})
},
success() {
const todo = uniCloud.importObject('todo')
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.success().then<void>((res : UTSJSONObject) : void => {
this.successErrCode = res['errCode'] as number
uni.showModal({
title: '提示',
content: res['showMessage'] as string,
showCancel: false
})
this.notify(res['showMessage'] as string, '提示')
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录